babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774
  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/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** 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 */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** 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 */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** 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 */
  693. static readonly GEQUAL: number;
  694. /** 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 */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * 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.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * 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.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. 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>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @returns a file request object
  1453. */
  1454. 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;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. 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;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. import { WebRequest } from "babylonjs/Misc/webRequest";
  1476. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1477. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1478. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1479. /** @hidden */
  1480. export class ShaderProcessor {
  1481. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1482. private static _ProcessPrecision;
  1483. private static _ExtractOperation;
  1484. private static _BuildSubExpression;
  1485. private static _BuildExpression;
  1486. private static _MoveCursorWithinIf;
  1487. private static _MoveCursor;
  1488. private static _EvaluatePreProcessors;
  1489. private static _PreparePreProcessors;
  1490. private static _ProcessShaderConversion;
  1491. private static _ProcessIncludes;
  1492. /**
  1493. * Loads a file from a url
  1494. * @param url url to load
  1495. * @param onSuccess callback called when the file successfully loads
  1496. * @param onProgress callback called while file is loading (if the server supports this mode)
  1497. * @param offlineProvider defines the offline provider for caching
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @returns a file request object
  1501. * @hidden
  1502. */
  1503. 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;
  1504. }
  1505. }
  1506. declare module "babylonjs/Maths/math.like" {
  1507. import { float, int, DeepImmutable } from "babylonjs/types";
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IColor4Like {
  1512. r: float;
  1513. g: float;
  1514. b: float;
  1515. a: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IColor3Like {
  1521. r: float;
  1522. g: float;
  1523. b: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IVector4Like {
  1529. x: float;
  1530. y: float;
  1531. z: float;
  1532. w: float;
  1533. }
  1534. /**
  1535. * @hidden
  1536. */
  1537. export interface IVector3Like {
  1538. x: float;
  1539. y: float;
  1540. z: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IVector2Like {
  1546. x: float;
  1547. y: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IMatrixLike {
  1553. toArray(): DeepImmutable<Float32Array>;
  1554. updateFlag: int;
  1555. }
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IViewportLike {
  1560. x: float;
  1561. y: float;
  1562. width: float;
  1563. height: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IPlaneLike {
  1569. normal: IVector3Like;
  1570. d: float;
  1571. normalize(): void;
  1572. }
  1573. }
  1574. declare module "babylonjs/Materials/iEffectFallbacks" {
  1575. import { Effect } from "babylonjs/Materials/effect";
  1576. /**
  1577. * Interface used to define common properties for effect fallbacks
  1578. */
  1579. export interface IEffectFallbacks {
  1580. /**
  1581. * Removes the defines that should be removed when falling back.
  1582. * @param currentDefines defines the current define statements for the shader.
  1583. * @param effect defines the current effect we try to compile
  1584. * @returns The resulting defines with defines of the current rank removed.
  1585. */
  1586. reduce(currentDefines: string, effect: Effect): string;
  1587. /**
  1588. * Removes the fallback from the bound mesh.
  1589. */
  1590. unBindMesh(): void;
  1591. /**
  1592. * Checks to see if more fallbacks are still availible.
  1593. */
  1594. hasMoreFallbacks: boolean;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1598. /**
  1599. * Class used to evalaute queries containing `and` and `or` operators
  1600. */
  1601. export class AndOrNotEvaluator {
  1602. /**
  1603. * Evaluate a query
  1604. * @param query defines the query to evaluate
  1605. * @param evaluateCallback defines the callback used to filter result
  1606. * @returns true if the query matches
  1607. */
  1608. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1609. private static _HandleParenthesisContent;
  1610. private static _SimplifyNegation;
  1611. }
  1612. }
  1613. declare module "babylonjs/Misc/tags" {
  1614. /**
  1615. * Class used to store custom tags
  1616. */
  1617. export class Tags {
  1618. /**
  1619. * Adds support for tags on the given object
  1620. * @param obj defines the object to use
  1621. */
  1622. static EnableFor(obj: any): void;
  1623. /**
  1624. * Removes tags support
  1625. * @param obj defines the object to use
  1626. */
  1627. static DisableFor(obj: any): void;
  1628. /**
  1629. * Gets a boolean indicating if the given object has tags
  1630. * @param obj defines the object to use
  1631. * @returns a boolean
  1632. */
  1633. static HasTags(obj: any): boolean;
  1634. /**
  1635. * Gets the tags available on a given object
  1636. * @param obj defines the object to use
  1637. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1638. * @returns the tags
  1639. */
  1640. static GetTags(obj: any, asString?: boolean): any;
  1641. /**
  1642. * Adds tags to an object
  1643. * @param obj defines the object to use
  1644. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1645. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1646. */
  1647. static AddTagsTo(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _AddTagTo(obj: any, tag: string): void;
  1652. /**
  1653. * Removes specific tags from a specific object
  1654. * @param obj defines the object to use
  1655. * @param tagsString defines the tags to remove
  1656. */
  1657. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1658. /**
  1659. * @hidden
  1660. */
  1661. static _RemoveTagFrom(obj: any, tag: string): void;
  1662. /**
  1663. * Defines if tags hosted on an object match a given query
  1664. * @param obj defines the object to use
  1665. * @param tagsQuery defines the tag query
  1666. * @returns a boolean
  1667. */
  1668. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1669. }
  1670. }
  1671. declare module "babylonjs/Maths/math.scalar" {
  1672. /**
  1673. * Scalar computation library
  1674. */
  1675. export class Scalar {
  1676. /**
  1677. * Two pi constants convenient for computation.
  1678. */
  1679. static TwoPi: number;
  1680. /**
  1681. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1682. * @param a number
  1683. * @param b number
  1684. * @param epsilon (default = 1.401298E-45)
  1685. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1686. */
  1687. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1688. /**
  1689. * Returns a string : the upper case translation of the number i to hexadecimal.
  1690. * @param i number
  1691. * @returns the upper case translation of the number i to hexadecimal.
  1692. */
  1693. static ToHex(i: number): string;
  1694. /**
  1695. * Returns -1 if value is negative and +1 is value is positive.
  1696. * @param value the value
  1697. * @returns the value itself if it's equal to zero.
  1698. */
  1699. static Sign(value: number): number;
  1700. /**
  1701. * Returns the value itself if it's between min and max.
  1702. * Returns min if the value is lower than min.
  1703. * Returns max if the value is greater than max.
  1704. * @param value the value to clmap
  1705. * @param min the min value to clamp to (default: 0)
  1706. * @param max the max value to clamp to (default: 1)
  1707. * @returns the clamped value
  1708. */
  1709. static Clamp(value: number, min?: number, max?: number): number;
  1710. /**
  1711. * the log2 of value.
  1712. * @param value the value to compute log2 of
  1713. * @returns the log2 of value.
  1714. */
  1715. static Log2(value: number): number;
  1716. /**
  1717. * Loops the value, so that it is never larger than length and never smaller than 0.
  1718. *
  1719. * This is similar to the modulo operator but it works with floating point numbers.
  1720. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1721. * With t = 5 and length = 2.5, the result would be 0.0.
  1722. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1723. * @param value the value
  1724. * @param length the length
  1725. * @returns the looped value
  1726. */
  1727. static Repeat(value: number, length: number): number;
  1728. /**
  1729. * Normalize the value between 0.0 and 1.0 using min and max values
  1730. * @param value value to normalize
  1731. * @param min max to normalize between
  1732. * @param max min to normalize between
  1733. * @returns the normalized value
  1734. */
  1735. static Normalize(value: number, min: number, max: number): number;
  1736. /**
  1737. * Denormalize the value from 0.0 and 1.0 using min and max values
  1738. * @param normalized value to denormalize
  1739. * @param min max to denormalize between
  1740. * @param max min to denormalize between
  1741. * @returns the denormalized value
  1742. */
  1743. static Denormalize(normalized: number, min: number, max: number): number;
  1744. /**
  1745. * Calculates the shortest difference between two given angles given in degrees.
  1746. * @param current current angle in degrees
  1747. * @param target target angle in degrees
  1748. * @returns the delta
  1749. */
  1750. static DeltaAngle(current: number, target: number): number;
  1751. /**
  1752. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1753. * @param tx value
  1754. * @param length length
  1755. * @returns The returned value will move back and forth between 0 and length
  1756. */
  1757. static PingPong(tx: number, length: number): number;
  1758. /**
  1759. * Interpolates between min and max with smoothing at the limits.
  1760. *
  1761. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1762. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1763. * @param from from
  1764. * @param to to
  1765. * @param tx value
  1766. * @returns the smooth stepped value
  1767. */
  1768. static SmoothStep(from: number, to: number, tx: number): number;
  1769. /**
  1770. * Moves a value current towards target.
  1771. *
  1772. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1773. * Negative values of maxDelta pushes the value away from target.
  1774. * @param current current value
  1775. * @param target target value
  1776. * @param maxDelta max distance to move
  1777. * @returns resulting value
  1778. */
  1779. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1780. /**
  1781. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. *
  1783. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1784. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1785. * @param current current value
  1786. * @param target target value
  1787. * @param maxDelta max distance to move
  1788. * @returns resulting angle
  1789. */
  1790. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1791. /**
  1792. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1793. * @param start start value
  1794. * @param end target value
  1795. * @param amount amount to lerp between
  1796. * @returns the lerped value
  1797. */
  1798. static Lerp(start: number, end: number, amount: number): number;
  1799. /**
  1800. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1801. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1802. * @param start start value
  1803. * @param end target value
  1804. * @param amount amount to lerp between
  1805. * @returns the lerped value
  1806. */
  1807. static LerpAngle(start: number, end: number, amount: number): number;
  1808. /**
  1809. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1810. * @param a start value
  1811. * @param b target value
  1812. * @param value value between a and b
  1813. * @returns the inverseLerp value
  1814. */
  1815. static InverseLerp(a: number, b: number, value: number): number;
  1816. /**
  1817. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1818. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1819. * @param value1 spline value
  1820. * @param tangent1 spline value
  1821. * @param value2 spline value
  1822. * @param tangent2 spline value
  1823. * @param amount input value
  1824. * @returns hermite result
  1825. */
  1826. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1827. /**
  1828. * Returns a random float number between and min and max values
  1829. * @param min min value of random
  1830. * @param max max value of random
  1831. * @returns random value
  1832. */
  1833. static RandomRange(min: number, max: number): number;
  1834. /**
  1835. * This function returns percentage of a number in a given range.
  1836. *
  1837. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1838. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1839. * @param number to convert to percentage
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the percentage
  1843. */
  1844. static RangeToPercent(number: number, min: number, max: number): number;
  1845. /**
  1846. * This function returns number that corresponds to the percentage in a given range.
  1847. *
  1848. * PercentToRange(0.34,0,100) will return 34.
  1849. * @param percent to convert to number
  1850. * @param min min range
  1851. * @param max max range
  1852. * @returns the number
  1853. */
  1854. static PercentToRange(percent: number, min: number, max: number): number;
  1855. /**
  1856. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1857. * @param angle The angle to normalize in radian.
  1858. * @return The converted angle.
  1859. */
  1860. static NormalizeRadians(angle: number): number;
  1861. }
  1862. }
  1863. declare module "babylonjs/Maths/math.constants" {
  1864. /**
  1865. * Constant used to convert a value to gamma space
  1866. * @ignorenaming
  1867. */
  1868. export const ToGammaSpace: number;
  1869. /**
  1870. * Constant used to convert a value to linear space
  1871. * @ignorenaming
  1872. */
  1873. export const ToLinearSpace = 2.2;
  1874. /**
  1875. * Constant used to define the minimal number value in Babylon.js
  1876. * @ignorenaming
  1877. */
  1878. let Epsilon: number;
  1879. export { Epsilon };
  1880. }
  1881. declare module "babylonjs/Maths/math.viewport" {
  1882. /**
  1883. * Class used to represent a viewport on screen
  1884. */
  1885. export class Viewport {
  1886. /** viewport left coordinate */
  1887. x: number;
  1888. /** viewport top coordinate */
  1889. y: number;
  1890. /**viewport width */
  1891. width: number;
  1892. /** viewport height */
  1893. height: number;
  1894. /**
  1895. * Creates a Viewport object located at (x, y) and sized (width, height)
  1896. * @param x defines viewport left coordinate
  1897. * @param y defines viewport top coordinate
  1898. * @param width defines the viewport width
  1899. * @param height defines the viewport height
  1900. */
  1901. constructor(
  1902. /** viewport left coordinate */
  1903. x: number,
  1904. /** viewport top coordinate */
  1905. y: number,
  1906. /**viewport width */
  1907. width: number,
  1908. /** viewport height */
  1909. height: number);
  1910. /**
  1911. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1912. * @param renderWidth defines the rendering width
  1913. * @param renderHeight defines the rendering height
  1914. * @returns a new Viewport
  1915. */
  1916. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1917. /**
  1918. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1919. * @param renderWidth defines the rendering width
  1920. * @param renderHeight defines the rendering height
  1921. * @param ref defines the target viewport
  1922. * @returns the current viewport
  1923. */
  1924. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1925. /**
  1926. * Returns a new Viewport copied from the current one
  1927. * @returns a new Viewport
  1928. */
  1929. clone(): Viewport;
  1930. }
  1931. }
  1932. declare module "babylonjs/Misc/arrayTools" {
  1933. /**
  1934. * Class containing a set of static utilities functions for arrays.
  1935. */
  1936. export class ArrayTools {
  1937. /**
  1938. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1939. * @param size the number of element to construct and put in the array
  1940. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1941. * @returns a new array filled with new objects
  1942. */
  1943. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1944. }
  1945. }
  1946. declare module "babylonjs/Maths/math.vector" {
  1947. import { Viewport } from "babylonjs/Maths/math.viewport";
  1948. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1949. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1950. /**
  1951. * Class representing a vector containing 2 coordinates
  1952. */
  1953. export class Vector2 {
  1954. /** defines the first coordinate */
  1955. x: number;
  1956. /** defines the second coordinate */
  1957. y: number;
  1958. /**
  1959. * Creates a new Vector2 from the given x and y coordinates
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. */
  1963. constructor(
  1964. /** defines the first coordinate */
  1965. x?: number,
  1966. /** defines the second coordinate */
  1967. y?: number);
  1968. /**
  1969. * Gets a string with the Vector2 coordinates
  1970. * @returns a string with the Vector2 coordinates
  1971. */
  1972. toString(): string;
  1973. /**
  1974. * Gets class name
  1975. * @returns the string "Vector2"
  1976. */
  1977. getClassName(): string;
  1978. /**
  1979. * Gets current vector hash code
  1980. * @returns the Vector2 hash code as a number
  1981. */
  1982. getHashCode(): number;
  1983. /**
  1984. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1985. * @param array defines the source array
  1986. * @param index defines the offset in source array
  1987. * @returns the current Vector2
  1988. */
  1989. toArray(array: FloatArray, index?: number): Vector2;
  1990. /**
  1991. * Copy the current vector to an array
  1992. * @returns a new array with 2 elements: the Vector2 coordinates.
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1997. * @param source defines the source Vector2
  1998. * @returns the current updated Vector2
  1999. */
  2000. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2001. /**
  2002. * Sets the Vector2 coordinates with the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns the current updated Vector2
  2006. */
  2007. copyFromFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Sets the Vector2 coordinates with the given floats
  2010. * @param x defines the first coordinate
  2011. * @param y defines the second coordinate
  2012. * @returns the current updated Vector2
  2013. */
  2014. set(x: number, y: number): Vector2;
  2015. /**
  2016. * Add another vector with the current one
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2019. */
  2020. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2021. /**
  2022. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2023. * @param otherVector defines the other vector
  2024. * @param result defines the target vector
  2025. * @returns the unmodified current Vector2
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2028. /**
  2029. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2030. * @param otherVector defines the other vector
  2031. * @returns the current updated Vector2
  2032. */
  2033. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2034. /**
  2035. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns a new Vector2
  2038. */
  2039. addVector3(otherVector: Vector3): Vector2;
  2040. /**
  2041. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. subtract(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Multiplies in place the current Vector2 coordinates by the given ones
  2061. * @param otherVector defines the other vector
  2062. * @returns the current updated Vector2
  2063. */
  2064. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2065. /**
  2066. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2067. * @param otherVector defines the other vector
  2068. * @returns a new Vector2
  2069. */
  2070. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2071. /**
  2072. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2073. * @param otherVector defines the other vector
  2074. * @param result defines the target vector
  2075. * @returns the unmodified current Vector2
  2076. */
  2077. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2078. /**
  2079. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2080. * @param x defines the first coordinate
  2081. * @param y defines the second coordinate
  2082. * @returns a new Vector2
  2083. */
  2084. multiplyByFloats(x: number, y: number): Vector2;
  2085. /**
  2086. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2087. * @param otherVector defines the other vector
  2088. * @returns a new Vector2
  2089. */
  2090. divide(otherVector: Vector2): Vector2;
  2091. /**
  2092. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2093. * @param otherVector defines the other vector
  2094. * @param result defines the target vector
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2098. /**
  2099. * Divides the current Vector2 coordinates by the given ones
  2100. * @param otherVector defines the other vector
  2101. * @returns the current updated Vector2
  2102. */
  2103. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2104. /**
  2105. * Gets a new Vector2 with current Vector2 negated coordinates
  2106. * @returns a new Vector2
  2107. */
  2108. negate(): Vector2;
  2109. /**
  2110. * Multiply the Vector2 coordinates by scale
  2111. * @param scale defines the scaling factor
  2112. * @returns the current updated Vector2
  2113. */
  2114. scaleInPlace(scale: number): Vector2;
  2115. /**
  2116. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2117. * @param scale defines the scaling factor
  2118. * @returns a new Vector2
  2119. */
  2120. scale(scale: number): Vector2;
  2121. /**
  2122. * Scale the current Vector2 values by a factor to a given Vector2
  2123. * @param scale defines the scale factor
  2124. * @param result defines the Vector2 object where to store the result
  2125. * @returns the unmodified current Vector2
  2126. */
  2127. scaleToRef(scale: number, result: Vector2): Vector2;
  2128. /**
  2129. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2130. * @param scale defines the scale factor
  2131. * @param result defines the Vector2 object where to store the result
  2132. * @returns the unmodified current Vector2
  2133. */
  2134. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2135. /**
  2136. * Gets a boolean if two vectors are equals
  2137. * @param otherVector defines the other vector
  2138. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2139. */
  2140. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2141. /**
  2142. * Gets a boolean if two vectors are equals (using an epsilon value)
  2143. * @param otherVector defines the other vector
  2144. * @param epsilon defines the minimal distance to consider equality
  2145. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2146. */
  2147. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2148. /**
  2149. * Gets a new Vector2 from current Vector2 floored values
  2150. * @returns a new Vector2
  2151. */
  2152. floor(): Vector2;
  2153. /**
  2154. * Gets a new Vector2 from current Vector2 floored values
  2155. * @returns a new Vector2
  2156. */
  2157. fract(): Vector2;
  2158. /**
  2159. * Gets the length of the vector
  2160. * @returns the vector length (float)
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Gets the vector squared length
  2165. * @returns the vector squared length (float)
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalize the vector
  2170. * @returns the current updated Vector2
  2171. */
  2172. normalize(): Vector2;
  2173. /**
  2174. * Gets a new Vector2 copied from the Vector2
  2175. * @returns a new Vector2
  2176. */
  2177. clone(): Vector2;
  2178. /**
  2179. * Gets a new Vector2(0, 0)
  2180. * @returns a new Vector2
  2181. */
  2182. static Zero(): Vector2;
  2183. /**
  2184. * Gets a new Vector2(1, 1)
  2185. * @returns a new Vector2
  2186. */
  2187. static One(): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set from the given index element of the given array
  2190. * @param array defines the data source
  2191. * @param offset defines the offset in the data source
  2192. * @returns a new Vector2
  2193. */
  2194. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2195. /**
  2196. * Sets "result" from the given index element of the given array
  2197. * @param array defines the data source
  2198. * @param offset defines the offset in the data source
  2199. * @param result defines the target vector
  2200. */
  2201. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2202. /**
  2203. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2204. * @param value1 defines 1st point of control
  2205. * @param value2 defines 2nd point of control
  2206. * @param value3 defines 3rd point of control
  2207. * @param value4 defines 4th point of control
  2208. * @param amount defines the interpolation factor
  2209. * @returns a new Vector2
  2210. */
  2211. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2212. /**
  2213. * 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".
  2214. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2215. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2216. * @param value defines the value to clamp
  2217. * @param min defines the lower limit
  2218. * @param max defines the upper limit
  2219. * @returns a new Vector2
  2220. */
  2221. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2222. /**
  2223. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2224. * @param value1 defines the 1st control point
  2225. * @param tangent1 defines the outgoing tangent
  2226. * @param value2 defines the 2nd control point
  2227. * @param tangent2 defines the incoming tangent
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2234. * @param start defines the start vector
  2235. * @param end defines the end vector
  2236. * @param amount defines the interpolation factor
  2237. * @returns a new Vector2
  2238. */
  2239. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2240. /**
  2241. * Gets the dot product of the vector "left" and the vector "right"
  2242. * @param left defines first vector
  2243. * @param right defines second vector
  2244. * @returns the dot product (float)
  2245. */
  2246. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2247. /**
  2248. * Returns a new Vector2 equal to the normalized given vector
  2249. * @param vector defines the vector to normalize
  2250. * @returns a new Vector2
  2251. */
  2252. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2253. /**
  2254. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2255. * @param left defines 1st vector
  2256. * @param right defines 2nd vector
  2257. * @returns a new Vector2
  2258. */
  2259. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2260. /**
  2261. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2262. * @param left defines 1st vector
  2263. * @param right defines 2nd vector
  2264. * @returns a new Vector2
  2265. */
  2266. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2267. /**
  2268. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2269. * @param vector defines the vector to transform
  2270. * @param transformation defines the matrix to apply
  2271. * @returns a new Vector2
  2272. */
  2273. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2274. /**
  2275. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2276. * @param vector defines the vector to transform
  2277. * @param transformation defines the matrix to apply
  2278. * @param result defines the target vector
  2279. */
  2280. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2281. /**
  2282. * Determines if a given vector is included in a triangle
  2283. * @param p defines the vector to test
  2284. * @param p0 defines 1st triangle point
  2285. * @param p1 defines 2nd triangle point
  2286. * @param p2 defines 3rd triangle point
  2287. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2288. */
  2289. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2290. /**
  2291. * Gets the distance between the vectors "value1" and "value2"
  2292. * @param value1 defines first vector
  2293. * @param value2 defines second vector
  2294. * @returns the distance between vectors
  2295. */
  2296. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2297. /**
  2298. * Returns the squared distance between the vectors "value1" and "value2"
  2299. * @param value1 defines first vector
  2300. * @param value2 defines second vector
  2301. * @returns the squared distance between vectors
  2302. */
  2303. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2304. /**
  2305. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2306. * @param value1 defines first vector
  2307. * @param value2 defines second vector
  2308. * @returns a new Vector2
  2309. */
  2310. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2311. /**
  2312. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2313. * @param p defines the middle point
  2314. * @param segA defines one point of the segment
  2315. * @param segB defines the other point of the segment
  2316. * @returns the shortest distance
  2317. */
  2318. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2319. }
  2320. /**
  2321. * Class used to store (x,y,z) vector representation
  2322. * A Vector3 is the main object used in 3D geometry
  2323. * It can represent etiher the coordinates of a point the space, either a direction
  2324. * Reminder: js uses a left handed forward facing system
  2325. */
  2326. export class Vector3 {
  2327. /**
  2328. * Defines the first coordinates (on X axis)
  2329. */
  2330. x: number;
  2331. /**
  2332. * Defines the second coordinates (on Y axis)
  2333. */
  2334. y: number;
  2335. /**
  2336. * Defines the third coordinates (on Z axis)
  2337. */
  2338. z: number;
  2339. private static _UpReadOnly;
  2340. private static _ZeroReadOnly;
  2341. /**
  2342. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2343. * @param x defines the first coordinates (on X axis)
  2344. * @param y defines the second coordinates (on Y axis)
  2345. * @param z defines the third coordinates (on Z axis)
  2346. */
  2347. constructor(
  2348. /**
  2349. * Defines the first coordinates (on X axis)
  2350. */
  2351. x?: number,
  2352. /**
  2353. * Defines the second coordinates (on Y axis)
  2354. */
  2355. y?: number,
  2356. /**
  2357. * Defines the third coordinates (on Z axis)
  2358. */
  2359. z?: number);
  2360. /**
  2361. * Creates a string representation of the Vector3
  2362. * @returns a string with the Vector3 coordinates.
  2363. */
  2364. toString(): string;
  2365. /**
  2366. * Gets the class name
  2367. * @returns the string "Vector3"
  2368. */
  2369. getClassName(): string;
  2370. /**
  2371. * Creates the Vector3 hash code
  2372. * @returns a number which tends to be unique between Vector3 instances
  2373. */
  2374. getHashCode(): number;
  2375. /**
  2376. * Creates an array containing three elements : the coordinates of the Vector3
  2377. * @returns a new array of numbers
  2378. */
  2379. asArray(): number[];
  2380. /**
  2381. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2382. * @param array defines the destination array
  2383. * @param index defines the offset in the destination array
  2384. * @returns the current Vector3
  2385. */
  2386. toArray(array: FloatArray, index?: number): Vector3;
  2387. /**
  2388. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2389. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2390. */
  2391. toQuaternion(): Quaternion;
  2392. /**
  2393. * Adds the given vector to the current Vector3
  2394. * @param otherVector defines the second operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2398. /**
  2399. * Adds the given coordinates to the current Vector3
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2406. /**
  2407. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Subtract the given vector from the current Vector3
  2421. * @param otherVector defines the second operand
  2422. * @returns the current updated Vector3
  2423. */
  2424. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2425. /**
  2426. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2427. * @param otherVector defines the second operand
  2428. * @returns the resulting Vector3
  2429. */
  2430. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2431. /**
  2432. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2433. * @param otherVector defines the second operand
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the current Vector3
  2436. */
  2437. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2438. /**
  2439. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @returns the resulting Vector3
  2444. */
  2445. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2446. /**
  2447. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @param result defines the Vector3 object where to store the result
  2452. * @returns the current Vector3
  2453. */
  2454. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2455. /**
  2456. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2457. * @returns a new Vector3
  2458. */
  2459. negate(): Vector3;
  2460. /**
  2461. * Negate this vector in place
  2462. * @returns this
  2463. */
  2464. negateInPlace(): Vector3;
  2465. /**
  2466. * Multiplies the Vector3 coordinates by the float "scale"
  2467. * @param scale defines the multiplier factor
  2468. * @returns the current updated Vector3
  2469. */
  2470. scaleInPlace(scale: number): Vector3;
  2471. /**
  2472. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2473. * @param scale defines the multiplier factor
  2474. * @returns a new Vector3
  2475. */
  2476. scale(scale: number): Vector3;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2479. * @param scale defines the multiplier factor
  2480. * @param result defines the Vector3 object where to store the result
  2481. * @returns the current Vector3
  2482. */
  2483. scaleToRef(scale: number, result: Vector3): Vector3;
  2484. /**
  2485. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2486. * @param scale defines the scale factor
  2487. * @param result defines the Vector3 object where to store the result
  2488. * @returns the unmodified current Vector3
  2489. */
  2490. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2491. /**
  2492. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2493. * @param otherVector defines the second operand
  2494. * @returns true if both vectors are equals
  2495. */
  2496. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2497. /**
  2498. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2499. * @param otherVector defines the second operand
  2500. * @param epsilon defines the minimal distance to define values as equals
  2501. * @returns true if both vectors are distant less than epsilon
  2502. */
  2503. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2504. /**
  2505. * Returns true if the current Vector3 coordinates equals the given floats
  2506. * @param x defines the x coordinate of the operand
  2507. * @param y defines the y coordinate of the operand
  2508. * @param z defines the z coordinate of the operand
  2509. * @returns true if both vectors are equals
  2510. */
  2511. equalsToFloats(x: number, y: number, z: number): boolean;
  2512. /**
  2513. * Multiplies the current Vector3 coordinates by the given ones
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the new Vector3
  2522. */
  2523. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2533. * @param x defines the x coordinate of the operand
  2534. * @param y defines the y coordinate of the operand
  2535. * @param z defines the z coordinate of the operand
  2536. * @returns the new Vector3
  2537. */
  2538. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2539. /**
  2540. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2541. * @param otherVector defines the second operand
  2542. * @returns the new Vector3
  2543. */
  2544. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2547. * @param otherVector defines the second operand
  2548. * @param result defines the Vector3 object where to store the result
  2549. * @returns the current Vector3
  2550. */
  2551. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2552. /**
  2553. * Divides the current Vector3 coordinates by the given ones.
  2554. * @param otherVector defines the second operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. divideInPlace(otherVector: Vector3): Vector3;
  2558. /**
  2559. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2560. * @param other defines the second operand
  2561. * @returns the current updated Vector3
  2562. */
  2563. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2564. /**
  2565. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2566. * @param other defines the second operand
  2567. * @returns the current updated Vector3
  2568. */
  2569. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2570. /**
  2571. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2572. * @param x defines the x coordinate of the operand
  2573. * @param y defines the y coordinate of the operand
  2574. * @param z defines the z coordinate of the operand
  2575. * @returns the current updated Vector3
  2576. */
  2577. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2578. /**
  2579. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2580. * @param x defines the x coordinate of the operand
  2581. * @param y defines the y coordinate of the operand
  2582. * @param z defines the z coordinate of the operand
  2583. * @returns the current updated Vector3
  2584. */
  2585. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2586. /**
  2587. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2588. * Check if is non uniform within a certain amount of decimal places to account for this
  2589. * @param epsilon the amount the values can differ
  2590. * @returns if the the vector is non uniform to a certain number of decimal places
  2591. */
  2592. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2593. /**
  2594. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2595. */
  2596. get isNonUniform(): boolean;
  2597. /**
  2598. * Gets a new Vector3 from current Vector3 floored values
  2599. * @returns a new Vector3
  2600. */
  2601. floor(): Vector3;
  2602. /**
  2603. * Gets a new Vector3 from current Vector3 floored values
  2604. * @returns a new Vector3
  2605. */
  2606. fract(): Vector3;
  2607. /**
  2608. * Gets the length of the Vector3
  2609. * @returns the length of the Vector3
  2610. */
  2611. length(): number;
  2612. /**
  2613. * Gets the squared length of the Vector3
  2614. * @returns squared length of the Vector3
  2615. */
  2616. lengthSquared(): number;
  2617. /**
  2618. * Normalize the current Vector3.
  2619. * Please note that this is an in place operation.
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalize(): Vector3;
  2623. /**
  2624. * Reorders the x y z properties of the vector in place
  2625. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2626. * @returns the current updated vector
  2627. */
  2628. reorderInPlace(order: string): this;
  2629. /**
  2630. * Rotates the vector around 0,0,0 by a quaternion
  2631. * @param quaternion the rotation quaternion
  2632. * @param result vector to store the result
  2633. * @returns the resulting vector
  2634. */
  2635. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2636. /**
  2637. * Rotates a vector around a given point
  2638. * @param quaternion the rotation quaternion
  2639. * @param point the point to rotate around
  2640. * @param result vector to store the result
  2641. * @returns the resulting vector
  2642. */
  2643. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2644. /**
  2645. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2646. * The cross product is then orthogonal to both current and "other"
  2647. * @param other defines the right operand
  2648. * @returns the cross product
  2649. */
  2650. cross(other: Vector3): Vector3;
  2651. /**
  2652. * Normalize the current Vector3 with the given input length.
  2653. * Please note that this is an in place operation.
  2654. * @param len the length of the vector
  2655. * @returns the current updated Vector3
  2656. */
  2657. normalizeFromLength(len: number): Vector3;
  2658. /**
  2659. * Normalize the current Vector3 to a new vector
  2660. * @returns the new Vector3
  2661. */
  2662. normalizeToNew(): Vector3;
  2663. /**
  2664. * Normalize the current Vector3 to the reference
  2665. * @param reference define the Vector3 to update
  2666. * @returns the updated Vector3
  2667. */
  2668. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2669. /**
  2670. * Creates a new Vector3 copied from the current Vector3
  2671. * @returns the new Vector3
  2672. */
  2673. clone(): Vector3;
  2674. /**
  2675. * Copies the given vector coordinates to the current Vector3 ones
  2676. * @param source defines the source Vector3
  2677. * @returns the current updated Vector3
  2678. */
  2679. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2680. /**
  2681. * Copies the given floats to the current Vector3 coordinates
  2682. * @param x defines the x coordinate of the operand
  2683. * @param y defines the y coordinate of the operand
  2684. * @param z defines the z coordinate of the operand
  2685. * @returns the current updated Vector3
  2686. */
  2687. copyFromFloats(x: number, y: number, z: number): Vector3;
  2688. /**
  2689. * Copies the given floats to the current Vector3 coordinates
  2690. * @param x defines the x coordinate of the operand
  2691. * @param y defines the y coordinate of the operand
  2692. * @param z defines the z coordinate of the operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. set(x: number, y: number, z: number): Vector3;
  2696. /**
  2697. * Copies the given float to the current Vector3 coordinates
  2698. * @param v defines the x, y and z coordinates of the operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. setAll(v: number): Vector3;
  2702. /**
  2703. * Get the clip factor between two vectors
  2704. * @param vector0 defines the first operand
  2705. * @param vector1 defines the second operand
  2706. * @param axis defines the axis to use
  2707. * @param size defines the size along the axis
  2708. * @returns the clip factor
  2709. */
  2710. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2711. /**
  2712. * Get angle between two vectors
  2713. * @param vector0 angle between vector0 and vector1
  2714. * @param vector1 angle between vector0 and vector1
  2715. * @param normal direction of the normal
  2716. * @return the angle between vector0 and vector1
  2717. */
  2718. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2719. /**
  2720. * Returns a new Vector3 set from the index "offset" of the given array
  2721. * @param array defines the source array
  2722. * @param offset defines the offset in the source array
  2723. * @returns the new Vector3
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2726. /**
  2727. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2728. * @param array defines the source array
  2729. * @param offset defines the offset in the source array
  2730. * @returns the new Vector3
  2731. * @deprecated Please use FromArray instead.
  2732. */
  2733. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2734. /**
  2735. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2736. * @param array defines the source array
  2737. * @param offset defines the offset in the source array
  2738. * @param result defines the Vector3 where to store the result
  2739. */
  2740. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2741. /**
  2742. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2743. * @param array defines the source array
  2744. * @param offset defines the offset in the source array
  2745. * @param result defines the Vector3 where to store the result
  2746. * @deprecated Please use FromArrayToRef instead.
  2747. */
  2748. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2749. /**
  2750. * Sets the given vector "result" with the given floats.
  2751. * @param x defines the x coordinate of the source
  2752. * @param y defines the y coordinate of the source
  2753. * @param z defines the z coordinate of the source
  2754. * @param result defines the Vector3 where to store the result
  2755. */
  2756. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2759. * @returns a new empty Vector3
  2760. */
  2761. static Zero(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2764. * @returns a new unit Vector3
  2765. */
  2766. static One(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2769. * @returns a new up Vector3
  2770. */
  2771. static Up(): Vector3;
  2772. /**
  2773. * Gets a up Vector3 that must not be updated
  2774. */
  2775. static get UpReadOnly(): DeepImmutable<Vector3>;
  2776. /**
  2777. * Gets a zero Vector3 that must not be updated
  2778. */
  2779. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2780. /**
  2781. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2782. * @returns a new down Vector3
  2783. */
  2784. static Down(): Vector3;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2787. * @returns a new forward Vector3
  2788. */
  2789. static Forward(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2792. * @returns a new forward Vector3
  2793. */
  2794. static Backward(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2797. * @returns a new right Vector3
  2798. */
  2799. static Right(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2802. * @returns a new left Vector3
  2803. */
  2804. static Left(): Vector3;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2807. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the transformed Vector3
  2811. */
  2812. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2815. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2823. * This method computes tranformed coordinates only, not transformed direction vectors
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2833. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2834. * @param vector defines the Vector3 to transform
  2835. * @param transformation defines the transformation matrix
  2836. * @returns the new Vector3
  2837. */
  2838. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2839. /**
  2840. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2841. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2842. * @param vector defines the Vector3 to transform
  2843. * @param transformation defines the transformation matrix
  2844. * @param result defines the Vector3 where to store the result
  2845. */
  2846. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2847. /**
  2848. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2849. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2850. * @param x define the x coordinate of the source vector
  2851. * @param y define the y coordinate of the source vector
  2852. * @param z define the z coordinate of the source vector
  2853. * @param transformation defines the transformation matrix
  2854. * @param result defines the Vector3 where to store the result
  2855. */
  2856. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2857. /**
  2858. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2859. * @param value1 defines the first control point
  2860. * @param value2 defines the second control point
  2861. * @param value3 defines the third control point
  2862. * @param value4 defines the fourth control point
  2863. * @param amount defines the amount on the spline to use
  2864. * @returns the new Vector3
  2865. */
  2866. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2867. /**
  2868. * 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"
  2869. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2870. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2871. * @param value defines the current value
  2872. * @param min defines the lower range value
  2873. * @param max defines the upper range value
  2874. * @returns the new Vector3
  2875. */
  2876. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * 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"
  2879. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2880. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2881. * @param value defines the current value
  2882. * @param min defines the lower range value
  2883. * @param max defines the upper range value
  2884. * @param result defines the Vector3 where to store the result
  2885. */
  2886. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2887. /**
  2888. * Checks if a given vector is inside a specific range
  2889. * @param v defines the vector to test
  2890. * @param min defines the minimum range
  2891. * @param max defines the maximum range
  2892. */
  2893. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2894. /**
  2895. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2896. * @param value1 defines the first control point
  2897. * @param tangent1 defines the first tangent vector
  2898. * @param value2 defines the second control point
  2899. * @param tangent2 defines the second tangent vector
  2900. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2901. * @returns the new Vector3
  2902. */
  2903. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2904. /**
  2905. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2906. * @param start defines the start value
  2907. * @param end defines the end value
  2908. * @param amount max defines amount between both (between 0 and 1)
  2909. * @returns the new Vector3
  2910. */
  2911. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2912. /**
  2913. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2914. * @param start defines the start value
  2915. * @param end defines the end value
  2916. * @param amount max defines amount between both (between 0 and 1)
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2920. /**
  2921. * Returns the dot product (float) between the vectors "left" and "right"
  2922. * @param left defines the left operand
  2923. * @param right defines the right operand
  2924. * @returns the dot product
  2925. */
  2926. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2927. /**
  2928. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2929. * The cross product is then orthogonal to both "left" and "right"
  2930. * @param left defines the left operand
  2931. * @param right defines the right operand
  2932. * @returns the cross product
  2933. */
  2934. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2935. /**
  2936. * Sets the given vector "result" with the cross product of "left" and "right"
  2937. * The cross product is then orthogonal to both "left" and "right"
  2938. * @param left defines the left operand
  2939. * @param right defines the right operand
  2940. * @param result defines the Vector3 where to store the result
  2941. */
  2942. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2943. /**
  2944. * Returns a new Vector3 as the normalization of the given vector
  2945. * @param vector defines the Vector3 to normalize
  2946. * @returns the new Vector3
  2947. */
  2948. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2949. /**
  2950. * Sets the given vector "result" with the normalization of the given first vector
  2951. * @param vector defines the Vector3 to normalize
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2955. /**
  2956. * Project a Vector3 onto screen space
  2957. * @param vector defines the Vector3 to project
  2958. * @param world defines the world matrix to use
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @param viewport defines the screen viewport to use
  2961. * @returns the new Vector3
  2962. */
  2963. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2964. /** @hidden */
  2965. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Unproject from screen space to object space
  2968. * @param source defines the screen space Vector3 to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param transform defines the transform (view x projection) matrix to use
  2973. * @returns the new Vector3
  2974. */
  2975. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2976. /**
  2977. * Unproject from screen space to object space
  2978. * @param source defines the screen space Vector3 to use
  2979. * @param viewportWidth defines the current width of the viewport
  2980. * @param viewportHeight defines the current height of the viewport
  2981. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2982. * @param view defines the view matrix to use
  2983. * @param projection defines the projection matrix to use
  2984. * @returns the new Vector3
  2985. */
  2986. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2987. /**
  2988. * Unproject from screen space to object space
  2989. * @param source defines the screen space Vector3 to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Unproject from screen space to object space
  3000. * @param sourceX defines the screen space x coordinate to use
  3001. * @param sourceY defines the screen space y coordinate to use
  3002. * @param sourceZ defines the screen space z coordinate to use
  3003. * @param viewportWidth defines the current width of the viewport
  3004. * @param viewportHeight defines the current height of the viewport
  3005. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3006. * @param view defines the view matrix to use
  3007. * @param projection defines the projection matrix to use
  3008. * @param result defines the Vector3 where to store the result
  3009. */
  3010. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3011. /**
  3012. * Gets the minimal coordinate values between two Vector3
  3013. * @param left defines the first operand
  3014. * @param right defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Gets the maximal coordinate values between two Vector3
  3020. * @param left defines the first operand
  3021. * @param right defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Returns the distance between the vectors "value1" and "value2"
  3027. * @param value1 defines the first operand
  3028. * @param value2 defines the second operand
  3029. * @returns the distance
  3030. */
  3031. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3032. /**
  3033. * Returns the squared distance between the vectors "value1" and "value2"
  3034. * @param value1 defines the first operand
  3035. * @param value2 defines the second operand
  3036. * @returns the squared distance
  3037. */
  3038. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3039. /**
  3040. * Returns a new Vector3 located at the center between "value1" and "value2"
  3041. * @param value1 defines the first operand
  3042. * @param value2 defines the second operand
  3043. * @returns the new Vector3
  3044. */
  3045. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3046. /**
  3047. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3048. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3049. * to something in order to rotate it from its local system to the given target system
  3050. * Note: axis1, axis2 and axis3 are normalized during this operation
  3051. * @param axis1 defines the first axis
  3052. * @param axis2 defines the second axis
  3053. * @param axis3 defines the third axis
  3054. * @returns a new Vector3
  3055. */
  3056. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3057. /**
  3058. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3059. * @param axis1 defines the first axis
  3060. * @param axis2 defines the second axis
  3061. * @param axis3 defines the third axis
  3062. * @param ref defines the Vector3 where to store the result
  3063. */
  3064. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3065. }
  3066. /**
  3067. * Vector4 class created for EulerAngle class conversion to Quaternion
  3068. */
  3069. export class Vector4 {
  3070. /** x value of the vector */
  3071. x: number;
  3072. /** y value of the vector */
  3073. y: number;
  3074. /** z value of the vector */
  3075. z: number;
  3076. /** w value of the vector */
  3077. w: number;
  3078. /**
  3079. * Creates a Vector4 object from the given floats.
  3080. * @param x x value of the vector
  3081. * @param y y value of the vector
  3082. * @param z z value of the vector
  3083. * @param w w value of the vector
  3084. */
  3085. constructor(
  3086. /** x value of the vector */
  3087. x: number,
  3088. /** y value of the vector */
  3089. y: number,
  3090. /** z value of the vector */
  3091. z: number,
  3092. /** w value of the vector */
  3093. w: number);
  3094. /**
  3095. * Returns the string with the Vector4 coordinates.
  3096. * @returns a string containing all the vector values
  3097. */
  3098. toString(): string;
  3099. /**
  3100. * Returns the string "Vector4".
  3101. * @returns "Vector4"
  3102. */
  3103. getClassName(): string;
  3104. /**
  3105. * Returns the Vector4 hash code.
  3106. * @returns a unique hash code
  3107. */
  3108. getHashCode(): number;
  3109. /**
  3110. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3111. * @returns the resulting array
  3112. */
  3113. asArray(): number[];
  3114. /**
  3115. * Populates the given array from the given index with the Vector4 coordinates.
  3116. * @param array array to populate
  3117. * @param index index of the array to start at (default: 0)
  3118. * @returns the Vector4.
  3119. */
  3120. toArray(array: FloatArray, index?: number): Vector4;
  3121. /**
  3122. * Adds the given vector to the current Vector4.
  3123. * @param otherVector the vector to add
  3124. * @returns the updated Vector4.
  3125. */
  3126. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3127. /**
  3128. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3129. * @param otherVector the vector to add
  3130. * @returns the resulting vector
  3131. */
  3132. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3135. * @param otherVector the vector to add
  3136. * @param result the vector to store the result
  3137. * @returns the current Vector4.
  3138. */
  3139. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3140. /**
  3141. * Subtract in place the given vector from the current Vector4.
  3142. * @param otherVector the vector to subtract
  3143. * @returns the updated Vector4.
  3144. */
  3145. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3146. /**
  3147. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3148. * @param otherVector the vector to add
  3149. * @returns the new vector with the result
  3150. */
  3151. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3152. /**
  3153. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3154. * @param otherVector the vector to subtract
  3155. * @param result the vector to store the result
  3156. * @returns the current Vector4.
  3157. */
  3158. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3159. /**
  3160. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3161. */
  3162. /**
  3163. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3164. * @param x value to subtract
  3165. * @param y value to subtract
  3166. * @param z value to subtract
  3167. * @param w value to subtract
  3168. * @returns new vector containing the result
  3169. */
  3170. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3171. /**
  3172. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3173. * @param x value to subtract
  3174. * @param y value to subtract
  3175. * @param z value to subtract
  3176. * @param w value to subtract
  3177. * @param result the vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3181. /**
  3182. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3183. * @returns a new vector with the negated values
  3184. */
  3185. negate(): Vector4;
  3186. /**
  3187. * Multiplies the current Vector4 coordinates by scale (float).
  3188. * @param scale the number to scale with
  3189. * @returns the updated Vector4.
  3190. */
  3191. scaleInPlace(scale: number): Vector4;
  3192. /**
  3193. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3194. * @param scale the number to scale with
  3195. * @returns a new vector with the result
  3196. */
  3197. scale(scale: number): Vector4;
  3198. /**
  3199. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3200. * @param scale the number to scale with
  3201. * @param result a vector to store the result in
  3202. * @returns the current Vector4.
  3203. */
  3204. scaleToRef(scale: number, result: Vector4): Vector4;
  3205. /**
  3206. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3207. * @param scale defines the scale factor
  3208. * @param result defines the Vector4 object where to store the result
  3209. * @returns the unmodified current Vector4
  3210. */
  3211. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3212. /**
  3213. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3214. * @param otherVector the vector to compare against
  3215. * @returns true if they are equal
  3216. */
  3217. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3218. /**
  3219. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3220. * @param otherVector vector to compare against
  3221. * @param epsilon (Default: very small number)
  3222. * @returns true if they are equal
  3223. */
  3224. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3225. /**
  3226. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3227. * @param x x value to compare against
  3228. * @param y y value to compare against
  3229. * @param z z value to compare against
  3230. * @param w w value to compare against
  3231. * @returns true if equal
  3232. */
  3233. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3234. /**
  3235. * Multiplies in place the current Vector4 by the given one.
  3236. * @param otherVector vector to multiple with
  3237. * @returns the updated Vector4.
  3238. */
  3239. multiplyInPlace(otherVector: Vector4): Vector4;
  3240. /**
  3241. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3242. * @param otherVector vector to multiple with
  3243. * @returns resulting new vector
  3244. */
  3245. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3246. /**
  3247. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3248. * @param otherVector vector to multiple with
  3249. * @param result vector to store the result
  3250. * @returns the current Vector4.
  3251. */
  3252. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3253. /**
  3254. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3255. * @param x x value multiply with
  3256. * @param y y value multiply with
  3257. * @param z z value multiply with
  3258. * @param w w value multiply with
  3259. * @returns resulting new vector
  3260. */
  3261. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3264. * @param otherVector vector to devide with
  3265. * @returns resulting new vector
  3266. */
  3267. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3270. * @param otherVector vector to devide with
  3271. * @param result vector to store the result
  3272. * @returns the current Vector4.
  3273. */
  3274. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3275. /**
  3276. * Divides the current Vector3 coordinates by the given ones.
  3277. * @param otherVector vector to devide with
  3278. * @returns the updated Vector3.
  3279. */
  3280. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3283. * @param other defines the second operand
  3284. * @returns the current updated Vector4
  3285. */
  3286. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3287. /**
  3288. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3289. * @param other defines the second operand
  3290. * @returns the current updated Vector4
  3291. */
  3292. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3293. /**
  3294. * Gets a new Vector4 from current Vector4 floored values
  3295. * @returns a new Vector4
  3296. */
  3297. floor(): Vector4;
  3298. /**
  3299. * Gets a new Vector4 from current Vector3 floored values
  3300. * @returns a new Vector4
  3301. */
  3302. fract(): Vector4;
  3303. /**
  3304. * Returns the Vector4 length (float).
  3305. * @returns the length
  3306. */
  3307. length(): number;
  3308. /**
  3309. * Returns the Vector4 squared length (float).
  3310. * @returns the length squared
  3311. */
  3312. lengthSquared(): number;
  3313. /**
  3314. * Normalizes in place the Vector4.
  3315. * @returns the updated Vector4.
  3316. */
  3317. normalize(): Vector4;
  3318. /**
  3319. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3320. * @returns this converted to a new vector3
  3321. */
  3322. toVector3(): Vector3;
  3323. /**
  3324. * Returns a new Vector4 copied from the current one.
  3325. * @returns the new cloned vector
  3326. */
  3327. clone(): Vector4;
  3328. /**
  3329. * Updates the current Vector4 with the given one coordinates.
  3330. * @param source the source vector to copy from
  3331. * @returns the updated Vector4.
  3332. */
  3333. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Updates the current Vector4 coordinates with the given floats.
  3336. * @param x float to copy from
  3337. * @param y float to copy from
  3338. * @param z float to copy from
  3339. * @param w float to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to set from
  3346. * @param y float to set from
  3347. * @param z float to set from
  3348. * @param w float to set from
  3349. * @returns the updated Vector4.
  3350. */
  3351. set(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Copies the given float to the current Vector3 coordinates
  3354. * @param v defines the x, y, z and w coordinates of the operand
  3355. * @returns the current updated Vector3
  3356. */
  3357. setAll(v: number): Vector4;
  3358. /**
  3359. * Returns a new Vector4 set from the starting index of the given array.
  3360. * @param array the array to pull values from
  3361. * @param offset the offset into the array to start at
  3362. * @returns the new vector
  3363. */
  3364. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3365. /**
  3366. * Updates the given vector "result" from the starting index of the given array.
  3367. * @param array the array to pull values from
  3368. * @param offset the offset into the array to start at
  3369. * @param result the vector to store the result in
  3370. */
  3371. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3372. /**
  3373. * Updates the given vector "result" from the starting index of the given Float32Array.
  3374. * @param array the array to pull values from
  3375. * @param offset the offset into the array to start at
  3376. * @param result the vector to store the result in
  3377. */
  3378. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3379. /**
  3380. * Updates the given vector "result" coordinates from the given floats.
  3381. * @param x float to set from
  3382. * @param y float to set from
  3383. * @param z float to set from
  3384. * @param w float to set from
  3385. * @param result the vector to the floats in
  3386. */
  3387. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3388. /**
  3389. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3390. * @returns the new vector
  3391. */
  3392. static Zero(): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3395. * @returns the new vector
  3396. */
  3397. static One(): Vector4;
  3398. /**
  3399. * Returns a new normalized Vector4 from the given one.
  3400. * @param vector the vector to normalize
  3401. * @returns the vector
  3402. */
  3403. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the given vector "result" from the normalization of the given one.
  3406. * @param vector the vector to normalize
  3407. * @param result the vector to store the result in
  3408. */
  3409. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3410. /**
  3411. * Returns a vector with the minimum values from the left and right vectors
  3412. * @param left left vector to minimize
  3413. * @param right right vector to minimize
  3414. * @returns a new vector with the minimum of the left and right vector values
  3415. */
  3416. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a vector with the maximum values from the left and right vectors
  3419. * @param left left vector to maximize
  3420. * @param right right vector to maximize
  3421. * @returns a new vector with the maximum of the left and right vector values
  3422. */
  3423. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Returns the distance (float) between the vectors "value1" and "value2".
  3426. * @param value1 value to calulate the distance between
  3427. * @param value2 value to calulate the distance between
  3428. * @return the distance between the two vectors
  3429. */
  3430. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3431. /**
  3432. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3433. * @param value1 value to calulate the distance between
  3434. * @param value2 value to calulate the distance between
  3435. * @return the distance between the two vectors squared
  3436. */
  3437. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3438. /**
  3439. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3440. * @param value1 value to calulate the center between
  3441. * @param value2 value to calulate the center between
  3442. * @return the center between the two vectors
  3443. */
  3444. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3447. * This methods computes transformed normalized direction vectors only.
  3448. * @param vector the vector to transform
  3449. * @param transformation the transformation matrix to apply
  3450. * @returns the new vector
  3451. */
  3452. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3453. /**
  3454. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3455. * This methods computes transformed normalized direction vectors only.
  3456. * @param vector the vector to transform
  3457. * @param transformation the transformation matrix to apply
  3458. * @param result the vector to store the result in
  3459. */
  3460. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3461. /**
  3462. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3463. * This methods computes transformed normalized direction vectors only.
  3464. * @param x value to transform
  3465. * @param y value to transform
  3466. * @param z value to transform
  3467. * @param w value to transform
  3468. * @param transformation the transformation matrix to apply
  3469. * @param result the vector to store the results in
  3470. */
  3471. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3472. /**
  3473. * Creates a new Vector4 from a Vector3
  3474. * @param source defines the source data
  3475. * @param w defines the 4th component (default is 0)
  3476. * @returns a new Vector4
  3477. */
  3478. static FromVector3(source: Vector3, w?: number): Vector4;
  3479. }
  3480. /**
  3481. * Class used to store quaternion data
  3482. * @see https://en.wikipedia.org/wiki/Quaternion
  3483. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3484. */
  3485. export class Quaternion {
  3486. /** defines the first component (0 by default) */
  3487. x: number;
  3488. /** defines the second component (0 by default) */
  3489. y: number;
  3490. /** defines the third component (0 by default) */
  3491. z: number;
  3492. /** defines the fourth component (1.0 by default) */
  3493. w: number;
  3494. /**
  3495. * Creates a new Quaternion from the given floats
  3496. * @param x defines the first component (0 by default)
  3497. * @param y defines the second component (0 by default)
  3498. * @param z defines the third component (0 by default)
  3499. * @param w defines the fourth component (1.0 by default)
  3500. */
  3501. constructor(
  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. * Gets a string representation for the current quaternion
  3512. * @returns a string with the Quaternion coordinates
  3513. */
  3514. toString(): string;
  3515. /**
  3516. * Gets the class name of the quaternion
  3517. * @returns the string "Quaternion"
  3518. */
  3519. getClassName(): string;
  3520. /**
  3521. * Gets a hash code for this quaternion
  3522. * @returns the quaternion hash code
  3523. */
  3524. getHashCode(): number;
  3525. /**
  3526. * Copy the quaternion to an array
  3527. * @returns a new array populated with 4 elements from the quaternion coordinates
  3528. */
  3529. asArray(): number[];
  3530. /**
  3531. * Check if two quaternions are equals
  3532. * @param otherQuaternion defines the second operand
  3533. * @return true if the current quaternion and the given one coordinates are strictly equals
  3534. */
  3535. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3536. /**
  3537. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3538. * @param otherQuaternion defines the other quaternion
  3539. * @param epsilon defines the minimal distance to consider equality
  3540. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3541. */
  3542. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3543. /**
  3544. * Clone the current quaternion
  3545. * @returns a new quaternion copied from the current one
  3546. */
  3547. clone(): Quaternion;
  3548. /**
  3549. * Copy a quaternion to the current one
  3550. * @param other defines the other quaternion
  3551. * @returns the updated current quaternion
  3552. */
  3553. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Updates the current quaternion with the given float coordinates
  3556. * @param x defines the x coordinate
  3557. * @param y defines the y coordinate
  3558. * @param z defines the z coordinate
  3559. * @param w defines the w coordinate
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3563. /**
  3564. * Updates the current quaternion from the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. set(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Adds two quaternions
  3574. * @param other defines the second operand
  3575. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3576. */
  3577. add(other: DeepImmutable<Quaternion>): Quaternion;
  3578. /**
  3579. * Add a quaternion to the current one
  3580. * @param other defines the quaternion to add
  3581. * @returns the current quaternion
  3582. */
  3583. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3584. /**
  3585. * Subtract two quaternions
  3586. * @param other defines the second operand
  3587. * @returns a new quaternion as the subtraction result of the given one from the current one
  3588. */
  3589. subtract(other: Quaternion): Quaternion;
  3590. /**
  3591. * Multiplies the current quaternion by a scale factor
  3592. * @param value defines the scale factor
  3593. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3594. */
  3595. scale(value: number): Quaternion;
  3596. /**
  3597. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3598. * @param scale defines the scale factor
  3599. * @param result defines the Quaternion object where to store the result
  3600. * @returns the unmodified current quaternion
  3601. */
  3602. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3603. /**
  3604. * Multiplies in place the current quaternion by a scale factor
  3605. * @param value defines the scale factor
  3606. * @returns the current modified quaternion
  3607. */
  3608. scaleInPlace(value: number): Quaternion;
  3609. /**
  3610. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3611. * @param scale defines the scale factor
  3612. * @param result defines the Quaternion object where to store the result
  3613. * @returns the unmodified current quaternion
  3614. */
  3615. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3616. /**
  3617. * Multiplies two quaternions
  3618. * @param q1 defines the second operand
  3619. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3620. */
  3621. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3622. /**
  3623. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3624. * @param q1 defines the second operand
  3625. * @param result defines the target quaternion
  3626. * @returns the current quaternion
  3627. */
  3628. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3629. /**
  3630. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3631. * @param q1 defines the second operand
  3632. * @returns the currentupdated quaternion
  3633. */
  3634. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3635. /**
  3636. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3637. * @param ref defines the target quaternion
  3638. * @returns the current quaternion
  3639. */
  3640. conjugateToRef(ref: Quaternion): Quaternion;
  3641. /**
  3642. * Conjugates in place (1-q) the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. conjugateInPlace(): Quaternion;
  3646. /**
  3647. * Conjugates in place (1-q) the current quaternion
  3648. * @returns a new quaternion
  3649. */
  3650. conjugate(): Quaternion;
  3651. /**
  3652. * Gets length of current quaternion
  3653. * @returns the quaternion length (float)
  3654. */
  3655. length(): number;
  3656. /**
  3657. * Normalize in place the current quaternion
  3658. * @returns the current updated quaternion
  3659. */
  3660. normalize(): Quaternion;
  3661. /**
  3662. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3663. * @param order is a reserved parameter and is ignore for now
  3664. * @returns a new Vector3 containing the Euler angles
  3665. */
  3666. toEulerAngles(order?: string): Vector3;
  3667. /**
  3668. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3669. * @param result defines the vector which will be filled with the Euler angles
  3670. * @param order is a reserved parameter and is ignore for now
  3671. * @returns the current unchanged quaternion
  3672. */
  3673. toEulerAnglesToRef(result: Vector3): Quaternion;
  3674. /**
  3675. * Updates the given rotation matrix with the current quaternion values
  3676. * @param result defines the target matrix
  3677. * @returns the current unchanged quaternion
  3678. */
  3679. toRotationMatrix(result: Matrix): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given rotation matrix values
  3682. * @param matrix defines the source matrix
  3683. * @returns the current updated quaternion
  3684. */
  3685. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3686. /**
  3687. * Creates a new quaternion from a rotation matrix
  3688. * @param matrix defines the source matrix
  3689. * @returns a new quaternion created from the given rotation matrix values
  3690. */
  3691. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3692. /**
  3693. * Updates the given quaternion with the given rotation matrix values
  3694. * @param matrix defines the source matrix
  3695. * @param result defines the target quaternion
  3696. */
  3697. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3698. /**
  3699. * Returns the dot product (float) between the quaternions "left" and "right"
  3700. * @param left defines the left operand
  3701. * @param right defines the right operand
  3702. * @returns the dot product
  3703. */
  3704. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3705. /**
  3706. * Checks if the two quaternions are close to each other
  3707. * @param quat0 defines the first quaternion to check
  3708. * @param quat1 defines the second quaternion to check
  3709. * @returns true if the two quaternions are close to each other
  3710. */
  3711. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3712. /**
  3713. * Creates an empty quaternion
  3714. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3715. */
  3716. static Zero(): Quaternion;
  3717. /**
  3718. * Inverse a given quaternion
  3719. * @param q defines the source quaternion
  3720. * @returns a new quaternion as the inverted current quaternion
  3721. */
  3722. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Inverse a given quaternion
  3725. * @param q defines the source quaternion
  3726. * @param result the quaternion the result will be stored in
  3727. * @returns the result quaternion
  3728. */
  3729. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3730. /**
  3731. * Creates an identity quaternion
  3732. * @returns the identity quaternion
  3733. */
  3734. static Identity(): Quaternion;
  3735. /**
  3736. * Gets a boolean indicating if the given quaternion is identity
  3737. * @param quaternion defines the quaternion to check
  3738. * @returns true if the quaternion is identity
  3739. */
  3740. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Creates a quaternion from a rotation around an axis
  3743. * @param axis defines the axis to use
  3744. * @param angle defines the angle to use
  3745. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3746. */
  3747. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3748. /**
  3749. * Creates a rotation around an axis and stores it into the given quaternion
  3750. * @param axis defines the axis to use
  3751. * @param angle defines the angle to use
  3752. * @param result defines the target quaternion
  3753. * @returns the target quaternion
  3754. */
  3755. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Creates a new quaternion from data stored into an array
  3758. * @param array defines the data source
  3759. * @param offset defines the offset in the source array where the data starts
  3760. * @returns a new quaternion
  3761. */
  3762. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @returns the new Quaternion
  3769. */
  3770. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3771. /**
  3772. * Updates a quaternion from Euler rotation angles
  3773. * @param x Pitch
  3774. * @param y Yaw
  3775. * @param z Roll
  3776. * @param result the quaternion to store the result
  3777. * @returns the updated quaternion
  3778. */
  3779. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3780. /**
  3781. * Create a quaternion from Euler rotation vector
  3782. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3783. * @returns the new Quaternion
  3784. */
  3785. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3786. /**
  3787. * Updates a quaternion from Euler rotation vector
  3788. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3789. * @param result the quaternion to store the result
  3790. * @returns the updated quaternion
  3791. */
  3792. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3793. /**
  3794. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @returns the new quaternion
  3799. */
  3800. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3801. /**
  3802. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3803. * @param yaw defines the rotation around Y axis
  3804. * @param pitch defines the rotation around X axis
  3805. * @param roll defines the rotation around Z axis
  3806. * @param result defines the target quaternion
  3807. */
  3808. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3817. /**
  3818. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3819. * @param alpha defines the rotation around first axis
  3820. * @param beta defines the rotation around second axis
  3821. * @param gamma defines the rotation around third axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3825. /**
  3826. * 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)
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3833. /**
  3834. * 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
  3835. * @param axis1 defines the first axis
  3836. * @param axis2 defines the second axis
  3837. * @param axis3 defines the third axis
  3838. * @param ref defines the target quaternion
  3839. */
  3840. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3841. /**
  3842. * Interpolates between two quaternions
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @returns the new interpolated quaternion
  3847. */
  3848. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3849. /**
  3850. * Interpolates between two quaternions and stores it into a target quaternion
  3851. * @param left defines first quaternion
  3852. * @param right defines second quaternion
  3853. * @param amount defines the gradient to use
  3854. * @param result defines the target quaternion
  3855. */
  3856. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3857. /**
  3858. * Interpolate between two quaternions using Hermite interpolation
  3859. * @param value1 defines first quaternion
  3860. * @param tangent1 defines the incoming tangent
  3861. * @param value2 defines second quaternion
  3862. * @param tangent2 defines the outgoing tangent
  3863. * @param amount defines the target quaternion
  3864. * @returns the new interpolated quaternion
  3865. */
  3866. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3867. }
  3868. /**
  3869. * Class used to store matrix data (4x4)
  3870. */
  3871. export class Matrix {
  3872. private static _updateFlagSeed;
  3873. private static _identityReadOnly;
  3874. private _isIdentity;
  3875. private _isIdentityDirty;
  3876. private _isIdentity3x2;
  3877. private _isIdentity3x2Dirty;
  3878. /**
  3879. * Gets the update flag of the matrix which is an unique number for the matrix.
  3880. * It will be incremented every time the matrix data change.
  3881. * You can use it to speed the comparison between two versions of the same matrix.
  3882. */
  3883. updateFlag: number;
  3884. private readonly _m;
  3885. /**
  3886. * Gets the internal data of the matrix
  3887. */
  3888. get m(): DeepImmutable<Float32Array>;
  3889. /** @hidden */
  3890. _markAsUpdated(): void;
  3891. /** @hidden */
  3892. private _updateIdentityStatus;
  3893. /**
  3894. * Creates an empty matrix (filled with zeros)
  3895. */
  3896. constructor();
  3897. /**
  3898. * Check if the current matrix is identity
  3899. * @returns true is the matrix is the identity matrix
  3900. */
  3901. isIdentity(): boolean;
  3902. /**
  3903. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3904. * @returns true is the matrix is the identity matrix
  3905. */
  3906. isIdentityAs3x2(): boolean;
  3907. /**
  3908. * Gets the determinant of the matrix
  3909. * @returns the matrix determinant
  3910. */
  3911. determinant(): number;
  3912. /**
  3913. * Returns the matrix as a Float32Array
  3914. * @returns the matrix underlying array
  3915. */
  3916. toArray(): DeepImmutable<Float32Array>;
  3917. /**
  3918. * Returns the matrix as a Float32Array
  3919. * @returns the matrix underlying array.
  3920. */
  3921. asArray(): DeepImmutable<Float32Array>;
  3922. /**
  3923. * Inverts the current matrix in place
  3924. * @returns the current inverted matrix
  3925. */
  3926. invert(): Matrix;
  3927. /**
  3928. * Sets all the matrix elements to zero
  3929. * @returns the current matrix
  3930. */
  3931. reset(): Matrix;
  3932. /**
  3933. * Adds the current matrix with a second one
  3934. * @param other defines the matrix to add
  3935. * @returns a new matrix as the addition of the current matrix and the given one
  3936. */
  3937. add(other: DeepImmutable<Matrix>): Matrix;
  3938. /**
  3939. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3940. * @param other defines the matrix to add
  3941. * @param result defines the target matrix
  3942. * @returns the current matrix
  3943. */
  3944. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3945. /**
  3946. * Adds in place the given matrix to the current matrix
  3947. * @param other defines the second operand
  3948. * @returns the current updated matrix
  3949. */
  3950. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3951. /**
  3952. * Sets the given matrix to the current inverted Matrix
  3953. * @param other defines the target matrix
  3954. * @returns the unmodified current matrix
  3955. */
  3956. invertToRef(other: Matrix): Matrix;
  3957. /**
  3958. * add a value at the specified position in the current Matrix
  3959. * @param index the index of the value within the matrix. between 0 and 15.
  3960. * @param value the value to be added
  3961. * @returns the current updated matrix
  3962. */
  3963. addAtIndex(index: number, value: number): Matrix;
  3964. /**
  3965. * mutiply the specified position in the current Matrix by a value
  3966. * @param index the index of the value within the matrix. between 0 and 15.
  3967. * @param value the value to be added
  3968. * @returns the current updated matrix
  3969. */
  3970. multiplyAtIndex(index: number, value: number): Matrix;
  3971. /**
  3972. * Inserts the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Adds the translation vector (using 3 floats) in the current matrix
  3981. * @param x defines the 1st component of the translation
  3982. * @param y defines the 2nd component of the translation
  3983. * @param z defines the 3rd component of the translation
  3984. * @returns the current updated matrix
  3985. */
  3986. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector in the current matrix
  3989. * @param vector3 defines the translation to insert
  3990. * @returns the current updated matrix
  3991. */
  3992. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3993. /**
  3994. * Gets the translation value of the current matrix
  3995. * @returns a new Vector3 as the extracted translation from the matrix
  3996. */
  3997. getTranslation(): Vector3;
  3998. /**
  3999. * Fill a Vector3 with the extracted translation from the matrix
  4000. * @param result defines the Vector3 where to store the translation
  4001. * @returns the current matrix
  4002. */
  4003. getTranslationToRef(result: Vector3): Matrix;
  4004. /**
  4005. * Remove rotation and scaling part from the matrix
  4006. * @returns the updated matrix
  4007. */
  4008. removeRotationAndScaling(): Matrix;
  4009. /**
  4010. * Multiply two matrices
  4011. * @param other defines the second operand
  4012. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4013. */
  4014. multiply(other: DeepImmutable<Matrix>): Matrix;
  4015. /**
  4016. * Copy the current matrix from the given one
  4017. * @param other defines the source matrix
  4018. * @returns the current updated matrix
  4019. */
  4020. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4021. /**
  4022. * Populates the given array from the starting index with the current matrix values
  4023. * @param array defines the target array
  4024. * @param offset defines the offset in the target array where to start storing values
  4025. * @returns the current matrix
  4026. */
  4027. copyToArray(array: Float32Array, offset?: number): Matrix;
  4028. /**
  4029. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4030. * @param other defines the second operand
  4031. * @param result defines the matrix where to store the multiplication
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4035. /**
  4036. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4037. * @param other defines the second operand
  4038. * @param result defines the array where to store the multiplication
  4039. * @param offset defines the offset in the target array where to start storing values
  4040. * @returns the current matrix
  4041. */
  4042. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4043. /**
  4044. * Check equality between this matrix and a second one
  4045. * @param value defines the second matrix to compare
  4046. * @returns true is the current matrix and the given one values are strictly equal
  4047. */
  4048. equals(value: DeepImmutable<Matrix>): boolean;
  4049. /**
  4050. * Clone the current matrix
  4051. * @returns a new matrix from the current matrix
  4052. */
  4053. clone(): Matrix;
  4054. /**
  4055. * Returns the name of the current matrix class
  4056. * @returns the string "Matrix"
  4057. */
  4058. getClassName(): string;
  4059. /**
  4060. * Gets the hash code of the current matrix
  4061. * @returns the hash code
  4062. */
  4063. getHashCode(): number;
  4064. /**
  4065. * Decomposes the current Matrix into a translation, rotation and scaling components
  4066. * @param scale defines the scale vector3 given as a reference to update
  4067. * @param rotation defines the rotation quaternion given as a reference to update
  4068. * @param translation defines the translation vector3 given as a reference to update
  4069. * @returns true if operation was successful
  4070. */
  4071. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4072. /**
  4073. * Gets specific row of the matrix
  4074. * @param index defines the number of the row to get
  4075. * @returns the index-th row of the current matrix as a new Vector4
  4076. */
  4077. getRow(index: number): Nullable<Vector4>;
  4078. /**
  4079. * Sets the index-th row of the current matrix to the vector4 values
  4080. * @param index defines the number of the row to set
  4081. * @param row defines the target vector4
  4082. * @returns the updated current matrix
  4083. */
  4084. setRow(index: number, row: Vector4): Matrix;
  4085. /**
  4086. * Compute the transpose of the matrix
  4087. * @returns the new transposed matrix
  4088. */
  4089. transpose(): Matrix;
  4090. /**
  4091. * Compute the transpose of the matrix and store it in a given matrix
  4092. * @param result defines the target matrix
  4093. * @returns the current matrix
  4094. */
  4095. transposeToRef(result: Matrix): Matrix;
  4096. /**
  4097. * Sets the index-th row of the current matrix with the given 4 x float values
  4098. * @param index defines the row index
  4099. * @param x defines the x component to set
  4100. * @param y defines the y component to set
  4101. * @param z defines the z component to set
  4102. * @param w defines the w component to set
  4103. * @returns the updated current matrix
  4104. */
  4105. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4106. /**
  4107. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4108. * @param scale defines the scale factor
  4109. * @returns a new matrix
  4110. */
  4111. scale(scale: number): Matrix;
  4112. /**
  4113. * Scale the current matrix values by a factor to a given result matrix
  4114. * @param scale defines the scale factor
  4115. * @param result defines the matrix to store the result
  4116. * @returns the current matrix
  4117. */
  4118. scaleToRef(scale: number, result: Matrix): Matrix;
  4119. /**
  4120. * Scale the current matrix values by a factor and add the result to a given matrix
  4121. * @param scale defines the scale factor
  4122. * @param result defines the Matrix to store the result
  4123. * @returns the current matrix
  4124. */
  4125. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4126. /**
  4127. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4128. * @param ref matrix to store the result
  4129. */
  4130. toNormalMatrix(ref: Matrix): void;
  4131. /**
  4132. * Gets only rotation part of the current matrix
  4133. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4134. */
  4135. getRotationMatrix(): Matrix;
  4136. /**
  4137. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4138. * @param result defines the target matrix to store data to
  4139. * @returns the current matrix
  4140. */
  4141. getRotationMatrixToRef(result: Matrix): Matrix;
  4142. /**
  4143. * Toggles model matrix from being right handed to left handed in place and vice versa
  4144. */
  4145. toggleModelMatrixHandInPlace(): void;
  4146. /**
  4147. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4148. */
  4149. toggleProjectionMatrixHandInPlace(): void;
  4150. /**
  4151. * Creates a matrix from an array
  4152. * @param array defines the source array
  4153. * @param offset defines an offset in the source array
  4154. * @returns a new Matrix set from the starting index of the given array
  4155. */
  4156. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4157. /**
  4158. * Copy the content of an array into a given matrix
  4159. * @param array defines the source array
  4160. * @param offset defines an offset in the source array
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4164. /**
  4165. * Stores an array into a matrix after having multiplied each component by a given factor
  4166. * @param array defines the source array
  4167. * @param offset defines the offset in the source array
  4168. * @param scale defines the scaling factor
  4169. * @param result defines the target matrix
  4170. */
  4171. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4172. /**
  4173. * Gets an identity matrix that must not be updated
  4174. */
  4175. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4176. /**
  4177. * Stores a list of values (16) inside a given matrix
  4178. * @param initialM11 defines 1st value of 1st row
  4179. * @param initialM12 defines 2nd value of 1st row
  4180. * @param initialM13 defines 3rd value of 1st row
  4181. * @param initialM14 defines 4th value of 1st row
  4182. * @param initialM21 defines 1st value of 2nd row
  4183. * @param initialM22 defines 2nd value of 2nd row
  4184. * @param initialM23 defines 3rd value of 2nd row
  4185. * @param initialM24 defines 4th value of 2nd row
  4186. * @param initialM31 defines 1st value of 3rd row
  4187. * @param initialM32 defines 2nd value of 3rd row
  4188. * @param initialM33 defines 3rd value of 3rd row
  4189. * @param initialM34 defines 4th value of 3rd row
  4190. * @param initialM41 defines 1st value of 4th row
  4191. * @param initialM42 defines 2nd value of 4th row
  4192. * @param initialM43 defines 3rd value of 4th row
  4193. * @param initialM44 defines 4th value of 4th row
  4194. * @param result defines the target matrix
  4195. */
  4196. 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;
  4197. /**
  4198. * Creates new matrix from a list of values (16)
  4199. * @param initialM11 defines 1st value of 1st row
  4200. * @param initialM12 defines 2nd value of 1st row
  4201. * @param initialM13 defines 3rd value of 1st row
  4202. * @param initialM14 defines 4th value of 1st row
  4203. * @param initialM21 defines 1st value of 2nd row
  4204. * @param initialM22 defines 2nd value of 2nd row
  4205. * @param initialM23 defines 3rd value of 2nd row
  4206. * @param initialM24 defines 4th value of 2nd row
  4207. * @param initialM31 defines 1st value of 3rd row
  4208. * @param initialM32 defines 2nd value of 3rd row
  4209. * @param initialM33 defines 3rd value of 3rd row
  4210. * @param initialM34 defines 4th value of 3rd row
  4211. * @param initialM41 defines 1st value of 4th row
  4212. * @param initialM42 defines 2nd value of 4th row
  4213. * @param initialM43 defines 3rd value of 4th row
  4214. * @param initialM44 defines 4th value of 4th row
  4215. * @returns the new matrix
  4216. */
  4217. 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;
  4218. /**
  4219. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @returns a new matrix
  4224. */
  4225. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4226. /**
  4227. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4228. * @param scale defines the scale vector3
  4229. * @param rotation defines the rotation quaternion
  4230. * @param translation defines the translation vector3
  4231. * @param result defines the target matrix
  4232. */
  4233. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4234. /**
  4235. * Creates a new identity matrix
  4236. * @returns a new identity matrix
  4237. */
  4238. static Identity(): Matrix;
  4239. /**
  4240. * Creates a new identity matrix and stores the result in a given matrix
  4241. * @param result defines the target matrix
  4242. */
  4243. static IdentityToRef(result: Matrix): void;
  4244. /**
  4245. * Creates a new zero matrix
  4246. * @returns a new zero matrix
  4247. */
  4248. static Zero(): Matrix;
  4249. /**
  4250. * Creates a new rotation matrix for "angle" radians around the X axis
  4251. * @param angle defines the angle (in radians) to use
  4252. * @return the new matrix
  4253. */
  4254. static RotationX(angle: number): Matrix;
  4255. /**
  4256. * Creates a new matrix as the invert of a given matrix
  4257. * @param source defines the source matrix
  4258. * @returns the new matrix
  4259. */
  4260. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4263. * @param angle defines the angle (in radians) to use
  4264. * @param result defines the target matrix
  4265. */
  4266. static RotationXToRef(angle: number, result: Matrix): void;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Y axis
  4269. * @param angle defines the angle (in radians) to use
  4270. * @return the new matrix
  4271. */
  4272. static RotationY(angle: number): Matrix;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4275. * @param angle defines the angle (in radians) to use
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationYToRef(angle: number, result: Matrix): void;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the Z axis
  4281. * @param angle defines the angle (in radians) to use
  4282. * @return the new matrix
  4283. */
  4284. static RotationZ(angle: number): Matrix;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4287. * @param angle defines the angle (in radians) to use
  4288. * @param result defines the target matrix
  4289. */
  4290. static RotationZToRef(angle: number, result: Matrix): void;
  4291. /**
  4292. * Creates a new rotation matrix for "angle" radians around the given axis
  4293. * @param axis defines the axis to use
  4294. * @param angle defines the angle (in radians) to use
  4295. * @return the new matrix
  4296. */
  4297. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4298. /**
  4299. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4300. * @param axis defines the axis to use
  4301. * @param angle defines the angle (in radians) to use
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4305. /**
  4306. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4307. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4308. * @param from defines the vector to align
  4309. * @param to defines the vector to align to
  4310. * @param result defines the target matrix
  4311. */
  4312. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4313. /**
  4314. * Creates a rotation matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @returns the new rotation matrix
  4319. */
  4320. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4321. /**
  4322. * Creates a rotation matrix and stores it in a given matrix
  4323. * @param yaw defines the yaw angle in radians (Y axis)
  4324. * @param pitch defines the pitch angle in radians (X axis)
  4325. * @param roll defines the roll angle in radians (X axis)
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4329. /**
  4330. * Creates a scaling matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @returns the new matrix
  4335. */
  4336. static Scaling(x: number, y: number, z: number): Matrix;
  4337. /**
  4338. * Creates a scaling matrix and stores it in a given matrix
  4339. * @param x defines the scale factor on X axis
  4340. * @param y defines the scale factor on Y axis
  4341. * @param z defines the scale factor on Z axis
  4342. * @param result defines the target matrix
  4343. */
  4344. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4345. /**
  4346. * Creates a translation matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Translation(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a translation matrix and stores it in a given matrix
  4355. * @param x defines the translation on X axis
  4356. * @param y defines the translation on Y axis
  4357. * @param z defines the translationon Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @returns the new matrix
  4367. */
  4368. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4369. /**
  4370. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4371. * @param startValue defines the start value
  4372. * @param endValue defines the end value
  4373. * @param gradient defines the gradient factor
  4374. * @param result defines the Matrix object where to store data
  4375. */
  4376. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4377. /**
  4378. * Builds a new matrix whose values are computed by:
  4379. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4380. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4381. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4382. * @param startValue defines the first matrix
  4383. * @param endValue defines the second matrix
  4384. * @param gradient defines the gradient between the two matrices
  4385. * @returns the new matrix
  4386. */
  4387. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4388. /**
  4389. * Update a matrix to values which are computed by:
  4390. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4391. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4392. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4393. * @param startValue defines the first matrix
  4394. * @param endValue defines the second matrix
  4395. * @param gradient defines the gradient between the two matrices
  4396. * @param result defines the target matrix
  4397. */
  4398. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4399. /**
  4400. * 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"
  4401. * This function works in left handed mode
  4402. * @param eye defines the final position of the entity
  4403. * @param target defines where the entity should look at
  4404. * @param up defines the up vector for the entity
  4405. * @returns the new matrix
  4406. */
  4407. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4408. /**
  4409. * 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".
  4410. * This function works in left handed mode
  4411. * @param eye defines the final position of the entity
  4412. * @param target defines where the entity should look at
  4413. * @param up defines the up vector for the entity
  4414. * @param result defines the target matrix
  4415. */
  4416. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4417. /**
  4418. * 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"
  4419. * This function works in right handed mode
  4420. * @param eye defines the final position of the entity
  4421. * @param target defines where the entity should look at
  4422. * @param up defines the up vector for the entity
  4423. * @returns the new matrix
  4424. */
  4425. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4426. /**
  4427. * 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".
  4428. * This function works in right handed mode
  4429. * @param eye defines the final position of the entity
  4430. * @param target defines where the entity should look at
  4431. * @param up defines the up vector for the entity
  4432. * @param result defines the target matrix
  4433. */
  4434. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4435. /**
  4436. * Create a left-handed orthographic projection matrix
  4437. * @param width defines the viewport width
  4438. * @param height defines the viewport height
  4439. * @param znear defines the near clip plane
  4440. * @param zfar defines the far clip plane
  4441. * @returns a new matrix as a left-handed orthographic projection matrix
  4442. */
  4443. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4444. /**
  4445. * Store a left-handed orthographic projection to a given matrix
  4446. * @param width defines the viewport width
  4447. * @param height defines the viewport height
  4448. * @param znear defines the near clip plane
  4449. * @param zfar defines the far clip plane
  4450. * @param result defines the target matrix
  4451. */
  4452. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4453. /**
  4454. * Create a left-handed orthographic projection matrix
  4455. * @param left defines the viewport left coordinate
  4456. * @param right defines the viewport right coordinate
  4457. * @param bottom defines the viewport bottom coordinate
  4458. * @param top defines the viewport top coordinate
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @returns a new matrix as a left-handed orthographic projection matrix
  4462. */
  4463. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4464. /**
  4465. * Stores a left-handed orthographic projection into a given matrix
  4466. * @param left defines the viewport left coordinate
  4467. * @param right defines the viewport right coordinate
  4468. * @param bottom defines the viewport bottom coordinate
  4469. * @param top defines the viewport top coordinate
  4470. * @param znear defines the near clip plane
  4471. * @param zfar defines the far clip plane
  4472. * @param result defines the target matrix
  4473. */
  4474. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4475. /**
  4476. * Creates a right-handed orthographic projection matrix
  4477. * @param left defines the viewport left coordinate
  4478. * @param right defines the viewport right coordinate
  4479. * @param bottom defines the viewport bottom coordinate
  4480. * @param top defines the viewport top coordinate
  4481. * @param znear defines the near clip plane
  4482. * @param zfar defines the far clip plane
  4483. * @returns a new matrix as a right-handed orthographic projection matrix
  4484. */
  4485. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4486. /**
  4487. * Stores a right-handed orthographic projection into a given matrix
  4488. * @param left defines the viewport left coordinate
  4489. * @param right defines the viewport right coordinate
  4490. * @param bottom defines the viewport bottom coordinate
  4491. * @param top defines the viewport top coordinate
  4492. * @param znear defines the near clip plane
  4493. * @param zfar defines the far clip plane
  4494. * @param result defines the target matrix
  4495. */
  4496. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4497. /**
  4498. * Creates a left-handed perspective projection matrix
  4499. * @param width defines the viewport width
  4500. * @param height defines the viewport height
  4501. * @param znear defines the near clip plane
  4502. * @param zfar defines the far clip plane
  4503. * @returns a new matrix as a left-handed perspective projection matrix
  4504. */
  4505. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4506. /**
  4507. * Creates a left-handed perspective projection matrix
  4508. * @param fov defines the horizontal field of view
  4509. * @param aspect defines the aspect ratio
  4510. * @param znear defines the near clip plane
  4511. * @param zfar defines the far clip plane
  4512. * @returns a new matrix as a left-handed perspective projection matrix
  4513. */
  4514. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4515. /**
  4516. * Stores a left-handed perspective projection into a given matrix
  4517. * @param fov defines the horizontal field of view
  4518. * @param aspect defines the aspect ratio
  4519. * @param znear defines the near clip plane
  4520. * @param zfar defines the far clip plane
  4521. * @param result defines the target matrix
  4522. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4523. */
  4524. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4525. /**
  4526. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4527. * @param fov defines the horizontal field of view
  4528. * @param aspect defines the aspect ratio
  4529. * @param znear defines the near clip plane
  4530. * @param zfar not used as infinity is used as far clip
  4531. * @param result defines the target matrix
  4532. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4533. */
  4534. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4535. /**
  4536. * Creates a right-handed perspective projection matrix
  4537. * @param fov defines the horizontal field of view
  4538. * @param aspect defines the aspect ratio
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @returns a new matrix as a right-handed perspective projection matrix
  4542. */
  4543. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4544. /**
  4545. * Stores a right-handed perspective projection into a given matrix
  4546. * @param fov defines the horizontal field of view
  4547. * @param aspect defines the aspect ratio
  4548. * @param znear defines the near clip plane
  4549. * @param zfar defines the far clip plane
  4550. * @param result defines the target matrix
  4551. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4552. */
  4553. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4554. /**
  4555. * Stores a right-handed perspective projection into a given matrix
  4556. * @param fov defines the horizontal field of view
  4557. * @param aspect defines the aspect ratio
  4558. * @param znear defines the near clip plane
  4559. * @param zfar not used as infinity is used as far clip
  4560. * @param result defines the target matrix
  4561. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4562. */
  4563. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4564. /**
  4565. * Stores a perspective projection for WebVR info a given matrix
  4566. * @param fov defines the field of view
  4567. * @param znear defines the near clip plane
  4568. * @param zfar defines the far clip plane
  4569. * @param result defines the target matrix
  4570. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4571. */
  4572. static PerspectiveFovWebVRToRef(fov: {
  4573. upDegrees: number;
  4574. downDegrees: number;
  4575. leftDegrees: number;
  4576. rightDegrees: number;
  4577. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4578. /**
  4579. * Computes a complete transformation matrix
  4580. * @param viewport defines the viewport to use
  4581. * @param world defines the world matrix
  4582. * @param view defines the view matrix
  4583. * @param projection defines the projection matrix
  4584. * @param zmin defines the near clip plane
  4585. * @param zmax defines the far clip plane
  4586. * @returns the transformation matrix
  4587. */
  4588. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4589. /**
  4590. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4591. * @param matrix defines the matrix to use
  4592. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4593. */
  4594. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4595. /**
  4596. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4597. * @param matrix defines the matrix to use
  4598. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4599. */
  4600. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4601. /**
  4602. * Compute the transpose of a given matrix
  4603. * @param matrix defines the matrix to transpose
  4604. * @returns the new matrix
  4605. */
  4606. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4607. /**
  4608. * Compute the transpose of a matrix and store it in a target matrix
  4609. * @param matrix defines the matrix to transpose
  4610. * @param result defines the target matrix
  4611. */
  4612. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4613. /**
  4614. * Computes a reflection matrix from a plane
  4615. * @param plane defines the reflection plane
  4616. * @returns a new matrix
  4617. */
  4618. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4619. /**
  4620. * Computes a reflection matrix from a plane
  4621. * @param plane defines the reflection plane
  4622. * @param result defines the target matrix
  4623. */
  4624. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4625. /**
  4626. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4627. * @param xaxis defines the value of the 1st axis
  4628. * @param yaxis defines the value of the 2nd axis
  4629. * @param zaxis defines the value of the 3rd axis
  4630. * @param result defines the target matrix
  4631. */
  4632. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4635. * @param quat defines the quaternion to use
  4636. * @param result defines the target matrix
  4637. */
  4638. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4639. }
  4640. /**
  4641. * @hidden
  4642. */
  4643. export class TmpVectors {
  4644. static Vector2: Vector2[];
  4645. static Vector3: Vector3[];
  4646. static Vector4: Vector4[];
  4647. static Quaternion: Quaternion[];
  4648. static Matrix: Matrix[];
  4649. }
  4650. }
  4651. declare module "babylonjs/Maths/math.path" {
  4652. import { DeepImmutable, Nullable } from "babylonjs/types";
  4653. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4654. /**
  4655. * Defines potential orientation for back face culling
  4656. */
  4657. export enum Orientation {
  4658. /**
  4659. * Clockwise
  4660. */
  4661. CW = 0,
  4662. /** Counter clockwise */
  4663. CCW = 1
  4664. }
  4665. /** Class used to represent a Bezier curve */
  4666. export class BezierCurve {
  4667. /**
  4668. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4669. * @param t defines the time
  4670. * @param x1 defines the left coordinate on X axis
  4671. * @param y1 defines the left coordinate on Y axis
  4672. * @param x2 defines the right coordinate on X axis
  4673. * @param y2 defines the right coordinate on Y axis
  4674. * @returns the interpolated value
  4675. */
  4676. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4677. }
  4678. /**
  4679. * Defines angle representation
  4680. */
  4681. export class Angle {
  4682. private _radians;
  4683. /**
  4684. * Creates an Angle object of "radians" radians (float).
  4685. * @param radians the angle in radians
  4686. */
  4687. constructor(radians: number);
  4688. /**
  4689. * Get value in degrees
  4690. * @returns the Angle value in degrees (float)
  4691. */
  4692. degrees(): number;
  4693. /**
  4694. * Get value in radians
  4695. * @returns the Angle value in radians (float)
  4696. */
  4697. radians(): number;
  4698. /**
  4699. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4700. * @param a defines first vector
  4701. * @param b defines second vector
  4702. * @returns a new Angle
  4703. */
  4704. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4705. /**
  4706. * Gets a new Angle object from the given float in radians
  4707. * @param radians defines the angle value in radians
  4708. * @returns a new Angle
  4709. */
  4710. static FromRadians(radians: number): Angle;
  4711. /**
  4712. * Gets a new Angle object from the given float in degrees
  4713. * @param degrees defines the angle value in degrees
  4714. * @returns a new Angle
  4715. */
  4716. static FromDegrees(degrees: number): Angle;
  4717. }
  4718. /**
  4719. * This represents an arc in a 2d space.
  4720. */
  4721. export class Arc2 {
  4722. /** Defines the start point of the arc */
  4723. startPoint: Vector2;
  4724. /** Defines the mid point of the arc */
  4725. midPoint: Vector2;
  4726. /** Defines the end point of the arc */
  4727. endPoint: Vector2;
  4728. /**
  4729. * Defines the center point of the arc.
  4730. */
  4731. centerPoint: Vector2;
  4732. /**
  4733. * Defines the radius of the arc.
  4734. */
  4735. radius: number;
  4736. /**
  4737. * Defines the angle of the arc (from mid point to end point).
  4738. */
  4739. angle: Angle;
  4740. /**
  4741. * Defines the start angle of the arc (from start point to middle point).
  4742. */
  4743. startAngle: Angle;
  4744. /**
  4745. * Defines the orientation of the arc (clock wise/counter clock wise).
  4746. */
  4747. orientation: Orientation;
  4748. /**
  4749. * Creates an Arc object from the three given points : start, middle and end.
  4750. * @param startPoint Defines the start point of the arc
  4751. * @param midPoint Defines the midlle point of the arc
  4752. * @param endPoint Defines the end point of the arc
  4753. */
  4754. constructor(
  4755. /** Defines the start point of the arc */
  4756. startPoint: Vector2,
  4757. /** Defines the mid point of the arc */
  4758. midPoint: Vector2,
  4759. /** Defines the end point of the arc */
  4760. endPoint: Vector2);
  4761. }
  4762. /**
  4763. * Represents a 2D path made up of multiple 2D points
  4764. */
  4765. export class Path2 {
  4766. private _points;
  4767. private _length;
  4768. /**
  4769. * If the path start and end point are the same
  4770. */
  4771. closed: boolean;
  4772. /**
  4773. * Creates a Path2 object from the starting 2D coordinates x and y.
  4774. * @param x the starting points x value
  4775. * @param y the starting points y value
  4776. */
  4777. constructor(x: number, y: number);
  4778. /**
  4779. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4780. * @param x the added points x value
  4781. * @param y the added points y value
  4782. * @returns the updated Path2.
  4783. */
  4784. addLineTo(x: number, y: number): Path2;
  4785. /**
  4786. * 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.
  4787. * @param midX middle point x value
  4788. * @param midY middle point y value
  4789. * @param endX end point x value
  4790. * @param endY end point y value
  4791. * @param numberOfSegments (default: 36)
  4792. * @returns the updated Path2.
  4793. */
  4794. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4795. /**
  4796. * Closes the Path2.
  4797. * @returns the Path2.
  4798. */
  4799. close(): Path2;
  4800. /**
  4801. * Gets the sum of the distance between each sequential point in the path
  4802. * @returns the Path2 total length (float).
  4803. */
  4804. length(): number;
  4805. /**
  4806. * Gets the points which construct the path
  4807. * @returns the Path2 internal array of points.
  4808. */
  4809. getPoints(): Vector2[];
  4810. /**
  4811. * Retreives the point at the distance aways from the starting point
  4812. * @param normalizedLengthPosition the length along the path to retreive the point from
  4813. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4814. */
  4815. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4816. /**
  4817. * Creates a new path starting from an x and y position
  4818. * @param x starting x value
  4819. * @param y starting y value
  4820. * @returns a new Path2 starting at the coordinates (x, y).
  4821. */
  4822. static StartingAt(x: number, y: number): Path2;
  4823. }
  4824. /**
  4825. * Represents a 3D path made up of multiple 3D points
  4826. */
  4827. export class Path3D {
  4828. /**
  4829. * an array of Vector3, the curve axis of the Path3D
  4830. */
  4831. path: Vector3[];
  4832. private _curve;
  4833. private _distances;
  4834. private _tangents;
  4835. private _normals;
  4836. private _binormals;
  4837. private _raw;
  4838. private _alignTangentsWithPath;
  4839. private readonly _pointAtData;
  4840. /**
  4841. * new Path3D(path, normal, raw)
  4842. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4843. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4844. * @param path an array of Vector3, the curve axis of the Path3D
  4845. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4846. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4847. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4848. */
  4849. constructor(
  4850. /**
  4851. * an array of Vector3, the curve axis of the Path3D
  4852. */
  4853. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4854. /**
  4855. * Returns the Path3D array of successive Vector3 designing its curve.
  4856. * @returns the Path3D array of successive Vector3 designing its curve.
  4857. */
  4858. getCurve(): Vector3[];
  4859. /**
  4860. * Returns the Path3D array of successive Vector3 designing its curve.
  4861. * @returns the Path3D array of successive Vector3 designing its curve.
  4862. */
  4863. getPoints(): Vector3[];
  4864. /**
  4865. * @returns the computed length (float) of the path.
  4866. */
  4867. length(): number;
  4868. /**
  4869. * Returns an array populated with tangent vectors on each Path3D curve point.
  4870. * @returns an array populated with tangent vectors on each Path3D curve point.
  4871. */
  4872. getTangents(): Vector3[];
  4873. /**
  4874. * Returns an array populated with normal vectors on each Path3D curve point.
  4875. * @returns an array populated with normal vectors on each Path3D curve point.
  4876. */
  4877. getNormals(): Vector3[];
  4878. /**
  4879. * Returns an array populated with binormal vectors on each Path3D curve point.
  4880. * @returns an array populated with binormal vectors on each Path3D curve point.
  4881. */
  4882. getBinormals(): Vector3[];
  4883. /**
  4884. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4885. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4886. */
  4887. getDistances(): number[];
  4888. /**
  4889. * Returns an interpolated point along this path
  4890. * @param position the position of the point along this path, from 0.0 to 1.0
  4891. * @returns a new Vector3 as the point
  4892. */
  4893. getPointAt(position: number): Vector3;
  4894. /**
  4895. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4896. * @param position the position of the point along this path, from 0.0 to 1.0
  4897. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4898. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4899. */
  4900. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4901. /**
  4902. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4903. * @param position the position of the point along this path, from 0.0 to 1.0
  4904. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4905. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4906. */
  4907. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4908. /**
  4909. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4910. * @param position the position of the point along this path, from 0.0 to 1.0
  4911. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4912. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4913. */
  4914. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4915. /**
  4916. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4917. * @param position the position of the point along this path, from 0.0 to 1.0
  4918. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4919. */
  4920. getDistanceAt(position: number): number;
  4921. /**
  4922. * Returns the array index of the previous point of an interpolated point along this path
  4923. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4924. * @returns the array index
  4925. */
  4926. getPreviousPointIndexAt(position: number): number;
  4927. /**
  4928. * 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)
  4929. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4930. * @returns the sub position
  4931. */
  4932. getSubPositionAt(position: number): number;
  4933. /**
  4934. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4935. * @param target the vector of which to get the closest position to
  4936. * @returns the position of the closest virtual point on this path to the target vector
  4937. */
  4938. getClosestPositionTo(target: Vector3): number;
  4939. /**
  4940. * Returns a sub path (slice) of this path
  4941. * @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
  4942. * @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
  4943. * @returns a sub path (slice) of this path
  4944. */
  4945. slice(start?: number, end?: number): Path3D;
  4946. /**
  4947. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4948. * @param path path which all values are copied into the curves points
  4949. * @param firstNormal which should be projected onto the curve
  4950. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4951. * @returns the same object updated.
  4952. */
  4953. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4954. private _compute;
  4955. private _getFirstNonNullVector;
  4956. private _getLastNonNullVector;
  4957. private _normalVector;
  4958. /**
  4959. * Updates the point at data for an interpolated point along this curve
  4960. * @param position the position of the point along this curve, from 0.0 to 1.0
  4961. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4962. * @returns the (updated) point at data
  4963. */
  4964. private _updatePointAtData;
  4965. /**
  4966. * Updates the point at data from the specified parameters
  4967. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4968. * @param point the interpolated point
  4969. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4970. */
  4971. private _setPointAtData;
  4972. /**
  4973. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4974. */
  4975. private _updateInterpolationMatrix;
  4976. }
  4977. /**
  4978. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4979. * A Curve3 is designed from a series of successive Vector3.
  4980. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4981. */
  4982. export class Curve3 {
  4983. private _points;
  4984. private _length;
  4985. /**
  4986. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4987. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4988. * @param v1 (Vector3) the control point
  4989. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4996. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4997. * @param v1 (Vector3) the first control point
  4998. * @param v2 (Vector3) the second control point
  4999. * @param v3 (Vector3) the end point of the Cubic Bezier
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5006. * @param p1 (Vector3) the origin point of the Hermite Spline
  5007. * @param t1 (Vector3) the tangent vector at the origin point
  5008. * @param p2 (Vector3) the end point of the Hermite Spline
  5009. * @param t2 (Vector3) the tangent vector at the end point
  5010. * @param nbPoints (integer) the wanted number of points in the curve
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5014. /**
  5015. * Returns a Curve3 object along a CatmullRom Spline curve :
  5016. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5017. * @param nbPoints (integer) the wanted number of points between each curve control points
  5018. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5019. * @returns the created Curve3
  5020. */
  5021. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5022. /**
  5023. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5024. * A Curve3 is designed from a series of successive Vector3.
  5025. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5026. * @param points points which make up the curve
  5027. */
  5028. constructor(points: Vector3[]);
  5029. /**
  5030. * @returns the Curve3 stored array of successive Vector3
  5031. */
  5032. getPoints(): Vector3[];
  5033. /**
  5034. * @returns the computed length (float) of the curve.
  5035. */
  5036. length(): number;
  5037. /**
  5038. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5039. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5040. * curveA and curveB keep unchanged.
  5041. * @param curve the curve to continue from this curve
  5042. * @returns the newly constructed curve
  5043. */
  5044. continue(curve: DeepImmutable<Curve3>): Curve3;
  5045. private _computeLength;
  5046. }
  5047. }
  5048. declare module "babylonjs/Animations/easing" {
  5049. /**
  5050. * This represents the main contract an easing function should follow.
  5051. * Easing functions are used throughout the animation system.
  5052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5053. */
  5054. export interface IEasingFunction {
  5055. /**
  5056. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5057. * of the easing function.
  5058. * The link below provides some of the most common examples of easing functions.
  5059. * @see https://easings.net/
  5060. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5061. * @returns the corresponding value on the curve defined by the easing function
  5062. */
  5063. ease(gradient: number): number;
  5064. }
  5065. /**
  5066. * Base class used for every default easing function.
  5067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5068. */
  5069. export class EasingFunction implements IEasingFunction {
  5070. /**
  5071. * Interpolation follows the mathematical formula associated with the easing function.
  5072. */
  5073. static readonly EASINGMODE_EASEIN: number;
  5074. /**
  5075. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5076. */
  5077. static readonly EASINGMODE_EASEOUT: number;
  5078. /**
  5079. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5080. */
  5081. static readonly EASINGMODE_EASEINOUT: number;
  5082. private _easingMode;
  5083. /**
  5084. * Sets the easing mode of the current function.
  5085. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5086. */
  5087. setEasingMode(easingMode: number): void;
  5088. /**
  5089. * Gets the current easing mode.
  5090. * @returns the easing mode
  5091. */
  5092. getEasingMode(): number;
  5093. /**
  5094. * @hidden
  5095. */
  5096. easeInCore(gradient: number): number;
  5097. /**
  5098. * Given an input gradient between 0 and 1, this returns the corresponding value
  5099. * of the easing function.
  5100. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5101. * @returns the corresponding value on the curve defined by the easing function
  5102. */
  5103. ease(gradient: number): number;
  5104. }
  5105. /**
  5106. * Easing function with a circle shape (see link below).
  5107. * @see https://easings.net/#easeInCirc
  5108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5109. */
  5110. export class CircleEase extends EasingFunction implements IEasingFunction {
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a ease back shape (see link below).
  5116. * @see https://easings.net/#easeInBack
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BackEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the amplitude of the function */
  5121. amplitude: number;
  5122. /**
  5123. * Instantiates a back ease easing
  5124. * @see https://easings.net/#easeInBack
  5125. * @param amplitude Defines the amplitude of the function
  5126. */
  5127. constructor(
  5128. /** Defines the amplitude of the function */
  5129. amplitude?: number);
  5130. /** @hidden */
  5131. easeInCore(gradient: number): number;
  5132. }
  5133. /**
  5134. * Easing function with a bouncing shape (see link below).
  5135. * @see https://easings.net/#easeInBounce
  5136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5137. */
  5138. export class BounceEase extends EasingFunction implements IEasingFunction {
  5139. /** Defines the number of bounces */
  5140. bounces: number;
  5141. /** Defines the amplitude of the bounce */
  5142. bounciness: number;
  5143. /**
  5144. * Instantiates a bounce easing
  5145. * @see https://easings.net/#easeInBounce
  5146. * @param bounces Defines the number of bounces
  5147. * @param bounciness Defines the amplitude of the bounce
  5148. */
  5149. constructor(
  5150. /** Defines the number of bounces */
  5151. bounces?: number,
  5152. /** Defines the amplitude of the bounce */
  5153. bounciness?: number);
  5154. /** @hidden */
  5155. easeInCore(gradient: number): number;
  5156. }
  5157. /**
  5158. * Easing function with a power of 3 shape (see link below).
  5159. * @see https://easings.net/#easeInCubic
  5160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5161. */
  5162. export class CubicEase extends EasingFunction implements IEasingFunction {
  5163. /** @hidden */
  5164. easeInCore(gradient: number): number;
  5165. }
  5166. /**
  5167. * Easing function with an elastic shape (see link below).
  5168. * @see https://easings.net/#easeInElastic
  5169. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5170. */
  5171. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5172. /** Defines the number of oscillations*/
  5173. oscillations: number;
  5174. /** Defines the amplitude of the oscillations*/
  5175. springiness: number;
  5176. /**
  5177. * Instantiates an elastic easing function
  5178. * @see https://easings.net/#easeInElastic
  5179. * @param oscillations Defines the number of oscillations
  5180. * @param springiness Defines the amplitude of the oscillations
  5181. */
  5182. constructor(
  5183. /** Defines the number of oscillations*/
  5184. oscillations?: number,
  5185. /** Defines the amplitude of the oscillations*/
  5186. springiness?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with an exponential shape (see link below).
  5192. * @see https://easings.net/#easeInExpo
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the exponent of the function */
  5197. exponent: number;
  5198. /**
  5199. * Instantiates an exponential easing function
  5200. * @see https://easings.net/#easeInExpo
  5201. * @param exponent Defines the exponent of the function
  5202. */
  5203. constructor(
  5204. /** Defines the exponent of the function */
  5205. exponent?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class PowerEase extends EasingFunction implements IEasingFunction {
  5215. /** Defines the power of the function */
  5216. power: number;
  5217. /**
  5218. * Instantiates an power base easing function
  5219. * @see https://easings.net/#easeInQuad
  5220. * @param power Defines the power of the function
  5221. */
  5222. constructor(
  5223. /** Defines the power of the function */
  5224. power?: number);
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a power of 2 shape (see link below).
  5230. * @see https://easings.net/#easeInQuad
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5234. /** @hidden */
  5235. easeInCore(gradient: number): number;
  5236. }
  5237. /**
  5238. * Easing function with a power of 4 shape (see link below).
  5239. * @see https://easings.net/#easeInQuart
  5240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5241. */
  5242. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5243. /** @hidden */
  5244. easeInCore(gradient: number): number;
  5245. }
  5246. /**
  5247. * Easing function with a power of 5 shape (see link below).
  5248. * @see https://easings.net/#easeInQuint
  5249. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5250. */
  5251. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a sin shape (see link below).
  5257. * @see https://easings.net/#easeInSine
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class SineEase extends EasingFunction implements IEasingFunction {
  5261. /** @hidden */
  5262. easeInCore(gradient: number): number;
  5263. }
  5264. /**
  5265. * Easing function with a bezier shape (see link below).
  5266. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5270. /** Defines the x component of the start tangent in the bezier curve */
  5271. x1: number;
  5272. /** Defines the y component of the start tangent in the bezier curve */
  5273. y1: number;
  5274. /** Defines the x component of the end tangent in the bezier curve */
  5275. x2: number;
  5276. /** Defines the y component of the end tangent in the bezier curve */
  5277. y2: number;
  5278. /**
  5279. * Instantiates a bezier function
  5280. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5281. * @param x1 Defines the x component of the start tangent in the bezier curve
  5282. * @param y1 Defines the y component of the start tangent in the bezier curve
  5283. * @param x2 Defines the x component of the end tangent in the bezier curve
  5284. * @param y2 Defines the y component of the end tangent in the bezier curve
  5285. */
  5286. constructor(
  5287. /** Defines the x component of the start tangent in the bezier curve */
  5288. x1?: number,
  5289. /** Defines the y component of the start tangent in the bezier curve */
  5290. y1?: number,
  5291. /** Defines the x component of the end tangent in the bezier curve */
  5292. x2?: number,
  5293. /** Defines the y component of the end tangent in the bezier curve */
  5294. y2?: number);
  5295. /** @hidden */
  5296. easeInCore(gradient: number): number;
  5297. }
  5298. }
  5299. declare module "babylonjs/Maths/math.color" {
  5300. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5301. /**
  5302. * Class used to hold a RBG color
  5303. */
  5304. export class Color3 {
  5305. /**
  5306. * Defines the red component (between 0 and 1, default is 0)
  5307. */
  5308. r: number;
  5309. /**
  5310. * Defines the green component (between 0 and 1, default is 0)
  5311. */
  5312. g: number;
  5313. /**
  5314. * Defines the blue component (between 0 and 1, default is 0)
  5315. */
  5316. b: number;
  5317. /**
  5318. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5319. * @param r defines the red component (between 0 and 1, default is 0)
  5320. * @param g defines the green component (between 0 and 1, default is 0)
  5321. * @param b defines the blue component (between 0 and 1, default is 0)
  5322. */
  5323. constructor(
  5324. /**
  5325. * Defines the red component (between 0 and 1, default is 0)
  5326. */
  5327. r?: number,
  5328. /**
  5329. * Defines the green component (between 0 and 1, default is 0)
  5330. */
  5331. g?: number,
  5332. /**
  5333. * Defines the blue component (between 0 and 1, default is 0)
  5334. */
  5335. b?: number);
  5336. /**
  5337. * Creates a string with the Color3 current values
  5338. * @returns the string representation of the Color3 object
  5339. */
  5340. toString(): string;
  5341. /**
  5342. * Returns the string "Color3"
  5343. * @returns "Color3"
  5344. */
  5345. getClassName(): string;
  5346. /**
  5347. * Compute the Color3 hash code
  5348. * @returns an unique number that can be used to hash Color3 objects
  5349. */
  5350. getHashCode(): number;
  5351. /**
  5352. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5353. * @param array defines the array where to store the r,g,b components
  5354. * @param index defines an optional index in the target array to define where to start storing values
  5355. * @returns the current Color3 object
  5356. */
  5357. toArray(array: FloatArray, index?: number): Color3;
  5358. /**
  5359. * Returns a new Color4 object from the current Color3 and the given alpha
  5360. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5361. * @returns a new Color4 object
  5362. */
  5363. toColor4(alpha?: number): Color4;
  5364. /**
  5365. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5366. * @returns the new array
  5367. */
  5368. asArray(): number[];
  5369. /**
  5370. * Returns the luminance value
  5371. * @returns a float value
  5372. */
  5373. toLuminance(): number;
  5374. /**
  5375. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3 object
  5378. */
  5379. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines the Color3 object where to store the result
  5384. * @returns the current Color3
  5385. */
  5386. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Determines equality between Color3 objects
  5389. * @param otherColor defines the second operand
  5390. * @returns true if the rgb values are equal to the given ones
  5391. */
  5392. equals(otherColor: DeepImmutable<Color3>): boolean;
  5393. /**
  5394. * Determines equality between the current Color3 object and a set of r,b,g values
  5395. * @param r defines the red component to check
  5396. * @param g defines the green component to check
  5397. * @param b defines the blue component to check
  5398. * @returns true if the rgb values are equal to the given ones
  5399. */
  5400. equalsFloats(r: number, g: number, b: number): boolean;
  5401. /**
  5402. * Multiplies in place each rgb value by scale
  5403. * @param scale defines the scaling factor
  5404. * @returns the updated Color3
  5405. */
  5406. scale(scale: number): Color3;
  5407. /**
  5408. * Multiplies the rgb values by scale and stores the result into "result"
  5409. * @param scale defines the scaling factor
  5410. * @param result defines the Color3 object where to store the result
  5411. * @returns the unmodified current Color3
  5412. */
  5413. scaleToRef(scale: number, result: Color3): Color3;
  5414. /**
  5415. * Scale the current Color3 values by a factor and add the result to a given Color3
  5416. * @param scale defines the scale factor
  5417. * @param result defines color to store the result into
  5418. * @returns the unmodified current Color3
  5419. */
  5420. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5421. /**
  5422. * Clamps the rgb values by the min and max values and stores the result into "result"
  5423. * @param min defines minimum clamping value (default is 0)
  5424. * @param max defines maximum clamping value (default is 1)
  5425. * @param result defines color to store the result into
  5426. * @returns the original Color3
  5427. */
  5428. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5429. /**
  5430. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5431. * @param otherColor defines the second operand
  5432. * @returns the new Color3
  5433. */
  5434. add(otherColor: DeepImmutable<Color3>): Color3;
  5435. /**
  5436. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5437. * @param otherColor defines the second operand
  5438. * @param result defines Color3 object to store the result into
  5439. * @returns the unmodified current Color3
  5440. */
  5441. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5442. /**
  5443. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5444. * @param otherColor defines the second operand
  5445. * @returns the new Color3
  5446. */
  5447. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5448. /**
  5449. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5450. * @param otherColor defines the second operand
  5451. * @param result defines Color3 object to store the result into
  5452. * @returns the unmodified current Color3
  5453. */
  5454. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5455. /**
  5456. * Copy the current object
  5457. * @returns a new Color3 copied the current one
  5458. */
  5459. clone(): Color3;
  5460. /**
  5461. * Copies the rgb values from the source in the current Color3
  5462. * @param source defines the source Color3 object
  5463. * @returns the updated Color3 object
  5464. */
  5465. copyFrom(source: DeepImmutable<Color3>): Color3;
  5466. /**
  5467. * Updates the Color3 rgb values from the given floats
  5468. * @param r defines the red component to read from
  5469. * @param g defines the green component to read from
  5470. * @param b defines the blue component to read from
  5471. * @returns the current Color3 object
  5472. */
  5473. copyFromFloats(r: number, g: number, b: number): Color3;
  5474. /**
  5475. * Updates the Color3 rgb values from the given floats
  5476. * @param r defines the red component to read from
  5477. * @param g defines the green component to read from
  5478. * @param b defines the blue component to read from
  5479. * @returns the current Color3 object
  5480. */
  5481. set(r: number, g: number, b: number): Color3;
  5482. /**
  5483. * Compute the Color3 hexadecimal code as a string
  5484. * @returns a string containing the hexadecimal representation of the Color3 object
  5485. */
  5486. toHexString(): string;
  5487. /**
  5488. * Computes a new Color3 converted from the current one to linear space
  5489. * @returns a new Color3 object
  5490. */
  5491. toLinearSpace(): Color3;
  5492. /**
  5493. * Converts current color in rgb space to HSV values
  5494. * @returns a new color3 representing the HSV values
  5495. */
  5496. toHSV(): Color3;
  5497. /**
  5498. * Converts current color in rgb space to HSV values
  5499. * @param result defines the Color3 where to store the HSV values
  5500. */
  5501. toHSVToRef(result: Color3): void;
  5502. /**
  5503. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the linear space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5508. /**
  5509. * Computes a new Color3 converted from the current one to gamma space
  5510. * @returns a new Color3 object
  5511. */
  5512. toGammaSpace(): Color3;
  5513. /**
  5514. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5515. * @param convertedColor defines the Color3 object where to store the gamma space version
  5516. * @returns the unmodified Color3
  5517. */
  5518. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5519. private static _BlackReadOnly;
  5520. /**
  5521. * Convert Hue, saturation and value to a Color3 (RGB)
  5522. * @param hue defines the hue
  5523. * @param saturation defines the saturation
  5524. * @param value defines the value
  5525. * @param result defines the Color3 where to store the RGB values
  5526. */
  5527. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5528. /**
  5529. * Creates a new Color3 from the string containing valid hexadecimal values
  5530. * @param hex defines a string containing valid hexadecimal values
  5531. * @returns a new Color3 object
  5532. */
  5533. static FromHexString(hex: string): Color3;
  5534. /**
  5535. * Creates a new Color3 from the starting index of the given array
  5536. * @param array defines the source array
  5537. * @param offset defines an offset in the source array
  5538. * @returns a new Color3 object
  5539. */
  5540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5541. /**
  5542. * Creates a new Color3 from integer values (< 256)
  5543. * @param r defines the red component to read from (value between 0 and 255)
  5544. * @param g defines the green component to read from (value between 0 and 255)
  5545. * @param b defines the blue component to read from (value between 0 and 255)
  5546. * @returns a new Color3 object
  5547. */
  5548. static FromInts(r: number, g: number, b: number): Color3;
  5549. /**
  5550. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5551. * @param start defines the start Color3 value
  5552. * @param end defines the end Color3 value
  5553. * @param amount defines the gradient value between start and end
  5554. * @returns a new Color3 object
  5555. */
  5556. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5557. /**
  5558. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5559. * @param left defines the start value
  5560. * @param right defines the end value
  5561. * @param amount defines the gradient factor
  5562. * @param result defines the Color3 object where to store the result
  5563. */
  5564. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5565. /**
  5566. * Returns a Color3 value containing a red color
  5567. * @returns a new Color3 object
  5568. */
  5569. static Red(): Color3;
  5570. /**
  5571. * Returns a Color3 value containing a green color
  5572. * @returns a new Color3 object
  5573. */
  5574. static Green(): Color3;
  5575. /**
  5576. * Returns a Color3 value containing a blue color
  5577. * @returns a new Color3 object
  5578. */
  5579. static Blue(): Color3;
  5580. /**
  5581. * Returns a Color3 value containing a black color
  5582. * @returns a new Color3 object
  5583. */
  5584. static Black(): Color3;
  5585. /**
  5586. * Gets a Color3 value containing a black color that must not be updated
  5587. */
  5588. static get BlackReadOnly(): DeepImmutable<Color3>;
  5589. /**
  5590. * Returns a Color3 value containing a white color
  5591. * @returns a new Color3 object
  5592. */
  5593. static White(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a purple color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Purple(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a magenta color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Magenta(): Color3;
  5604. /**
  5605. * Returns a Color3 value containing a yellow color
  5606. * @returns a new Color3 object
  5607. */
  5608. static Yellow(): Color3;
  5609. /**
  5610. * Returns a Color3 value containing a gray color
  5611. * @returns a new Color3 object
  5612. */
  5613. static Gray(): Color3;
  5614. /**
  5615. * Returns a Color3 value containing a teal color
  5616. * @returns a new Color3 object
  5617. */
  5618. static Teal(): Color3;
  5619. /**
  5620. * Returns a Color3 value containing a random color
  5621. * @returns a new Color3 object
  5622. */
  5623. static Random(): Color3;
  5624. }
  5625. /**
  5626. * Class used to hold a RBGA color
  5627. */
  5628. export class Color4 {
  5629. /**
  5630. * Defines the red component (between 0 and 1, default is 0)
  5631. */
  5632. r: number;
  5633. /**
  5634. * Defines the green component (between 0 and 1, default is 0)
  5635. */
  5636. g: number;
  5637. /**
  5638. * Defines the blue component (between 0 and 1, default is 0)
  5639. */
  5640. b: number;
  5641. /**
  5642. * Defines the alpha component (between 0 and 1, default is 1)
  5643. */
  5644. a: number;
  5645. /**
  5646. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5647. * @param r defines the red component (between 0 and 1, default is 0)
  5648. * @param g defines the green component (between 0 and 1, default is 0)
  5649. * @param b defines the blue component (between 0 and 1, default is 0)
  5650. * @param a defines the alpha component (between 0 and 1, default is 1)
  5651. */
  5652. constructor(
  5653. /**
  5654. * Defines the red component (between 0 and 1, default is 0)
  5655. */
  5656. r?: number,
  5657. /**
  5658. * Defines the green component (between 0 and 1, default is 0)
  5659. */
  5660. g?: number,
  5661. /**
  5662. * Defines the blue component (between 0 and 1, default is 0)
  5663. */
  5664. b?: number,
  5665. /**
  5666. * Defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. a?: number);
  5669. /**
  5670. * Adds in place the given Color4 values to the current Color4 object
  5671. * @param right defines the second operand
  5672. * @returns the current updated Color4 object
  5673. */
  5674. addInPlace(right: DeepImmutable<Color4>): Color4;
  5675. /**
  5676. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5677. * @returns the new array
  5678. */
  5679. asArray(): number[];
  5680. /**
  5681. * Stores from the starting index in the given array the Color4 successive values
  5682. * @param array defines the array where to store the r,g,b components
  5683. * @param index defines an optional index in the target array to define where to start storing values
  5684. * @returns the current Color4 object
  5685. */
  5686. toArray(array: number[], index?: number): Color4;
  5687. /**
  5688. * Determines equality between Color4 objects
  5689. * @param otherColor defines the second operand
  5690. * @returns true if the rgba values are equal to the given ones
  5691. */
  5692. equals(otherColor: DeepImmutable<Color4>): boolean;
  5693. /**
  5694. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5695. * @param right defines the second operand
  5696. * @returns a new Color4 object
  5697. */
  5698. add(right: DeepImmutable<Color4>): Color4;
  5699. /**
  5700. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5701. * @param right defines the second operand
  5702. * @returns a new Color4 object
  5703. */
  5704. subtract(right: DeepImmutable<Color4>): Color4;
  5705. /**
  5706. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5707. * @param right defines the second operand
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the current Color4 object
  5710. */
  5711. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5712. /**
  5713. * Creates a new Color4 with the current Color4 values multiplied by scale
  5714. * @param scale defines the scaling factor to apply
  5715. * @returns a new Color4 object
  5716. */
  5717. scale(scale: number): Color4;
  5718. /**
  5719. * Multiplies the current Color4 values by scale and stores the result in "result"
  5720. * @param scale defines the scaling factor to apply
  5721. * @param result defines the Color4 object where to store the result
  5722. * @returns the current unmodified Color4
  5723. */
  5724. scaleToRef(scale: number, result: Color4): Color4;
  5725. /**
  5726. * Scale the current Color4 values by a factor and add the result to a given Color4
  5727. * @param scale defines the scale factor
  5728. * @param result defines the Color4 object where to store the result
  5729. * @returns the unmodified current Color4
  5730. */
  5731. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5732. /**
  5733. * Clamps the rgb values by the min and max values and stores the result into "result"
  5734. * @param min defines minimum clamping value (default is 0)
  5735. * @param max defines maximum clamping value (default is 1)
  5736. * @param result defines color to store the result into.
  5737. * @returns the cuurent Color4
  5738. */
  5739. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5740. /**
  5741. * Multipy an Color4 value by another and return a new Color4 object
  5742. * @param color defines the Color4 value to multiply by
  5743. * @returns a new Color4 object
  5744. */
  5745. multiply(color: Color4): Color4;
  5746. /**
  5747. * Multipy a Color4 value by another and push the result in a reference value
  5748. * @param color defines the Color4 value to multiply by
  5749. * @param result defines the Color4 to fill the result in
  5750. * @returns the result Color4
  5751. */
  5752. multiplyToRef(color: Color4, result: Color4): Color4;
  5753. /**
  5754. * Creates a string with the Color4 current values
  5755. * @returns the string representation of the Color4 object
  5756. */
  5757. toString(): string;
  5758. /**
  5759. * Returns the string "Color4"
  5760. * @returns "Color4"
  5761. */
  5762. getClassName(): string;
  5763. /**
  5764. * Compute the Color4 hash code
  5765. * @returns an unique number that can be used to hash Color4 objects
  5766. */
  5767. getHashCode(): number;
  5768. /**
  5769. * Creates a new Color4 copied from the current one
  5770. * @returns a new Color4 object
  5771. */
  5772. clone(): Color4;
  5773. /**
  5774. * Copies the given Color4 values into the current one
  5775. * @param source defines the source Color4 object
  5776. * @returns the current updated Color4 object
  5777. */
  5778. copyFrom(source: Color4): Color4;
  5779. /**
  5780. * Copies the given float values into the current one
  5781. * @param r defines the red component to read from
  5782. * @param g defines the green component to read from
  5783. * @param b defines the blue component to read from
  5784. * @param a defines the alpha component to read from
  5785. * @returns the current updated Color4 object
  5786. */
  5787. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5788. /**
  5789. * Copies the given float values into the current one
  5790. * @param r defines the red component to read from
  5791. * @param g defines the green component to read from
  5792. * @param b defines the blue component to read from
  5793. * @param a defines the alpha component to read from
  5794. * @returns the current updated Color4 object
  5795. */
  5796. set(r: number, g: number, b: number, a: number): Color4;
  5797. /**
  5798. * Compute the Color4 hexadecimal code as a string
  5799. * @returns a string containing the hexadecimal representation of the Color4 object
  5800. */
  5801. toHexString(): string;
  5802. /**
  5803. * Computes a new Color4 converted from the current one to linear space
  5804. * @returns a new Color4 object
  5805. */
  5806. toLinearSpace(): Color4;
  5807. /**
  5808. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5809. * @param convertedColor defines the Color4 object where to store the linear space version
  5810. * @returns the unmodified Color4
  5811. */
  5812. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5813. /**
  5814. * Computes a new Color4 converted from the current one to gamma space
  5815. * @returns a new Color4 object
  5816. */
  5817. toGammaSpace(): Color4;
  5818. /**
  5819. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5820. * @param convertedColor defines the Color4 object where to store the gamma space version
  5821. * @returns the unmodified Color4
  5822. */
  5823. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5824. /**
  5825. * Creates a new Color4 from the string containing valid hexadecimal values
  5826. * @param hex defines a string containing valid hexadecimal values
  5827. * @returns a new Color4 object
  5828. */
  5829. static FromHexString(hex: string): Color4;
  5830. /**
  5831. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5832. * @param left defines the start value
  5833. * @param right defines the end value
  5834. * @param amount defines the gradient factor
  5835. * @returns a new Color4 object
  5836. */
  5837. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5838. /**
  5839. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5840. * @param left defines the start value
  5841. * @param right defines the end value
  5842. * @param amount defines the gradient factor
  5843. * @param result defines the Color4 object where to store data
  5844. */
  5845. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5846. /**
  5847. * Creates a new Color4 from a Color3 and an alpha value
  5848. * @param color3 defines the source Color3 to read from
  5849. * @param alpha defines the alpha component (1.0 by default)
  5850. * @returns a new Color4 object
  5851. */
  5852. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5853. /**
  5854. * Creates a new Color4 from the starting index element of the given array
  5855. * @param array defines the source array to read from
  5856. * @param offset defines the offset in the source array
  5857. * @returns a new Color4 object
  5858. */
  5859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5860. /**
  5861. * Creates a new Color3 from integer values (< 256)
  5862. * @param r defines the red component to read from (value between 0 and 255)
  5863. * @param g defines the green component to read from (value between 0 and 255)
  5864. * @param b defines the blue component to read from (value between 0 and 255)
  5865. * @param a defines the alpha component to read from (value between 0 and 255)
  5866. * @returns a new Color3 object
  5867. */
  5868. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5869. /**
  5870. * Check the content of a given array and convert it to an array containing RGBA data
  5871. * If the original array was already containing count * 4 values then it is returned directly
  5872. * @param colors defines the array to check
  5873. * @param count defines the number of RGBA data to expect
  5874. * @returns an array containing count * 4 values (RGBA)
  5875. */
  5876. static CheckColors4(colors: number[], count: number): number[];
  5877. }
  5878. /**
  5879. * @hidden
  5880. */
  5881. export class TmpColors {
  5882. static Color3: Color3[];
  5883. static Color4: Color4[];
  5884. }
  5885. }
  5886. declare module "babylonjs/Animations/animationKey" {
  5887. /**
  5888. * Defines an interface which represents an animation key frame
  5889. */
  5890. export interface IAnimationKey {
  5891. /**
  5892. * Frame of the key frame
  5893. */
  5894. frame: number;
  5895. /**
  5896. * Value at the specifies key frame
  5897. */
  5898. value: any;
  5899. /**
  5900. * The input tangent for the cubic hermite spline
  5901. */
  5902. inTangent?: any;
  5903. /**
  5904. * The output tangent for the cubic hermite spline
  5905. */
  5906. outTangent?: any;
  5907. /**
  5908. * The animation interpolation type
  5909. */
  5910. interpolation?: AnimationKeyInterpolation;
  5911. }
  5912. /**
  5913. * Enum for the animation key frame interpolation type
  5914. */
  5915. export enum AnimationKeyInterpolation {
  5916. /**
  5917. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5918. */
  5919. STEP = 1
  5920. }
  5921. }
  5922. declare module "babylonjs/Animations/animationRange" {
  5923. /**
  5924. * Represents the range of an animation
  5925. */
  5926. export class AnimationRange {
  5927. /**The name of the animation range**/
  5928. name: string;
  5929. /**The starting frame of the animation */
  5930. from: number;
  5931. /**The ending frame of the animation*/
  5932. to: number;
  5933. /**
  5934. * Initializes the range of an animation
  5935. * @param name The name of the animation range
  5936. * @param from The starting frame of the animation
  5937. * @param to The ending frame of the animation
  5938. */
  5939. constructor(
  5940. /**The name of the animation range**/
  5941. name: string,
  5942. /**The starting frame of the animation */
  5943. from: number,
  5944. /**The ending frame of the animation*/
  5945. to: number);
  5946. /**
  5947. * Makes a copy of the animation range
  5948. * @returns A copy of the animation range
  5949. */
  5950. clone(): AnimationRange;
  5951. }
  5952. }
  5953. declare module "babylonjs/Animations/animationEvent" {
  5954. /**
  5955. * Composed of a frame, and an action function
  5956. */
  5957. export class AnimationEvent {
  5958. /** The frame for which the event is triggered **/
  5959. frame: number;
  5960. /** The event to perform when triggered **/
  5961. action: (currentFrame: number) => void;
  5962. /** Specifies if the event should be triggered only once**/
  5963. onlyOnce?: boolean | undefined;
  5964. /**
  5965. * Specifies if the animation event is done
  5966. */
  5967. isDone: boolean;
  5968. /**
  5969. * Initializes the animation event
  5970. * @param frame The frame for which the event is triggered
  5971. * @param action The event to perform when triggered
  5972. * @param onlyOnce Specifies if the event should be triggered only once
  5973. */
  5974. constructor(
  5975. /** The frame for which the event is triggered **/
  5976. frame: number,
  5977. /** The event to perform when triggered **/
  5978. action: (currentFrame: number) => void,
  5979. /** Specifies if the event should be triggered only once**/
  5980. onlyOnce?: boolean | undefined);
  5981. /** @hidden */
  5982. _clone(): AnimationEvent;
  5983. }
  5984. }
  5985. declare module "babylonjs/Behaviors/behavior" {
  5986. import { Nullable } from "babylonjs/types";
  5987. /**
  5988. * Interface used to define a behavior
  5989. */
  5990. export interface Behavior<T> {
  5991. /** gets or sets behavior's name */
  5992. name: string;
  5993. /**
  5994. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5995. */
  5996. init(): void;
  5997. /**
  5998. * Called when the behavior is attached to a target
  5999. * @param target defines the target where the behavior is attached to
  6000. */
  6001. attach(target: T): void;
  6002. /**
  6003. * Called when the behavior is detached from its target
  6004. */
  6005. detach(): void;
  6006. }
  6007. /**
  6008. * Interface implemented by classes supporting behaviors
  6009. */
  6010. export interface IBehaviorAware<T> {
  6011. /**
  6012. * Attach a behavior
  6013. * @param behavior defines the behavior to attach
  6014. * @returns the current host
  6015. */
  6016. addBehavior(behavior: Behavior<T>): T;
  6017. /**
  6018. * Remove a behavior from the current object
  6019. * @param behavior defines the behavior to detach
  6020. * @returns the current host
  6021. */
  6022. removeBehavior(behavior: Behavior<T>): T;
  6023. /**
  6024. * Gets a behavior using its name to search
  6025. * @param name defines the name to search
  6026. * @returns the behavior or null if not found
  6027. */
  6028. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6029. }
  6030. }
  6031. declare module "babylonjs/Misc/smartArray" {
  6032. /**
  6033. * Defines an array and its length.
  6034. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6035. */
  6036. export interface ISmartArrayLike<T> {
  6037. /**
  6038. * The data of the array.
  6039. */
  6040. data: Array<T>;
  6041. /**
  6042. * The active length of the array.
  6043. */
  6044. length: number;
  6045. }
  6046. /**
  6047. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6048. */
  6049. export class SmartArray<T> implements ISmartArrayLike<T> {
  6050. /**
  6051. * The full set of data from the array.
  6052. */
  6053. data: Array<T>;
  6054. /**
  6055. * The active length of the array.
  6056. */
  6057. length: number;
  6058. protected _id: number;
  6059. /**
  6060. * Instantiates a Smart Array.
  6061. * @param capacity defines the default capacity of the array.
  6062. */
  6063. constructor(capacity: number);
  6064. /**
  6065. * Pushes a value at the end of the active data.
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Iterates over the active data and apply the lambda to them.
  6071. * @param func defines the action to apply on each value.
  6072. */
  6073. forEach(func: (content: T) => void): void;
  6074. /**
  6075. * Sorts the full sets of data.
  6076. * @param compareFn defines the comparison function to apply.
  6077. */
  6078. sort(compareFn: (a: T, b: T) => number): void;
  6079. /**
  6080. * Resets the active data to an empty array.
  6081. */
  6082. reset(): void;
  6083. /**
  6084. * Releases all the data from the array as well as the array.
  6085. */
  6086. dispose(): void;
  6087. /**
  6088. * Concats the active data with a given array.
  6089. * @param array defines the data to concatenate with.
  6090. */
  6091. concat(array: any): void;
  6092. /**
  6093. * Returns the position of a value in the active data.
  6094. * @param value defines the value to find the index for
  6095. * @returns the index if found in the active data otherwise -1
  6096. */
  6097. indexOf(value: T): number;
  6098. /**
  6099. * Returns whether an element is part of the active data.
  6100. * @param value defines the value to look for
  6101. * @returns true if found in the active data otherwise false
  6102. */
  6103. contains(value: T): boolean;
  6104. private static _GlobalId;
  6105. }
  6106. /**
  6107. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6108. * The data in this array can only be present once
  6109. */
  6110. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6111. private _duplicateId;
  6112. /**
  6113. * Pushes a value at the end of the active data.
  6114. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6115. * @param value defines the object to push in the array.
  6116. */
  6117. push(value: T): void;
  6118. /**
  6119. * Pushes a value at the end of the active data.
  6120. * If the data is already present, it won t be added again
  6121. * @param value defines the object to push in the array.
  6122. * @returns true if added false if it was already present
  6123. */
  6124. pushNoDuplicate(value: T): boolean;
  6125. /**
  6126. * Resets the active data to an empty array.
  6127. */
  6128. reset(): void;
  6129. /**
  6130. * Concats the active data with a given array.
  6131. * This ensures no dupplicate will be present in the result.
  6132. * @param array defines the data to concatenate with.
  6133. */
  6134. concatWithNoDuplicate(array: any): void;
  6135. }
  6136. }
  6137. declare module "babylonjs/Cameras/cameraInputsManager" {
  6138. import { Nullable } from "babylonjs/types";
  6139. import { Camera } from "babylonjs/Cameras/camera";
  6140. /**
  6141. * @ignore
  6142. * This is a list of all the different input types that are available in the application.
  6143. * Fo instance: ArcRotateCameraGamepadInput...
  6144. */
  6145. export var CameraInputTypes: {};
  6146. /**
  6147. * This is the contract to implement in order to create a new input class.
  6148. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6149. */
  6150. export interface ICameraInput<TCamera extends Camera> {
  6151. /**
  6152. * Defines the camera the input is attached to.
  6153. */
  6154. camera: Nullable<TCamera>;
  6155. /**
  6156. * Gets the class name of the current intput.
  6157. * @returns the class name
  6158. */
  6159. getClassName(): string;
  6160. /**
  6161. * Get the friendly name associated with the input class.
  6162. * @returns the input friendly name
  6163. */
  6164. getSimpleName(): string;
  6165. /**
  6166. * Attach the input controls to a specific dom element to get the input from.
  6167. * @param element Defines the element the controls should be listened from
  6168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6169. */
  6170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6171. /**
  6172. * Detach the current controls from the specified dom element.
  6173. * @param element Defines the element to stop listening the inputs from
  6174. */
  6175. detachControl(element: Nullable<HTMLElement>): void;
  6176. /**
  6177. * Update the current camera state depending on the inputs that have been used this frame.
  6178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6179. */
  6180. checkInputs?: () => void;
  6181. }
  6182. /**
  6183. * Represents a map of input types to input instance or input index to input instance.
  6184. */
  6185. export interface CameraInputsMap<TCamera extends Camera> {
  6186. /**
  6187. * Accessor to the input by input type.
  6188. */
  6189. [name: string]: ICameraInput<TCamera>;
  6190. /**
  6191. * Accessor to the input by input index.
  6192. */
  6193. [idx: number]: ICameraInput<TCamera>;
  6194. }
  6195. /**
  6196. * This represents the input manager used within a camera.
  6197. * It helps dealing with all the different kind of input attached to a camera.
  6198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6199. */
  6200. export class CameraInputsManager<TCamera extends Camera> {
  6201. /**
  6202. * Defines the list of inputs attahed to the camera.
  6203. */
  6204. attached: CameraInputsMap<TCamera>;
  6205. /**
  6206. * Defines the dom element the camera is collecting inputs from.
  6207. * This is null if the controls have not been attached.
  6208. */
  6209. attachedElement: Nullable<HTMLElement>;
  6210. /**
  6211. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6212. */
  6213. noPreventDefault: boolean;
  6214. /**
  6215. * Defined the camera the input manager belongs to.
  6216. */
  6217. camera: TCamera;
  6218. /**
  6219. * Update the current camera state depending on the inputs that have been used this frame.
  6220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6221. */
  6222. checkInputs: () => void;
  6223. /**
  6224. * Instantiate a new Camera Input Manager.
  6225. * @param camera Defines the camera the input manager blongs to
  6226. */
  6227. constructor(camera: TCamera);
  6228. /**
  6229. * Add an input method to a camera
  6230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6231. * @param input camera input method
  6232. */
  6233. add(input: ICameraInput<TCamera>): void;
  6234. /**
  6235. * Remove a specific input method from a camera
  6236. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6237. * @param inputToRemove camera input method
  6238. */
  6239. remove(inputToRemove: ICameraInput<TCamera>): void;
  6240. /**
  6241. * Remove a specific input type from a camera
  6242. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6243. * @param inputType the type of the input to remove
  6244. */
  6245. removeByType(inputType: string): void;
  6246. private _addCheckInputs;
  6247. /**
  6248. * Attach the input controls to the currently attached dom element to listen the events from.
  6249. * @param input Defines the input to attach
  6250. */
  6251. attachInput(input: ICameraInput<TCamera>): void;
  6252. /**
  6253. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6254. * @param element Defines the dom element to collect the events from
  6255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6256. */
  6257. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6258. /**
  6259. * Detach the current manager inputs controls from a specific dom element.
  6260. * @param element Defines the dom element to collect the events from
  6261. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6262. */
  6263. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6264. /**
  6265. * Rebuild the dynamic inputCheck function from the current list of
  6266. * defined inputs in the manager.
  6267. */
  6268. rebuildInputCheck(): void;
  6269. /**
  6270. * Remove all attached input methods from a camera
  6271. */
  6272. clear(): void;
  6273. /**
  6274. * Serialize the current input manager attached to a camera.
  6275. * This ensures than once parsed,
  6276. * the input associated to the camera will be identical to the current ones
  6277. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6278. */
  6279. serialize(serializedCamera: any): void;
  6280. /**
  6281. * Parses an input manager serialized JSON to restore the previous list of inputs
  6282. * and states associated to a camera.
  6283. * @param parsedCamera Defines the JSON to parse
  6284. */
  6285. parse(parsedCamera: any): void;
  6286. }
  6287. }
  6288. declare module "babylonjs/Meshes/buffer" {
  6289. import { Nullable, DataArray } from "babylonjs/types";
  6290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6291. /**
  6292. * Class used to store data that will be store in GPU memory
  6293. */
  6294. export class Buffer {
  6295. private _engine;
  6296. private _buffer;
  6297. /** @hidden */
  6298. _data: Nullable<DataArray>;
  6299. private _updatable;
  6300. private _instanced;
  6301. private _divisor;
  6302. /**
  6303. * Gets the byte stride.
  6304. */
  6305. readonly byteStride: number;
  6306. /**
  6307. * Constructor
  6308. * @param engine the engine
  6309. * @param data the data to use for this buffer
  6310. * @param updatable whether the data is updatable
  6311. * @param stride the stride (optional)
  6312. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6313. * @param instanced whether the buffer is instanced (optional)
  6314. * @param useBytes set to true if the stride in in bytes (optional)
  6315. * @param divisor sets an optional divisor for instances (1 by default)
  6316. */
  6317. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6318. /**
  6319. * Create a new VertexBuffer based on the current buffer
  6320. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6321. * @param offset defines offset in the buffer (0 by default)
  6322. * @param size defines the size in floats of attributes (position is 3 for instance)
  6323. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6324. * @param instanced defines if the vertex buffer contains indexed data
  6325. * @param useBytes defines if the offset and stride are in bytes *
  6326. * @param divisor sets an optional divisor for instances (1 by default)
  6327. * @returns the new vertex buffer
  6328. */
  6329. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6330. /**
  6331. * Gets a boolean indicating if the Buffer is updatable?
  6332. * @returns true if the buffer is updatable
  6333. */
  6334. isUpdatable(): boolean;
  6335. /**
  6336. * Gets current buffer's data
  6337. * @returns a DataArray or null
  6338. */
  6339. getData(): Nullable<DataArray>;
  6340. /**
  6341. * Gets underlying native buffer
  6342. * @returns underlying native buffer
  6343. */
  6344. getBuffer(): Nullable<DataBuffer>;
  6345. /**
  6346. * Gets the stride in float32 units (i.e. byte stride / 4).
  6347. * May not be an integer if the byte stride is not divisible by 4.
  6348. * @returns the stride in float32 units
  6349. * @deprecated Please use byteStride instead.
  6350. */
  6351. getStrideSize(): number;
  6352. /**
  6353. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6354. * @param data defines the data to store
  6355. */
  6356. create(data?: Nullable<DataArray>): void;
  6357. /** @hidden */
  6358. _rebuild(): void;
  6359. /**
  6360. * Update current buffer data
  6361. * @param data defines the data to store
  6362. */
  6363. update(data: DataArray): void;
  6364. /**
  6365. * Updates the data directly.
  6366. * @param data the new data
  6367. * @param offset the new offset
  6368. * @param vertexCount the vertex count (optional)
  6369. * @param useBytes set to true if the offset is in bytes
  6370. */
  6371. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6372. /**
  6373. * Release all resources
  6374. */
  6375. dispose(): void;
  6376. }
  6377. /**
  6378. * Specialized buffer used to store vertex data
  6379. */
  6380. export class VertexBuffer {
  6381. /** @hidden */
  6382. _buffer: Buffer;
  6383. private _kind;
  6384. private _size;
  6385. private _ownsBuffer;
  6386. private _instanced;
  6387. private _instanceDivisor;
  6388. /**
  6389. * The byte type.
  6390. */
  6391. static readonly BYTE: number;
  6392. /**
  6393. * The unsigned byte type.
  6394. */
  6395. static readonly UNSIGNED_BYTE: number;
  6396. /**
  6397. * The short type.
  6398. */
  6399. static readonly SHORT: number;
  6400. /**
  6401. * The unsigned short type.
  6402. */
  6403. static readonly UNSIGNED_SHORT: number;
  6404. /**
  6405. * The integer type.
  6406. */
  6407. static readonly INT: number;
  6408. /**
  6409. * The unsigned integer type.
  6410. */
  6411. static readonly UNSIGNED_INT: number;
  6412. /**
  6413. * The float type.
  6414. */
  6415. static readonly FLOAT: number;
  6416. /**
  6417. * Gets or sets the instance divisor when in instanced mode
  6418. */
  6419. get instanceDivisor(): number;
  6420. set instanceDivisor(value: number);
  6421. /**
  6422. * Gets the byte stride.
  6423. */
  6424. readonly byteStride: number;
  6425. /**
  6426. * Gets the byte offset.
  6427. */
  6428. readonly byteOffset: number;
  6429. /**
  6430. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6431. */
  6432. readonly normalized: boolean;
  6433. /**
  6434. * Gets the data type of each component in the array.
  6435. */
  6436. readonly type: number;
  6437. /**
  6438. * Constructor
  6439. * @param engine the engine
  6440. * @param data the data to use for this vertex buffer
  6441. * @param kind the vertex buffer kind
  6442. * @param updatable whether the data is updatable
  6443. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6444. * @param stride the stride (optional)
  6445. * @param instanced whether the buffer is instanced (optional)
  6446. * @param offset the offset of the data (optional)
  6447. * @param size the number of components (optional)
  6448. * @param type the type of the component (optional)
  6449. * @param normalized whether the data contains normalized data (optional)
  6450. * @param useBytes set to true if stride and offset are in bytes (optional)
  6451. * @param divisor defines the instance divisor to use (1 by default)
  6452. */
  6453. 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);
  6454. /** @hidden */
  6455. _rebuild(): void;
  6456. /**
  6457. * Returns the kind of the VertexBuffer (string)
  6458. * @returns a string
  6459. */
  6460. getKind(): string;
  6461. /**
  6462. * Gets a boolean indicating if the VertexBuffer is updatable?
  6463. * @returns true if the buffer is updatable
  6464. */
  6465. isUpdatable(): boolean;
  6466. /**
  6467. * Gets current buffer's data
  6468. * @returns a DataArray or null
  6469. */
  6470. getData(): Nullable<DataArray>;
  6471. /**
  6472. * Gets underlying native buffer
  6473. * @returns underlying native buffer
  6474. */
  6475. getBuffer(): Nullable<DataBuffer>;
  6476. /**
  6477. * Gets the stride in float32 units (i.e. byte stride / 4).
  6478. * May not be an integer if the byte stride is not divisible by 4.
  6479. * @returns the stride in float32 units
  6480. * @deprecated Please use byteStride instead.
  6481. */
  6482. getStrideSize(): number;
  6483. /**
  6484. * Returns the offset as a multiple of the type byte length.
  6485. * @returns the offset in bytes
  6486. * @deprecated Please use byteOffset instead.
  6487. */
  6488. getOffset(): number;
  6489. /**
  6490. * Returns the number of components per vertex attribute (integer)
  6491. * @returns the size in float
  6492. */
  6493. getSize(): number;
  6494. /**
  6495. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6496. * @returns true if this buffer is instanced
  6497. */
  6498. getIsInstanced(): boolean;
  6499. /**
  6500. * Returns the instancing divisor, zero for non-instanced (integer).
  6501. * @returns a number
  6502. */
  6503. getInstanceDivisor(): number;
  6504. /**
  6505. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6506. * @param data defines the data to store
  6507. */
  6508. create(data?: DataArray): void;
  6509. /**
  6510. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6511. * This function will create a new buffer if the current one is not updatable
  6512. * @param data defines the data to store
  6513. */
  6514. update(data: DataArray): void;
  6515. /**
  6516. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6517. * Returns the directly updated WebGLBuffer.
  6518. * @param data the new data
  6519. * @param offset the new offset
  6520. * @param useBytes set to true if the offset is in bytes
  6521. */
  6522. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6523. /**
  6524. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6525. */
  6526. dispose(): void;
  6527. /**
  6528. * Enumerates each value of this vertex buffer as numbers.
  6529. * @param count the number of values to enumerate
  6530. * @param callback the callback function called for each value
  6531. */
  6532. forEach(count: number, callback: (value: number, index: number) => void): void;
  6533. /**
  6534. * Positions
  6535. */
  6536. static readonly PositionKind: string;
  6537. /**
  6538. * Normals
  6539. */
  6540. static readonly NormalKind: string;
  6541. /**
  6542. * Tangents
  6543. */
  6544. static readonly TangentKind: string;
  6545. /**
  6546. * Texture coordinates
  6547. */
  6548. static readonly UVKind: string;
  6549. /**
  6550. * Texture coordinates 2
  6551. */
  6552. static readonly UV2Kind: string;
  6553. /**
  6554. * Texture coordinates 3
  6555. */
  6556. static readonly UV3Kind: string;
  6557. /**
  6558. * Texture coordinates 4
  6559. */
  6560. static readonly UV4Kind: string;
  6561. /**
  6562. * Texture coordinates 5
  6563. */
  6564. static readonly UV5Kind: string;
  6565. /**
  6566. * Texture coordinates 6
  6567. */
  6568. static readonly UV6Kind: string;
  6569. /**
  6570. * Colors
  6571. */
  6572. static readonly ColorKind: string;
  6573. /**
  6574. * Matrix indices (for bones)
  6575. */
  6576. static readonly MatricesIndicesKind: string;
  6577. /**
  6578. * Matrix weights (for bones)
  6579. */
  6580. static readonly MatricesWeightsKind: string;
  6581. /**
  6582. * Additional matrix indices (for bones)
  6583. */
  6584. static readonly MatricesIndicesExtraKind: string;
  6585. /**
  6586. * Additional matrix weights (for bones)
  6587. */
  6588. static readonly MatricesWeightsExtraKind: string;
  6589. /**
  6590. * Deduces the stride given a kind.
  6591. * @param kind The kind string to deduce
  6592. * @returns The deduced stride
  6593. */
  6594. static DeduceStride(kind: string): number;
  6595. /**
  6596. * Gets the byte length of the given type.
  6597. * @param type the type
  6598. * @returns the number of bytes
  6599. */
  6600. static GetTypeByteLength(type: number): number;
  6601. /**
  6602. * Enumerates each value of the given parameters as numbers.
  6603. * @param data the data to enumerate
  6604. * @param byteOffset the byte offset of the data
  6605. * @param byteStride the byte stride of the data
  6606. * @param componentCount the number of components per element
  6607. * @param componentType the type of the component
  6608. * @param count the number of values to enumerate
  6609. * @param normalized whether the data is normalized
  6610. * @param callback the callback function called for each value
  6611. */
  6612. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6613. private static _GetFloatValue;
  6614. }
  6615. }
  6616. declare module "babylonjs/Collisions/intersectionInfo" {
  6617. import { Nullable } from "babylonjs/types";
  6618. /**
  6619. * @hidden
  6620. */
  6621. export class IntersectionInfo {
  6622. bu: Nullable<number>;
  6623. bv: Nullable<number>;
  6624. distance: number;
  6625. faceId: number;
  6626. subMeshId: number;
  6627. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6628. }
  6629. }
  6630. declare module "babylonjs/Maths/math.plane" {
  6631. import { DeepImmutable } from "babylonjs/types";
  6632. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6633. /**
  6634. * Represens a plane by the equation ax + by + cz + d = 0
  6635. */
  6636. export class Plane {
  6637. private static _TmpMatrix;
  6638. /**
  6639. * Normal of the plane (a,b,c)
  6640. */
  6641. normal: Vector3;
  6642. /**
  6643. * d component of the plane
  6644. */
  6645. d: number;
  6646. /**
  6647. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6648. * @param a a component of the plane
  6649. * @param b b component of the plane
  6650. * @param c c component of the plane
  6651. * @param d d component of the plane
  6652. */
  6653. constructor(a: number, b: number, c: number, d: number);
  6654. /**
  6655. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6656. */
  6657. asArray(): number[];
  6658. /**
  6659. * @returns a new plane copied from the current Plane.
  6660. */
  6661. clone(): Plane;
  6662. /**
  6663. * @returns the string "Plane".
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * @returns the Plane hash code.
  6668. */
  6669. getHashCode(): number;
  6670. /**
  6671. * Normalize the current Plane in place.
  6672. * @returns the updated Plane.
  6673. */
  6674. normalize(): Plane;
  6675. /**
  6676. * Applies a transformation the plane and returns the result
  6677. * @param transformation the transformation matrix to be applied to the plane
  6678. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6679. */
  6680. transform(transformation: DeepImmutable<Matrix>): Plane;
  6681. /**
  6682. * Calcualtte the dot product between the point and the plane normal
  6683. * @param point point to calculate the dot product with
  6684. * @returns the dot product (float) of the point coordinates and the plane normal.
  6685. */
  6686. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6687. /**
  6688. * Updates the current Plane from the plane defined by the three given points.
  6689. * @param point1 one of the points used to contruct the plane
  6690. * @param point2 one of the points used to contruct the plane
  6691. * @param point3 one of the points used to contruct the plane
  6692. * @returns the updated Plane.
  6693. */
  6694. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Checks if the plane is facing a given direction
  6697. * @param direction the direction to check if the plane is facing
  6698. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6699. * @returns True is the vector "direction" is the same side than the plane normal.
  6700. */
  6701. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6702. /**
  6703. * Calculates the distance to a point
  6704. * @param point point to calculate distance to
  6705. * @returns the signed distance (float) from the given point to the Plane.
  6706. */
  6707. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6708. /**
  6709. * Creates a plane from an array
  6710. * @param array the array to create a plane from
  6711. * @returns a new Plane from the given array.
  6712. */
  6713. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6714. /**
  6715. * Creates a plane from three points
  6716. * @param point1 point used to create the plane
  6717. * @param point2 point used to create the plane
  6718. * @param point3 point used to create the plane
  6719. * @returns a new Plane defined by the three given points.
  6720. */
  6721. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6722. /**
  6723. * Creates a plane from an origin point and a normal
  6724. * @param origin origin of the plane to be constructed
  6725. * @param normal normal of the plane to be constructed
  6726. * @returns a new Plane the normal vector to this plane at the given origin point.
  6727. * Note : the vector "normal" is updated because normalized.
  6728. */
  6729. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6730. /**
  6731. * Calculates the distance from a plane and a point
  6732. * @param origin origin of the plane to be constructed
  6733. * @param normal normal of the plane to be constructed
  6734. * @param point point to calculate distance to
  6735. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6736. */
  6737. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6738. }
  6739. }
  6740. declare module "babylonjs/Culling/boundingSphere" {
  6741. import { DeepImmutable } from "babylonjs/types";
  6742. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6743. import { Plane } from "babylonjs/Maths/math.plane";
  6744. /**
  6745. * Class used to store bounding sphere information
  6746. */
  6747. export class BoundingSphere {
  6748. /**
  6749. * Gets the center of the bounding sphere in local space
  6750. */
  6751. readonly center: Vector3;
  6752. /**
  6753. * Radius of the bounding sphere in local space
  6754. */
  6755. radius: number;
  6756. /**
  6757. * Gets the center of the bounding sphere in world space
  6758. */
  6759. readonly centerWorld: Vector3;
  6760. /**
  6761. * Radius of the bounding sphere in world space
  6762. */
  6763. radiusWorld: number;
  6764. /**
  6765. * Gets the minimum vector in local space
  6766. */
  6767. readonly minimum: Vector3;
  6768. /**
  6769. * Gets the maximum vector in local space
  6770. */
  6771. readonly maximum: Vector3;
  6772. private _worldMatrix;
  6773. private static readonly TmpVector3;
  6774. /**
  6775. * Creates a new bounding sphere
  6776. * @param min defines the minimum vector (in local space)
  6777. * @param max defines the maximum vector (in local space)
  6778. * @param worldMatrix defines the new world matrix
  6779. */
  6780. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6781. /**
  6782. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6783. * @param min defines the new minimum vector (in local space)
  6784. * @param max defines the new maximum vector (in local space)
  6785. * @param worldMatrix defines the new world matrix
  6786. */
  6787. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6788. /**
  6789. * Scale the current bounding sphere by applying a scale factor
  6790. * @param factor defines the scale factor to apply
  6791. * @returns the current bounding box
  6792. */
  6793. scale(factor: number): BoundingSphere;
  6794. /**
  6795. * Gets the world matrix of the bounding box
  6796. * @returns a matrix
  6797. */
  6798. getWorldMatrix(): DeepImmutable<Matrix>;
  6799. /** @hidden */
  6800. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6801. /**
  6802. * Tests if the bounding sphere is intersecting the frustum planes
  6803. * @param frustumPlanes defines the frustum planes to test
  6804. * @returns true if there is an intersection
  6805. */
  6806. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6807. /**
  6808. * Tests if the bounding sphere center is in between the frustum planes.
  6809. * Used for optimistic fast inclusion.
  6810. * @param frustumPlanes defines the frustum planes to test
  6811. * @returns true if the sphere center is in between the frustum planes
  6812. */
  6813. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6814. /**
  6815. * Tests if a point is inside the bounding sphere
  6816. * @param point defines the point to test
  6817. * @returns true if the point is inside the bounding sphere
  6818. */
  6819. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6820. /**
  6821. * Checks if two sphere intersct
  6822. * @param sphere0 sphere 0
  6823. * @param sphere1 sphere 1
  6824. * @returns true if the speres intersect
  6825. */
  6826. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6827. }
  6828. }
  6829. declare module "babylonjs/Culling/boundingBox" {
  6830. import { DeepImmutable } from "babylonjs/types";
  6831. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6832. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6833. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6834. import { Plane } from "babylonjs/Maths/math.plane";
  6835. /**
  6836. * Class used to store bounding box information
  6837. */
  6838. export class BoundingBox implements ICullable {
  6839. /**
  6840. * Gets the 8 vectors representing the bounding box in local space
  6841. */
  6842. readonly vectors: Vector3[];
  6843. /**
  6844. * Gets the center of the bounding box in local space
  6845. */
  6846. readonly center: Vector3;
  6847. /**
  6848. * Gets the center of the bounding box in world space
  6849. */
  6850. readonly centerWorld: Vector3;
  6851. /**
  6852. * Gets the extend size in local space
  6853. */
  6854. readonly extendSize: Vector3;
  6855. /**
  6856. * Gets the extend size in world space
  6857. */
  6858. readonly extendSizeWorld: Vector3;
  6859. /**
  6860. * Gets the OBB (object bounding box) directions
  6861. */
  6862. readonly directions: Vector3[];
  6863. /**
  6864. * Gets the 8 vectors representing the bounding box in world space
  6865. */
  6866. readonly vectorsWorld: Vector3[];
  6867. /**
  6868. * Gets the minimum vector in world space
  6869. */
  6870. readonly minimumWorld: Vector3;
  6871. /**
  6872. * Gets the maximum vector in world space
  6873. */
  6874. readonly maximumWorld: Vector3;
  6875. /**
  6876. * Gets the minimum vector in local space
  6877. */
  6878. readonly minimum: Vector3;
  6879. /**
  6880. * Gets the maximum vector in local space
  6881. */
  6882. readonly maximum: Vector3;
  6883. private _worldMatrix;
  6884. private static readonly TmpVector3;
  6885. /**
  6886. * @hidden
  6887. */
  6888. _tag: number;
  6889. /**
  6890. * Creates a new bounding box
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding box by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingBox;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(world: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding box is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding box is entirely inside the frustum planes
  6924. * @param frustumPlanes defines the frustum planes to test
  6925. * @returns true if there is an inclusion
  6926. */
  6927. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6928. /**
  6929. * Tests if a point is inside the bounding box
  6930. * @param point defines the point to test
  6931. * @returns true if the point is inside the bounding box
  6932. */
  6933. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6934. /**
  6935. * Tests if the bounding box intersects with a bounding sphere
  6936. * @param sphere defines the sphere to test
  6937. * @returns true if there is an intersection
  6938. */
  6939. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6940. /**
  6941. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6942. * @param min defines the min vector to use
  6943. * @param max defines the max vector to use
  6944. * @returns true if there is an intersection
  6945. */
  6946. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Tests if two bounding boxes are intersections
  6949. * @param box0 defines the first box to test
  6950. * @param box1 defines the second box to test
  6951. * @returns true if there is an intersection
  6952. */
  6953. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6954. /**
  6955. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6956. * @param minPoint defines the minimum vector of the bounding box
  6957. * @param maxPoint defines the maximum vector of the bounding box
  6958. * @param sphereCenter defines the sphere center
  6959. * @param sphereRadius defines the sphere radius
  6960. * @returns true if there is an intersection
  6961. */
  6962. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6963. /**
  6964. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6965. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @return true if there is an inclusion
  6968. */
  6969. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6972. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6973. * @param frustumPlanes defines the frustum planes to test
  6974. * @return true if there is an intersection
  6975. */
  6976. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6977. }
  6978. }
  6979. declare module "babylonjs/Collisions/collider" {
  6980. import { Nullable, IndicesArray } from "babylonjs/types";
  6981. import { Vector3 } from "babylonjs/Maths/math.vector";
  6982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6983. import { Plane } from "babylonjs/Maths/math.plane";
  6984. /** @hidden */
  6985. export class Collider {
  6986. /** Define if a collision was found */
  6987. collisionFound: boolean;
  6988. /**
  6989. * Define last intersection point in local space
  6990. */
  6991. intersectionPoint: Vector3;
  6992. /**
  6993. * Define last collided mesh
  6994. */
  6995. collidedMesh: Nullable<AbstractMesh>;
  6996. private _collisionPoint;
  6997. private _planeIntersectionPoint;
  6998. private _tempVector;
  6999. private _tempVector2;
  7000. private _tempVector3;
  7001. private _tempVector4;
  7002. private _edge;
  7003. private _baseToVertex;
  7004. private _destinationPoint;
  7005. private _slidePlaneNormal;
  7006. private _displacementVector;
  7007. /** @hidden */
  7008. _radius: Vector3;
  7009. /** @hidden */
  7010. _retry: number;
  7011. private _velocity;
  7012. private _basePoint;
  7013. private _epsilon;
  7014. /** @hidden */
  7015. _velocityWorldLength: number;
  7016. /** @hidden */
  7017. _basePointWorld: Vector3;
  7018. private _velocityWorld;
  7019. private _normalizedVelocity;
  7020. /** @hidden */
  7021. _initialVelocity: Vector3;
  7022. /** @hidden */
  7023. _initialPosition: Vector3;
  7024. private _nearestDistance;
  7025. private _collisionMask;
  7026. get collisionMask(): number;
  7027. set collisionMask(mask: number);
  7028. /**
  7029. * Gets the plane normal used to compute the sliding response (in local space)
  7030. */
  7031. get slidePlaneNormal(): Vector3;
  7032. /** @hidden */
  7033. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7034. /** @hidden */
  7035. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7036. /** @hidden */
  7037. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7038. /** @hidden */
  7039. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7042. /** @hidden */
  7043. _getResponse(pos: Vector3, vel: Vector3): void;
  7044. }
  7045. }
  7046. declare module "babylonjs/Culling/boundingInfo" {
  7047. import { DeepImmutable } from "babylonjs/types";
  7048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7050. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7051. import { Plane } from "babylonjs/Maths/math.plane";
  7052. import { Collider } from "babylonjs/Collisions/collider";
  7053. /**
  7054. * Interface for cullable objects
  7055. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7056. */
  7057. export interface ICullable {
  7058. /**
  7059. * Checks if the object or part of the object is in the frustum
  7060. * @param frustumPlanes Camera near/planes
  7061. * @returns true if the object is in frustum otherwise false
  7062. */
  7063. isInFrustum(frustumPlanes: Plane[]): boolean;
  7064. /**
  7065. * Checks if a cullable object (mesh...) is in the camera frustum
  7066. * Unlike isInFrustum this cheks the full bounding box
  7067. * @param frustumPlanes Camera near/planes
  7068. * @returns true if the object is in frustum otherwise false
  7069. */
  7070. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7071. }
  7072. /**
  7073. * Info for a bounding data of a mesh
  7074. */
  7075. export class BoundingInfo implements ICullable {
  7076. /**
  7077. * Bounding box for the mesh
  7078. */
  7079. readonly boundingBox: BoundingBox;
  7080. /**
  7081. * Bounding sphere for the mesh
  7082. */
  7083. readonly boundingSphere: BoundingSphere;
  7084. private _isLocked;
  7085. private static readonly TmpVector3;
  7086. /**
  7087. * Constructs bounding info
  7088. * @param minimum min vector of the bounding box/sphere
  7089. * @param maximum max vector of the bounding box/sphere
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * min vector of the bounding box/sphere
  7102. */
  7103. get minimum(): Vector3;
  7104. /**
  7105. * max vector of the bounding box/sphere
  7106. */
  7107. get maximum(): Vector3;
  7108. /**
  7109. * If the info is locked and won't be updated to avoid perf overhead
  7110. */
  7111. get isLocked(): boolean;
  7112. set isLocked(value: boolean);
  7113. /**
  7114. * Updates the bounding sphere and box
  7115. * @param world world matrix to be used to update
  7116. */
  7117. update(world: DeepImmutable<Matrix>): void;
  7118. /**
  7119. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7120. * @param center New center of the bounding info
  7121. * @param extend New extend of the bounding info
  7122. * @returns the current bounding info
  7123. */
  7124. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7125. /**
  7126. * Scale the current bounding info by applying a scale factor
  7127. * @param factor defines the scale factor to apply
  7128. * @returns the current bounding info
  7129. */
  7130. scale(factor: number): BoundingInfo;
  7131. /**
  7132. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7133. * @param frustumPlanes defines the frustum to test
  7134. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7135. * @returns true if the bounding info is in the frustum planes
  7136. */
  7137. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7138. /**
  7139. * Gets the world distance between the min and max points of the bounding box
  7140. */
  7141. get diagonalLength(): number;
  7142. /**
  7143. * Checks if a cullable object (mesh...) is in the camera frustum
  7144. * Unlike isInFrustum this cheks the full bounding box
  7145. * @param frustumPlanes Camera near/planes
  7146. * @returns true if the object is in frustum otherwise false
  7147. */
  7148. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7149. /** @hidden */
  7150. _checkCollision(collider: Collider): boolean;
  7151. /**
  7152. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7153. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7154. * @param point the point to check intersection with
  7155. * @returns if the point intersects
  7156. */
  7157. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7158. /**
  7159. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7160. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7161. * @param boundingInfo the bounding info to check intersection with
  7162. * @param precise if the intersection should be done using OBB
  7163. * @returns if the bounding info intersects
  7164. */
  7165. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7166. }
  7167. }
  7168. declare module "babylonjs/Maths/math.functions" {
  7169. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7170. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7171. /**
  7172. * Extracts minimum and maximum values from a list of indexed positions
  7173. * @param positions defines the positions to use
  7174. * @param indices defines the indices to the positions
  7175. * @param indexStart defines the start index
  7176. * @param indexCount defines the end index
  7177. * @param bias defines bias value to add to the result
  7178. * @return minimum and maximum values
  7179. */
  7180. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7181. minimum: Vector3;
  7182. maximum: Vector3;
  7183. };
  7184. /**
  7185. * Extracts minimum and maximum values from a list of positions
  7186. * @param positions defines the positions to use
  7187. * @param start defines the start index in the positions array
  7188. * @param count defines the number of positions to handle
  7189. * @param bias defines bias value to add to the result
  7190. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7191. * @return minimum and maximum values
  7192. */
  7193. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7194. minimum: Vector3;
  7195. maximum: Vector3;
  7196. };
  7197. }
  7198. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7199. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7200. /** @hidden */
  7201. export class WebGLDataBuffer extends DataBuffer {
  7202. private _buffer;
  7203. constructor(resource: WebGLBuffer);
  7204. get underlyingResource(): any;
  7205. }
  7206. }
  7207. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7208. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7209. import { Nullable } from "babylonjs/types";
  7210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7211. /** @hidden */
  7212. export class WebGLPipelineContext implements IPipelineContext {
  7213. engine: ThinEngine;
  7214. program: Nullable<WebGLProgram>;
  7215. context?: WebGLRenderingContext;
  7216. vertexShader?: WebGLShader;
  7217. fragmentShader?: WebGLShader;
  7218. isParallelCompiled: boolean;
  7219. onCompiled?: () => void;
  7220. transformFeedback?: WebGLTransformFeedback | null;
  7221. vertexCompilationError: Nullable<string>;
  7222. fragmentCompilationError: Nullable<string>;
  7223. programLinkError: Nullable<string>;
  7224. programValidationError: Nullable<string>;
  7225. get isAsync(): boolean;
  7226. get isReady(): boolean;
  7227. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7228. }
  7229. }
  7230. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7231. import { FloatArray, Nullable } from "babylonjs/types";
  7232. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7233. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7234. module "babylonjs/Engines/thinEngine" {
  7235. interface ThinEngine {
  7236. /**
  7237. * Create an uniform buffer
  7238. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7239. * @param elements defines the content of the uniform buffer
  7240. * @returns the webGL uniform buffer
  7241. */
  7242. createUniformBuffer(elements: FloatArray): DataBuffer;
  7243. /**
  7244. * Create a dynamic uniform buffer
  7245. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7246. * @param elements defines the content of the uniform buffer
  7247. * @returns the webGL uniform buffer
  7248. */
  7249. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7250. /**
  7251. * Update an existing uniform buffer
  7252. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7253. * @param uniformBuffer defines the target uniform buffer
  7254. * @param elements defines the content to update
  7255. * @param offset defines the offset in the uniform buffer where update should start
  7256. * @param count defines the size of the data to update
  7257. */
  7258. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7259. /**
  7260. * Bind an uniform buffer to the current webGL context
  7261. * @param buffer defines the buffer to bind
  7262. */
  7263. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7264. /**
  7265. * Bind a buffer to the current webGL context at a given location
  7266. * @param buffer defines the buffer to bind
  7267. * @param location defines the index where to bind the buffer
  7268. */
  7269. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7270. /**
  7271. * Bind a specific block at a given index in a specific shader program
  7272. * @param pipelineContext defines the pipeline context to use
  7273. * @param blockName defines the block name
  7274. * @param index defines the index where to bind the block
  7275. */
  7276. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7277. }
  7278. }
  7279. }
  7280. declare module "babylonjs/Materials/uniformBuffer" {
  7281. import { Nullable, FloatArray } from "babylonjs/types";
  7282. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7283. import { Engine } from "babylonjs/Engines/engine";
  7284. import { Effect } from "babylonjs/Materials/effect";
  7285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7286. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7287. import { Color3 } from "babylonjs/Maths/math.color";
  7288. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7289. /**
  7290. * Uniform buffer objects.
  7291. *
  7292. * Handles blocks of uniform on the GPU.
  7293. *
  7294. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7295. *
  7296. * For more information, please refer to :
  7297. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7298. */
  7299. export class UniformBuffer {
  7300. private _engine;
  7301. private _buffer;
  7302. private _data;
  7303. private _bufferData;
  7304. private _dynamic?;
  7305. private _uniformLocations;
  7306. private _uniformSizes;
  7307. private _uniformLocationPointer;
  7308. private _needSync;
  7309. private _noUBO;
  7310. private _currentEffect;
  7311. /** @hidden */
  7312. _alreadyBound: boolean;
  7313. private static _MAX_UNIFORM_SIZE;
  7314. private static _tempBuffer;
  7315. /**
  7316. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7321. /**
  7322. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7327. /**
  7328. * Lambda to Update a single float in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateFloat: (name: string, x: number) => void;
  7333. /**
  7334. * Lambda to Update a vec2 of float in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7339. /**
  7340. * Lambda to Update a vec3 of float in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update a vec4 of float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7351. /**
  7352. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateMatrix: (name: string, mat: Matrix) => void;
  7357. /**
  7358. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateVector3: (name: string, vector: Vector3) => void;
  7363. /**
  7364. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateVector4: (name: string, vector: Vector4) => void;
  7369. /**
  7370. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7375. /**
  7376. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7381. /**
  7382. * Instantiates a new Uniform buffer objects.
  7383. *
  7384. * Handles blocks of uniform on the GPU.
  7385. *
  7386. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7387. *
  7388. * For more information, please refer to :
  7389. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7390. * @param engine Define the engine the buffer is associated with
  7391. * @param data Define the data contained in the buffer
  7392. * @param dynamic Define if the buffer is updatable
  7393. */
  7394. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7395. /**
  7396. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7397. * or just falling back on setUniformXXX calls.
  7398. */
  7399. get useUbo(): boolean;
  7400. /**
  7401. * Indicates if the WebGL underlying uniform buffer is in sync
  7402. * with the javascript cache data.
  7403. */
  7404. get isSync(): boolean;
  7405. /**
  7406. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7407. * Also, a dynamic UniformBuffer will disable cache verification and always
  7408. * update the underlying WebGL uniform buffer to the GPU.
  7409. * @returns if Dynamic, otherwise false
  7410. */
  7411. isDynamic(): boolean;
  7412. /**
  7413. * The data cache on JS side.
  7414. * @returns the underlying data as a float array
  7415. */
  7416. getData(): Float32Array;
  7417. /**
  7418. * The underlying WebGL Uniform buffer.
  7419. * @returns the webgl buffer
  7420. */
  7421. getBuffer(): Nullable<DataBuffer>;
  7422. /**
  7423. * std140 layout specifies how to align data within an UBO structure.
  7424. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7425. * for specs.
  7426. */
  7427. private _fillAlignment;
  7428. /**
  7429. * Adds an uniform in the buffer.
  7430. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7431. * for the layout to be correct !
  7432. * @param name Name of the uniform, as used in the uniform block in the shader.
  7433. * @param size Data size, or data directly.
  7434. */
  7435. addUniform(name: string, size: number | number[]): void;
  7436. /**
  7437. * Adds a Matrix 4x4 to the uniform buffer.
  7438. * @param name Name of the uniform, as used in the uniform block in the shader.
  7439. * @param mat A 4x4 matrix.
  7440. */
  7441. addMatrix(name: string, mat: Matrix): void;
  7442. /**
  7443. * Adds a vec2 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param x Define the x component value of the vec2
  7446. * @param y Define the y component value of the vec2
  7447. */
  7448. addFloat2(name: string, x: number, y: number): void;
  7449. /**
  7450. * Adds a vec3 to the uniform buffer.
  7451. * @param name Name of the uniform, as used in the uniform block in the shader.
  7452. * @param x Define the x component value of the vec3
  7453. * @param y Define the y component value of the vec3
  7454. * @param z Define the z component value of the vec3
  7455. */
  7456. addFloat3(name: string, x: number, y: number, z: number): void;
  7457. /**
  7458. * Adds a vec3 to the uniform buffer.
  7459. * @param name Name of the uniform, as used in the uniform block in the shader.
  7460. * @param color Define the vec3 from a Color
  7461. */
  7462. addColor3(name: string, color: Color3): void;
  7463. /**
  7464. * Adds a vec4 to the uniform buffer.
  7465. * @param name Name of the uniform, as used in the uniform block in the shader.
  7466. * @param color Define the rgb components from a Color
  7467. * @param alpha Define the a component of the vec4
  7468. */
  7469. addColor4(name: string, color: Color3, alpha: number): void;
  7470. /**
  7471. * Adds a vec3 to the uniform buffer.
  7472. * @param name Name of the uniform, as used in the uniform block in the shader.
  7473. * @param vector Define the vec3 components from a Vector
  7474. */
  7475. addVector3(name: string, vector: Vector3): void;
  7476. /**
  7477. * Adds a Matrix 3x3 to the uniform buffer.
  7478. * @param name Name of the uniform, as used in the uniform block in the shader.
  7479. */
  7480. addMatrix3x3(name: string): void;
  7481. /**
  7482. * Adds a Matrix 2x2 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. */
  7485. addMatrix2x2(name: string): void;
  7486. /**
  7487. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7488. */
  7489. create(): void;
  7490. /** @hidden */
  7491. _rebuild(): void;
  7492. /**
  7493. * Updates the WebGL Uniform Buffer on the GPU.
  7494. * If the `dynamic` flag is set to true, no cache comparison is done.
  7495. * Otherwise, the buffer will be updated only if the cache differs.
  7496. */
  7497. update(): void;
  7498. /**
  7499. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. * @param size Define the size of the data.
  7503. */
  7504. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7505. private _valueCache;
  7506. private _cacheMatrix;
  7507. private _updateMatrix3x3ForUniform;
  7508. private _updateMatrix3x3ForEffect;
  7509. private _updateMatrix2x2ForEffect;
  7510. private _updateMatrix2x2ForUniform;
  7511. private _updateFloatForEffect;
  7512. private _updateFloatForUniform;
  7513. private _updateFloat2ForEffect;
  7514. private _updateFloat2ForUniform;
  7515. private _updateFloat3ForEffect;
  7516. private _updateFloat3ForUniform;
  7517. private _updateFloat4ForEffect;
  7518. private _updateFloat4ForUniform;
  7519. private _updateMatrixForEffect;
  7520. private _updateMatrixForUniform;
  7521. private _updateVector3ForEffect;
  7522. private _updateVector3ForUniform;
  7523. private _updateVector4ForEffect;
  7524. private _updateVector4ForUniform;
  7525. private _updateColor3ForEffect;
  7526. private _updateColor3ForUniform;
  7527. private _updateColor4ForEffect;
  7528. private _updateColor4ForUniform;
  7529. /**
  7530. * Sets a sampler uniform on the effect.
  7531. * @param name Define the name of the sampler.
  7532. * @param texture Define the texture to set in the sampler
  7533. */
  7534. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7535. /**
  7536. * Directly updates the value of the uniform in the cache AND on the GPU.
  7537. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7538. * @param data Define the flattened data
  7539. */
  7540. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7541. /**
  7542. * Binds this uniform buffer to an effect.
  7543. * @param effect Define the effect to bind the buffer to
  7544. * @param name Name of the uniform block in the shader.
  7545. */
  7546. bindToEffect(effect: Effect, name: string): void;
  7547. /**
  7548. * Disposes the uniform buffer.
  7549. */
  7550. dispose(): void;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/iInspectable" {
  7554. /**
  7555. * Enum that determines the text-wrapping mode to use.
  7556. */
  7557. export enum InspectableType {
  7558. /**
  7559. * Checkbox for booleans
  7560. */
  7561. Checkbox = 0,
  7562. /**
  7563. * Sliders for numbers
  7564. */
  7565. Slider = 1,
  7566. /**
  7567. * Vector3
  7568. */
  7569. Vector3 = 2,
  7570. /**
  7571. * Quaternions
  7572. */
  7573. Quaternion = 3,
  7574. /**
  7575. * Color3
  7576. */
  7577. Color3 = 4,
  7578. /**
  7579. * String
  7580. */
  7581. String = 5
  7582. }
  7583. /**
  7584. * Interface used to define custom inspectable properties.
  7585. * This interface is used by the inspector to display custom property grids
  7586. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7587. */
  7588. export interface IInspectable {
  7589. /**
  7590. * Gets the label to display
  7591. */
  7592. label: string;
  7593. /**
  7594. * Gets the name of the property to edit
  7595. */
  7596. propertyName: string;
  7597. /**
  7598. * Gets the type of the editor to use
  7599. */
  7600. type: InspectableType;
  7601. /**
  7602. * Gets the minimum value of the property when using in "slider" mode
  7603. */
  7604. min?: number;
  7605. /**
  7606. * Gets the maximum value of the property when using in "slider" mode
  7607. */
  7608. max?: number;
  7609. /**
  7610. * Gets the setp to use when using in "slider" mode
  7611. */
  7612. step?: number;
  7613. }
  7614. }
  7615. declare module "babylonjs/Misc/timingTools" {
  7616. /**
  7617. * Class used to provide helper for timing
  7618. */
  7619. export class TimingTools {
  7620. /**
  7621. * Polyfill for setImmediate
  7622. * @param action defines the action to execute after the current execution block
  7623. */
  7624. static SetImmediate(action: () => void): void;
  7625. }
  7626. }
  7627. declare module "babylonjs/Misc/instantiationTools" {
  7628. /**
  7629. * Class used to enable instatition of objects by class name
  7630. */
  7631. export class InstantiationTools {
  7632. /**
  7633. * Use this object to register external classes like custom textures or material
  7634. * to allow the laoders to instantiate them
  7635. */
  7636. static RegisteredExternalClasses: {
  7637. [key: string]: Object;
  7638. };
  7639. /**
  7640. * Tries to instantiate a new object from a given class name
  7641. * @param className defines the class name to instantiate
  7642. * @returns the new object or null if the system was not able to do the instantiation
  7643. */
  7644. static Instantiate(className: string): any;
  7645. }
  7646. }
  7647. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7648. /**
  7649. * Define options used to create a depth texture
  7650. */
  7651. export class DepthTextureCreationOptions {
  7652. /** Specifies whether or not a stencil should be allocated in the texture */
  7653. generateStencil?: boolean;
  7654. /** Specifies whether or not bilinear filtering is enable on the texture */
  7655. bilinearFiltering?: boolean;
  7656. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7657. comparisonFunction?: number;
  7658. /** Specifies if the created texture is a cube texture */
  7659. isCube?: boolean;
  7660. }
  7661. }
  7662. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7664. import { Nullable } from "babylonjs/types";
  7665. import { Scene } from "babylonjs/scene";
  7666. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7667. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7668. module "babylonjs/Engines/thinEngine" {
  7669. interface ThinEngine {
  7670. /**
  7671. * Creates a depth stencil cube texture.
  7672. * This is only available in WebGL 2.
  7673. * @param size The size of face edge in the cube texture.
  7674. * @param options The options defining the cube texture.
  7675. * @returns The cube texture
  7676. */
  7677. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7678. /**
  7679. * Creates a cube texture
  7680. * @param rootUrl defines the url where the files to load is located
  7681. * @param scene defines the current scene
  7682. * @param files defines the list of files to load (1 per face)
  7683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7684. * @param onLoad defines an optional callback raised when the texture is loaded
  7685. * @param onError defines an optional callback raised if there is an issue to load the texture
  7686. * @param format defines the format of the data
  7687. * @param forcedExtension defines the extension to use to pick the right loader
  7688. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7689. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7690. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7691. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7692. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7693. * @returns the cube texture as an InternalTexture
  7694. */
  7695. 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;
  7696. /**
  7697. * Creates a cube texture
  7698. * @param rootUrl defines the url where the files to load is located
  7699. * @param scene defines the current scene
  7700. * @param files defines the list of files to load (1 per face)
  7701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7702. * @param onLoad defines an optional callback raised when the texture is loaded
  7703. * @param onError defines an optional callback raised if there is an issue to load the texture
  7704. * @param format defines the format of the data
  7705. * @param forcedExtension defines the extension to use to pick the right loader
  7706. * @returns the cube texture as an InternalTexture
  7707. */
  7708. 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;
  7709. /**
  7710. * Creates a cube texture
  7711. * @param rootUrl defines the url where the files to load is located
  7712. * @param scene defines the current scene
  7713. * @param files defines the list of files to load (1 per face)
  7714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7715. * @param onLoad defines an optional callback raised when the texture is loaded
  7716. * @param onError defines an optional callback raised if there is an issue to load the texture
  7717. * @param format defines the format of the data
  7718. * @param forcedExtension defines the extension to use to pick the right loader
  7719. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  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, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7725. /** @hidden */
  7726. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7727. /** @hidden */
  7728. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7729. /** @hidden */
  7730. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7731. /** @hidden */
  7732. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7733. /**
  7734. * @hidden
  7735. */
  7736. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7737. }
  7738. }
  7739. }
  7740. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7741. import { Nullable } from "babylonjs/types";
  7742. import { Scene } from "babylonjs/scene";
  7743. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7745. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7746. /**
  7747. * Class for creating a cube texture
  7748. */
  7749. export class CubeTexture extends BaseTexture {
  7750. private _delayedOnLoad;
  7751. /**
  7752. * The url of the texture
  7753. */
  7754. url: string;
  7755. /**
  7756. * Gets or sets the center of the bounding box associated with the cube texture.
  7757. * It must define where the camera used to render the texture was set
  7758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7759. */
  7760. boundingBoxPosition: Vector3;
  7761. private _boundingBoxSize;
  7762. /**
  7763. * Gets or sets the size of the bounding box associated with the cube texture
  7764. * When defined, the cubemap will switch to local mode
  7765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7766. * @example https://www.babylonjs-playground.com/#RNASML
  7767. */
  7768. set boundingBoxSize(value: Vector3);
  7769. /**
  7770. * Returns the bounding box size
  7771. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7772. */
  7773. get boundingBoxSize(): Vector3;
  7774. protected _rotationY: number;
  7775. /**
  7776. * Sets texture matrix rotation angle around Y axis in radians.
  7777. */
  7778. set rotationY(value: number);
  7779. /**
  7780. * Gets texture matrix rotation angle around Y axis radians.
  7781. */
  7782. get rotationY(): number;
  7783. /**
  7784. * Are mip maps generated for this texture or not.
  7785. */
  7786. get noMipmap(): boolean;
  7787. private _noMipmap;
  7788. private _files;
  7789. protected _forcedExtension: Nullable<string>;
  7790. private _extensions;
  7791. private _textureMatrix;
  7792. private _format;
  7793. private _createPolynomials;
  7794. /** @hidden */
  7795. _prefiltered: boolean;
  7796. /**
  7797. * Creates a cube texture from an array of image urls
  7798. * @param files defines an array of image urls
  7799. * @param scene defines the hosting scene
  7800. * @param noMipmap specifies if mip maps are not used
  7801. * @returns a cube texture
  7802. */
  7803. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7804. /**
  7805. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7806. * @param url defines the url of the prefiltered texture
  7807. * @param scene defines the scene the texture is attached to
  7808. * @param forcedExtension defines the extension of the file if different from the url
  7809. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7810. * @return the prefiltered texture
  7811. */
  7812. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7813. /**
  7814. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7815. * as prefiltered data.
  7816. * @param rootUrl defines the url of the texture or the root name of the six images
  7817. * @param scene defines the scene the texture is attached to
  7818. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7819. * @param noMipmap defines if mipmaps should be created or not
  7820. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7821. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7822. * @param onError defines a callback triggered in case of error during load
  7823. * @param format defines the internal format to use for the texture once loaded
  7824. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7825. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7826. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7827. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7828. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7829. * @return the cube texture
  7830. */
  7831. 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);
  7832. /**
  7833. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7834. */
  7835. get isPrefiltered(): boolean;
  7836. /**
  7837. * Get the current class name of the texture useful for serialization or dynamic coding.
  7838. * @returns "CubeTexture"
  7839. */
  7840. getClassName(): string;
  7841. /**
  7842. * Update the url (and optional buffer) of this texture if url was null during construction.
  7843. * @param url the url of the texture
  7844. * @param forcedExtension defines the extension to use
  7845. * @param onLoad callback called when the texture is loaded (defaults to null)
  7846. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7847. */
  7848. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7849. /**
  7850. * Delays loading of the cube texture
  7851. * @param forcedExtension defines the extension to use
  7852. */
  7853. delayLoad(forcedExtension?: string): void;
  7854. /**
  7855. * Returns the reflection texture matrix
  7856. * @returns the reflection texture matrix
  7857. */
  7858. getReflectionTextureMatrix(): Matrix;
  7859. /**
  7860. * Sets the reflection texture matrix
  7861. * @param value Reflection texture matrix
  7862. */
  7863. setReflectionTextureMatrix(value: Matrix): void;
  7864. /**
  7865. * Parses text to create a cube texture
  7866. * @param parsedTexture define the serialized text to read from
  7867. * @param scene defines the hosting scene
  7868. * @param rootUrl defines the root url of the cube texture
  7869. * @returns a cube texture
  7870. */
  7871. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7872. /**
  7873. * Makes a clone, or deep copy, of the cube texture
  7874. * @returns a new cube texture
  7875. */
  7876. clone(): CubeTexture;
  7877. }
  7878. }
  7879. declare module "babylonjs/Materials/materialDefines" {
  7880. /**
  7881. * Manages the defines for the Material
  7882. */
  7883. export class MaterialDefines {
  7884. /** @hidden */
  7885. protected _keys: string[];
  7886. private _isDirty;
  7887. /** @hidden */
  7888. _renderId: number;
  7889. /** @hidden */
  7890. _areLightsDirty: boolean;
  7891. /** @hidden */
  7892. _areLightsDisposed: boolean;
  7893. /** @hidden */
  7894. _areAttributesDirty: boolean;
  7895. /** @hidden */
  7896. _areTexturesDirty: boolean;
  7897. /** @hidden */
  7898. _areFresnelDirty: boolean;
  7899. /** @hidden */
  7900. _areMiscDirty: boolean;
  7901. /** @hidden */
  7902. _areImageProcessingDirty: boolean;
  7903. /** @hidden */
  7904. _normals: boolean;
  7905. /** @hidden */
  7906. _uvs: boolean;
  7907. /** @hidden */
  7908. _needNormals: boolean;
  7909. /** @hidden */
  7910. _needUVs: boolean;
  7911. [id: string]: any;
  7912. /**
  7913. * Specifies if the material needs to be re-calculated
  7914. */
  7915. get isDirty(): boolean;
  7916. /**
  7917. * Marks the material to indicate that it has been re-calculated
  7918. */
  7919. markAsProcessed(): void;
  7920. /**
  7921. * Marks the material to indicate that it needs to be re-calculated
  7922. */
  7923. markAsUnprocessed(): void;
  7924. /**
  7925. * Marks the material to indicate all of its defines need to be re-calculated
  7926. */
  7927. markAllAsDirty(): void;
  7928. /**
  7929. * Marks the material to indicate that image processing needs to be re-calculated
  7930. */
  7931. markAsImageProcessingDirty(): void;
  7932. /**
  7933. * Marks the material to indicate the lights need to be re-calculated
  7934. * @param disposed Defines whether the light is dirty due to dispose or not
  7935. */
  7936. markAsLightDirty(disposed?: boolean): void;
  7937. /**
  7938. * Marks the attribute state as changed
  7939. */
  7940. markAsAttributesDirty(): void;
  7941. /**
  7942. * Marks the texture state as changed
  7943. */
  7944. markAsTexturesDirty(): void;
  7945. /**
  7946. * Marks the fresnel state as changed
  7947. */
  7948. markAsFresnelDirty(): void;
  7949. /**
  7950. * Marks the misc state as changed
  7951. */
  7952. markAsMiscDirty(): void;
  7953. /**
  7954. * Rebuilds the material defines
  7955. */
  7956. rebuild(): void;
  7957. /**
  7958. * Specifies if two material defines are equal
  7959. * @param other - A material define instance to compare to
  7960. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7961. */
  7962. isEqual(other: MaterialDefines): boolean;
  7963. /**
  7964. * Clones this instance's defines to another instance
  7965. * @param other - material defines to clone values to
  7966. */
  7967. cloneTo(other: MaterialDefines): void;
  7968. /**
  7969. * Resets the material define values
  7970. */
  7971. reset(): void;
  7972. /**
  7973. * Converts the material define values to a string
  7974. * @returns - String of material define information
  7975. */
  7976. toString(): string;
  7977. }
  7978. }
  7979. declare module "babylonjs/Materials/colorCurves" {
  7980. import { Effect } from "babylonjs/Materials/effect";
  7981. /**
  7982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7984. * 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;
  7985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7986. */
  7987. export class ColorCurves {
  7988. private _dirty;
  7989. private _tempColor;
  7990. private _globalCurve;
  7991. private _highlightsCurve;
  7992. private _midtonesCurve;
  7993. private _shadowsCurve;
  7994. private _positiveCurve;
  7995. private _negativeCurve;
  7996. private _globalHue;
  7997. private _globalDensity;
  7998. private _globalSaturation;
  7999. private _globalExposure;
  8000. /**
  8001. * Gets the global Hue value.
  8002. * 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).
  8003. */
  8004. get globalHue(): number;
  8005. /**
  8006. * Sets the global Hue value.
  8007. * 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).
  8008. */
  8009. set globalHue(value: number);
  8010. /**
  8011. * Gets the global Density value.
  8012. * 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.
  8013. * Values less than zero provide a filter of opposite hue.
  8014. */
  8015. get globalDensity(): number;
  8016. /**
  8017. * Sets the global Density value.
  8018. * 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.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. set globalDensity(value: number);
  8022. /**
  8023. * Gets the global Saturation value.
  8024. * 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.
  8025. */
  8026. get globalSaturation(): number;
  8027. /**
  8028. * Sets the global Saturation value.
  8029. * 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.
  8030. */
  8031. set globalSaturation(value: number);
  8032. /**
  8033. * Gets the global Exposure value.
  8034. * 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.
  8035. */
  8036. get globalExposure(): number;
  8037. /**
  8038. * Sets the global Exposure value.
  8039. * 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.
  8040. */
  8041. set globalExposure(value: number);
  8042. private _highlightsHue;
  8043. private _highlightsDensity;
  8044. private _highlightsSaturation;
  8045. private _highlightsExposure;
  8046. /**
  8047. * Gets the highlights Hue value.
  8048. * 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).
  8049. */
  8050. get highlightsHue(): number;
  8051. /**
  8052. * Sets the highlights Hue value.
  8053. * 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).
  8054. */
  8055. set highlightsHue(value: number);
  8056. /**
  8057. * Gets the highlights Density value.
  8058. * 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.
  8059. * Values less than zero provide a filter of opposite hue.
  8060. */
  8061. get highlightsDensity(): number;
  8062. /**
  8063. * Sets the highlights Density value.
  8064. * 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.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. set highlightsDensity(value: number);
  8068. /**
  8069. * Gets the highlights Saturation value.
  8070. * 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.
  8071. */
  8072. get highlightsSaturation(): number;
  8073. /**
  8074. * Sets the highlights Saturation value.
  8075. * 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.
  8076. */
  8077. set highlightsSaturation(value: number);
  8078. /**
  8079. * Gets the highlights Exposure value.
  8080. * 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.
  8081. */
  8082. get highlightsExposure(): number;
  8083. /**
  8084. * Sets the highlights Exposure value.
  8085. * 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.
  8086. */
  8087. set highlightsExposure(value: number);
  8088. private _midtonesHue;
  8089. private _midtonesDensity;
  8090. private _midtonesSaturation;
  8091. private _midtonesExposure;
  8092. /**
  8093. * Gets the midtones Hue value.
  8094. * 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).
  8095. */
  8096. get midtonesHue(): number;
  8097. /**
  8098. * Sets the midtones Hue value.
  8099. * 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).
  8100. */
  8101. set midtonesHue(value: number);
  8102. /**
  8103. * Gets the midtones Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. get midtonesDensity(): number;
  8108. /**
  8109. * Sets the midtones Density value.
  8110. * 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.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. set midtonesDensity(value: number);
  8114. /**
  8115. * Gets the midtones Saturation value.
  8116. * 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.
  8117. */
  8118. get midtonesSaturation(): number;
  8119. /**
  8120. * Sets the midtones Saturation value.
  8121. * 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.
  8122. */
  8123. set midtonesSaturation(value: number);
  8124. /**
  8125. * Gets the midtones Exposure value.
  8126. * 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.
  8127. */
  8128. get midtonesExposure(): number;
  8129. /**
  8130. * Sets the midtones Exposure value.
  8131. * 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.
  8132. */
  8133. set midtonesExposure(value: number);
  8134. private _shadowsHue;
  8135. private _shadowsDensity;
  8136. private _shadowsSaturation;
  8137. private _shadowsExposure;
  8138. /**
  8139. * Gets the shadows Hue value.
  8140. * 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).
  8141. */
  8142. get shadowsHue(): number;
  8143. /**
  8144. * Sets the shadows Hue value.
  8145. * 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).
  8146. */
  8147. set shadowsHue(value: number);
  8148. /**
  8149. * Gets the shadows Density value.
  8150. * 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.
  8151. * Values less than zero provide a filter of opposite hue.
  8152. */
  8153. get shadowsDensity(): number;
  8154. /**
  8155. * Sets the shadows Density value.
  8156. * 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.
  8157. * Values less than zero provide a filter of opposite hue.
  8158. */
  8159. set shadowsDensity(value: number);
  8160. /**
  8161. * Gets the shadows Saturation value.
  8162. * 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.
  8163. */
  8164. get shadowsSaturation(): number;
  8165. /**
  8166. * Sets the shadows Saturation value.
  8167. * 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.
  8168. */
  8169. set shadowsSaturation(value: number);
  8170. /**
  8171. * Gets the shadows Exposure value.
  8172. * 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.
  8173. */
  8174. get shadowsExposure(): number;
  8175. /**
  8176. * Sets the shadows Exposure value.
  8177. * 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.
  8178. */
  8179. set shadowsExposure(value: number);
  8180. /**
  8181. * Returns the class name
  8182. * @returns The class name
  8183. */
  8184. getClassName(): string;
  8185. /**
  8186. * Binds the color curves to the shader.
  8187. * @param colorCurves The color curve to bind
  8188. * @param effect The effect to bind to
  8189. * @param positiveUniform The positive uniform shader parameter
  8190. * @param neutralUniform The neutral uniform shader parameter
  8191. * @param negativeUniform The negative uniform shader parameter
  8192. */
  8193. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8194. /**
  8195. * Prepare the list of uniforms associated with the ColorCurves effects.
  8196. * @param uniformsList The list of uniforms used in the effect
  8197. */
  8198. static PrepareUniforms(uniformsList: string[]): void;
  8199. /**
  8200. * Returns color grading data based on a hue, density, saturation and exposure value.
  8201. * @param filterHue The hue of the color filter.
  8202. * @param filterDensity The density of the color filter.
  8203. * @param saturation The saturation.
  8204. * @param exposure The exposure.
  8205. * @param result The result data container.
  8206. */
  8207. private getColorGradingDataToRef;
  8208. /**
  8209. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8210. * @param value The input slider value in range [-100,100].
  8211. * @returns Adjusted value.
  8212. */
  8213. private static applyColorGradingSliderNonlinear;
  8214. /**
  8215. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8216. * @param hue The hue (H) input.
  8217. * @param saturation The saturation (S) input.
  8218. * @param brightness The brightness (B) input.
  8219. * @result An RGBA color represented as Vector4.
  8220. */
  8221. private static fromHSBToRef;
  8222. /**
  8223. * Returns a value clamped between min and max
  8224. * @param value The value to clamp
  8225. * @param min The minimum of value
  8226. * @param max The maximum of value
  8227. * @returns The clamped value.
  8228. */
  8229. private static clamp;
  8230. /**
  8231. * Clones the current color curve instance.
  8232. * @return The cloned curves
  8233. */
  8234. clone(): ColorCurves;
  8235. /**
  8236. * Serializes the current color curve instance to a json representation.
  8237. * @return a JSON representation
  8238. */
  8239. serialize(): any;
  8240. /**
  8241. * Parses the color curve from a json representation.
  8242. * @param source the JSON source to parse
  8243. * @return The parsed curves
  8244. */
  8245. static Parse(source: any): ColorCurves;
  8246. }
  8247. }
  8248. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8249. import { Observable } from "babylonjs/Misc/observable";
  8250. import { Nullable } from "babylonjs/types";
  8251. import { Color4 } from "babylonjs/Maths/math.color";
  8252. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8253. import { Effect } from "babylonjs/Materials/effect";
  8254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8255. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8256. /**
  8257. * Interface to follow in your material defines to integrate easily the
  8258. * Image proccessing functions.
  8259. * @hidden
  8260. */
  8261. export interface IImageProcessingConfigurationDefines {
  8262. IMAGEPROCESSING: boolean;
  8263. VIGNETTE: boolean;
  8264. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8265. VIGNETTEBLENDMODEOPAQUE: boolean;
  8266. TONEMAPPING: boolean;
  8267. TONEMAPPING_ACES: boolean;
  8268. CONTRAST: boolean;
  8269. EXPOSURE: boolean;
  8270. COLORCURVES: boolean;
  8271. COLORGRADING: boolean;
  8272. COLORGRADING3D: boolean;
  8273. SAMPLER3DGREENDEPTH: boolean;
  8274. SAMPLER3DBGRMAP: boolean;
  8275. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8276. }
  8277. /**
  8278. * @hidden
  8279. */
  8280. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8281. IMAGEPROCESSING: boolean;
  8282. VIGNETTE: boolean;
  8283. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8284. VIGNETTEBLENDMODEOPAQUE: boolean;
  8285. TONEMAPPING: boolean;
  8286. TONEMAPPING_ACES: boolean;
  8287. CONTRAST: boolean;
  8288. COLORCURVES: boolean;
  8289. COLORGRADING: boolean;
  8290. COLORGRADING3D: boolean;
  8291. SAMPLER3DGREENDEPTH: boolean;
  8292. SAMPLER3DBGRMAP: boolean;
  8293. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8294. EXPOSURE: boolean;
  8295. constructor();
  8296. }
  8297. /**
  8298. * This groups together the common properties used for image processing either in direct forward pass
  8299. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8300. * or not.
  8301. */
  8302. export class ImageProcessingConfiguration {
  8303. /**
  8304. * Default tone mapping applied in BabylonJS.
  8305. */
  8306. static readonly TONEMAPPING_STANDARD: number;
  8307. /**
  8308. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8309. * to other engines rendering to increase portability.
  8310. */
  8311. static readonly TONEMAPPING_ACES: number;
  8312. /**
  8313. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8314. */
  8315. colorCurves: Nullable<ColorCurves>;
  8316. private _colorCurvesEnabled;
  8317. /**
  8318. * Gets wether the color curves effect is enabled.
  8319. */
  8320. get colorCurvesEnabled(): boolean;
  8321. /**
  8322. * Sets wether the color curves effect is enabled.
  8323. */
  8324. set colorCurvesEnabled(value: boolean);
  8325. private _colorGradingTexture;
  8326. /**
  8327. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8328. */
  8329. get colorGradingTexture(): Nullable<BaseTexture>;
  8330. /**
  8331. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8332. */
  8333. set colorGradingTexture(value: Nullable<BaseTexture>);
  8334. private _colorGradingEnabled;
  8335. /**
  8336. * Gets wether the color grading effect is enabled.
  8337. */
  8338. get colorGradingEnabled(): boolean;
  8339. /**
  8340. * Sets wether the color grading effect is enabled.
  8341. */
  8342. set colorGradingEnabled(value: boolean);
  8343. private _colorGradingWithGreenDepth;
  8344. /**
  8345. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8346. */
  8347. get colorGradingWithGreenDepth(): boolean;
  8348. /**
  8349. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8350. */
  8351. set colorGradingWithGreenDepth(value: boolean);
  8352. private _colorGradingBGR;
  8353. /**
  8354. * Gets wether the color grading texture contains BGR values.
  8355. */
  8356. get colorGradingBGR(): boolean;
  8357. /**
  8358. * Sets wether the color grading texture contains BGR values.
  8359. */
  8360. set colorGradingBGR(value: boolean);
  8361. /** @hidden */
  8362. _exposure: number;
  8363. /**
  8364. * Gets the Exposure used in the effect.
  8365. */
  8366. get exposure(): number;
  8367. /**
  8368. * Sets the Exposure used in the effect.
  8369. */
  8370. set exposure(value: number);
  8371. private _toneMappingEnabled;
  8372. /**
  8373. * Gets wether the tone mapping effect is enabled.
  8374. */
  8375. get toneMappingEnabled(): boolean;
  8376. /**
  8377. * Sets wether the tone mapping effect is enabled.
  8378. */
  8379. set toneMappingEnabled(value: boolean);
  8380. private _toneMappingType;
  8381. /**
  8382. * Gets the type of tone mapping effect.
  8383. */
  8384. get toneMappingType(): number;
  8385. /**
  8386. * Sets the type of tone mapping effect used in BabylonJS.
  8387. */
  8388. set toneMappingType(value: number);
  8389. protected _contrast: number;
  8390. /**
  8391. * Gets the contrast used in the effect.
  8392. */
  8393. get contrast(): number;
  8394. /**
  8395. * Sets the contrast used in the effect.
  8396. */
  8397. set contrast(value: number);
  8398. /**
  8399. * Vignette stretch size.
  8400. */
  8401. vignetteStretch: number;
  8402. /**
  8403. * Vignette centre X Offset.
  8404. */
  8405. vignetteCentreX: number;
  8406. /**
  8407. * Vignette centre Y Offset.
  8408. */
  8409. vignetteCentreY: number;
  8410. /**
  8411. * Vignette weight or intensity of the vignette effect.
  8412. */
  8413. vignetteWeight: number;
  8414. /**
  8415. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8416. * if vignetteEnabled is set to true.
  8417. */
  8418. vignetteColor: Color4;
  8419. /**
  8420. * Camera field of view used by the Vignette effect.
  8421. */
  8422. vignetteCameraFov: number;
  8423. private _vignetteBlendMode;
  8424. /**
  8425. * Gets the vignette blend mode allowing different kind of effect.
  8426. */
  8427. get vignetteBlendMode(): number;
  8428. /**
  8429. * Sets the vignette blend mode allowing different kind of effect.
  8430. */
  8431. set vignetteBlendMode(value: number);
  8432. private _vignetteEnabled;
  8433. /**
  8434. * Gets wether the vignette effect is enabled.
  8435. */
  8436. get vignetteEnabled(): boolean;
  8437. /**
  8438. * Sets wether the vignette effect is enabled.
  8439. */
  8440. set vignetteEnabled(value: boolean);
  8441. private _applyByPostProcess;
  8442. /**
  8443. * Gets wether the image processing is applied through a post process or not.
  8444. */
  8445. get applyByPostProcess(): boolean;
  8446. /**
  8447. * Sets wether the image processing is applied through a post process or not.
  8448. */
  8449. set applyByPostProcess(value: boolean);
  8450. private _isEnabled;
  8451. /**
  8452. * Gets wether the image processing is enabled or not.
  8453. */
  8454. get isEnabled(): boolean;
  8455. /**
  8456. * Sets wether the image processing is enabled or not.
  8457. */
  8458. set isEnabled(value: boolean);
  8459. /**
  8460. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8461. */
  8462. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8463. /**
  8464. * Method called each time the image processing information changes requires to recompile the effect.
  8465. */
  8466. protected _updateParameters(): void;
  8467. /**
  8468. * Gets the current class name.
  8469. * @return "ImageProcessingConfiguration"
  8470. */
  8471. getClassName(): string;
  8472. /**
  8473. * Prepare the list of uniforms associated with the Image Processing effects.
  8474. * @param uniforms The list of uniforms used in the effect
  8475. * @param defines the list of defines currently in use
  8476. */
  8477. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8478. /**
  8479. * Prepare the list of samplers associated with the Image Processing effects.
  8480. * @param samplersList The list of uniforms used in the effect
  8481. * @param defines the list of defines currently in use
  8482. */
  8483. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8484. /**
  8485. * Prepare the list of defines associated to the shader.
  8486. * @param defines the list of defines to complete
  8487. * @param forPostProcess Define if we are currently in post process mode or not
  8488. */
  8489. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8490. /**
  8491. * Returns true if all the image processing information are ready.
  8492. * @returns True if ready, otherwise, false
  8493. */
  8494. isReady(): boolean;
  8495. /**
  8496. * Binds the image processing to the shader.
  8497. * @param effect The effect to bind to
  8498. * @param overrideAspectRatio Override the aspect ratio of the effect
  8499. */
  8500. bind(effect: Effect, overrideAspectRatio?: number): void;
  8501. /**
  8502. * Clones the current image processing instance.
  8503. * @return The cloned image processing
  8504. */
  8505. clone(): ImageProcessingConfiguration;
  8506. /**
  8507. * Serializes the current image processing instance to a json representation.
  8508. * @return a JSON representation
  8509. */
  8510. serialize(): any;
  8511. /**
  8512. * Parses the image processing from a json representation.
  8513. * @param source the JSON source to parse
  8514. * @return The parsed image processing
  8515. */
  8516. static Parse(source: any): ImageProcessingConfiguration;
  8517. private static _VIGNETTEMODE_MULTIPLY;
  8518. private static _VIGNETTEMODE_OPAQUE;
  8519. /**
  8520. * Used to apply the vignette as a mix with the pixel color.
  8521. */
  8522. static get VIGNETTEMODE_MULTIPLY(): number;
  8523. /**
  8524. * Used to apply the vignette as a replacement of the pixel color.
  8525. */
  8526. static get VIGNETTEMODE_OPAQUE(): number;
  8527. }
  8528. }
  8529. declare module "babylonjs/Shaders/postprocess.vertex" {
  8530. /** @hidden */
  8531. export var postprocessVertexShader: {
  8532. name: string;
  8533. shader: string;
  8534. };
  8535. }
  8536. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8538. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8539. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8540. module "babylonjs/Engines/thinEngine" {
  8541. interface ThinEngine {
  8542. /**
  8543. * Creates a new render target texture
  8544. * @param size defines the size of the texture
  8545. * @param options defines the options used to create the texture
  8546. * @returns a new render target texture stored in an InternalTexture
  8547. */
  8548. createRenderTargetTexture(size: number | {
  8549. width: number;
  8550. height: number;
  8551. layers?: number;
  8552. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8553. /**
  8554. * Creates a depth stencil texture.
  8555. * This is only available in WebGL 2 or with the depth texture extension available.
  8556. * @param size The size of face edge in the texture.
  8557. * @param options The options defining the texture.
  8558. * @returns The texture
  8559. */
  8560. createDepthStencilTexture(size: number | {
  8561. width: number;
  8562. height: number;
  8563. layers?: number;
  8564. }, options: DepthTextureCreationOptions): InternalTexture;
  8565. /** @hidden */
  8566. _createDepthStencilTexture(size: number | {
  8567. width: number;
  8568. height: number;
  8569. layers?: number;
  8570. }, options: DepthTextureCreationOptions): InternalTexture;
  8571. }
  8572. }
  8573. }
  8574. declare module "babylonjs/Maths/math.axis" {
  8575. import { Vector3 } from "babylonjs/Maths/math.vector";
  8576. /** Defines supported spaces */
  8577. export enum Space {
  8578. /** Local (object) space */
  8579. LOCAL = 0,
  8580. /** World space */
  8581. WORLD = 1,
  8582. /** Bone space */
  8583. BONE = 2
  8584. }
  8585. /** Defines the 3 main axes */
  8586. export class Axis {
  8587. /** X axis */
  8588. static X: Vector3;
  8589. /** Y axis */
  8590. static Y: Vector3;
  8591. /** Z axis */
  8592. static Z: Vector3;
  8593. }
  8594. }
  8595. declare module "babylonjs/Cameras/targetCamera" {
  8596. import { Nullable } from "babylonjs/types";
  8597. import { Camera } from "babylonjs/Cameras/camera";
  8598. import { Scene } from "babylonjs/scene";
  8599. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8600. /**
  8601. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8602. * This is the base of the follow, arc rotate cameras and Free camera
  8603. * @see http://doc.babylonjs.com/features/cameras
  8604. */
  8605. export class TargetCamera extends Camera {
  8606. private static _RigCamTransformMatrix;
  8607. private static _TargetTransformMatrix;
  8608. private static _TargetFocalPoint;
  8609. /**
  8610. * Define the current direction the camera is moving to
  8611. */
  8612. cameraDirection: Vector3;
  8613. /**
  8614. * Define the current rotation the camera is rotating to
  8615. */
  8616. cameraRotation: Vector2;
  8617. /**
  8618. * When set, the up vector of the camera will be updated by the rotation of the camera
  8619. */
  8620. updateUpVectorFromRotation: boolean;
  8621. private _tmpQuaternion;
  8622. /**
  8623. * Define the current rotation of the camera
  8624. */
  8625. rotation: Vector3;
  8626. /**
  8627. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8628. */
  8629. rotationQuaternion: Quaternion;
  8630. /**
  8631. * Define the current speed of the camera
  8632. */
  8633. speed: number;
  8634. /**
  8635. * Add constraint to the camera to prevent it to move freely in all directions and
  8636. * around all axis.
  8637. */
  8638. noRotationConstraint: boolean;
  8639. /**
  8640. * Define the current target of the camera as an object or a position.
  8641. */
  8642. lockedTarget: any;
  8643. /** @hidden */
  8644. _currentTarget: Vector3;
  8645. /** @hidden */
  8646. _initialFocalDistance: number;
  8647. /** @hidden */
  8648. _viewMatrix: Matrix;
  8649. /** @hidden */
  8650. _camMatrix: Matrix;
  8651. /** @hidden */
  8652. _cameraTransformMatrix: Matrix;
  8653. /** @hidden */
  8654. _cameraRotationMatrix: Matrix;
  8655. /** @hidden */
  8656. _referencePoint: Vector3;
  8657. /** @hidden */
  8658. _transformedReferencePoint: Vector3;
  8659. protected _globalCurrentTarget: Vector3;
  8660. protected _globalCurrentUpVector: Vector3;
  8661. /** @hidden */
  8662. _reset: () => void;
  8663. private _defaultUp;
  8664. /**
  8665. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8666. * This is the base of the follow, arc rotate cameras and Free camera
  8667. * @see http://doc.babylonjs.com/features/cameras
  8668. * @param name Defines the name of the camera in the scene
  8669. * @param position Defines the start position of the camera in the scene
  8670. * @param scene Defines the scene the camera belongs to
  8671. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8672. */
  8673. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8674. /**
  8675. * Gets the position in front of the camera at a given distance.
  8676. * @param distance The distance from the camera we want the position to be
  8677. * @returns the position
  8678. */
  8679. getFrontPosition(distance: number): Vector3;
  8680. /** @hidden */
  8681. _getLockedTargetPosition(): Nullable<Vector3>;
  8682. private _storedPosition;
  8683. private _storedRotation;
  8684. private _storedRotationQuaternion;
  8685. /**
  8686. * Store current camera state of the camera (fov, position, rotation, etc..)
  8687. * @returns the camera
  8688. */
  8689. storeState(): Camera;
  8690. /**
  8691. * Restored camera state. You must call storeState() first
  8692. * @returns whether it was successful or not
  8693. * @hidden
  8694. */
  8695. _restoreStateValues(): boolean;
  8696. /** @hidden */
  8697. _initCache(): void;
  8698. /** @hidden */
  8699. _updateCache(ignoreParentClass?: boolean): void;
  8700. /** @hidden */
  8701. _isSynchronizedViewMatrix(): boolean;
  8702. /** @hidden */
  8703. _computeLocalCameraSpeed(): number;
  8704. /**
  8705. * Defines the target the camera should look at.
  8706. * @param target Defines the new target as a Vector or a mesh
  8707. */
  8708. setTarget(target: Vector3): void;
  8709. /**
  8710. * Return the current target position of the camera. This value is expressed in local space.
  8711. * @returns the target position
  8712. */
  8713. getTarget(): Vector3;
  8714. /** @hidden */
  8715. _decideIfNeedsToMove(): boolean;
  8716. /** @hidden */
  8717. _updatePosition(): void;
  8718. /** @hidden */
  8719. _checkInputs(): void;
  8720. protected _updateCameraRotationMatrix(): void;
  8721. /**
  8722. * 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)
  8723. * @returns the current camera
  8724. */
  8725. private _rotateUpVectorWithCameraRotationMatrix;
  8726. private _cachedRotationZ;
  8727. private _cachedQuaternionRotationZ;
  8728. /** @hidden */
  8729. _getViewMatrix(): Matrix;
  8730. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8731. /**
  8732. * @hidden
  8733. */
  8734. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8735. /**
  8736. * @hidden
  8737. */
  8738. _updateRigCameras(): void;
  8739. private _getRigCamPositionAndTarget;
  8740. /**
  8741. * Gets the current object class name.
  8742. * @return the class name
  8743. */
  8744. getClassName(): string;
  8745. }
  8746. }
  8747. declare module "babylonjs/Events/keyboardEvents" {
  8748. /**
  8749. * Gather the list of keyboard event types as constants.
  8750. */
  8751. export class KeyboardEventTypes {
  8752. /**
  8753. * The keydown event is fired when a key becomes active (pressed).
  8754. */
  8755. static readonly KEYDOWN: number;
  8756. /**
  8757. * The keyup event is fired when a key has been released.
  8758. */
  8759. static readonly KEYUP: number;
  8760. }
  8761. /**
  8762. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8763. */
  8764. export class KeyboardInfo {
  8765. /**
  8766. * Defines the type of event (KeyboardEventTypes)
  8767. */
  8768. type: number;
  8769. /**
  8770. * Defines the related dom event
  8771. */
  8772. event: KeyboardEvent;
  8773. /**
  8774. * Instantiates a new keyboard info.
  8775. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8776. * @param type Defines the type of event (KeyboardEventTypes)
  8777. * @param event Defines the related dom event
  8778. */
  8779. constructor(
  8780. /**
  8781. * Defines the type of event (KeyboardEventTypes)
  8782. */
  8783. type: number,
  8784. /**
  8785. * Defines the related dom event
  8786. */
  8787. event: KeyboardEvent);
  8788. }
  8789. /**
  8790. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8791. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8792. */
  8793. export class KeyboardInfoPre extends KeyboardInfo {
  8794. /**
  8795. * Defines the type of event (KeyboardEventTypes)
  8796. */
  8797. type: number;
  8798. /**
  8799. * Defines the related dom event
  8800. */
  8801. event: KeyboardEvent;
  8802. /**
  8803. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8804. */
  8805. skipOnPointerObservable: boolean;
  8806. /**
  8807. * Instantiates a new keyboard pre info.
  8808. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8809. * @param type Defines the type of event (KeyboardEventTypes)
  8810. * @param event Defines the related dom event
  8811. */
  8812. constructor(
  8813. /**
  8814. * Defines the type of event (KeyboardEventTypes)
  8815. */
  8816. type: number,
  8817. /**
  8818. * Defines the related dom event
  8819. */
  8820. event: KeyboardEvent);
  8821. }
  8822. }
  8823. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8824. import { Nullable } from "babylonjs/types";
  8825. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8826. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8827. /**
  8828. * Manage the keyboard inputs to control the movement of a free camera.
  8829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8830. */
  8831. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8832. /**
  8833. * Defines the camera the input is attached to.
  8834. */
  8835. camera: FreeCamera;
  8836. /**
  8837. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8838. */
  8839. keysUp: number[];
  8840. /**
  8841. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8842. */
  8843. keysDown: number[];
  8844. /**
  8845. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8846. */
  8847. keysLeft: number[];
  8848. /**
  8849. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8850. */
  8851. keysRight: number[];
  8852. private _keys;
  8853. private _onCanvasBlurObserver;
  8854. private _onKeyboardObserver;
  8855. private _engine;
  8856. private _scene;
  8857. /**
  8858. * Attach the input controls to a specific dom element to get the input from.
  8859. * @param element Defines the element the controls should be listened from
  8860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8861. */
  8862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8863. /**
  8864. * Detach the current controls from the specified dom element.
  8865. * @param element Defines the element to stop listening the inputs from
  8866. */
  8867. detachControl(element: Nullable<HTMLElement>): void;
  8868. /**
  8869. * Update the current camera state depending on the inputs that have been used this frame.
  8870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8871. */
  8872. checkInputs(): void;
  8873. /**
  8874. * Gets the class name of the current intput.
  8875. * @returns the class name
  8876. */
  8877. getClassName(): string;
  8878. /** @hidden */
  8879. _onLostFocus(): void;
  8880. /**
  8881. * Get the friendly name associated with the input class.
  8882. * @returns the input friendly name
  8883. */
  8884. getSimpleName(): string;
  8885. }
  8886. }
  8887. declare module "babylonjs/Lights/shadowLight" {
  8888. import { Camera } from "babylonjs/Cameras/camera";
  8889. import { Scene } from "babylonjs/scene";
  8890. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8892. import { Light } from "babylonjs/Lights/light";
  8893. /**
  8894. * Interface describing all the common properties and methods a shadow light needs to implement.
  8895. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8896. * as well as binding the different shadow properties to the effects.
  8897. */
  8898. export interface IShadowLight extends Light {
  8899. /**
  8900. * The light id in the scene (used in scene.findLighById for instance)
  8901. */
  8902. id: string;
  8903. /**
  8904. * The position the shdow will be casted from.
  8905. */
  8906. position: Vector3;
  8907. /**
  8908. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8909. */
  8910. direction: Vector3;
  8911. /**
  8912. * The transformed position. Position of the light in world space taking parenting in account.
  8913. */
  8914. transformedPosition: Vector3;
  8915. /**
  8916. * The transformed direction. Direction of the light in world space taking parenting in account.
  8917. */
  8918. transformedDirection: Vector3;
  8919. /**
  8920. * The friendly name of the light in the scene.
  8921. */
  8922. name: string;
  8923. /**
  8924. * Defines the shadow projection clipping minimum z value.
  8925. */
  8926. shadowMinZ: number;
  8927. /**
  8928. * Defines the shadow projection clipping maximum z value.
  8929. */
  8930. shadowMaxZ: number;
  8931. /**
  8932. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8933. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8934. */
  8935. computeTransformedInformation(): boolean;
  8936. /**
  8937. * Gets the scene the light belongs to.
  8938. * @returns The scene
  8939. */
  8940. getScene(): Scene;
  8941. /**
  8942. * Callback defining a custom Projection Matrix Builder.
  8943. * This can be used to override the default projection matrix computation.
  8944. */
  8945. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8946. /**
  8947. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8948. * @param matrix The materix to updated with the projection information
  8949. * @param viewMatrix The transform matrix of the light
  8950. * @param renderList The list of mesh to render in the map
  8951. * @returns The current light
  8952. */
  8953. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8954. /**
  8955. * Gets the current depth scale used in ESM.
  8956. * @returns The scale
  8957. */
  8958. getDepthScale(): number;
  8959. /**
  8960. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8961. * @returns true if a cube texture needs to be use
  8962. */
  8963. needCube(): boolean;
  8964. /**
  8965. * Detects if the projection matrix requires to be recomputed this frame.
  8966. * @returns true if it requires to be recomputed otherwise, false.
  8967. */
  8968. needProjectionMatrixCompute(): boolean;
  8969. /**
  8970. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8971. */
  8972. forceProjectionMatrixCompute(): void;
  8973. /**
  8974. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8975. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8976. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8977. */
  8978. getShadowDirection(faceIndex?: number): Vector3;
  8979. /**
  8980. * Gets the minZ used for shadow according to both the scene and the light.
  8981. * @param activeCamera The camera we are returning the min for
  8982. * @returns the depth min z
  8983. */
  8984. getDepthMinZ(activeCamera: Camera): number;
  8985. /**
  8986. * Gets the maxZ used for shadow according to both the scene and the light.
  8987. * @param activeCamera The camera we are returning the max for
  8988. * @returns the depth max z
  8989. */
  8990. getDepthMaxZ(activeCamera: Camera): number;
  8991. }
  8992. /**
  8993. * Base implementation IShadowLight
  8994. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8995. */
  8996. export abstract class ShadowLight extends Light implements IShadowLight {
  8997. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8998. protected _position: Vector3;
  8999. protected _setPosition(value: Vector3): void;
  9000. /**
  9001. * Sets the position the shadow will be casted from. Also use as the light position for both
  9002. * point and spot lights.
  9003. */
  9004. get position(): Vector3;
  9005. /**
  9006. * Sets the position the shadow will be casted from. Also use as the light position for both
  9007. * point and spot lights.
  9008. */
  9009. set position(value: Vector3);
  9010. protected _direction: Vector3;
  9011. protected _setDirection(value: Vector3): void;
  9012. /**
  9013. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9014. * Also use as the light direction on spot and directional lights.
  9015. */
  9016. get direction(): Vector3;
  9017. /**
  9018. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9019. * Also use as the light direction on spot and directional lights.
  9020. */
  9021. set direction(value: Vector3);
  9022. protected _shadowMinZ: number;
  9023. /**
  9024. * Gets the shadow projection clipping minimum z value.
  9025. */
  9026. get shadowMinZ(): number;
  9027. /**
  9028. * Sets the shadow projection clipping minimum z value.
  9029. */
  9030. set shadowMinZ(value: number);
  9031. protected _shadowMaxZ: number;
  9032. /**
  9033. * Sets the shadow projection clipping maximum z value.
  9034. */
  9035. get shadowMaxZ(): number;
  9036. /**
  9037. * Gets the shadow projection clipping maximum z value.
  9038. */
  9039. set shadowMaxZ(value: number);
  9040. /**
  9041. * Callback defining a custom Projection Matrix Builder.
  9042. * This can be used to override the default projection matrix computation.
  9043. */
  9044. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9045. /**
  9046. * The transformed position. Position of the light in world space taking parenting in account.
  9047. */
  9048. transformedPosition: Vector3;
  9049. /**
  9050. * The transformed direction. Direction of the light in world space taking parenting in account.
  9051. */
  9052. transformedDirection: Vector3;
  9053. private _needProjectionMatrixCompute;
  9054. /**
  9055. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9056. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9057. */
  9058. computeTransformedInformation(): boolean;
  9059. /**
  9060. * Return the depth scale used for the shadow map.
  9061. * @returns the depth scale.
  9062. */
  9063. getDepthScale(): number;
  9064. /**
  9065. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9066. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9067. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9068. */
  9069. getShadowDirection(faceIndex?: number): Vector3;
  9070. /**
  9071. * Returns the ShadowLight absolute position in the World.
  9072. * @returns the position vector in world space
  9073. */
  9074. getAbsolutePosition(): Vector3;
  9075. /**
  9076. * Sets the ShadowLight direction toward the passed target.
  9077. * @param target The point to target in local space
  9078. * @returns the updated ShadowLight direction
  9079. */
  9080. setDirectionToTarget(target: Vector3): Vector3;
  9081. /**
  9082. * Returns the light rotation in euler definition.
  9083. * @returns the x y z rotation in local space.
  9084. */
  9085. getRotation(): Vector3;
  9086. /**
  9087. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9088. * @returns true if a cube texture needs to be use
  9089. */
  9090. needCube(): boolean;
  9091. /**
  9092. * Detects if the projection matrix requires to be recomputed this frame.
  9093. * @returns true if it requires to be recomputed otherwise, false.
  9094. */
  9095. needProjectionMatrixCompute(): boolean;
  9096. /**
  9097. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9098. */
  9099. forceProjectionMatrixCompute(): void;
  9100. /** @hidden */
  9101. _initCache(): void;
  9102. /** @hidden */
  9103. _isSynchronized(): boolean;
  9104. /**
  9105. * Computes the world matrix of the node
  9106. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9107. * @returns the world matrix
  9108. */
  9109. computeWorldMatrix(force?: boolean): Matrix;
  9110. /**
  9111. * Gets the minZ used for shadow according to both the scene and the light.
  9112. * @param activeCamera The camera we are returning the min for
  9113. * @returns the depth min z
  9114. */
  9115. getDepthMinZ(activeCamera: Camera): number;
  9116. /**
  9117. * Gets the maxZ used for shadow according to both the scene and the light.
  9118. * @param activeCamera The camera we are returning the max for
  9119. * @returns the depth max z
  9120. */
  9121. getDepthMaxZ(activeCamera: Camera): number;
  9122. /**
  9123. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9124. * @param matrix The materix to updated with the projection information
  9125. * @param viewMatrix The transform matrix of the light
  9126. * @param renderList The list of mesh to render in the map
  9127. * @returns The current light
  9128. */
  9129. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9130. }
  9131. }
  9132. declare module "babylonjs/Materials/effectFallbacks" {
  9133. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9134. import { Effect } from "babylonjs/Materials/effect";
  9135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9136. /**
  9137. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9138. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9139. */
  9140. export class EffectFallbacks implements IEffectFallbacks {
  9141. private _defines;
  9142. private _currentRank;
  9143. private _maxRank;
  9144. private _mesh;
  9145. /**
  9146. * Removes the fallback from the bound mesh.
  9147. */
  9148. unBindMesh(): void;
  9149. /**
  9150. * Adds a fallback on the specified property.
  9151. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9152. * @param define The name of the define in the shader
  9153. */
  9154. addFallback(rank: number, define: string): void;
  9155. /**
  9156. * Sets the mesh to use CPU skinning when needing to fallback.
  9157. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9158. * @param mesh The mesh to use the fallbacks.
  9159. */
  9160. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9161. /**
  9162. * Checks to see if more fallbacks are still availible.
  9163. */
  9164. get hasMoreFallbacks(): boolean;
  9165. /**
  9166. * Removes the defines that should be removed when falling back.
  9167. * @param currentDefines defines the current define statements for the shader.
  9168. * @param effect defines the current effect we try to compile
  9169. * @returns The resulting defines with defines of the current rank removed.
  9170. */
  9171. reduce(currentDefines: string, effect: Effect): string;
  9172. }
  9173. }
  9174. declare module "babylonjs/Materials/materialHelper" {
  9175. import { Nullable } from "babylonjs/types";
  9176. import { Scene } from "babylonjs/scene";
  9177. import { Engine } from "babylonjs/Engines/engine";
  9178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9179. import { Light } from "babylonjs/Lights/light";
  9180. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9181. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9183. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9184. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9185. /**
  9186. * "Static Class" containing the most commonly used helper while dealing with material for
  9187. * rendering purpose.
  9188. *
  9189. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9190. *
  9191. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9192. */
  9193. export class MaterialHelper {
  9194. /**
  9195. * Bind the current view position to an effect.
  9196. * @param effect The effect to be bound
  9197. * @param scene The scene the eyes position is used from
  9198. */
  9199. static BindEyePosition(effect: Effect, scene: Scene): void;
  9200. /**
  9201. * Helps preparing the defines values about the UVs in used in the effect.
  9202. * UVs are shared as much as we can accross channels in the shaders.
  9203. * @param texture The texture we are preparing the UVs for
  9204. * @param defines The defines to update
  9205. * @param key The channel key "diffuse", "specular"... used in the shader
  9206. */
  9207. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9208. /**
  9209. * Binds a texture matrix value to its corrsponding uniform
  9210. * @param texture The texture to bind the matrix for
  9211. * @param uniformBuffer The uniform buffer receivin the data
  9212. * @param key The channel key "diffuse", "specular"... used in the shader
  9213. */
  9214. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9215. /**
  9216. * Gets the current status of the fog (should it be enabled?)
  9217. * @param mesh defines the mesh to evaluate for fog support
  9218. * @param scene defines the hosting scene
  9219. * @returns true if fog must be enabled
  9220. */
  9221. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9222. /**
  9223. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9224. * @param mesh defines the current mesh
  9225. * @param scene defines the current scene
  9226. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9227. * @param pointsCloud defines if point cloud rendering has to be turned on
  9228. * @param fogEnabled defines if fog has to be turned on
  9229. * @param alphaTest defines if alpha testing has to be turned on
  9230. * @param defines defines the current list of defines
  9231. */
  9232. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9233. /**
  9234. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9235. * @param scene defines the current scene
  9236. * @param engine defines the current engine
  9237. * @param defines specifies the list of active defines
  9238. * @param useInstances defines if instances have to be turned on
  9239. * @param useClipPlane defines if clip plane have to be turned on
  9240. */
  9241. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9242. /**
  9243. * Prepares the defines for bones
  9244. * @param mesh The mesh containing the geometry data we will draw
  9245. * @param defines The defines to update
  9246. */
  9247. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9248. /**
  9249. * Prepares the defines for morph targets
  9250. * @param mesh The mesh containing the geometry data we will draw
  9251. * @param defines The defines to update
  9252. */
  9253. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9254. /**
  9255. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9256. * @param mesh The mesh containing the geometry data we will draw
  9257. * @param defines The defines to update
  9258. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9259. * @param useBones Precise whether bones should be used or not (override mesh info)
  9260. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9261. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9262. * @returns false if defines are considered not dirty and have not been checked
  9263. */
  9264. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9265. /**
  9266. * Prepares the defines related to multiview
  9267. * @param scene The scene we are intending to draw
  9268. * @param defines The defines to update
  9269. */
  9270. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9271. /**
  9272. * Prepares the defines related to the light information passed in parameter
  9273. * @param scene The scene we are intending to draw
  9274. * @param mesh The mesh the effect is compiling for
  9275. * @param light The light the effect is compiling for
  9276. * @param lightIndex The index of the light
  9277. * @param defines The defines to update
  9278. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9279. * @param state Defines the current state regarding what is needed (normals, etc...)
  9280. */
  9281. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9282. needNormals: boolean;
  9283. needRebuild: boolean;
  9284. shadowEnabled: boolean;
  9285. specularEnabled: boolean;
  9286. lightmapMode: boolean;
  9287. }): void;
  9288. /**
  9289. * Prepares the defines related to the light information passed in parameter
  9290. * @param scene The scene we are intending to draw
  9291. * @param mesh The mesh the effect is compiling for
  9292. * @param defines The defines to update
  9293. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9294. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9295. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9296. * @returns true if normals will be required for the rest of the effect
  9297. */
  9298. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9299. /**
  9300. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9301. * @param lightIndex defines the light index
  9302. * @param uniformsList The uniform list
  9303. * @param samplersList The sampler list
  9304. * @param projectedLightTexture defines if projected texture must be used
  9305. * @param uniformBuffersList defines an optional list of uniform buffers
  9306. */
  9307. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9308. /**
  9309. * Prepares the uniforms and samplers list to be used in the effect
  9310. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9311. * @param samplersList The sampler list
  9312. * @param defines The defines helping in the list generation
  9313. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9314. */
  9315. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9316. /**
  9317. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9318. * @param defines The defines to update while falling back
  9319. * @param fallbacks The authorized effect fallbacks
  9320. * @param maxSimultaneousLights The maximum number of lights allowed
  9321. * @param rank the current rank of the Effect
  9322. * @returns The newly affected rank
  9323. */
  9324. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9325. private static _TmpMorphInfluencers;
  9326. /**
  9327. * Prepares the list of attributes required for morph targets according to the effect defines.
  9328. * @param attribs The current list of supported attribs
  9329. * @param mesh The mesh to prepare the morph targets attributes for
  9330. * @param influencers The number of influencers
  9331. */
  9332. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9333. /**
  9334. * Prepares the list of attributes required for morph targets according to the effect defines.
  9335. * @param attribs The current list of supported attribs
  9336. * @param mesh The mesh to prepare the morph targets attributes for
  9337. * @param defines The current Defines of the effect
  9338. */
  9339. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9340. /**
  9341. * Prepares the list of attributes required for bones according to the effect defines.
  9342. * @param attribs The current list of supported attribs
  9343. * @param mesh The mesh to prepare the bones attributes for
  9344. * @param defines The current Defines of the effect
  9345. * @param fallbacks The current efffect fallback strategy
  9346. */
  9347. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9348. /**
  9349. * Check and prepare the list of attributes required for instances according to the effect defines.
  9350. * @param attribs The current list of supported attribs
  9351. * @param defines The current MaterialDefines of the effect
  9352. */
  9353. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9354. /**
  9355. * Add the list of attributes required for instances to the attribs array.
  9356. * @param attribs The current list of supported attribs
  9357. */
  9358. static PushAttributesForInstances(attribs: string[]): void;
  9359. /**
  9360. * Binds the light information to the effect.
  9361. * @param light The light containing the generator
  9362. * @param effect The effect we are binding the data to
  9363. * @param lightIndex The light index in the effect used to render
  9364. */
  9365. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9366. /**
  9367. * Binds the lights information from the scene to the effect for the given mesh.
  9368. * @param light Light to bind
  9369. * @param lightIndex Light index
  9370. * @param scene The scene where the light belongs to
  9371. * @param effect The effect we are binding the data to
  9372. * @param useSpecular Defines if specular is supported
  9373. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9374. */
  9375. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9376. /**
  9377. * Binds the lights information from the scene to the effect for the given mesh.
  9378. * @param scene The scene the lights belongs to
  9379. * @param mesh The mesh we are binding the information to render
  9380. * @param effect The effect we are binding the data to
  9381. * @param defines The generated defines for the effect
  9382. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9383. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9384. */
  9385. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9386. private static _tempFogColor;
  9387. /**
  9388. * Binds the fog information from the scene to the effect for the given mesh.
  9389. * @param scene The scene the lights belongs to
  9390. * @param mesh The mesh we are binding the information to render
  9391. * @param effect The effect we are binding the data to
  9392. * @param linearSpace Defines if the fog effect is applied in linear space
  9393. */
  9394. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9395. /**
  9396. * Binds the bones information from the mesh to the effect.
  9397. * @param mesh The mesh we are binding the information to render
  9398. * @param effect The effect we are binding the data to
  9399. */
  9400. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9401. /**
  9402. * Binds the morph targets information from the mesh to the effect.
  9403. * @param abstractMesh The mesh we are binding the information to render
  9404. * @param effect The effect we are binding the data to
  9405. */
  9406. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9407. /**
  9408. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9409. * @param defines The generated defines used in the effect
  9410. * @param effect The effect we are binding the data to
  9411. * @param scene The scene we are willing to render with logarithmic scale for
  9412. */
  9413. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9414. /**
  9415. * Binds the clip plane information from the scene to the effect.
  9416. * @param scene The scene the clip plane information are extracted from
  9417. * @param effect The effect we are binding the data to
  9418. */
  9419. static BindClipPlane(effect: Effect, scene: Scene): void;
  9420. }
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9423. /** @hidden */
  9424. export var packingFunctions: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9430. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9431. /** @hidden */
  9432. export var shadowMapPixelShader: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9438. /** @hidden */
  9439. export var bonesDeclaration: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9445. /** @hidden */
  9446. export var morphTargetsVertexGlobalDeclaration: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9452. /** @hidden */
  9453. export var morphTargetsVertexDeclaration: {
  9454. name: string;
  9455. shader: string;
  9456. };
  9457. }
  9458. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9459. /** @hidden */
  9460. export var instancesDeclaration: {
  9461. name: string;
  9462. shader: string;
  9463. };
  9464. }
  9465. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9466. /** @hidden */
  9467. export var helperFunctions: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9473. /** @hidden */
  9474. export var morphTargetsVertex: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9480. /** @hidden */
  9481. export var instancesVertex: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9487. /** @hidden */
  9488. export var bonesVertex: {
  9489. name: string;
  9490. shader: string;
  9491. };
  9492. }
  9493. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9494. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9495. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9496. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9497. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9498. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9499. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9500. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9501. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9502. /** @hidden */
  9503. export var shadowMapVertexShader: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9509. /** @hidden */
  9510. export var depthBoxBlurPixelShader: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9516. import { SmartArray } from "babylonjs/Misc/smartArray";
  9517. import { Nullable } from "babylonjs/types";
  9518. import { Scene } from "babylonjs/scene";
  9519. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9520. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9522. import { Mesh } from "babylonjs/Meshes/mesh";
  9523. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9524. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9525. import { Effect } from "babylonjs/Materials/effect";
  9526. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9527. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  9528. import "babylonjs/Shaders/shadowMap.fragment";
  9529. import "babylonjs/Shaders/shadowMap.vertex";
  9530. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9531. import { Observable } from "babylonjs/Misc/observable";
  9532. /**
  9533. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9534. */
  9535. export interface ICustomShaderOptions {
  9536. /**
  9537. * Gets or sets the custom shader name to use
  9538. */
  9539. shaderName: string;
  9540. /**
  9541. * The list of attribute names used in the shader
  9542. */
  9543. attributes?: string[];
  9544. /**
  9545. * The list of unifrom names used in the shader
  9546. */
  9547. uniforms?: string[];
  9548. /**
  9549. * The list of sampler names used in the shader
  9550. */
  9551. samplers?: string[];
  9552. /**
  9553. * The list of defines used in the shader
  9554. */
  9555. defines?: string[];
  9556. }
  9557. /**
  9558. * Interface to implement to create a shadow generator compatible with BJS.
  9559. */
  9560. export interface IShadowGenerator {
  9561. /**
  9562. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9563. * @returns The render target texture if present otherwise, null
  9564. */
  9565. getShadowMap(): Nullable<RenderTargetTexture>;
  9566. /**
  9567. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9568. * @param subMesh The submesh we want to render in the shadow map
  9569. * @param useInstances Defines wether will draw in the map using instances
  9570. * @returns true if ready otherwise, false
  9571. */
  9572. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9573. /**
  9574. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9575. * @param defines Defines of the material we want to update
  9576. * @param lightIndex Index of the light in the enabled light list of the material
  9577. */
  9578. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9579. /**
  9580. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9581. * defined in the generator but impacting the effect).
  9582. * It implies the unifroms available on the materials are the standard BJS ones.
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. /**
  9599. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9600. * @param onCompiled Callback triggered at the and of the effects compilation
  9601. * @param options Sets of optional options forcing the compilation with different modes
  9602. */
  9603. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9604. useInstances: boolean;
  9605. }>): void;
  9606. /**
  9607. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9608. * @param options Sets of optional options forcing the compilation with different modes
  9609. * @returns A promise that resolves when the compilation completes
  9610. */
  9611. forceCompilationAsync(options?: Partial<{
  9612. useInstances: boolean;
  9613. }>): Promise<void>;
  9614. /**
  9615. * Serializes the shadow generator setup to a json object.
  9616. * @returns The serialized JSON object
  9617. */
  9618. serialize(): any;
  9619. /**
  9620. * Disposes the Shadow map and related Textures and effects.
  9621. */
  9622. dispose(): void;
  9623. }
  9624. /**
  9625. * Default implementation IShadowGenerator.
  9626. * This is the main object responsible of generating shadows in the framework.
  9627. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9628. */
  9629. export class ShadowGenerator implements IShadowGenerator {
  9630. /**
  9631. * Name of the shadow generator class
  9632. */
  9633. static CLASSNAME: string;
  9634. /**
  9635. * Shadow generator mode None: no filtering applied.
  9636. */
  9637. static readonly FILTER_NONE: number;
  9638. /**
  9639. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9640. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9641. */
  9642. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9643. /**
  9644. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9645. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9646. */
  9647. static readonly FILTER_POISSONSAMPLING: number;
  9648. /**
  9649. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9650. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9651. */
  9652. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9653. /**
  9654. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9655. * edge artifacts on steep falloff.
  9656. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9657. */
  9658. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9659. /**
  9660. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9661. * edge artifacts on steep falloff.
  9662. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9663. */
  9664. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9665. /**
  9666. * Shadow generator mode PCF: Percentage Closer Filtering
  9667. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9668. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9669. */
  9670. static readonly FILTER_PCF: number;
  9671. /**
  9672. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9673. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9674. * Contact Hardening
  9675. */
  9676. static readonly FILTER_PCSS: number;
  9677. /**
  9678. * Reserved for PCF and PCSS
  9679. * Highest Quality.
  9680. *
  9681. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9682. *
  9683. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9684. */
  9685. static readonly QUALITY_HIGH: number;
  9686. /**
  9687. * Reserved for PCF and PCSS
  9688. * Good tradeoff for quality/perf cross devices
  9689. *
  9690. * Execute PCF on a 3*3 kernel.
  9691. *
  9692. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9693. */
  9694. static readonly QUALITY_MEDIUM: number;
  9695. /**
  9696. * Reserved for PCF and PCSS
  9697. * The lowest quality but the fastest.
  9698. *
  9699. * Execute PCF on a 1*1 kernel.
  9700. *
  9701. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9702. */
  9703. static readonly QUALITY_LOW: number;
  9704. /** Gets or sets the custom shader name to use */
  9705. customShaderOptions: ICustomShaderOptions;
  9706. /**
  9707. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9708. */
  9709. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9710. /**
  9711. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9712. */
  9713. onAfterShadowMapRenderObservable: Observable<Effect>;
  9714. /**
  9715. * Observable triggered before a mesh is rendered in the shadow map.
  9716. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9717. */
  9718. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9719. /**
  9720. * Observable triggered after a mesh is rendered in the shadow map.
  9721. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9722. */
  9723. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9724. protected _bias: number;
  9725. /**
  9726. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9727. */
  9728. get bias(): number;
  9729. /**
  9730. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9731. */
  9732. set bias(bias: number);
  9733. protected _normalBias: number;
  9734. /**
  9735. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9736. */
  9737. get normalBias(): number;
  9738. /**
  9739. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9740. */
  9741. set normalBias(normalBias: number);
  9742. protected _blurBoxOffset: number;
  9743. /**
  9744. * Gets the blur box offset: offset applied during the blur pass.
  9745. * Only useful if useKernelBlur = false
  9746. */
  9747. get blurBoxOffset(): number;
  9748. /**
  9749. * Sets the blur box offset: offset applied during the blur pass.
  9750. * Only useful if useKernelBlur = false
  9751. */
  9752. set blurBoxOffset(value: number);
  9753. protected _blurScale: number;
  9754. /**
  9755. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9756. * 2 means half of the size.
  9757. */
  9758. get blurScale(): number;
  9759. /**
  9760. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9761. * 2 means half of the size.
  9762. */
  9763. set blurScale(value: number);
  9764. protected _blurKernel: number;
  9765. /**
  9766. * Gets the blur kernel: kernel size of the blur pass.
  9767. * Only useful if useKernelBlur = true
  9768. */
  9769. get blurKernel(): number;
  9770. /**
  9771. * Sets the blur kernel: kernel size of the blur pass.
  9772. * Only useful if useKernelBlur = true
  9773. */
  9774. set blurKernel(value: number);
  9775. protected _useKernelBlur: boolean;
  9776. /**
  9777. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9778. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9779. */
  9780. get useKernelBlur(): boolean;
  9781. /**
  9782. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9783. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9784. */
  9785. set useKernelBlur(value: boolean);
  9786. protected _depthScale: number;
  9787. /**
  9788. * Gets the depth scale used in ESM mode.
  9789. */
  9790. get depthScale(): number;
  9791. /**
  9792. * Sets the depth scale used in ESM mode.
  9793. * This can override the scale stored on the light.
  9794. */
  9795. set depthScale(value: number);
  9796. protected _validateFilter(filter: number): number;
  9797. protected _filter: number;
  9798. /**
  9799. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9800. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9801. */
  9802. get filter(): number;
  9803. /**
  9804. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9805. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9806. */
  9807. set filter(value: number);
  9808. /**
  9809. * Gets if the current filter is set to Poisson Sampling.
  9810. */
  9811. get usePoissonSampling(): boolean;
  9812. /**
  9813. * Sets the current filter to Poisson Sampling.
  9814. */
  9815. set usePoissonSampling(value: boolean);
  9816. /**
  9817. * Gets if the current filter is set to ESM.
  9818. */
  9819. get useExponentialShadowMap(): boolean;
  9820. /**
  9821. * Sets the current filter is to ESM.
  9822. */
  9823. set useExponentialShadowMap(value: boolean);
  9824. /**
  9825. * Gets if the current filter is set to filtered ESM.
  9826. */
  9827. get useBlurExponentialShadowMap(): boolean;
  9828. /**
  9829. * Gets if the current filter is set to filtered ESM.
  9830. */
  9831. set useBlurExponentialShadowMap(value: boolean);
  9832. /**
  9833. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9834. * exponential to prevent steep falloff artifacts).
  9835. */
  9836. get useCloseExponentialShadowMap(): boolean;
  9837. /**
  9838. * Sets the current filter to "close ESM" (using the inverse of the
  9839. * exponential to prevent steep falloff artifacts).
  9840. */
  9841. set useCloseExponentialShadowMap(value: boolean);
  9842. /**
  9843. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9844. * exponential to prevent steep falloff artifacts).
  9845. */
  9846. get useBlurCloseExponentialShadowMap(): boolean;
  9847. /**
  9848. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9849. * exponential to prevent steep falloff artifacts).
  9850. */
  9851. set useBlurCloseExponentialShadowMap(value: boolean);
  9852. /**
  9853. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9854. */
  9855. get usePercentageCloserFiltering(): boolean;
  9856. /**
  9857. * Sets the current filter to "PCF" (percentage closer filtering).
  9858. */
  9859. set usePercentageCloserFiltering(value: boolean);
  9860. protected _filteringQuality: number;
  9861. /**
  9862. * Gets the PCF or PCSS Quality.
  9863. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9864. */
  9865. get filteringQuality(): number;
  9866. /**
  9867. * Sets the PCF or PCSS Quality.
  9868. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9869. */
  9870. set filteringQuality(filteringQuality: number);
  9871. /**
  9872. * Gets if the current filter is set to "PCSS" (contact hardening).
  9873. */
  9874. get useContactHardeningShadow(): boolean;
  9875. /**
  9876. * Sets the current filter to "PCSS" (contact hardening).
  9877. */
  9878. set useContactHardeningShadow(value: boolean);
  9879. protected _contactHardeningLightSizeUVRatio: number;
  9880. /**
  9881. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9882. * Using a ratio helps keeping shape stability independently of the map size.
  9883. *
  9884. * It does not account for the light projection as it was having too much
  9885. * instability during the light setup or during light position changes.
  9886. *
  9887. * Only valid if useContactHardeningShadow is true.
  9888. */
  9889. get contactHardeningLightSizeUVRatio(): number;
  9890. /**
  9891. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9892. * Using a ratio helps keeping shape stability independently of the map size.
  9893. *
  9894. * It does not account for the light projection as it was having too much
  9895. * instability during the light setup or during light position changes.
  9896. *
  9897. * Only valid if useContactHardeningShadow is true.
  9898. */
  9899. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9900. protected _darkness: number;
  9901. /** Gets or sets the actual darkness of a shadow */
  9902. get darkness(): number;
  9903. set darkness(value: number);
  9904. /**
  9905. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9906. * 0 means strongest and 1 would means no shadow.
  9907. * @returns the darkness.
  9908. */
  9909. getDarkness(): number;
  9910. /**
  9911. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9912. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9913. * @returns the shadow generator allowing fluent coding.
  9914. */
  9915. setDarkness(darkness: number): ShadowGenerator;
  9916. protected _transparencyShadow: boolean;
  9917. /** Gets or sets the ability to have transparent shadow */
  9918. get transparencyShadow(): boolean;
  9919. set transparencyShadow(value: boolean);
  9920. /**
  9921. * Sets the ability to have transparent shadow (boolean).
  9922. * @param transparent True if transparent else False
  9923. * @returns the shadow generator allowing fluent coding
  9924. */
  9925. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9926. protected _shadowMap: Nullable<RenderTargetTexture>;
  9927. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9928. /**
  9929. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9930. * @returns The render target texture if present otherwise, null
  9931. */
  9932. getShadowMap(): Nullable<RenderTargetTexture>;
  9933. /**
  9934. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9935. * @returns The render target texture if the shadow map is present otherwise, null
  9936. */
  9937. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9938. /**
  9939. * Gets the class name of that object
  9940. * @returns "ShadowGenerator"
  9941. */
  9942. getClassName(): string;
  9943. /**
  9944. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9945. * @param mesh Mesh to add
  9946. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9947. * @returns the Shadow Generator itself
  9948. */
  9949. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9950. /**
  9951. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9952. * @param mesh Mesh to remove
  9953. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9954. * @returns the Shadow Generator itself
  9955. */
  9956. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9957. /**
  9958. * Controls the extent to which the shadows fade out at the edge of the frustum
  9959. */
  9960. frustumEdgeFalloff: number;
  9961. protected _light: IShadowLight;
  9962. /**
  9963. * Returns the associated light object.
  9964. * @returns the light generating the shadow
  9965. */
  9966. getLight(): IShadowLight;
  9967. /**
  9968. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9969. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9970. * It might on the other hand introduce peter panning.
  9971. */
  9972. forceBackFacesOnly: boolean;
  9973. protected _scene: Scene;
  9974. protected _lightDirection: Vector3;
  9975. protected _effect: Effect;
  9976. protected _viewMatrix: Matrix;
  9977. protected _projectionMatrix: Matrix;
  9978. protected _transformMatrix: Matrix;
  9979. protected _cachedPosition: Vector3;
  9980. protected _cachedDirection: Vector3;
  9981. protected _cachedDefines: string;
  9982. protected _currentRenderID: number;
  9983. protected _boxBlurPostprocess: Nullable<PostProcess>;
  9984. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  9985. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  9986. protected _blurPostProcesses: PostProcess[];
  9987. protected _mapSize: number;
  9988. protected _currentFaceIndex: number;
  9989. protected _currentFaceIndexCache: number;
  9990. protected _textureType: number;
  9991. protected _defaultTextureMatrix: Matrix;
  9992. protected _storedUniqueId: Nullable<number>;
  9993. /** @hidden */
  9994. static _SceneComponentInitialization: (scene: Scene) => void;
  9995. /**
  9996. * Creates a ShadowGenerator object.
  9997. * A ShadowGenerator is the required tool to use the shadows.
  9998. * Each light casting shadows needs to use its own ShadowGenerator.
  9999. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10000. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10001. * @param light The light object generating the shadows.
  10002. * @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.
  10003. */
  10004. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10005. protected _initializeGenerator(): void;
  10006. protected _createTargetRenderTexture(): void;
  10007. protected _initializeShadowMap(): void;
  10008. protected _initializeBlurRTTAndPostProcesses(): void;
  10009. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  10010. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  10011. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  10012. protected _applyFilterValues(): void;
  10013. /**
  10014. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10015. * @param onCompiled Callback triggered at the and of the effects compilation
  10016. * @param options Sets of optional options forcing the compilation with different modes
  10017. */
  10018. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  10019. useInstances: boolean;
  10020. }>): void;
  10021. /**
  10022. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10023. * @param options Sets of optional options forcing the compilation with different modes
  10024. * @returns A promise that resolves when the compilation completes
  10025. */
  10026. forceCompilationAsync(options?: Partial<{
  10027. useInstances: boolean;
  10028. }>): Promise<void>;
  10029. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  10030. /**
  10031. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10032. * @param subMesh The submesh we want to render in the shadow map
  10033. * @param useInstances Defines wether will draw in the map using instances
  10034. * @returns true if ready otherwise, false
  10035. */
  10036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10037. /**
  10038. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10039. * @param defines Defines of the material we want to update
  10040. * @param lightIndex Index of the light in the enabled light list of the material
  10041. */
  10042. prepareDefines(defines: any, lightIndex: number): void;
  10043. /**
  10044. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10045. * defined in the generator but impacting the effect).
  10046. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10047. * @param effect The effect we are binfing the information for
  10048. */
  10049. bindShadowLight(lightIndex: string, effect: Effect): void;
  10050. /**
  10051. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10052. * (eq to shadow prjection matrix * light transform matrix)
  10053. * @returns The transform matrix used to create the shadow map
  10054. */
  10055. getTransformMatrix(): Matrix;
  10056. /**
  10057. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10058. * Cube and 2D textures for instance.
  10059. */
  10060. recreateShadowMap(): void;
  10061. protected _disposeBlurPostProcesses(): void;
  10062. protected _disposeRTTandPostProcesses(): void;
  10063. /**
  10064. * Disposes the ShadowGenerator.
  10065. * Returns nothing.
  10066. */
  10067. dispose(): void;
  10068. /**
  10069. * Serializes the shadow generator setup to a json object.
  10070. * @returns The serialized JSON object
  10071. */
  10072. serialize(): any;
  10073. /**
  10074. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10075. * @param parsedShadowGenerator The JSON object to parse
  10076. * @param scene The scene to create the shadow map for
  10077. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  10078. * @returns The parsed shadow generator
  10079. */
  10080. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  10081. }
  10082. }
  10083. declare module "babylonjs/Lights/light" {
  10084. import { Nullable } from "babylonjs/types";
  10085. import { Scene } from "babylonjs/scene";
  10086. import { Vector3 } from "babylonjs/Maths/math.vector";
  10087. import { Color3 } from "babylonjs/Maths/math.color";
  10088. import { Node } from "babylonjs/node";
  10089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10090. import { Effect } from "babylonjs/Materials/effect";
  10091. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10092. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10093. /**
  10094. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10095. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10096. * 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.
  10097. */
  10098. export abstract class Light extends Node {
  10099. /**
  10100. * Falloff Default: light is falling off following the material specification:
  10101. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10102. */
  10103. static readonly FALLOFF_DEFAULT: number;
  10104. /**
  10105. * Falloff Physical: light is falling off following the inverse squared distance law.
  10106. */
  10107. static readonly FALLOFF_PHYSICAL: number;
  10108. /**
  10109. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10110. * to enhance interoperability with other engines.
  10111. */
  10112. static readonly FALLOFF_GLTF: number;
  10113. /**
  10114. * Falloff Standard: light is falling off like in the standard material
  10115. * to enhance interoperability with other materials.
  10116. */
  10117. static readonly FALLOFF_STANDARD: number;
  10118. /**
  10119. * If every light affecting the material is in this lightmapMode,
  10120. * material.lightmapTexture adds or multiplies
  10121. * (depends on material.useLightmapAsShadowmap)
  10122. * after every other light calculations.
  10123. */
  10124. static readonly LIGHTMAP_DEFAULT: number;
  10125. /**
  10126. * material.lightmapTexture as only diffuse lighting from this light
  10127. * adds only specular lighting from this light
  10128. * adds dynamic shadows
  10129. */
  10130. static readonly LIGHTMAP_SPECULAR: number;
  10131. /**
  10132. * material.lightmapTexture as only lighting
  10133. * no light calculation from this light
  10134. * only adds dynamic shadows from this light
  10135. */
  10136. static readonly LIGHTMAP_SHADOWSONLY: number;
  10137. /**
  10138. * Each light type uses the default quantity according to its type:
  10139. * point/spot lights use luminous intensity
  10140. * directional lights use illuminance
  10141. */
  10142. static readonly INTENSITYMODE_AUTOMATIC: number;
  10143. /**
  10144. * lumen (lm)
  10145. */
  10146. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10147. /**
  10148. * candela (lm/sr)
  10149. */
  10150. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10151. /**
  10152. * lux (lm/m^2)
  10153. */
  10154. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10155. /**
  10156. * nit (cd/m^2)
  10157. */
  10158. static readonly INTENSITYMODE_LUMINANCE: number;
  10159. /**
  10160. * Light type const id of the point light.
  10161. */
  10162. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10163. /**
  10164. * Light type const id of the directional light.
  10165. */
  10166. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10167. /**
  10168. * Light type const id of the spot light.
  10169. */
  10170. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10171. /**
  10172. * Light type const id of the hemispheric light.
  10173. */
  10174. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10175. /**
  10176. * Diffuse gives the basic color to an object.
  10177. */
  10178. diffuse: Color3;
  10179. /**
  10180. * Specular produces a highlight color on an object.
  10181. * Note: This is note affecting PBR materials.
  10182. */
  10183. specular: Color3;
  10184. /**
  10185. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10186. * falling off base on range or angle.
  10187. * This can be set to any values in Light.FALLOFF_x.
  10188. *
  10189. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10190. * other types of materials.
  10191. */
  10192. falloffType: number;
  10193. /**
  10194. * Strength of the light.
  10195. * Note: By default it is define in the framework own unit.
  10196. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10197. */
  10198. intensity: number;
  10199. private _range;
  10200. protected _inverseSquaredRange: number;
  10201. /**
  10202. * Defines how far from the source the light is impacting in scene units.
  10203. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10204. */
  10205. get range(): number;
  10206. /**
  10207. * Defines how far from the source the light is impacting in scene units.
  10208. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10209. */
  10210. set range(value: number);
  10211. /**
  10212. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10213. * of light.
  10214. */
  10215. private _photometricScale;
  10216. private _intensityMode;
  10217. /**
  10218. * Gets the photometric scale used to interpret the intensity.
  10219. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10220. */
  10221. get intensityMode(): number;
  10222. /**
  10223. * Sets the photometric scale used to interpret the intensity.
  10224. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10225. */
  10226. set intensityMode(value: number);
  10227. private _radius;
  10228. /**
  10229. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10230. */
  10231. get radius(): number;
  10232. /**
  10233. * sets the light radius used by PBR Materials to simulate soft area lights.
  10234. */
  10235. set radius(value: number);
  10236. private _renderPriority;
  10237. /**
  10238. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10239. * exceeding the number allowed of the materials.
  10240. */
  10241. renderPriority: number;
  10242. private _shadowEnabled;
  10243. /**
  10244. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10245. * the current shadow generator.
  10246. */
  10247. get shadowEnabled(): boolean;
  10248. /**
  10249. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10250. * the current shadow generator.
  10251. */
  10252. set shadowEnabled(value: boolean);
  10253. private _includedOnlyMeshes;
  10254. /**
  10255. * Gets the only meshes impacted by this light.
  10256. */
  10257. get includedOnlyMeshes(): AbstractMesh[];
  10258. /**
  10259. * Sets the only meshes impacted by this light.
  10260. */
  10261. set includedOnlyMeshes(value: AbstractMesh[]);
  10262. private _excludedMeshes;
  10263. /**
  10264. * Gets the meshes not impacted by this light.
  10265. */
  10266. get excludedMeshes(): AbstractMesh[];
  10267. /**
  10268. * Sets the meshes not impacted by this light.
  10269. */
  10270. set excludedMeshes(value: AbstractMesh[]);
  10271. private _excludeWithLayerMask;
  10272. /**
  10273. * Gets the layer id use to find what meshes are not impacted by the light.
  10274. * Inactive if 0
  10275. */
  10276. get excludeWithLayerMask(): number;
  10277. /**
  10278. * Sets the layer id use to find what meshes are not impacted by the light.
  10279. * Inactive if 0
  10280. */
  10281. set excludeWithLayerMask(value: number);
  10282. private _includeOnlyWithLayerMask;
  10283. /**
  10284. * Gets the layer id use to find what meshes are impacted by the light.
  10285. * Inactive if 0
  10286. */
  10287. get includeOnlyWithLayerMask(): number;
  10288. /**
  10289. * Sets the layer id use to find what meshes are impacted by the light.
  10290. * Inactive if 0
  10291. */
  10292. set includeOnlyWithLayerMask(value: number);
  10293. private _lightmapMode;
  10294. /**
  10295. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10296. */
  10297. get lightmapMode(): number;
  10298. /**
  10299. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10300. */
  10301. set lightmapMode(value: number);
  10302. /**
  10303. * Shadow generator associted to the light.
  10304. * @hidden Internal use only.
  10305. */
  10306. _shadowGenerator: Nullable<IShadowGenerator>;
  10307. /**
  10308. * @hidden Internal use only.
  10309. */
  10310. _excludedMeshesIds: string[];
  10311. /**
  10312. * @hidden Internal use only.
  10313. */
  10314. _includedOnlyMeshesIds: string[];
  10315. /**
  10316. * The current light unifom buffer.
  10317. * @hidden Internal use only.
  10318. */
  10319. _uniformBuffer: UniformBuffer;
  10320. /** @hidden */
  10321. _renderId: number;
  10322. /**
  10323. * Creates a Light object in the scene.
  10324. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10325. * @param name The firendly name of the light
  10326. * @param scene The scene the light belongs too
  10327. */
  10328. constructor(name: string, scene: Scene);
  10329. protected abstract _buildUniformLayout(): void;
  10330. /**
  10331. * Sets the passed Effect "effect" with the Light information.
  10332. * @param effect The effect to update
  10333. * @param lightIndex The index of the light in the effect to update
  10334. * @returns The light
  10335. */
  10336. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10337. /**
  10338. * Sets the passed Effect "effect" with the Light textures.
  10339. * @param effect The effect to update
  10340. * @param lightIndex The index of the light in the effect to update
  10341. * @returns The light
  10342. */
  10343. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10344. /**
  10345. * Binds the lights information from the scene to the effect for the given mesh.
  10346. * @param lightIndex Light index
  10347. * @param scene The scene where the light belongs to
  10348. * @param effect The effect we are binding the data to
  10349. * @param useSpecular Defines if specular is supported
  10350. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10351. */
  10352. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10353. /**
  10354. * Sets the passed Effect "effect" with the Light information.
  10355. * @param effect The effect to update
  10356. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10357. * @returns The light
  10358. */
  10359. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10360. /**
  10361. * Returns the string "Light".
  10362. * @returns the class name
  10363. */
  10364. getClassName(): string;
  10365. /** @hidden */
  10366. readonly _isLight: boolean;
  10367. /**
  10368. * Converts the light information to a readable string for debug purpose.
  10369. * @param fullDetails Supports for multiple levels of logging within scene loading
  10370. * @returns the human readable light info
  10371. */
  10372. toString(fullDetails?: boolean): string;
  10373. /** @hidden */
  10374. protected _syncParentEnabledState(): void;
  10375. /**
  10376. * Set the enabled state of this node.
  10377. * @param value - the new enabled state
  10378. */
  10379. setEnabled(value: boolean): void;
  10380. /**
  10381. * Returns the Light associated shadow generator if any.
  10382. * @return the associated shadow generator.
  10383. */
  10384. getShadowGenerator(): Nullable<IShadowGenerator>;
  10385. /**
  10386. * Returns a Vector3, the absolute light position in the World.
  10387. * @returns the world space position of the light
  10388. */
  10389. getAbsolutePosition(): Vector3;
  10390. /**
  10391. * Specifies if the light will affect the passed mesh.
  10392. * @param mesh The mesh to test against the light
  10393. * @return true the mesh is affected otherwise, false.
  10394. */
  10395. canAffectMesh(mesh: AbstractMesh): boolean;
  10396. /**
  10397. * Sort function to order lights for rendering.
  10398. * @param a First Light object to compare to second.
  10399. * @param b Second Light object to compare first.
  10400. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10401. */
  10402. static CompareLightsPriority(a: Light, b: Light): number;
  10403. /**
  10404. * Releases resources associated with this node.
  10405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10407. */
  10408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10409. /**
  10410. * Returns the light type ID (integer).
  10411. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10412. */
  10413. getTypeID(): number;
  10414. /**
  10415. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10416. * @returns the scaled intensity in intensity mode unit
  10417. */
  10418. getScaledIntensity(): number;
  10419. /**
  10420. * Returns a new Light object, named "name", from the current one.
  10421. * @param name The name of the cloned light
  10422. * @returns the new created light
  10423. */
  10424. clone(name: string): Nullable<Light>;
  10425. /**
  10426. * Serializes the current light into a Serialization object.
  10427. * @returns the serialized object.
  10428. */
  10429. serialize(): any;
  10430. /**
  10431. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10432. * This new light is named "name" and added to the passed scene.
  10433. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10434. * @param name The friendly name of the light
  10435. * @param scene The scene the new light will belong to
  10436. * @returns the constructor function
  10437. */
  10438. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10439. /**
  10440. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10441. * @param parsedLight The JSON representation of the light
  10442. * @param scene The scene to create the parsed light in
  10443. * @returns the created light after parsing
  10444. */
  10445. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10446. private _hookArrayForExcluded;
  10447. private _hookArrayForIncludedOnly;
  10448. private _resyncMeshes;
  10449. /**
  10450. * Forces the meshes to update their light related information in their rendering used effects
  10451. * @hidden Internal Use Only
  10452. */
  10453. _markMeshesAsLightDirty(): void;
  10454. /**
  10455. * Recomputes the cached photometric scale if needed.
  10456. */
  10457. private _computePhotometricScale;
  10458. /**
  10459. * Returns the Photometric Scale according to the light type and intensity mode.
  10460. */
  10461. private _getPhotometricScale;
  10462. /**
  10463. * Reorder the light in the scene according to their defined priority.
  10464. * @hidden Internal Use Only
  10465. */
  10466. _reorderLightsInScene(): void;
  10467. /**
  10468. * Prepares the list of defines specific to the light type.
  10469. * @param defines the list of defines
  10470. * @param lightIndex defines the index of the light for the effect
  10471. */
  10472. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10473. }
  10474. }
  10475. declare module "babylonjs/Actions/action" {
  10476. import { Observable } from "babylonjs/Misc/observable";
  10477. import { Condition } from "babylonjs/Actions/condition";
  10478. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10479. import { ActionManager } from "babylonjs/Actions/actionManager";
  10480. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10481. /**
  10482. * Interface used to define Action
  10483. */
  10484. export interface IAction {
  10485. /**
  10486. * Trigger for the action
  10487. */
  10488. trigger: number;
  10489. /** Options of the trigger */
  10490. triggerOptions: any;
  10491. /**
  10492. * Gets the trigger parameters
  10493. * @returns the trigger parameters
  10494. */
  10495. getTriggerParameter(): any;
  10496. /**
  10497. * Internal only - executes current action event
  10498. * @hidden
  10499. */
  10500. _executeCurrent(evt?: ActionEvent): void;
  10501. /**
  10502. * Serialize placeholder for child classes
  10503. * @param parent of child
  10504. * @returns the serialized object
  10505. */
  10506. serialize(parent: any): any;
  10507. /**
  10508. * Internal only
  10509. * @hidden
  10510. */
  10511. _prepare(): void;
  10512. /**
  10513. * Internal only - manager for action
  10514. * @hidden
  10515. */
  10516. _actionManager: AbstractActionManager;
  10517. /**
  10518. * Adds action to chain of actions, may be a DoNothingAction
  10519. * @param action defines the next action to execute
  10520. * @returns The action passed in
  10521. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10522. */
  10523. then(action: IAction): IAction;
  10524. }
  10525. /**
  10526. * The action to be carried out following a trigger
  10527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10528. */
  10529. export class Action implements IAction {
  10530. /** the trigger, with or without parameters, for the action */
  10531. triggerOptions: any;
  10532. /**
  10533. * Trigger for the action
  10534. */
  10535. trigger: number;
  10536. /**
  10537. * Internal only - manager for action
  10538. * @hidden
  10539. */
  10540. _actionManager: ActionManager;
  10541. private _nextActiveAction;
  10542. private _child;
  10543. private _condition?;
  10544. private _triggerParameter;
  10545. /**
  10546. * An event triggered prior to action being executed.
  10547. */
  10548. onBeforeExecuteObservable: Observable<Action>;
  10549. /**
  10550. * Creates a new Action
  10551. * @param triggerOptions the trigger, with or without parameters, for the action
  10552. * @param condition an optional determinant of action
  10553. */
  10554. constructor(
  10555. /** the trigger, with or without parameters, for the action */
  10556. triggerOptions: any, condition?: Condition);
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. _prepare(): void;
  10562. /**
  10563. * Gets the trigger parameters
  10564. * @returns the trigger parameters
  10565. */
  10566. getTriggerParameter(): any;
  10567. /**
  10568. * Internal only - executes current action event
  10569. * @hidden
  10570. */
  10571. _executeCurrent(evt?: ActionEvent): void;
  10572. /**
  10573. * Execute placeholder for child classes
  10574. * @param evt optional action event
  10575. */
  10576. execute(evt?: ActionEvent): void;
  10577. /**
  10578. * Skips to next active action
  10579. */
  10580. skipToNextActiveAction(): void;
  10581. /**
  10582. * Adds action to chain of actions, may be a DoNothingAction
  10583. * @param action defines the next action to execute
  10584. * @returns The action passed in
  10585. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10586. */
  10587. then(action: Action): Action;
  10588. /**
  10589. * Internal only
  10590. * @hidden
  10591. */
  10592. _getProperty(propertyPath: string): string;
  10593. /**
  10594. * Internal only
  10595. * @hidden
  10596. */
  10597. _getEffectiveTarget(target: any, propertyPath: string): any;
  10598. /**
  10599. * Serialize placeholder for child classes
  10600. * @param parent of child
  10601. * @returns the serialized object
  10602. */
  10603. serialize(parent: any): any;
  10604. /**
  10605. * Internal only called by serialize
  10606. * @hidden
  10607. */
  10608. protected _serialize(serializedAction: any, parent?: any): any;
  10609. /**
  10610. * Internal only
  10611. * @hidden
  10612. */
  10613. static _SerializeValueAsString: (value: any) => string;
  10614. /**
  10615. * Internal only
  10616. * @hidden
  10617. */
  10618. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10619. name: string;
  10620. targetType: string;
  10621. value: string;
  10622. };
  10623. }
  10624. }
  10625. declare module "babylonjs/Actions/condition" {
  10626. import { ActionManager } from "babylonjs/Actions/actionManager";
  10627. /**
  10628. * A Condition applied to an Action
  10629. */
  10630. export class Condition {
  10631. /**
  10632. * Internal only - manager for action
  10633. * @hidden
  10634. */
  10635. _actionManager: ActionManager;
  10636. /**
  10637. * Internal only
  10638. * @hidden
  10639. */
  10640. _evaluationId: number;
  10641. /**
  10642. * Internal only
  10643. * @hidden
  10644. */
  10645. _currentResult: boolean;
  10646. /**
  10647. * Creates a new Condition
  10648. * @param actionManager the manager of the action the condition is applied to
  10649. */
  10650. constructor(actionManager: ActionManager);
  10651. /**
  10652. * Check if the current condition is valid
  10653. * @returns a boolean
  10654. */
  10655. isValid(): boolean;
  10656. /**
  10657. * Internal only
  10658. * @hidden
  10659. */
  10660. _getProperty(propertyPath: string): string;
  10661. /**
  10662. * Internal only
  10663. * @hidden
  10664. */
  10665. _getEffectiveTarget(target: any, propertyPath: string): any;
  10666. /**
  10667. * Serialize placeholder for child classes
  10668. * @returns the serialized object
  10669. */
  10670. serialize(): any;
  10671. /**
  10672. * Internal only
  10673. * @hidden
  10674. */
  10675. protected _serialize(serializedCondition: any): any;
  10676. }
  10677. /**
  10678. * Defines specific conditional operators as extensions of Condition
  10679. */
  10680. export class ValueCondition extends Condition {
  10681. /** path to specify the property of the target the conditional operator uses */
  10682. propertyPath: string;
  10683. /** the value compared by the conditional operator against the current value of the property */
  10684. value: any;
  10685. /** the conditional operator, default ValueCondition.IsEqual */
  10686. operator: number;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. private static _IsEqual;
  10692. /**
  10693. * Internal only
  10694. * @hidden
  10695. */
  10696. private static _IsDifferent;
  10697. /**
  10698. * Internal only
  10699. * @hidden
  10700. */
  10701. private static _IsGreater;
  10702. /**
  10703. * Internal only
  10704. * @hidden
  10705. */
  10706. private static _IsLesser;
  10707. /**
  10708. * returns the number for IsEqual
  10709. */
  10710. static get IsEqual(): number;
  10711. /**
  10712. * Returns the number for IsDifferent
  10713. */
  10714. static get IsDifferent(): number;
  10715. /**
  10716. * Returns the number for IsGreater
  10717. */
  10718. static get IsGreater(): number;
  10719. /**
  10720. * Returns the number for IsLesser
  10721. */
  10722. static get IsLesser(): number;
  10723. /**
  10724. * Internal only The action manager for the condition
  10725. * @hidden
  10726. */
  10727. _actionManager: ActionManager;
  10728. /**
  10729. * Internal only
  10730. * @hidden
  10731. */
  10732. private _target;
  10733. /**
  10734. * Internal only
  10735. * @hidden
  10736. */
  10737. private _effectiveTarget;
  10738. /**
  10739. * Internal only
  10740. * @hidden
  10741. */
  10742. private _property;
  10743. /**
  10744. * Creates a new ValueCondition
  10745. * @param actionManager manager for the action the condition applies to
  10746. * @param target for the action
  10747. * @param propertyPath path to specify the property of the target the conditional operator uses
  10748. * @param value the value compared by the conditional operator against the current value of the property
  10749. * @param operator the conditional operator, default ValueCondition.IsEqual
  10750. */
  10751. constructor(actionManager: ActionManager, target: any,
  10752. /** path to specify the property of the target the conditional operator uses */
  10753. propertyPath: string,
  10754. /** the value compared by the conditional operator against the current value of the property */
  10755. value: any,
  10756. /** the conditional operator, default ValueCondition.IsEqual */
  10757. operator?: number);
  10758. /**
  10759. * Compares the given value with the property value for the specified conditional operator
  10760. * @returns the result of the comparison
  10761. */
  10762. isValid(): boolean;
  10763. /**
  10764. * Serialize the ValueCondition into a JSON compatible object
  10765. * @returns serialization object
  10766. */
  10767. serialize(): any;
  10768. /**
  10769. * Gets the name of the conditional operator for the ValueCondition
  10770. * @param operator the conditional operator
  10771. * @returns the name
  10772. */
  10773. static GetOperatorName(operator: number): string;
  10774. }
  10775. /**
  10776. * Defines a predicate condition as an extension of Condition
  10777. */
  10778. export class PredicateCondition extends Condition {
  10779. /** defines the predicate function used to validate the condition */
  10780. predicate: () => boolean;
  10781. /**
  10782. * Internal only - manager for action
  10783. * @hidden
  10784. */
  10785. _actionManager: ActionManager;
  10786. /**
  10787. * Creates a new PredicateCondition
  10788. * @param actionManager manager for the action the condition applies to
  10789. * @param predicate defines the predicate function used to validate the condition
  10790. */
  10791. constructor(actionManager: ActionManager,
  10792. /** defines the predicate function used to validate the condition */
  10793. predicate: () => boolean);
  10794. /**
  10795. * @returns the validity of the predicate condition
  10796. */
  10797. isValid(): boolean;
  10798. }
  10799. /**
  10800. * Defines a state condition as an extension of Condition
  10801. */
  10802. export class StateCondition extends Condition {
  10803. /** Value to compare with target state */
  10804. value: string;
  10805. /**
  10806. * Internal only - manager for action
  10807. * @hidden
  10808. */
  10809. _actionManager: ActionManager;
  10810. /**
  10811. * Internal only
  10812. * @hidden
  10813. */
  10814. private _target;
  10815. /**
  10816. * Creates a new StateCondition
  10817. * @param actionManager manager for the action the condition applies to
  10818. * @param target of the condition
  10819. * @param value to compare with target state
  10820. */
  10821. constructor(actionManager: ActionManager, target: any,
  10822. /** Value to compare with target state */
  10823. value: string);
  10824. /**
  10825. * Gets a boolean indicating if the current condition is met
  10826. * @returns the validity of the state
  10827. */
  10828. isValid(): boolean;
  10829. /**
  10830. * Serialize the StateCondition into a JSON compatible object
  10831. * @returns serialization object
  10832. */
  10833. serialize(): any;
  10834. }
  10835. }
  10836. declare module "babylonjs/Actions/directActions" {
  10837. import { Action } from "babylonjs/Actions/action";
  10838. import { Condition } from "babylonjs/Actions/condition";
  10839. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10840. /**
  10841. * This defines an action responsible to toggle a boolean once triggered.
  10842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10843. */
  10844. export class SwitchBooleanAction extends Action {
  10845. /**
  10846. * The path to the boolean property in the target object
  10847. */
  10848. propertyPath: string;
  10849. private _target;
  10850. private _effectiveTarget;
  10851. private _property;
  10852. /**
  10853. * Instantiate the action
  10854. * @param triggerOptions defines the trigger options
  10855. * @param target defines the object containing the boolean
  10856. * @param propertyPath defines the path to the boolean property in the target object
  10857. * @param condition defines the trigger related conditions
  10858. */
  10859. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10860. /** @hidden */
  10861. _prepare(): void;
  10862. /**
  10863. * Execute the action toggle the boolean value.
  10864. */
  10865. execute(): void;
  10866. /**
  10867. * Serializes the actions and its related information.
  10868. * @param parent defines the object to serialize in
  10869. * @returns the serialized object
  10870. */
  10871. serialize(parent: any): any;
  10872. }
  10873. /**
  10874. * This defines an action responsible to set a the state field of the target
  10875. * to a desired value once triggered.
  10876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10877. */
  10878. export class SetStateAction extends Action {
  10879. /**
  10880. * The value to store in the state field.
  10881. */
  10882. value: string;
  10883. private _target;
  10884. /**
  10885. * Instantiate the action
  10886. * @param triggerOptions defines the trigger options
  10887. * @param target defines the object containing the state property
  10888. * @param value defines the value to store in the state field
  10889. * @param condition defines the trigger related conditions
  10890. */
  10891. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10892. /**
  10893. * Execute the action and store the value on the target state property.
  10894. */
  10895. execute(): void;
  10896. /**
  10897. * Serializes the actions and its related information.
  10898. * @param parent defines the object to serialize in
  10899. * @returns the serialized object
  10900. */
  10901. serialize(parent: any): any;
  10902. }
  10903. /**
  10904. * This defines an action responsible to set a property of the target
  10905. * to a desired value once triggered.
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10907. */
  10908. export class SetValueAction extends Action {
  10909. /**
  10910. * The path of the property to set in the target.
  10911. */
  10912. propertyPath: string;
  10913. /**
  10914. * The value to set in the property
  10915. */
  10916. value: any;
  10917. private _target;
  10918. private _effectiveTarget;
  10919. private _property;
  10920. /**
  10921. * Instantiate the action
  10922. * @param triggerOptions defines the trigger options
  10923. * @param target defines the object containing the property
  10924. * @param propertyPath defines the path of the property to set in the target
  10925. * @param value defines the value to set in the property
  10926. * @param condition defines the trigger related conditions
  10927. */
  10928. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10929. /** @hidden */
  10930. _prepare(): void;
  10931. /**
  10932. * Execute the action and set the targetted property to the desired value.
  10933. */
  10934. execute(): void;
  10935. /**
  10936. * Serializes the actions and its related information.
  10937. * @param parent defines the object to serialize in
  10938. * @returns the serialized object
  10939. */
  10940. serialize(parent: any): any;
  10941. }
  10942. /**
  10943. * This defines an action responsible to increment the target value
  10944. * to a desired value once triggered.
  10945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10946. */
  10947. export class IncrementValueAction extends Action {
  10948. /**
  10949. * The path of the property to increment in the target.
  10950. */
  10951. propertyPath: string;
  10952. /**
  10953. * The value we should increment the property by.
  10954. */
  10955. value: any;
  10956. private _target;
  10957. private _effectiveTarget;
  10958. private _property;
  10959. /**
  10960. * Instantiate the action
  10961. * @param triggerOptions defines the trigger options
  10962. * @param target defines the object containing the property
  10963. * @param propertyPath defines the path of the property to increment in the target
  10964. * @param value defines the value value we should increment the property by
  10965. * @param condition defines the trigger related conditions
  10966. */
  10967. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10968. /** @hidden */
  10969. _prepare(): void;
  10970. /**
  10971. * Execute the action and increment the target of the value amount.
  10972. */
  10973. execute(): void;
  10974. /**
  10975. * Serializes the actions and its related information.
  10976. * @param parent defines the object to serialize in
  10977. * @returns the serialized object
  10978. */
  10979. serialize(parent: any): any;
  10980. }
  10981. /**
  10982. * This defines an action responsible to start an animation once triggered.
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10984. */
  10985. export class PlayAnimationAction extends Action {
  10986. /**
  10987. * Where the animation should start (animation frame)
  10988. */
  10989. from: number;
  10990. /**
  10991. * Where the animation should stop (animation frame)
  10992. */
  10993. to: number;
  10994. /**
  10995. * Define if the animation should loop or stop after the first play.
  10996. */
  10997. loop?: boolean;
  10998. private _target;
  10999. /**
  11000. * Instantiate the action
  11001. * @param triggerOptions defines the trigger options
  11002. * @param target defines the target animation or animation name
  11003. * @param from defines from where the animation should start (animation frame)
  11004. * @param end defines where the animation should stop (animation frame)
  11005. * @param loop defines if the animation should loop or stop after the first play
  11006. * @param condition defines the trigger related conditions
  11007. */
  11008. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11009. /** @hidden */
  11010. _prepare(): void;
  11011. /**
  11012. * Execute the action and play the animation.
  11013. */
  11014. execute(): void;
  11015. /**
  11016. * Serializes the actions and its related information.
  11017. * @param parent defines the object to serialize in
  11018. * @returns the serialized object
  11019. */
  11020. serialize(parent: any): any;
  11021. }
  11022. /**
  11023. * This defines an action responsible to stop an animation once triggered.
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11025. */
  11026. export class StopAnimationAction extends Action {
  11027. private _target;
  11028. /**
  11029. * Instantiate the action
  11030. * @param triggerOptions defines the trigger options
  11031. * @param target defines the target animation or animation name
  11032. * @param condition defines the trigger related conditions
  11033. */
  11034. constructor(triggerOptions: any, target: any, condition?: Condition);
  11035. /** @hidden */
  11036. _prepare(): void;
  11037. /**
  11038. * Execute the action and stop the animation.
  11039. */
  11040. execute(): void;
  11041. /**
  11042. * Serializes the actions and its related information.
  11043. * @param parent defines the object to serialize in
  11044. * @returns the serialized object
  11045. */
  11046. serialize(parent: any): any;
  11047. }
  11048. /**
  11049. * This defines an action responsible that does nothing once triggered.
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11051. */
  11052. export class DoNothingAction extends Action {
  11053. /**
  11054. * Instantiate the action
  11055. * @param triggerOptions defines the trigger options
  11056. * @param condition defines the trigger related conditions
  11057. */
  11058. constructor(triggerOptions?: any, condition?: Condition);
  11059. /**
  11060. * Execute the action and do nothing.
  11061. */
  11062. execute(): void;
  11063. /**
  11064. * Serializes the actions and its related information.
  11065. * @param parent defines the object to serialize in
  11066. * @returns the serialized object
  11067. */
  11068. serialize(parent: any): any;
  11069. }
  11070. /**
  11071. * This defines an action responsible to trigger several actions once triggered.
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11073. */
  11074. export class CombineAction extends Action {
  11075. /**
  11076. * The list of aggregated animations to run.
  11077. */
  11078. children: Action[];
  11079. /**
  11080. * Instantiate the action
  11081. * @param triggerOptions defines the trigger options
  11082. * @param children defines the list of aggregated animations to run
  11083. * @param condition defines the trigger related conditions
  11084. */
  11085. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11086. /** @hidden */
  11087. _prepare(): void;
  11088. /**
  11089. * Execute the action and executes all the aggregated actions.
  11090. */
  11091. execute(evt: ActionEvent): void;
  11092. /**
  11093. * Serializes the actions and its related information.
  11094. * @param parent defines the object to serialize in
  11095. * @returns the serialized object
  11096. */
  11097. serialize(parent: any): any;
  11098. }
  11099. /**
  11100. * This defines an action responsible to run code (external event) once triggered.
  11101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11102. */
  11103. export class ExecuteCodeAction extends Action {
  11104. /**
  11105. * The callback function to run.
  11106. */
  11107. func: (evt: ActionEvent) => void;
  11108. /**
  11109. * Instantiate the action
  11110. * @param triggerOptions defines the trigger options
  11111. * @param func defines the callback function to run
  11112. * @param condition defines the trigger related conditions
  11113. */
  11114. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11115. /**
  11116. * Execute the action and run the attached code.
  11117. */
  11118. execute(evt: ActionEvent): void;
  11119. }
  11120. /**
  11121. * This defines an action responsible to set the parent property of the target once triggered.
  11122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11123. */
  11124. export class SetParentAction extends Action {
  11125. private _parent;
  11126. private _target;
  11127. /**
  11128. * Instantiate the action
  11129. * @param triggerOptions defines the trigger options
  11130. * @param target defines the target containing the parent property
  11131. * @param parent defines from where the animation should start (animation frame)
  11132. * @param condition defines the trigger related conditions
  11133. */
  11134. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11135. /** @hidden */
  11136. _prepare(): void;
  11137. /**
  11138. * Execute the action and set the parent property.
  11139. */
  11140. execute(): void;
  11141. /**
  11142. * Serializes the actions and its related information.
  11143. * @param parent defines the object to serialize in
  11144. * @returns the serialized object
  11145. */
  11146. serialize(parent: any): any;
  11147. }
  11148. }
  11149. declare module "babylonjs/Actions/actionManager" {
  11150. import { Nullable } from "babylonjs/types";
  11151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11152. import { Scene } from "babylonjs/scene";
  11153. import { IAction } from "babylonjs/Actions/action";
  11154. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11155. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11156. /**
  11157. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11158. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11160. */
  11161. export class ActionManager extends AbstractActionManager {
  11162. /**
  11163. * Nothing
  11164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11165. */
  11166. static readonly NothingTrigger: number;
  11167. /**
  11168. * On pick
  11169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11170. */
  11171. static readonly OnPickTrigger: number;
  11172. /**
  11173. * On left pick
  11174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11175. */
  11176. static readonly OnLeftPickTrigger: number;
  11177. /**
  11178. * On right pick
  11179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11180. */
  11181. static readonly OnRightPickTrigger: number;
  11182. /**
  11183. * On center pick
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11185. */
  11186. static readonly OnCenterPickTrigger: number;
  11187. /**
  11188. * On pick down
  11189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11190. */
  11191. static readonly OnPickDownTrigger: number;
  11192. /**
  11193. * On double pick
  11194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11195. */
  11196. static readonly OnDoublePickTrigger: number;
  11197. /**
  11198. * On pick up
  11199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11200. */
  11201. static readonly OnPickUpTrigger: number;
  11202. /**
  11203. * On pick out.
  11204. * This trigger will only be raised if you also declared a OnPickDown
  11205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11206. */
  11207. static readonly OnPickOutTrigger: number;
  11208. /**
  11209. * On long press
  11210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11211. */
  11212. static readonly OnLongPressTrigger: number;
  11213. /**
  11214. * On pointer over
  11215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11216. */
  11217. static readonly OnPointerOverTrigger: number;
  11218. /**
  11219. * On pointer out
  11220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11221. */
  11222. static readonly OnPointerOutTrigger: number;
  11223. /**
  11224. * On every frame
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11226. */
  11227. static readonly OnEveryFrameTrigger: number;
  11228. /**
  11229. * On intersection enter
  11230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11231. */
  11232. static readonly OnIntersectionEnterTrigger: number;
  11233. /**
  11234. * On intersection exit
  11235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11236. */
  11237. static readonly OnIntersectionExitTrigger: number;
  11238. /**
  11239. * On key down
  11240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11241. */
  11242. static readonly OnKeyDownTrigger: number;
  11243. /**
  11244. * On key up
  11245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11246. */
  11247. static readonly OnKeyUpTrigger: number;
  11248. private _scene;
  11249. /**
  11250. * Creates a new action manager
  11251. * @param scene defines the hosting scene
  11252. */
  11253. constructor(scene: Scene);
  11254. /**
  11255. * Releases all associated resources
  11256. */
  11257. dispose(): void;
  11258. /**
  11259. * Gets hosting scene
  11260. * @returns the hosting scene
  11261. */
  11262. getScene(): Scene;
  11263. /**
  11264. * Does this action manager handles actions of any of the given triggers
  11265. * @param triggers defines the triggers to be tested
  11266. * @return a boolean indicating whether one (or more) of the triggers is handled
  11267. */
  11268. hasSpecificTriggers(triggers: number[]): boolean;
  11269. /**
  11270. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11271. * speed.
  11272. * @param triggerA defines the trigger to be tested
  11273. * @param triggerB defines the trigger to be tested
  11274. * @return a boolean indicating whether one (or more) of the triggers is handled
  11275. */
  11276. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11277. /**
  11278. * Does this action manager handles actions of a given trigger
  11279. * @param trigger defines the trigger to be tested
  11280. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11281. * @return whether the trigger is handled
  11282. */
  11283. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11284. /**
  11285. * Does this action manager has pointer triggers
  11286. */
  11287. get hasPointerTriggers(): boolean;
  11288. /**
  11289. * Does this action manager has pick triggers
  11290. */
  11291. get hasPickTriggers(): boolean;
  11292. /**
  11293. * Registers an action to this action manager
  11294. * @param action defines the action to be registered
  11295. * @return the action amended (prepared) after registration
  11296. */
  11297. registerAction(action: IAction): Nullable<IAction>;
  11298. /**
  11299. * Unregisters an action to this action manager
  11300. * @param action defines the action to be unregistered
  11301. * @return a boolean indicating whether the action has been unregistered
  11302. */
  11303. unregisterAction(action: IAction): Boolean;
  11304. /**
  11305. * Process a specific trigger
  11306. * @param trigger defines the trigger to process
  11307. * @param evt defines the event details to be processed
  11308. */
  11309. processTrigger(trigger: number, evt?: IActionEvent): void;
  11310. /** @hidden */
  11311. _getEffectiveTarget(target: any, propertyPath: string): any;
  11312. /** @hidden */
  11313. _getProperty(propertyPath: string): string;
  11314. /**
  11315. * Serialize this manager to a JSON object
  11316. * @param name defines the property name to store this manager
  11317. * @returns a JSON representation of this manager
  11318. */
  11319. serialize(name: string): any;
  11320. /**
  11321. * Creates a new ActionManager from a JSON data
  11322. * @param parsedActions defines the JSON data to read from
  11323. * @param object defines the hosting mesh
  11324. * @param scene defines the hosting scene
  11325. */
  11326. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11327. /**
  11328. * Get a trigger name by index
  11329. * @param trigger defines the trigger index
  11330. * @returns a trigger name
  11331. */
  11332. static GetTriggerName(trigger: number): string;
  11333. }
  11334. }
  11335. declare module "babylonjs/Culling/ray" {
  11336. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11337. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11339. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11340. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11341. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11342. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11343. import { Plane } from "babylonjs/Maths/math.plane";
  11344. /**
  11345. * Class representing a ray with position and direction
  11346. */
  11347. export class Ray {
  11348. /** origin point */
  11349. origin: Vector3;
  11350. /** direction */
  11351. direction: Vector3;
  11352. /** length of the ray */
  11353. length: number;
  11354. private static readonly TmpVector3;
  11355. private _tmpRay;
  11356. /**
  11357. * Creates a new ray
  11358. * @param origin origin point
  11359. * @param direction direction
  11360. * @param length length of the ray
  11361. */
  11362. constructor(
  11363. /** origin point */
  11364. origin: Vector3,
  11365. /** direction */
  11366. direction: Vector3,
  11367. /** length of the ray */
  11368. length?: number);
  11369. /**
  11370. * Checks if the ray intersects a box
  11371. * @param minimum bound of the box
  11372. * @param maximum bound of the box
  11373. * @param intersectionTreshold extra extend to be added to the box in all direction
  11374. * @returns if the box was hit
  11375. */
  11376. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11377. /**
  11378. * Checks if the ray intersects a box
  11379. * @param box the bounding box to check
  11380. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11381. * @returns if the box was hit
  11382. */
  11383. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11384. /**
  11385. * If the ray hits a sphere
  11386. * @param sphere the bounding sphere to check
  11387. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11388. * @returns true if it hits the sphere
  11389. */
  11390. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11391. /**
  11392. * If the ray hits a triange
  11393. * @param vertex0 triangle vertex
  11394. * @param vertex1 triangle vertex
  11395. * @param vertex2 triangle vertex
  11396. * @returns intersection information if hit
  11397. */
  11398. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11399. /**
  11400. * Checks if ray intersects a plane
  11401. * @param plane the plane to check
  11402. * @returns the distance away it was hit
  11403. */
  11404. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11405. /**
  11406. * Calculate the intercept of a ray on a given axis
  11407. * @param axis to check 'x' | 'y' | 'z'
  11408. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11409. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11410. */
  11411. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11412. /**
  11413. * Checks if ray intersects a mesh
  11414. * @param mesh the mesh to check
  11415. * @param fastCheck if only the bounding box should checked
  11416. * @returns picking info of the intersecton
  11417. */
  11418. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11419. /**
  11420. * Checks if ray intersects a mesh
  11421. * @param meshes the meshes to check
  11422. * @param fastCheck if only the bounding box should checked
  11423. * @param results array to store result in
  11424. * @returns Array of picking infos
  11425. */
  11426. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11427. private _comparePickingInfo;
  11428. private static smallnum;
  11429. private static rayl;
  11430. /**
  11431. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11432. * @param sega the first point of the segment to test the intersection against
  11433. * @param segb the second point of the segment to test the intersection against
  11434. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11435. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11436. */
  11437. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11438. /**
  11439. * Update the ray from viewport position
  11440. * @param x position
  11441. * @param y y position
  11442. * @param viewportWidth viewport width
  11443. * @param viewportHeight viewport height
  11444. * @param world world matrix
  11445. * @param view view matrix
  11446. * @param projection projection matrix
  11447. * @returns this ray updated
  11448. */
  11449. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11450. /**
  11451. * Creates a ray with origin and direction of 0,0,0
  11452. * @returns the new ray
  11453. */
  11454. static Zero(): Ray;
  11455. /**
  11456. * Creates a new ray from screen space and viewport
  11457. * @param x position
  11458. * @param y y position
  11459. * @param viewportWidth viewport width
  11460. * @param viewportHeight viewport height
  11461. * @param world world matrix
  11462. * @param view view matrix
  11463. * @param projection projection matrix
  11464. * @returns new ray
  11465. */
  11466. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11467. /**
  11468. * 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
  11469. * transformed to the given world matrix.
  11470. * @param origin The origin point
  11471. * @param end The end point
  11472. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11473. * @returns the new ray
  11474. */
  11475. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11476. /**
  11477. * Transforms a ray by a matrix
  11478. * @param ray ray to transform
  11479. * @param matrix matrix to apply
  11480. * @returns the resulting new ray
  11481. */
  11482. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11483. /**
  11484. * Transforms a ray by a matrix
  11485. * @param ray ray to transform
  11486. * @param matrix matrix to apply
  11487. * @param result ray to store result in
  11488. */
  11489. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11490. /**
  11491. * Unproject a ray from screen space to object space
  11492. * @param sourceX defines the screen space x coordinate to use
  11493. * @param sourceY defines the screen space y coordinate to use
  11494. * @param viewportWidth defines the current width of the viewport
  11495. * @param viewportHeight defines the current height of the viewport
  11496. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11497. * @param view defines the view matrix to use
  11498. * @param projection defines the projection matrix to use
  11499. */
  11500. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11501. }
  11502. /**
  11503. * Type used to define predicate used to select faces when a mesh intersection is detected
  11504. */
  11505. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11506. module "babylonjs/scene" {
  11507. interface Scene {
  11508. /** @hidden */
  11509. _tempPickingRay: Nullable<Ray>;
  11510. /** @hidden */
  11511. _cachedRayForTransform: Ray;
  11512. /** @hidden */
  11513. _pickWithRayInverseMatrix: Matrix;
  11514. /** @hidden */
  11515. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11516. /** @hidden */
  11517. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11518. }
  11519. }
  11520. }
  11521. declare module "babylonjs/sceneComponent" {
  11522. import { Scene } from "babylonjs/scene";
  11523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11525. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11526. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11527. import { Nullable } from "babylonjs/types";
  11528. import { Camera } from "babylonjs/Cameras/camera";
  11529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11530. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11531. import { AbstractScene } from "babylonjs/abstractScene";
  11532. import { Mesh } from "babylonjs/Meshes/mesh";
  11533. /**
  11534. * Groups all the scene component constants in one place to ease maintenance.
  11535. * @hidden
  11536. */
  11537. export class SceneComponentConstants {
  11538. static readonly NAME_EFFECTLAYER: string;
  11539. static readonly NAME_LAYER: string;
  11540. static readonly NAME_LENSFLARESYSTEM: string;
  11541. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11542. static readonly NAME_PARTICLESYSTEM: string;
  11543. static readonly NAME_GAMEPAD: string;
  11544. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11545. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11546. static readonly NAME_DEPTHRENDERER: string;
  11547. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11548. static readonly NAME_SPRITE: string;
  11549. static readonly NAME_OUTLINERENDERER: string;
  11550. static readonly NAME_PROCEDURALTEXTURE: string;
  11551. static readonly NAME_SHADOWGENERATOR: string;
  11552. static readonly NAME_OCTREE: string;
  11553. static readonly NAME_PHYSICSENGINE: string;
  11554. static readonly NAME_AUDIO: string;
  11555. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11556. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11557. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11558. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11559. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11560. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11561. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11562. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11563. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11564. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11565. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11566. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11567. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11568. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11569. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11570. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11571. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11572. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11573. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11574. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11575. static readonly STEP_AFTERRENDER_AUDIO: number;
  11576. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11577. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11578. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11579. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11580. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11581. static readonly STEP_POINTERMOVE_SPRITE: number;
  11582. static readonly STEP_POINTERDOWN_SPRITE: number;
  11583. static readonly STEP_POINTERUP_SPRITE: number;
  11584. }
  11585. /**
  11586. * This represents a scene component.
  11587. *
  11588. * This is used to decouple the dependency the scene is having on the different workloads like
  11589. * layers, post processes...
  11590. */
  11591. export interface ISceneComponent {
  11592. /**
  11593. * The name of the component. Each component must have a unique name.
  11594. */
  11595. name: string;
  11596. /**
  11597. * The scene the component belongs to.
  11598. */
  11599. scene: Scene;
  11600. /**
  11601. * Register the component to one instance of a scene.
  11602. */
  11603. register(): void;
  11604. /**
  11605. * Rebuilds the elements related to this component in case of
  11606. * context lost for instance.
  11607. */
  11608. rebuild(): void;
  11609. /**
  11610. * Disposes the component and the associated ressources.
  11611. */
  11612. dispose(): void;
  11613. }
  11614. /**
  11615. * This represents a SERIALIZABLE scene component.
  11616. *
  11617. * This extends Scene Component to add Serialization methods on top.
  11618. */
  11619. export interface ISceneSerializableComponent extends ISceneComponent {
  11620. /**
  11621. * Adds all the elements from the container to the scene
  11622. * @param container the container holding the elements
  11623. */
  11624. addFromContainer(container: AbstractScene): void;
  11625. /**
  11626. * Removes all the elements in the container from the scene
  11627. * @param container contains the elements to remove
  11628. * @param dispose if the removed element should be disposed (default: false)
  11629. */
  11630. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11631. /**
  11632. * Serializes the component data to the specified json object
  11633. * @param serializationObject The object to serialize to
  11634. */
  11635. serialize(serializationObject: any): void;
  11636. }
  11637. /**
  11638. * Strong typing of a Mesh related stage step action
  11639. */
  11640. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11641. /**
  11642. * Strong typing of a Evaluate Sub Mesh related stage step action
  11643. */
  11644. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11645. /**
  11646. * Strong typing of a Active Mesh related stage step action
  11647. */
  11648. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11649. /**
  11650. * Strong typing of a Camera related stage step action
  11651. */
  11652. export type CameraStageAction = (camera: Camera) => void;
  11653. /**
  11654. * Strong typing of a Camera Frame buffer related stage step action
  11655. */
  11656. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11657. /**
  11658. * Strong typing of a Render Target related stage step action
  11659. */
  11660. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11661. /**
  11662. * Strong typing of a RenderingGroup related stage step action
  11663. */
  11664. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11665. /**
  11666. * Strong typing of a Mesh Render related stage step action
  11667. */
  11668. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11669. /**
  11670. * Strong typing of a simple stage step action
  11671. */
  11672. export type SimpleStageAction = () => void;
  11673. /**
  11674. * Strong typing of a render target action.
  11675. */
  11676. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11677. /**
  11678. * Strong typing of a pointer move action.
  11679. */
  11680. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11681. /**
  11682. * Strong typing of a pointer up/down action.
  11683. */
  11684. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11685. /**
  11686. * Representation of a stage in the scene (Basically a list of ordered steps)
  11687. * @hidden
  11688. */
  11689. export class Stage<T extends Function> extends Array<{
  11690. index: number;
  11691. component: ISceneComponent;
  11692. action: T;
  11693. }> {
  11694. /**
  11695. * Hide ctor from the rest of the world.
  11696. * @param items The items to add.
  11697. */
  11698. private constructor();
  11699. /**
  11700. * Creates a new Stage.
  11701. * @returns A new instance of a Stage
  11702. */
  11703. static Create<T extends Function>(): Stage<T>;
  11704. /**
  11705. * Registers a step in an ordered way in the targeted stage.
  11706. * @param index Defines the position to register the step in
  11707. * @param component Defines the component attached to the step
  11708. * @param action Defines the action to launch during the step
  11709. */
  11710. registerStep(index: number, component: ISceneComponent, action: T): void;
  11711. /**
  11712. * Clears all the steps from the stage.
  11713. */
  11714. clear(): void;
  11715. }
  11716. }
  11717. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11718. import { Nullable } from "babylonjs/types";
  11719. import { Observable } from "babylonjs/Misc/observable";
  11720. import { Scene } from "babylonjs/scene";
  11721. import { Sprite } from "babylonjs/Sprites/sprite";
  11722. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11723. import { Ray } from "babylonjs/Culling/ray";
  11724. import { Camera } from "babylonjs/Cameras/camera";
  11725. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11726. import { ISceneComponent } from "babylonjs/sceneComponent";
  11727. module "babylonjs/scene" {
  11728. interface Scene {
  11729. /** @hidden */
  11730. _pointerOverSprite: Nullable<Sprite>;
  11731. /** @hidden */
  11732. _pickedDownSprite: Nullable<Sprite>;
  11733. /** @hidden */
  11734. _tempSpritePickingRay: Nullable<Ray>;
  11735. /**
  11736. * All of the sprite managers added to this scene
  11737. * @see http://doc.babylonjs.com/babylon101/sprites
  11738. */
  11739. spriteManagers: Array<ISpriteManager>;
  11740. /**
  11741. * An event triggered when sprites rendering is about to start
  11742. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11743. */
  11744. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11745. /**
  11746. * An event triggered when sprites rendering is done
  11747. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11748. */
  11749. onAfterSpritesRenderingObservable: Observable<Scene>;
  11750. /** @hidden */
  11751. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11752. /** Launch a ray to try to pick a sprite in the scene
  11753. * @param x position on screen
  11754. * @param y position on screen
  11755. * @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
  11756. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11757. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11758. * @returns a PickingInfo
  11759. */
  11760. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11761. /** Use the given ray to pick a sprite in the scene
  11762. * @param ray The ray (in world space) to use to pick meshes
  11763. * @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
  11764. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11765. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11766. * @returns a PickingInfo
  11767. */
  11768. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11769. /** @hidden */
  11770. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11771. /** Launch a ray to try to pick sprites in the scene
  11772. * @param x position on screen
  11773. * @param y position on screen
  11774. * @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
  11775. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11776. * @returns a PickingInfo array
  11777. */
  11778. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11779. /** Use the given ray to pick sprites in the scene
  11780. * @param ray The ray (in world space) to use to pick meshes
  11781. * @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
  11782. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11783. * @returns a PickingInfo array
  11784. */
  11785. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11786. /**
  11787. * Force the sprite under the pointer
  11788. * @param sprite defines the sprite to use
  11789. */
  11790. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11791. /**
  11792. * Gets the sprite under the pointer
  11793. * @returns a Sprite or null if no sprite is under the pointer
  11794. */
  11795. getPointerOverSprite(): Nullable<Sprite>;
  11796. }
  11797. }
  11798. /**
  11799. * Defines the sprite scene component responsible to manage sprites
  11800. * in a given scene.
  11801. */
  11802. export class SpriteSceneComponent implements ISceneComponent {
  11803. /**
  11804. * The component name helpfull to identify the component in the list of scene components.
  11805. */
  11806. readonly name: string;
  11807. /**
  11808. * The scene the component belongs to.
  11809. */
  11810. scene: Scene;
  11811. /** @hidden */
  11812. private _spritePredicate;
  11813. /**
  11814. * Creates a new instance of the component for the given scene
  11815. * @param scene Defines the scene to register the component in
  11816. */
  11817. constructor(scene: Scene);
  11818. /**
  11819. * Registers the component in a given scene
  11820. */
  11821. register(): void;
  11822. /**
  11823. * Rebuilds the elements related to this component in case of
  11824. * context lost for instance.
  11825. */
  11826. rebuild(): void;
  11827. /**
  11828. * Disposes the component and the associated ressources.
  11829. */
  11830. dispose(): void;
  11831. private _pickSpriteButKeepRay;
  11832. private _pointerMove;
  11833. private _pointerDown;
  11834. private _pointerUp;
  11835. }
  11836. }
  11837. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11838. /** @hidden */
  11839. export var fogFragmentDeclaration: {
  11840. name: string;
  11841. shader: string;
  11842. };
  11843. }
  11844. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11845. /** @hidden */
  11846. export var fogFragment: {
  11847. name: string;
  11848. shader: string;
  11849. };
  11850. }
  11851. declare module "babylonjs/Shaders/sprites.fragment" {
  11852. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11853. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11854. /** @hidden */
  11855. export var spritesPixelShader: {
  11856. name: string;
  11857. shader: string;
  11858. };
  11859. }
  11860. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11861. /** @hidden */
  11862. export var fogVertexDeclaration: {
  11863. name: string;
  11864. shader: string;
  11865. };
  11866. }
  11867. declare module "babylonjs/Shaders/sprites.vertex" {
  11868. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11869. /** @hidden */
  11870. export var spritesVertexShader: {
  11871. name: string;
  11872. shader: string;
  11873. };
  11874. }
  11875. declare module "babylonjs/Sprites/spriteManager" {
  11876. import { IDisposable, Scene } from "babylonjs/scene";
  11877. import { Nullable } from "babylonjs/types";
  11878. import { Observable } from "babylonjs/Misc/observable";
  11879. import { Sprite } from "babylonjs/Sprites/sprite";
  11880. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11881. import { Camera } from "babylonjs/Cameras/camera";
  11882. import { Texture } from "babylonjs/Materials/Textures/texture";
  11883. import "babylonjs/Shaders/sprites.fragment";
  11884. import "babylonjs/Shaders/sprites.vertex";
  11885. import { Ray } from "babylonjs/Culling/ray";
  11886. /**
  11887. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11888. */
  11889. export interface ISpriteManager extends IDisposable {
  11890. /**
  11891. * Restricts the camera to viewing objects with the same layerMask.
  11892. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11893. */
  11894. layerMask: number;
  11895. /**
  11896. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11897. */
  11898. isPickable: boolean;
  11899. /**
  11900. * Specifies the rendering group id for this mesh (0 by default)
  11901. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11902. */
  11903. renderingGroupId: number;
  11904. /**
  11905. * Defines the list of sprites managed by the manager.
  11906. */
  11907. sprites: Array<Sprite>;
  11908. /**
  11909. * Tests the intersection of a sprite with a specific ray.
  11910. * @param ray The ray we are sending to test the collision
  11911. * @param camera The camera space we are sending rays in
  11912. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11913. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11914. * @returns picking info or null.
  11915. */
  11916. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11917. /**
  11918. * Intersects the sprites with a ray
  11919. * @param ray defines the ray to intersect with
  11920. * @param camera defines the current active camera
  11921. * @param predicate defines a predicate used to select candidate sprites
  11922. * @returns null if no hit or a PickingInfo array
  11923. */
  11924. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11925. /**
  11926. * Renders the list of sprites on screen.
  11927. */
  11928. render(): void;
  11929. }
  11930. /**
  11931. * Class used to manage multiple sprites on the same spritesheet
  11932. * @see http://doc.babylonjs.com/babylon101/sprites
  11933. */
  11934. export class SpriteManager implements ISpriteManager {
  11935. /** defines the manager's name */
  11936. name: string;
  11937. /** Gets the list of sprites */
  11938. sprites: Sprite[];
  11939. /** Gets or sets the rendering group id (0 by default) */
  11940. renderingGroupId: number;
  11941. /** Gets or sets camera layer mask */
  11942. layerMask: number;
  11943. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11944. fogEnabled: boolean;
  11945. /** Gets or sets a boolean indicating if the sprites are pickable */
  11946. isPickable: boolean;
  11947. /** Defines the default width of a cell in the spritesheet */
  11948. cellWidth: number;
  11949. /** Defines the default height of a cell in the spritesheet */
  11950. cellHeight: number;
  11951. /** Associative array from JSON sprite data file */
  11952. private _cellData;
  11953. /** Array of sprite names from JSON sprite data file */
  11954. private _spriteMap;
  11955. /** True when packed cell data from JSON file is ready*/
  11956. private _packedAndReady;
  11957. /**
  11958. * An event triggered when the manager is disposed.
  11959. */
  11960. onDisposeObservable: Observable<SpriteManager>;
  11961. private _onDisposeObserver;
  11962. /**
  11963. * Callback called when the manager is disposed
  11964. */
  11965. set onDispose(callback: () => void);
  11966. private _capacity;
  11967. private _fromPacked;
  11968. private _spriteTexture;
  11969. private _epsilon;
  11970. private _scene;
  11971. private _vertexData;
  11972. private _buffer;
  11973. private _vertexBuffers;
  11974. private _indexBuffer;
  11975. private _effectBase;
  11976. private _effectFog;
  11977. /**
  11978. * Gets or sets the spritesheet texture
  11979. */
  11980. get texture(): Texture;
  11981. set texture(value: Texture);
  11982. /**
  11983. * Creates a new sprite manager
  11984. * @param name defines the manager's name
  11985. * @param imgUrl defines the sprite sheet url
  11986. * @param capacity defines the maximum allowed number of sprites
  11987. * @param cellSize defines the size of a sprite cell
  11988. * @param scene defines the hosting scene
  11989. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11990. * @param samplingMode defines the smapling mode to use with spritesheet
  11991. * @param fromPacked set to false; do not alter
  11992. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11993. */
  11994. constructor(
  11995. /** defines the manager's name */
  11996. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11997. private _makePacked;
  11998. private _appendSpriteVertex;
  11999. /**
  12000. * Intersects the sprites with a ray
  12001. * @param ray defines the ray to intersect with
  12002. * @param camera defines the current active camera
  12003. * @param predicate defines a predicate used to select candidate sprites
  12004. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12005. * @returns null if no hit or a PickingInfo
  12006. */
  12007. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12008. /**
  12009. * Intersects the sprites with a ray
  12010. * @param ray defines the ray to intersect with
  12011. * @param camera defines the current active camera
  12012. * @param predicate defines a predicate used to select candidate sprites
  12013. * @returns null if no hit or a PickingInfo array
  12014. */
  12015. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  12016. /**
  12017. * Render all child sprites
  12018. */
  12019. render(): void;
  12020. /**
  12021. * Release associated resources
  12022. */
  12023. dispose(): void;
  12024. }
  12025. }
  12026. declare module "babylonjs/Sprites/sprite" {
  12027. import { Vector3 } from "babylonjs/Maths/math.vector";
  12028. import { Nullable } from "babylonjs/types";
  12029. import { ActionManager } from "babylonjs/Actions/actionManager";
  12030. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12031. import { Color4 } from "babylonjs/Maths/math.color";
  12032. /**
  12033. * Class used to represent a sprite
  12034. * @see http://doc.babylonjs.com/babylon101/sprites
  12035. */
  12036. export class Sprite {
  12037. /** defines the name */
  12038. name: string;
  12039. /** Gets or sets the current world position */
  12040. position: Vector3;
  12041. /** Gets or sets the main color */
  12042. color: Color4;
  12043. /** Gets or sets the width */
  12044. width: number;
  12045. /** Gets or sets the height */
  12046. height: number;
  12047. /** Gets or sets rotation angle */
  12048. angle: number;
  12049. /** Gets or sets the cell index in the sprite sheet */
  12050. cellIndex: number;
  12051. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12052. cellRef: string;
  12053. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12054. invertU: number;
  12055. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12056. invertV: number;
  12057. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12058. disposeWhenFinishedAnimating: boolean;
  12059. /** Gets the list of attached animations */
  12060. animations: Animation[];
  12061. /** Gets or sets a boolean indicating if the sprite can be picked */
  12062. isPickable: boolean;
  12063. /**
  12064. * Gets or sets the associated action manager
  12065. */
  12066. actionManager: Nullable<ActionManager>;
  12067. private _animationStarted;
  12068. private _loopAnimation;
  12069. private _fromIndex;
  12070. private _toIndex;
  12071. private _delay;
  12072. private _direction;
  12073. private _manager;
  12074. private _time;
  12075. private _onAnimationEnd;
  12076. /**
  12077. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12078. */
  12079. isVisible: boolean;
  12080. /**
  12081. * Gets or sets the sprite size
  12082. */
  12083. get size(): number;
  12084. set size(value: number);
  12085. /**
  12086. * Creates a new Sprite
  12087. * @param name defines the name
  12088. * @param manager defines the manager
  12089. */
  12090. constructor(
  12091. /** defines the name */
  12092. name: string, manager: ISpriteManager);
  12093. /**
  12094. * Starts an animation
  12095. * @param from defines the initial key
  12096. * @param to defines the end key
  12097. * @param loop defines if the animation must loop
  12098. * @param delay defines the start delay (in ms)
  12099. * @param onAnimationEnd defines a callback to call when animation ends
  12100. */
  12101. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12102. /** Stops current animation (if any) */
  12103. stopAnimation(): void;
  12104. /** @hidden */
  12105. _animate(deltaTime: number): void;
  12106. /** Release associated resources */
  12107. dispose(): void;
  12108. }
  12109. }
  12110. declare module "babylonjs/Collisions/pickingInfo" {
  12111. import { Nullable } from "babylonjs/types";
  12112. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12114. import { Sprite } from "babylonjs/Sprites/sprite";
  12115. import { Ray } from "babylonjs/Culling/ray";
  12116. /**
  12117. * Information about the result of picking within a scene
  12118. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12119. */
  12120. export class PickingInfo {
  12121. /** @hidden */
  12122. _pickingUnavailable: boolean;
  12123. /**
  12124. * If the pick collided with an object
  12125. */
  12126. hit: boolean;
  12127. /**
  12128. * Distance away where the pick collided
  12129. */
  12130. distance: number;
  12131. /**
  12132. * The location of pick collision
  12133. */
  12134. pickedPoint: Nullable<Vector3>;
  12135. /**
  12136. * The mesh corresponding the the pick collision
  12137. */
  12138. pickedMesh: Nullable<AbstractMesh>;
  12139. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12140. bu: number;
  12141. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12142. bv: number;
  12143. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12144. faceId: number;
  12145. /** Id of the the submesh that was picked */
  12146. subMeshId: number;
  12147. /** If a sprite was picked, this will be the sprite the pick collided with */
  12148. pickedSprite: Nullable<Sprite>;
  12149. /**
  12150. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12151. */
  12152. originMesh: Nullable<AbstractMesh>;
  12153. /**
  12154. * The ray that was used to perform the picking.
  12155. */
  12156. ray: Nullable<Ray>;
  12157. /**
  12158. * Gets the normal correspodning to the face the pick collided with
  12159. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12160. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12161. * @returns The normal correspodning to the face the pick collided with
  12162. */
  12163. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12164. /**
  12165. * Gets the texture coordinates of where the pick occured
  12166. * @returns the vector containing the coordnates of the texture
  12167. */
  12168. getTextureCoordinates(): Nullable<Vector2>;
  12169. }
  12170. }
  12171. declare module "babylonjs/Events/pointerEvents" {
  12172. import { Nullable } from "babylonjs/types";
  12173. import { Vector2 } from "babylonjs/Maths/math.vector";
  12174. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12175. import { Ray } from "babylonjs/Culling/ray";
  12176. /**
  12177. * Gather the list of pointer event types as constants.
  12178. */
  12179. export class PointerEventTypes {
  12180. /**
  12181. * 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.
  12182. */
  12183. static readonly POINTERDOWN: number;
  12184. /**
  12185. * The pointerup event is fired when a pointer is no longer active.
  12186. */
  12187. static readonly POINTERUP: number;
  12188. /**
  12189. * The pointermove event is fired when a pointer changes coordinates.
  12190. */
  12191. static readonly POINTERMOVE: number;
  12192. /**
  12193. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12194. */
  12195. static readonly POINTERWHEEL: number;
  12196. /**
  12197. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12198. */
  12199. static readonly POINTERPICK: number;
  12200. /**
  12201. * The pointertap event is fired when a the object has been touched and released without drag.
  12202. */
  12203. static readonly POINTERTAP: number;
  12204. /**
  12205. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12206. */
  12207. static readonly POINTERDOUBLETAP: number;
  12208. }
  12209. /**
  12210. * Base class of pointer info types.
  12211. */
  12212. export class PointerInfoBase {
  12213. /**
  12214. * Defines the type of event (PointerEventTypes)
  12215. */
  12216. type: number;
  12217. /**
  12218. * Defines the related dom event
  12219. */
  12220. event: PointerEvent | MouseWheelEvent;
  12221. /**
  12222. * Instantiates the base class of pointers info.
  12223. * @param type Defines the type of event (PointerEventTypes)
  12224. * @param event Defines the related dom event
  12225. */
  12226. constructor(
  12227. /**
  12228. * Defines the type of event (PointerEventTypes)
  12229. */
  12230. type: number,
  12231. /**
  12232. * Defines the related dom event
  12233. */
  12234. event: PointerEvent | MouseWheelEvent);
  12235. }
  12236. /**
  12237. * This class is used to store pointer related info for the onPrePointerObservable event.
  12238. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12239. */
  12240. export class PointerInfoPre extends PointerInfoBase {
  12241. /**
  12242. * Ray from a pointer if availible (eg. 6dof controller)
  12243. */
  12244. ray: Nullable<Ray>;
  12245. /**
  12246. * Defines the local position of the pointer on the canvas.
  12247. */
  12248. localPosition: Vector2;
  12249. /**
  12250. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12251. */
  12252. skipOnPointerObservable: boolean;
  12253. /**
  12254. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12255. * @param type Defines the type of event (PointerEventTypes)
  12256. * @param event Defines the related dom event
  12257. * @param localX Defines the local x coordinates of the pointer when the event occured
  12258. * @param localY Defines the local y coordinates of the pointer when the event occured
  12259. */
  12260. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12261. }
  12262. /**
  12263. * This type contains all the data related to a pointer event in Babylon.js.
  12264. * 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.
  12265. */
  12266. export class PointerInfo extends PointerInfoBase {
  12267. /**
  12268. * Defines the picking info associated to the info (if any)\
  12269. */
  12270. pickInfo: Nullable<PickingInfo>;
  12271. /**
  12272. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12273. * @param type Defines the type of event (PointerEventTypes)
  12274. * @param event Defines the related dom event
  12275. * @param pickInfo Defines the picking info associated to the info (if any)\
  12276. */
  12277. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12278. /**
  12279. * Defines the picking info associated to the info (if any)\
  12280. */
  12281. pickInfo: Nullable<PickingInfo>);
  12282. }
  12283. /**
  12284. * Data relating to a touch event on the screen.
  12285. */
  12286. export interface PointerTouch {
  12287. /**
  12288. * X coordinate of touch.
  12289. */
  12290. x: number;
  12291. /**
  12292. * Y coordinate of touch.
  12293. */
  12294. y: number;
  12295. /**
  12296. * Id of touch. Unique for each finger.
  12297. */
  12298. pointerId: number;
  12299. /**
  12300. * Event type passed from DOM.
  12301. */
  12302. type: any;
  12303. }
  12304. }
  12305. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12306. import { Observable } from "babylonjs/Misc/observable";
  12307. import { Nullable } from "babylonjs/types";
  12308. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12309. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12310. /**
  12311. * Manage the mouse inputs to control the movement of a free camera.
  12312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12313. */
  12314. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12315. /**
  12316. * Define if touch is enabled in the mouse input
  12317. */
  12318. touchEnabled: boolean;
  12319. /**
  12320. * Defines the camera the input is attached to.
  12321. */
  12322. camera: FreeCamera;
  12323. /**
  12324. * Defines the buttons associated with the input to handle camera move.
  12325. */
  12326. buttons: number[];
  12327. /**
  12328. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12329. */
  12330. angularSensibility: number;
  12331. private _pointerInput;
  12332. private _onMouseMove;
  12333. private _observer;
  12334. private previousPosition;
  12335. /**
  12336. * Observable for when a pointer move event occurs containing the move offset
  12337. */
  12338. onPointerMovedObservable: Observable<{
  12339. offsetX: number;
  12340. offsetY: number;
  12341. }>;
  12342. /**
  12343. * @hidden
  12344. * If the camera should be rotated automatically based on pointer movement
  12345. */
  12346. _allowCameraRotation: boolean;
  12347. /**
  12348. * Manage the mouse inputs to control the movement of a free camera.
  12349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12350. * @param touchEnabled Defines if touch is enabled or not
  12351. */
  12352. constructor(
  12353. /**
  12354. * Define if touch is enabled in the mouse input
  12355. */
  12356. touchEnabled?: boolean);
  12357. /**
  12358. * Attach the input controls to a specific dom element to get the input from.
  12359. * @param element Defines the element the controls should be listened from
  12360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12361. */
  12362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12363. /**
  12364. * Called on JS contextmenu event.
  12365. * Override this method to provide functionality.
  12366. */
  12367. protected onContextMenu(evt: PointerEvent): void;
  12368. /**
  12369. * Detach the current controls from the specified dom element.
  12370. * @param element Defines the element to stop listening the inputs from
  12371. */
  12372. detachControl(element: Nullable<HTMLElement>): void;
  12373. /**
  12374. * Gets the class name of the current intput.
  12375. * @returns the class name
  12376. */
  12377. getClassName(): string;
  12378. /**
  12379. * Get the friendly name associated with the input class.
  12380. * @returns the input friendly name
  12381. */
  12382. getSimpleName(): string;
  12383. }
  12384. }
  12385. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12386. import { Nullable } from "babylonjs/types";
  12387. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12388. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12389. /**
  12390. * Manage the touch inputs to control the movement of a free camera.
  12391. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12392. */
  12393. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12394. /**
  12395. * Defines the camera the input is attached to.
  12396. */
  12397. camera: FreeCamera;
  12398. /**
  12399. * Defines the touch sensibility for rotation.
  12400. * The higher the faster.
  12401. */
  12402. touchAngularSensibility: number;
  12403. /**
  12404. * Defines the touch sensibility for move.
  12405. * The higher the faster.
  12406. */
  12407. touchMoveSensibility: number;
  12408. private _offsetX;
  12409. private _offsetY;
  12410. private _pointerPressed;
  12411. private _pointerInput;
  12412. private _observer;
  12413. private _onLostFocus;
  12414. /**
  12415. * Attach the input controls to a specific dom element to get the input from.
  12416. * @param element Defines the element the controls should be listened from
  12417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12418. */
  12419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12420. /**
  12421. * Detach the current controls from the specified dom element.
  12422. * @param element Defines the element to stop listening the inputs from
  12423. */
  12424. detachControl(element: Nullable<HTMLElement>): void;
  12425. /**
  12426. * Update the current camera state depending on the inputs that have been used this frame.
  12427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12428. */
  12429. checkInputs(): void;
  12430. /**
  12431. * Gets the class name of the current intput.
  12432. * @returns the class name
  12433. */
  12434. getClassName(): string;
  12435. /**
  12436. * Get the friendly name associated with the input class.
  12437. * @returns the input friendly name
  12438. */
  12439. getSimpleName(): string;
  12440. }
  12441. }
  12442. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12443. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12444. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12445. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12446. import { Nullable } from "babylonjs/types";
  12447. /**
  12448. * Default Inputs manager for the FreeCamera.
  12449. * It groups all the default supported inputs for ease of use.
  12450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12451. */
  12452. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12453. /**
  12454. * @hidden
  12455. */
  12456. _mouseInput: Nullable<FreeCameraMouseInput>;
  12457. /**
  12458. * Instantiates a new FreeCameraInputsManager.
  12459. * @param camera Defines the camera the inputs belong to
  12460. */
  12461. constructor(camera: FreeCamera);
  12462. /**
  12463. * Add keyboard input support to the input manager.
  12464. * @returns the current input manager
  12465. */
  12466. addKeyboard(): FreeCameraInputsManager;
  12467. /**
  12468. * Add mouse input support to the input manager.
  12469. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12470. * @returns the current input manager
  12471. */
  12472. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12473. /**
  12474. * Removes the mouse input support from the manager
  12475. * @returns the current input manager
  12476. */
  12477. removeMouse(): FreeCameraInputsManager;
  12478. /**
  12479. * Add touch input support to the input manager.
  12480. * @returns the current input manager
  12481. */
  12482. addTouch(): FreeCameraInputsManager;
  12483. /**
  12484. * Remove all attached input methods from a camera
  12485. */
  12486. clear(): void;
  12487. }
  12488. }
  12489. declare module "babylonjs/Cameras/freeCamera" {
  12490. import { Vector3 } from "babylonjs/Maths/math.vector";
  12491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12492. import { Scene } from "babylonjs/scene";
  12493. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12494. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12495. /**
  12496. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12497. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12499. */
  12500. export class FreeCamera extends TargetCamera {
  12501. /**
  12502. * Define the collision ellipsoid of the camera.
  12503. * This is helpful to simulate a camera body like the player body around the camera
  12504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12505. */
  12506. ellipsoid: Vector3;
  12507. /**
  12508. * Define an offset for the position of the ellipsoid around the camera.
  12509. * This can be helpful to determine the center of the body near the gravity center of the body
  12510. * instead of its head.
  12511. */
  12512. ellipsoidOffset: Vector3;
  12513. /**
  12514. * Enable or disable collisions of the camera with the rest of the scene objects.
  12515. */
  12516. checkCollisions: boolean;
  12517. /**
  12518. * Enable or disable gravity on the camera.
  12519. */
  12520. applyGravity: boolean;
  12521. /**
  12522. * Define the input manager associated to the camera.
  12523. */
  12524. inputs: FreeCameraInputsManager;
  12525. /**
  12526. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12527. * Higher values reduce sensitivity.
  12528. */
  12529. get angularSensibility(): number;
  12530. /**
  12531. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12532. * Higher values reduce sensitivity.
  12533. */
  12534. set angularSensibility(value: number);
  12535. /**
  12536. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12537. */
  12538. get keysUp(): number[];
  12539. set keysUp(value: number[]);
  12540. /**
  12541. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12542. */
  12543. get keysDown(): number[];
  12544. set keysDown(value: number[]);
  12545. /**
  12546. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12547. */
  12548. get keysLeft(): number[];
  12549. set keysLeft(value: number[]);
  12550. /**
  12551. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12552. */
  12553. get keysRight(): number[];
  12554. set keysRight(value: number[]);
  12555. /**
  12556. * Event raised when the camera collide with a mesh in the scene.
  12557. */
  12558. onCollide: (collidedMesh: AbstractMesh) => void;
  12559. private _collider;
  12560. private _needMoveForGravity;
  12561. private _oldPosition;
  12562. private _diffPosition;
  12563. private _newPosition;
  12564. /** @hidden */
  12565. _localDirection: Vector3;
  12566. /** @hidden */
  12567. _transformedDirection: Vector3;
  12568. /**
  12569. * Instantiates a Free Camera.
  12570. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12571. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12572. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12573. * @param name Define the name of the camera in the scene
  12574. * @param position Define the start position of the camera in the scene
  12575. * @param scene Define the scene the camera belongs to
  12576. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12577. */
  12578. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12579. /**
  12580. * Attached controls to the current camera.
  12581. * @param element Defines the element the controls should be listened from
  12582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12583. */
  12584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12585. /**
  12586. * Detach the current controls from the camera.
  12587. * The camera will stop reacting to inputs.
  12588. * @param element Defines the element to stop listening the inputs from
  12589. */
  12590. detachControl(element: HTMLElement): void;
  12591. private _collisionMask;
  12592. /**
  12593. * Define a collision mask to limit the list of object the camera can collide with
  12594. */
  12595. get collisionMask(): number;
  12596. set collisionMask(mask: number);
  12597. /** @hidden */
  12598. _collideWithWorld(displacement: Vector3): void;
  12599. private _onCollisionPositionChange;
  12600. /** @hidden */
  12601. _checkInputs(): void;
  12602. /** @hidden */
  12603. _decideIfNeedsToMove(): boolean;
  12604. /** @hidden */
  12605. _updatePosition(): void;
  12606. /**
  12607. * Destroy the camera and release the current resources hold by it.
  12608. */
  12609. dispose(): void;
  12610. /**
  12611. * Gets the current object class name.
  12612. * @return the class name
  12613. */
  12614. getClassName(): string;
  12615. }
  12616. }
  12617. declare module "babylonjs/Gamepads/gamepad" {
  12618. import { Observable } from "babylonjs/Misc/observable";
  12619. /**
  12620. * Represents a gamepad control stick position
  12621. */
  12622. export class StickValues {
  12623. /**
  12624. * The x component of the control stick
  12625. */
  12626. x: number;
  12627. /**
  12628. * The y component of the control stick
  12629. */
  12630. y: number;
  12631. /**
  12632. * Initializes the gamepad x and y control stick values
  12633. * @param x The x component of the gamepad control stick value
  12634. * @param y The y component of the gamepad control stick value
  12635. */
  12636. constructor(
  12637. /**
  12638. * The x component of the control stick
  12639. */
  12640. x: number,
  12641. /**
  12642. * The y component of the control stick
  12643. */
  12644. y: number);
  12645. }
  12646. /**
  12647. * An interface which manages callbacks for gamepad button changes
  12648. */
  12649. export interface GamepadButtonChanges {
  12650. /**
  12651. * Called when a gamepad has been changed
  12652. */
  12653. changed: boolean;
  12654. /**
  12655. * Called when a gamepad press event has been triggered
  12656. */
  12657. pressChanged: boolean;
  12658. /**
  12659. * Called when a touch event has been triggered
  12660. */
  12661. touchChanged: boolean;
  12662. /**
  12663. * Called when a value has changed
  12664. */
  12665. valueChanged: boolean;
  12666. }
  12667. /**
  12668. * Represents a gamepad
  12669. */
  12670. export class Gamepad {
  12671. /**
  12672. * The id of the gamepad
  12673. */
  12674. id: string;
  12675. /**
  12676. * The index of the gamepad
  12677. */
  12678. index: number;
  12679. /**
  12680. * The browser gamepad
  12681. */
  12682. browserGamepad: any;
  12683. /**
  12684. * Specifies what type of gamepad this represents
  12685. */
  12686. type: number;
  12687. private _leftStick;
  12688. private _rightStick;
  12689. /** @hidden */
  12690. _isConnected: boolean;
  12691. private _leftStickAxisX;
  12692. private _leftStickAxisY;
  12693. private _rightStickAxisX;
  12694. private _rightStickAxisY;
  12695. /**
  12696. * Triggered when the left control stick has been changed
  12697. */
  12698. private _onleftstickchanged;
  12699. /**
  12700. * Triggered when the right control stick has been changed
  12701. */
  12702. private _onrightstickchanged;
  12703. /**
  12704. * Represents a gamepad controller
  12705. */
  12706. static GAMEPAD: number;
  12707. /**
  12708. * Represents a generic controller
  12709. */
  12710. static GENERIC: number;
  12711. /**
  12712. * Represents an XBox controller
  12713. */
  12714. static XBOX: number;
  12715. /**
  12716. * Represents a pose-enabled controller
  12717. */
  12718. static POSE_ENABLED: number;
  12719. /**
  12720. * Represents an Dual Shock controller
  12721. */
  12722. static DUALSHOCK: number;
  12723. /**
  12724. * Specifies whether the left control stick should be Y-inverted
  12725. */
  12726. protected _invertLeftStickY: boolean;
  12727. /**
  12728. * Specifies if the gamepad has been connected
  12729. */
  12730. get isConnected(): boolean;
  12731. /**
  12732. * Initializes the gamepad
  12733. * @param id The id of the gamepad
  12734. * @param index The index of the gamepad
  12735. * @param browserGamepad The browser gamepad
  12736. * @param leftStickX The x component of the left joystick
  12737. * @param leftStickY The y component of the left joystick
  12738. * @param rightStickX The x component of the right joystick
  12739. * @param rightStickY The y component of the right joystick
  12740. */
  12741. constructor(
  12742. /**
  12743. * The id of the gamepad
  12744. */
  12745. id: string,
  12746. /**
  12747. * The index of the gamepad
  12748. */
  12749. index: number,
  12750. /**
  12751. * The browser gamepad
  12752. */
  12753. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12754. /**
  12755. * Callback triggered when the left joystick has changed
  12756. * @param callback
  12757. */
  12758. onleftstickchanged(callback: (values: StickValues) => void): void;
  12759. /**
  12760. * Callback triggered when the right joystick has changed
  12761. * @param callback
  12762. */
  12763. onrightstickchanged(callback: (values: StickValues) => void): void;
  12764. /**
  12765. * Gets the left joystick
  12766. */
  12767. get leftStick(): StickValues;
  12768. /**
  12769. * Sets the left joystick values
  12770. */
  12771. set leftStick(newValues: StickValues);
  12772. /**
  12773. * Gets the right joystick
  12774. */
  12775. get rightStick(): StickValues;
  12776. /**
  12777. * Sets the right joystick value
  12778. */
  12779. set rightStick(newValues: StickValues);
  12780. /**
  12781. * Updates the gamepad joystick positions
  12782. */
  12783. update(): void;
  12784. /**
  12785. * Disposes the gamepad
  12786. */
  12787. dispose(): void;
  12788. }
  12789. /**
  12790. * Represents a generic gamepad
  12791. */
  12792. export class GenericPad extends Gamepad {
  12793. private _buttons;
  12794. private _onbuttondown;
  12795. private _onbuttonup;
  12796. /**
  12797. * Observable triggered when a button has been pressed
  12798. */
  12799. onButtonDownObservable: Observable<number>;
  12800. /**
  12801. * Observable triggered when a button has been released
  12802. */
  12803. onButtonUpObservable: Observable<number>;
  12804. /**
  12805. * Callback triggered when a button has been pressed
  12806. * @param callback Called when a button has been pressed
  12807. */
  12808. onbuttondown(callback: (buttonPressed: number) => void): void;
  12809. /**
  12810. * Callback triggered when a button has been released
  12811. * @param callback Called when a button has been released
  12812. */
  12813. onbuttonup(callback: (buttonReleased: number) => void): void;
  12814. /**
  12815. * Initializes the generic gamepad
  12816. * @param id The id of the generic gamepad
  12817. * @param index The index of the generic gamepad
  12818. * @param browserGamepad The browser gamepad
  12819. */
  12820. constructor(id: string, index: number, browserGamepad: any);
  12821. private _setButtonValue;
  12822. /**
  12823. * Updates the generic gamepad
  12824. */
  12825. update(): void;
  12826. /**
  12827. * Disposes the generic gamepad
  12828. */
  12829. dispose(): void;
  12830. }
  12831. }
  12832. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12833. import { Nullable } from "babylonjs/types";
  12834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12835. import { Scene } from "babylonjs/scene";
  12836. module "babylonjs/Engines/engine" {
  12837. interface Engine {
  12838. /**
  12839. * Creates a raw texture
  12840. * @param data defines the data to store in the texture
  12841. * @param width defines the width of the texture
  12842. * @param height defines the height of the texture
  12843. * @param format defines the format of the data
  12844. * @param generateMipMaps defines if the engine should generate the mip levels
  12845. * @param invertY defines if data must be stored with Y axis inverted
  12846. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12847. * @param compression defines the compression used (null by default)
  12848. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12849. * @returns the raw texture inside an InternalTexture
  12850. */
  12851. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12852. /**
  12853. * Update a raw texture
  12854. * @param texture defines the texture to update
  12855. * @param data defines the data to store in the texture
  12856. * @param format defines the format of the data
  12857. * @param invertY defines if data must be stored with Y axis inverted
  12858. */
  12859. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12860. /**
  12861. * Update a raw texture
  12862. * @param texture defines the texture to update
  12863. * @param data defines the data to store in the texture
  12864. * @param format defines the format of the data
  12865. * @param invertY defines if data must be stored with Y axis inverted
  12866. * @param compression defines the compression used (null by default)
  12867. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12868. */
  12869. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12870. /**
  12871. * Creates a new raw cube texture
  12872. * @param data defines the array of data to use to create each face
  12873. * @param size defines the size of the textures
  12874. * @param format defines the format of the data
  12875. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12876. * @param generateMipMaps defines if the engine should generate the mip levels
  12877. * @param invertY defines if data must be stored with Y axis inverted
  12878. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12879. * @param compression defines the compression used (null by default)
  12880. * @returns the cube texture as an InternalTexture
  12881. */
  12882. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12883. /**
  12884. * Update a raw cube texture
  12885. * @param texture defines the texture to udpdate
  12886. * @param data defines the data to store
  12887. * @param format defines the data format
  12888. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12889. * @param invertY defines if data must be stored with Y axis inverted
  12890. */
  12891. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12892. /**
  12893. * Update a raw cube texture
  12894. * @param texture defines the texture to udpdate
  12895. * @param data defines the data to store
  12896. * @param format defines the data format
  12897. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12898. * @param invertY defines if data must be stored with Y axis inverted
  12899. * @param compression defines the compression used (null by default)
  12900. */
  12901. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12902. /**
  12903. * Update a raw cube texture
  12904. * @param texture defines the texture to udpdate
  12905. * @param data defines the data to store
  12906. * @param format defines the data format
  12907. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12908. * @param invertY defines if data must be stored with Y axis inverted
  12909. * @param compression defines the compression used (null by default)
  12910. * @param level defines which level of the texture to update
  12911. */
  12912. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12913. /**
  12914. * Creates a new raw cube texture from a specified url
  12915. * @param url defines the url where the data is located
  12916. * @param scene defines the current scene
  12917. * @param size defines the size of the textures
  12918. * @param format defines the format of the data
  12919. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12920. * @param noMipmap defines if the engine should avoid generating the mip levels
  12921. * @param callback defines a callback used to extract texture data from loaded data
  12922. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12923. * @param onLoad defines a callback called when texture is loaded
  12924. * @param onError defines a callback called if there is an error
  12925. * @returns the cube texture as an InternalTexture
  12926. */
  12927. 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;
  12928. /**
  12929. * Creates a new raw cube texture from a specified url
  12930. * @param url defines the url where the data is located
  12931. * @param scene defines the current scene
  12932. * @param size defines the size of the textures
  12933. * @param format defines the format of the data
  12934. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12935. * @param noMipmap defines if the engine should avoid generating the mip levels
  12936. * @param callback defines a callback used to extract texture data from loaded data
  12937. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12938. * @param onLoad defines a callback called when texture is loaded
  12939. * @param onError defines a callback called if there is an error
  12940. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12941. * @param invertY defines if data must be stored with Y axis inverted
  12942. * @returns the cube texture as an InternalTexture
  12943. */
  12944. 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;
  12945. /**
  12946. * Creates a new raw 3D texture
  12947. * @param data defines the data used to create the texture
  12948. * @param width defines the width of the texture
  12949. * @param height defines the height of the texture
  12950. * @param depth defines the depth of the texture
  12951. * @param format defines the format of the texture
  12952. * @param generateMipMaps defines if the engine must generate mip levels
  12953. * @param invertY defines if data must be stored with Y axis inverted
  12954. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12955. * @param compression defines the compressed used (can be null)
  12956. * @param textureType defines the compressed used (can be null)
  12957. * @returns a new raw 3D texture (stored in an InternalTexture)
  12958. */
  12959. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12960. /**
  12961. * Update a raw 3D texture
  12962. * @param texture defines the texture to update
  12963. * @param data defines the data to store
  12964. * @param format defines the data format
  12965. * @param invertY defines if data must be stored with Y axis inverted
  12966. */
  12967. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12968. /**
  12969. * Update a raw 3D texture
  12970. * @param texture defines the texture to update
  12971. * @param data defines the data to store
  12972. * @param format defines the data format
  12973. * @param invertY defines if data must be stored with Y axis inverted
  12974. * @param compression defines the used compression (can be null)
  12975. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12976. */
  12977. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12978. /**
  12979. * Creates a new raw 2D array texture
  12980. * @param data defines the data used to create the texture
  12981. * @param width defines the width of the texture
  12982. * @param height defines the height of the texture
  12983. * @param depth defines the number of layers of the texture
  12984. * @param format defines the format of the texture
  12985. * @param generateMipMaps defines if the engine must generate mip levels
  12986. * @param invertY defines if data must be stored with Y axis inverted
  12987. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12988. * @param compression defines the compressed used (can be null)
  12989. * @param textureType defines the compressed used (can be null)
  12990. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12991. */
  12992. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12993. /**
  12994. * Update a raw 2D array texture
  12995. * @param texture defines the texture to update
  12996. * @param data defines the data to store
  12997. * @param format defines the data format
  12998. * @param invertY defines if data must be stored with Y axis inverted
  12999. */
  13000. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13001. /**
  13002. * Update a raw 2D array texture
  13003. * @param texture defines the texture to update
  13004. * @param data defines the data to store
  13005. * @param format defines the data format
  13006. * @param invertY defines if data must be stored with Y axis inverted
  13007. * @param compression defines the used compression (can be null)
  13008. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13009. */
  13010. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13011. }
  13012. }
  13013. }
  13014. declare module "babylonjs/Materials/Textures/rawTexture" {
  13015. import { Scene } from "babylonjs/scene";
  13016. import { Texture } from "babylonjs/Materials/Textures/texture";
  13017. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13018. /**
  13019. * Raw texture can help creating a texture directly from an array of data.
  13020. * This can be super useful if you either get the data from an uncompressed source or
  13021. * if you wish to create your texture pixel by pixel.
  13022. */
  13023. export class RawTexture extends Texture {
  13024. /**
  13025. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13026. */
  13027. format: number;
  13028. private _engine;
  13029. /**
  13030. * Instantiates a new RawTexture.
  13031. * Raw texture can help creating a texture directly from an array of data.
  13032. * This can be super useful if you either get the data from an uncompressed source or
  13033. * if you wish to create your texture pixel by pixel.
  13034. * @param data define the array of data to use to create the texture
  13035. * @param width define the width of the texture
  13036. * @param height define the height of the texture
  13037. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13038. * @param scene define the scene the texture belongs to
  13039. * @param generateMipMaps define whether mip maps should be generated or not
  13040. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13041. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13042. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13043. */
  13044. constructor(data: ArrayBufferView, width: number, height: number,
  13045. /**
  13046. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13047. */
  13048. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13049. /**
  13050. * Updates the texture underlying data.
  13051. * @param data Define the new data of the texture
  13052. */
  13053. update(data: ArrayBufferView): void;
  13054. /**
  13055. * Creates a luminance texture from some data.
  13056. * @param data Define the texture data
  13057. * @param width Define the width of the texture
  13058. * @param height Define the height of the texture
  13059. * @param scene Define the scene the texture belongs to
  13060. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13061. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13062. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13063. * @returns the luminance texture
  13064. */
  13065. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13066. /**
  13067. * Creates a luminance alpha texture from some data.
  13068. * @param data Define the texture data
  13069. * @param width Define the width of the texture
  13070. * @param height Define the height of the texture
  13071. * @param scene Define the scene the texture belongs to
  13072. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13073. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13074. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13075. * @returns the luminance alpha texture
  13076. */
  13077. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13078. /**
  13079. * Creates an alpha texture from some data.
  13080. * @param data Define the texture data
  13081. * @param width Define the width of the texture
  13082. * @param height Define the height of the texture
  13083. * @param scene Define the scene the texture belongs to
  13084. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13085. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13086. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13087. * @returns the alpha texture
  13088. */
  13089. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13090. /**
  13091. * Creates a RGB texture from some data.
  13092. * @param data Define the texture data
  13093. * @param width Define the width of the texture
  13094. * @param height Define the height of the texture
  13095. * @param scene Define the scene the texture belongs to
  13096. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13097. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13098. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13099. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13100. * @returns the RGB alpha texture
  13101. */
  13102. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13103. /**
  13104. * Creates a RGBA texture from some data.
  13105. * @param data Define the texture data
  13106. * @param width Define the width of the texture
  13107. * @param height Define the height of the texture
  13108. * @param scene Define the scene the texture belongs to
  13109. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13110. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13111. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13112. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13113. * @returns the RGBA texture
  13114. */
  13115. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13116. /**
  13117. * Creates a R texture from some data.
  13118. * @param data Define the texture data
  13119. * @param width Define the width of the texture
  13120. * @param height Define the height of the texture
  13121. * @param scene Define the scene the texture belongs to
  13122. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13123. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13124. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13125. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13126. * @returns the R texture
  13127. */
  13128. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13129. }
  13130. }
  13131. declare module "babylonjs/Maths/math.size" {
  13132. /**
  13133. * Interface for the size containing width and height
  13134. */
  13135. export interface ISize {
  13136. /**
  13137. * Width
  13138. */
  13139. width: number;
  13140. /**
  13141. * Heighht
  13142. */
  13143. height: number;
  13144. }
  13145. /**
  13146. * Size containing widht and height
  13147. */
  13148. export class Size implements ISize {
  13149. /**
  13150. * Width
  13151. */
  13152. width: number;
  13153. /**
  13154. * Height
  13155. */
  13156. height: number;
  13157. /**
  13158. * Creates a Size object from the given width and height (floats).
  13159. * @param width width of the new size
  13160. * @param height height of the new size
  13161. */
  13162. constructor(width: number, height: number);
  13163. /**
  13164. * Returns a string with the Size width and height
  13165. * @returns a string with the Size width and height
  13166. */
  13167. toString(): string;
  13168. /**
  13169. * "Size"
  13170. * @returns the string "Size"
  13171. */
  13172. getClassName(): string;
  13173. /**
  13174. * Returns the Size hash code.
  13175. * @returns a hash code for a unique width and height
  13176. */
  13177. getHashCode(): number;
  13178. /**
  13179. * Updates the current size from the given one.
  13180. * @param src the given size
  13181. */
  13182. copyFrom(src: Size): void;
  13183. /**
  13184. * Updates in place the current Size from the given floats.
  13185. * @param width width of the new size
  13186. * @param height height of the new size
  13187. * @returns the updated Size.
  13188. */
  13189. copyFromFloats(width: number, height: number): Size;
  13190. /**
  13191. * Updates in place the current Size from the given floats.
  13192. * @param width width to set
  13193. * @param height height to set
  13194. * @returns the updated Size.
  13195. */
  13196. set(width: number, height: number): Size;
  13197. /**
  13198. * Multiplies the width and height by numbers
  13199. * @param w factor to multiple the width by
  13200. * @param h factor to multiple the height by
  13201. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13202. */
  13203. multiplyByFloats(w: number, h: number): Size;
  13204. /**
  13205. * Clones the size
  13206. * @returns a new Size copied from the given one.
  13207. */
  13208. clone(): Size;
  13209. /**
  13210. * True if the current Size and the given one width and height are strictly equal.
  13211. * @param other the other size to compare against
  13212. * @returns True if the current Size and the given one width and height are strictly equal.
  13213. */
  13214. equals(other: Size): boolean;
  13215. /**
  13216. * The surface of the Size : width * height (float).
  13217. */
  13218. get surface(): number;
  13219. /**
  13220. * Create a new size of zero
  13221. * @returns a new Size set to (0.0, 0.0)
  13222. */
  13223. static Zero(): Size;
  13224. /**
  13225. * Sums the width and height of two sizes
  13226. * @param otherSize size to add to this size
  13227. * @returns a new Size set as the addition result of the current Size and the given one.
  13228. */
  13229. add(otherSize: Size): Size;
  13230. /**
  13231. * Subtracts the width and height of two
  13232. * @param otherSize size to subtract to this size
  13233. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13234. */
  13235. subtract(otherSize: Size): Size;
  13236. /**
  13237. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13238. * @param start starting size to lerp between
  13239. * @param end end size to lerp between
  13240. * @param amount amount to lerp between the start and end values
  13241. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13242. */
  13243. static Lerp(start: Size, end: Size, amount: number): Size;
  13244. }
  13245. }
  13246. declare module "babylonjs/Animations/runtimeAnimation" {
  13247. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13248. import { Animatable } from "babylonjs/Animations/animatable";
  13249. import { Scene } from "babylonjs/scene";
  13250. /**
  13251. * Defines a runtime animation
  13252. */
  13253. export class RuntimeAnimation {
  13254. private _events;
  13255. /**
  13256. * The current frame of the runtime animation
  13257. */
  13258. private _currentFrame;
  13259. /**
  13260. * The animation used by the runtime animation
  13261. */
  13262. private _animation;
  13263. /**
  13264. * The target of the runtime animation
  13265. */
  13266. private _target;
  13267. /**
  13268. * The initiating animatable
  13269. */
  13270. private _host;
  13271. /**
  13272. * The original value of the runtime animation
  13273. */
  13274. private _originalValue;
  13275. /**
  13276. * The original blend value of the runtime animation
  13277. */
  13278. private _originalBlendValue;
  13279. /**
  13280. * The offsets cache of the runtime animation
  13281. */
  13282. private _offsetsCache;
  13283. /**
  13284. * The high limits cache of the runtime animation
  13285. */
  13286. private _highLimitsCache;
  13287. /**
  13288. * Specifies if the runtime animation has been stopped
  13289. */
  13290. private _stopped;
  13291. /**
  13292. * The blending factor of the runtime animation
  13293. */
  13294. private _blendingFactor;
  13295. /**
  13296. * The BabylonJS scene
  13297. */
  13298. private _scene;
  13299. /**
  13300. * The current value of the runtime animation
  13301. */
  13302. private _currentValue;
  13303. /** @hidden */
  13304. _animationState: _IAnimationState;
  13305. /**
  13306. * The active target of the runtime animation
  13307. */
  13308. private _activeTargets;
  13309. private _currentActiveTarget;
  13310. private _directTarget;
  13311. /**
  13312. * The target path of the runtime animation
  13313. */
  13314. private _targetPath;
  13315. /**
  13316. * The weight of the runtime animation
  13317. */
  13318. private _weight;
  13319. /**
  13320. * The ratio offset of the runtime animation
  13321. */
  13322. private _ratioOffset;
  13323. /**
  13324. * The previous delay of the runtime animation
  13325. */
  13326. private _previousDelay;
  13327. /**
  13328. * The previous ratio of the runtime animation
  13329. */
  13330. private _previousRatio;
  13331. private _enableBlending;
  13332. private _keys;
  13333. private _minFrame;
  13334. private _maxFrame;
  13335. private _minValue;
  13336. private _maxValue;
  13337. private _targetIsArray;
  13338. /**
  13339. * Gets the current frame of the runtime animation
  13340. */
  13341. get currentFrame(): number;
  13342. /**
  13343. * Gets the weight of the runtime animation
  13344. */
  13345. get weight(): number;
  13346. /**
  13347. * Gets the current value of the runtime animation
  13348. */
  13349. get currentValue(): any;
  13350. /**
  13351. * Gets the target path of the runtime animation
  13352. */
  13353. get targetPath(): string;
  13354. /**
  13355. * Gets the actual target of the runtime animation
  13356. */
  13357. get target(): any;
  13358. /** @hidden */
  13359. _onLoop: () => void;
  13360. /**
  13361. * Create a new RuntimeAnimation object
  13362. * @param target defines the target of the animation
  13363. * @param animation defines the source animation object
  13364. * @param scene defines the hosting scene
  13365. * @param host defines the initiating Animatable
  13366. */
  13367. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13368. private _preparePath;
  13369. /**
  13370. * Gets the animation from the runtime animation
  13371. */
  13372. get animation(): Animation;
  13373. /**
  13374. * Resets the runtime animation to the beginning
  13375. * @param restoreOriginal defines whether to restore the target property to the original value
  13376. */
  13377. reset(restoreOriginal?: boolean): void;
  13378. /**
  13379. * Specifies if the runtime animation is stopped
  13380. * @returns Boolean specifying if the runtime animation is stopped
  13381. */
  13382. isStopped(): boolean;
  13383. /**
  13384. * Disposes of the runtime animation
  13385. */
  13386. dispose(): void;
  13387. /**
  13388. * Apply the interpolated value to the target
  13389. * @param currentValue defines the value computed by the animation
  13390. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13391. */
  13392. setValue(currentValue: any, weight: number): void;
  13393. private _getOriginalValues;
  13394. private _setValue;
  13395. /**
  13396. * Gets the loop pmode of the runtime animation
  13397. * @returns Loop Mode
  13398. */
  13399. private _getCorrectLoopMode;
  13400. /**
  13401. * Move the current animation to a given frame
  13402. * @param frame defines the frame to move to
  13403. */
  13404. goToFrame(frame: number): void;
  13405. /**
  13406. * @hidden Internal use only
  13407. */
  13408. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13409. /**
  13410. * Execute the current animation
  13411. * @param delay defines the delay to add to the current frame
  13412. * @param from defines the lower bound of the animation range
  13413. * @param to defines the upper bound of the animation range
  13414. * @param loop defines if the current animation must loop
  13415. * @param speedRatio defines the current speed ratio
  13416. * @param weight defines the weight of the animation (default is -1 so no weight)
  13417. * @param onLoop optional callback called when animation loops
  13418. * @returns a boolean indicating if the animation is running
  13419. */
  13420. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13421. }
  13422. }
  13423. declare module "babylonjs/Animations/animatable" {
  13424. import { Animation } from "babylonjs/Animations/animation";
  13425. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13426. import { Nullable } from "babylonjs/types";
  13427. import { Observable } from "babylonjs/Misc/observable";
  13428. import { Scene } from "babylonjs/scene";
  13429. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13430. import { Node } from "babylonjs/node";
  13431. /**
  13432. * Class used to store an actual running animation
  13433. */
  13434. export class Animatable {
  13435. /** defines the target object */
  13436. target: any;
  13437. /** defines the starting frame number (default is 0) */
  13438. fromFrame: number;
  13439. /** defines the ending frame number (default is 100) */
  13440. toFrame: number;
  13441. /** defines if the animation must loop (default is false) */
  13442. loopAnimation: boolean;
  13443. /** defines a callback to call when animation ends if it is not looping */
  13444. onAnimationEnd?: (() => void) | null | undefined;
  13445. /** defines a callback to call when animation loops */
  13446. onAnimationLoop?: (() => void) | null | undefined;
  13447. private _localDelayOffset;
  13448. private _pausedDelay;
  13449. private _runtimeAnimations;
  13450. private _paused;
  13451. private _scene;
  13452. private _speedRatio;
  13453. private _weight;
  13454. private _syncRoot;
  13455. /**
  13456. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13457. * This will only apply for non looping animation (default is true)
  13458. */
  13459. disposeOnEnd: boolean;
  13460. /**
  13461. * Gets a boolean indicating if the animation has started
  13462. */
  13463. animationStarted: boolean;
  13464. /**
  13465. * Observer raised when the animation ends
  13466. */
  13467. onAnimationEndObservable: Observable<Animatable>;
  13468. /**
  13469. * Observer raised when the animation loops
  13470. */
  13471. onAnimationLoopObservable: Observable<Animatable>;
  13472. /**
  13473. * Gets the root Animatable used to synchronize and normalize animations
  13474. */
  13475. get syncRoot(): Nullable<Animatable>;
  13476. /**
  13477. * Gets the current frame of the first RuntimeAnimation
  13478. * Used to synchronize Animatables
  13479. */
  13480. get masterFrame(): number;
  13481. /**
  13482. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13483. */
  13484. get weight(): number;
  13485. set weight(value: number);
  13486. /**
  13487. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13488. */
  13489. get speedRatio(): number;
  13490. set speedRatio(value: number);
  13491. /**
  13492. * Creates a new Animatable
  13493. * @param scene defines the hosting scene
  13494. * @param target defines the target object
  13495. * @param fromFrame defines the starting frame number (default is 0)
  13496. * @param toFrame defines the ending frame number (default is 100)
  13497. * @param loopAnimation defines if the animation must loop (default is false)
  13498. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13499. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13500. * @param animations defines a group of animation to add to the new Animatable
  13501. * @param onAnimationLoop defines a callback to call when animation loops
  13502. */
  13503. constructor(scene: Scene,
  13504. /** defines the target object */
  13505. target: any,
  13506. /** defines the starting frame number (default is 0) */
  13507. fromFrame?: number,
  13508. /** defines the ending frame number (default is 100) */
  13509. toFrame?: number,
  13510. /** defines if the animation must loop (default is false) */
  13511. loopAnimation?: boolean, speedRatio?: number,
  13512. /** defines a callback to call when animation ends if it is not looping */
  13513. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13514. /** defines a callback to call when animation loops */
  13515. onAnimationLoop?: (() => void) | null | undefined);
  13516. /**
  13517. * Synchronize and normalize current Animatable with a source Animatable
  13518. * This is useful when using animation weights and when animations are not of the same length
  13519. * @param root defines the root Animatable to synchronize with
  13520. * @returns the current Animatable
  13521. */
  13522. syncWith(root: Animatable): Animatable;
  13523. /**
  13524. * Gets the list of runtime animations
  13525. * @returns an array of RuntimeAnimation
  13526. */
  13527. getAnimations(): RuntimeAnimation[];
  13528. /**
  13529. * Adds more animations to the current animatable
  13530. * @param target defines the target of the animations
  13531. * @param animations defines the new animations to add
  13532. */
  13533. appendAnimations(target: any, animations: Animation[]): void;
  13534. /**
  13535. * Gets the source animation for a specific property
  13536. * @param property defines the propertyu to look for
  13537. * @returns null or the source animation for the given property
  13538. */
  13539. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13540. /**
  13541. * Gets the runtime animation for a specific property
  13542. * @param property defines the propertyu to look for
  13543. * @returns null or the runtime animation for the given property
  13544. */
  13545. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13546. /**
  13547. * Resets the animatable to its original state
  13548. */
  13549. reset(): void;
  13550. /**
  13551. * Allows the animatable to blend with current running animations
  13552. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13553. * @param blendingSpeed defines the blending speed to use
  13554. */
  13555. enableBlending(blendingSpeed: number): void;
  13556. /**
  13557. * Disable animation blending
  13558. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13559. */
  13560. disableBlending(): void;
  13561. /**
  13562. * Jump directly to a given frame
  13563. * @param frame defines the frame to jump to
  13564. */
  13565. goToFrame(frame: number): void;
  13566. /**
  13567. * Pause the animation
  13568. */
  13569. pause(): void;
  13570. /**
  13571. * Restart the animation
  13572. */
  13573. restart(): void;
  13574. private _raiseOnAnimationEnd;
  13575. /**
  13576. * Stop and delete the current animation
  13577. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13578. * @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)
  13579. */
  13580. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13581. /**
  13582. * Wait asynchronously for the animation to end
  13583. * @returns a promise which will be fullfilled when the animation ends
  13584. */
  13585. waitAsync(): Promise<Animatable>;
  13586. /** @hidden */
  13587. _animate(delay: number): boolean;
  13588. }
  13589. module "babylonjs/scene" {
  13590. interface Scene {
  13591. /** @hidden */
  13592. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13593. /** @hidden */
  13594. _processLateAnimationBindingsForMatrices(holder: {
  13595. totalWeight: number;
  13596. animations: RuntimeAnimation[];
  13597. originalValue: Matrix;
  13598. }): any;
  13599. /** @hidden */
  13600. _processLateAnimationBindingsForQuaternions(holder: {
  13601. totalWeight: number;
  13602. animations: RuntimeAnimation[];
  13603. originalValue: Quaternion;
  13604. }, refQuaternion: Quaternion): Quaternion;
  13605. /** @hidden */
  13606. _processLateAnimationBindings(): void;
  13607. /**
  13608. * Will start the animation sequence of a given target
  13609. * @param target defines the target
  13610. * @param from defines from which frame should animation start
  13611. * @param to defines until which frame should animation run.
  13612. * @param weight defines the weight to apply to the animation (1.0 by default)
  13613. * @param loop defines if the animation loops
  13614. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13615. * @param onAnimationEnd defines the function to be executed when the animation ends
  13616. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13617. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13618. * @param onAnimationLoop defines the callback to call when an animation loops
  13619. * @returns the animatable object created for this animation
  13620. */
  13621. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13622. /**
  13623. * Will start the animation sequence of a given target
  13624. * @param target defines the target
  13625. * @param from defines from which frame should animation start
  13626. * @param to defines until which frame should animation run.
  13627. * @param loop defines if the animation loops
  13628. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13629. * @param onAnimationEnd defines the function to be executed when the animation ends
  13630. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13631. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13632. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13633. * @param onAnimationLoop defines the callback to call when an animation loops
  13634. * @returns the animatable object created for this animation
  13635. */
  13636. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13637. /**
  13638. * Will start the animation sequence of a given target and its hierarchy
  13639. * @param target defines the target
  13640. * @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.
  13641. * @param from defines from which frame should animation start
  13642. * @param to defines until which frame should animation run.
  13643. * @param loop defines if the animation loops
  13644. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13645. * @param onAnimationEnd defines the function to be executed when the animation ends
  13646. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13647. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13648. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13649. * @param onAnimationLoop defines the callback to call when an animation loops
  13650. * @returns the list of created animatables
  13651. */
  13652. 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[];
  13653. /**
  13654. * Begin a new animation on a given node
  13655. * @param target defines the target where the animation will take place
  13656. * @param animations defines the list of animations to start
  13657. * @param from defines the initial value
  13658. * @param to defines the final value
  13659. * @param loop defines if you want animation to loop (off by default)
  13660. * @param speedRatio defines the speed ratio to apply to all animations
  13661. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13662. * @param onAnimationLoop defines the callback to call when an animation loops
  13663. * @returns the list of created animatables
  13664. */
  13665. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13666. /**
  13667. * Begin a new animation on a given node and its hierarchy
  13668. * @param target defines the root node where the animation will take place
  13669. * @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.
  13670. * @param animations defines the list of animations to start
  13671. * @param from defines the initial value
  13672. * @param to defines the final value
  13673. * @param loop defines if you want animation to loop (off by default)
  13674. * @param speedRatio defines the speed ratio to apply to all animations
  13675. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13676. * @param onAnimationLoop defines the callback to call when an animation loops
  13677. * @returns the list of animatables created for all nodes
  13678. */
  13679. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13680. /**
  13681. * Gets the animatable associated with a specific target
  13682. * @param target defines the target of the animatable
  13683. * @returns the required animatable if found
  13684. */
  13685. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13686. /**
  13687. * Gets all animatables associated with a given target
  13688. * @param target defines the target to look animatables for
  13689. * @returns an array of Animatables
  13690. */
  13691. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13692. /**
  13693. * Stops and removes all animations that have been applied to the scene
  13694. */
  13695. stopAllAnimations(): void;
  13696. /**
  13697. * Gets the current delta time used by animation engine
  13698. */
  13699. deltaTime: number;
  13700. }
  13701. }
  13702. module "babylonjs/Bones/bone" {
  13703. interface Bone {
  13704. /**
  13705. * Copy an animation range from another bone
  13706. * @param source defines the source bone
  13707. * @param rangeName defines the range name to copy
  13708. * @param frameOffset defines the frame offset
  13709. * @param rescaleAsRequired defines if rescaling must be applied if required
  13710. * @param skelDimensionsRatio defines the scaling ratio
  13711. * @returns true if operation was successful
  13712. */
  13713. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13714. }
  13715. }
  13716. }
  13717. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13718. /**
  13719. * Class used to override all child animations of a given target
  13720. */
  13721. export class AnimationPropertiesOverride {
  13722. /**
  13723. * Gets or sets a value indicating if animation blending must be used
  13724. */
  13725. enableBlending: boolean;
  13726. /**
  13727. * Gets or sets the blending speed to use when enableBlending is true
  13728. */
  13729. blendingSpeed: number;
  13730. /**
  13731. * Gets or sets the default loop mode to use
  13732. */
  13733. loopMode: number;
  13734. }
  13735. }
  13736. declare module "babylonjs/Bones/skeleton" {
  13737. import { Bone } from "babylonjs/Bones/bone";
  13738. import { Observable } from "babylonjs/Misc/observable";
  13739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13740. import { Scene } from "babylonjs/scene";
  13741. import { Nullable } from "babylonjs/types";
  13742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13743. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13744. import { Animatable } from "babylonjs/Animations/animatable";
  13745. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13746. import { Animation } from "babylonjs/Animations/animation";
  13747. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13748. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13749. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13750. /**
  13751. * Class used to handle skinning animations
  13752. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13753. */
  13754. export class Skeleton implements IAnimatable {
  13755. /** defines the skeleton name */
  13756. name: string;
  13757. /** defines the skeleton Id */
  13758. id: string;
  13759. /**
  13760. * Defines the list of child bones
  13761. */
  13762. bones: Bone[];
  13763. /**
  13764. * Defines an estimate of the dimension of the skeleton at rest
  13765. */
  13766. dimensionsAtRest: Vector3;
  13767. /**
  13768. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13769. */
  13770. needInitialSkinMatrix: boolean;
  13771. /**
  13772. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13773. */
  13774. overrideMesh: Nullable<AbstractMesh>;
  13775. /**
  13776. * Gets the list of animations attached to this skeleton
  13777. */
  13778. animations: Array<Animation>;
  13779. private _scene;
  13780. private _isDirty;
  13781. private _transformMatrices;
  13782. private _transformMatrixTexture;
  13783. private _meshesWithPoseMatrix;
  13784. private _animatables;
  13785. private _identity;
  13786. private _synchronizedWithMesh;
  13787. private _ranges;
  13788. private _lastAbsoluteTransformsUpdateId;
  13789. private _canUseTextureForBones;
  13790. private _uniqueId;
  13791. /** @hidden */
  13792. _numBonesWithLinkedTransformNode: number;
  13793. /** @hidden */
  13794. _hasWaitingData: Nullable<boolean>;
  13795. /**
  13796. * Specifies if the skeleton should be serialized
  13797. */
  13798. doNotSerialize: boolean;
  13799. private _useTextureToStoreBoneMatrices;
  13800. /**
  13801. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13802. * Please note that this option is not available if the hardware does not support it
  13803. */
  13804. get useTextureToStoreBoneMatrices(): boolean;
  13805. set useTextureToStoreBoneMatrices(value: boolean);
  13806. private _animationPropertiesOverride;
  13807. /**
  13808. * Gets or sets the animation properties override
  13809. */
  13810. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13811. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13812. /**
  13813. * List of inspectable custom properties (used by the Inspector)
  13814. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13815. */
  13816. inspectableCustomProperties: IInspectable[];
  13817. /**
  13818. * An observable triggered before computing the skeleton's matrices
  13819. */
  13820. onBeforeComputeObservable: Observable<Skeleton>;
  13821. /**
  13822. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13823. */
  13824. get isUsingTextureForMatrices(): boolean;
  13825. /**
  13826. * Gets the unique ID of this skeleton
  13827. */
  13828. get uniqueId(): number;
  13829. /**
  13830. * Creates a new skeleton
  13831. * @param name defines the skeleton name
  13832. * @param id defines the skeleton Id
  13833. * @param scene defines the hosting scene
  13834. */
  13835. constructor(
  13836. /** defines the skeleton name */
  13837. name: string,
  13838. /** defines the skeleton Id */
  13839. id: string, scene: Scene);
  13840. /**
  13841. * Gets the current object class name.
  13842. * @return the class name
  13843. */
  13844. getClassName(): string;
  13845. /**
  13846. * Returns an array containing the root bones
  13847. * @returns an array containing the root bones
  13848. */
  13849. getChildren(): Array<Bone>;
  13850. /**
  13851. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13852. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13853. * @returns a Float32Array containing matrices data
  13854. */
  13855. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13856. /**
  13857. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13858. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13859. * @returns a raw texture containing the data
  13860. */
  13861. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13862. /**
  13863. * Gets the current hosting scene
  13864. * @returns a scene object
  13865. */
  13866. getScene(): Scene;
  13867. /**
  13868. * Gets a string representing the current skeleton data
  13869. * @param fullDetails defines a boolean indicating if we want a verbose version
  13870. * @returns a string representing the current skeleton data
  13871. */
  13872. toString(fullDetails?: boolean): string;
  13873. /**
  13874. * Get bone's index searching by name
  13875. * @param name defines bone's name to search for
  13876. * @return the indice of the bone. Returns -1 if not found
  13877. */
  13878. getBoneIndexByName(name: string): number;
  13879. /**
  13880. * Creater a new animation range
  13881. * @param name defines the name of the range
  13882. * @param from defines the start key
  13883. * @param to defines the end key
  13884. */
  13885. createAnimationRange(name: string, from: number, to: number): void;
  13886. /**
  13887. * Delete a specific animation range
  13888. * @param name defines the name of the range
  13889. * @param deleteFrames defines if frames must be removed as well
  13890. */
  13891. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13892. /**
  13893. * Gets a specific animation range
  13894. * @param name defines the name of the range to look for
  13895. * @returns the requested animation range or null if not found
  13896. */
  13897. getAnimationRange(name: string): Nullable<AnimationRange>;
  13898. /**
  13899. * Gets the list of all animation ranges defined on this skeleton
  13900. * @returns an array
  13901. */
  13902. getAnimationRanges(): Nullable<AnimationRange>[];
  13903. /**
  13904. * Copy animation range from a source skeleton.
  13905. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13906. * @param source defines the source skeleton
  13907. * @param name defines the name of the range to copy
  13908. * @param rescaleAsRequired defines if rescaling must be applied if required
  13909. * @returns true if operation was successful
  13910. */
  13911. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13912. /**
  13913. * Forces the skeleton to go to rest pose
  13914. */
  13915. returnToRest(): void;
  13916. private _getHighestAnimationFrame;
  13917. /**
  13918. * Begin a specific animation range
  13919. * @param name defines the name of the range to start
  13920. * @param loop defines if looping must be turned on (false by default)
  13921. * @param speedRatio defines the speed ratio to apply (1 by default)
  13922. * @param onAnimationEnd defines a callback which will be called when animation will end
  13923. * @returns a new animatable
  13924. */
  13925. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13926. /** @hidden */
  13927. _markAsDirty(): void;
  13928. /** @hidden */
  13929. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13930. /** @hidden */
  13931. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13932. private _computeTransformMatrices;
  13933. /**
  13934. * Build all resources required to render a skeleton
  13935. */
  13936. prepare(): void;
  13937. /**
  13938. * Gets the list of animatables currently running for this skeleton
  13939. * @returns an array of animatables
  13940. */
  13941. getAnimatables(): IAnimatable[];
  13942. /**
  13943. * Clone the current skeleton
  13944. * @param name defines the name of the new skeleton
  13945. * @param id defines the id of the new skeleton
  13946. * @returns the new skeleton
  13947. */
  13948. clone(name: string, id?: string): Skeleton;
  13949. /**
  13950. * Enable animation blending for this skeleton
  13951. * @param blendingSpeed defines the blending speed to apply
  13952. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13953. */
  13954. enableBlending(blendingSpeed?: number): void;
  13955. /**
  13956. * Releases all resources associated with the current skeleton
  13957. */
  13958. dispose(): void;
  13959. /**
  13960. * Serialize the skeleton in a JSON object
  13961. * @returns a JSON object
  13962. */
  13963. serialize(): any;
  13964. /**
  13965. * Creates a new skeleton from serialized data
  13966. * @param parsedSkeleton defines the serialized data
  13967. * @param scene defines the hosting scene
  13968. * @returns a new skeleton
  13969. */
  13970. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13971. /**
  13972. * Compute all node absolute transforms
  13973. * @param forceUpdate defines if computation must be done even if cache is up to date
  13974. */
  13975. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13976. /**
  13977. * Gets the root pose matrix
  13978. * @returns a matrix
  13979. */
  13980. getPoseMatrix(): Nullable<Matrix>;
  13981. /**
  13982. * Sorts bones per internal index
  13983. */
  13984. sortBones(): void;
  13985. private _sortBones;
  13986. }
  13987. }
  13988. declare module "babylonjs/Bones/bone" {
  13989. import { Skeleton } from "babylonjs/Bones/skeleton";
  13990. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13991. import { Nullable } from "babylonjs/types";
  13992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13993. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13994. import { Node } from "babylonjs/node";
  13995. import { Space } from "babylonjs/Maths/math.axis";
  13996. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13997. /**
  13998. * Class used to store bone information
  13999. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14000. */
  14001. export class Bone extends Node {
  14002. /**
  14003. * defines the bone name
  14004. */
  14005. name: string;
  14006. private static _tmpVecs;
  14007. private static _tmpQuat;
  14008. private static _tmpMats;
  14009. /**
  14010. * Gets the list of child bones
  14011. */
  14012. children: Bone[];
  14013. /** Gets the animations associated with this bone */
  14014. animations: import("babylonjs/Animations/animation").Animation[];
  14015. /**
  14016. * Gets or sets bone length
  14017. */
  14018. length: number;
  14019. /**
  14020. * @hidden Internal only
  14021. * Set this value to map this bone to a different index in the transform matrices
  14022. * Set this value to -1 to exclude the bone from the transform matrices
  14023. */
  14024. _index: Nullable<number>;
  14025. private _skeleton;
  14026. private _localMatrix;
  14027. private _restPose;
  14028. private _baseMatrix;
  14029. private _absoluteTransform;
  14030. private _invertedAbsoluteTransform;
  14031. private _parent;
  14032. private _scalingDeterminant;
  14033. private _worldTransform;
  14034. private _localScaling;
  14035. private _localRotation;
  14036. private _localPosition;
  14037. private _needToDecompose;
  14038. private _needToCompose;
  14039. /** @hidden */
  14040. _linkedTransformNode: Nullable<TransformNode>;
  14041. /** @hidden */
  14042. _waitingTransformNodeId: Nullable<string>;
  14043. /** @hidden */
  14044. get _matrix(): Matrix;
  14045. /** @hidden */
  14046. set _matrix(value: Matrix);
  14047. /**
  14048. * Create a new bone
  14049. * @param name defines the bone name
  14050. * @param skeleton defines the parent skeleton
  14051. * @param parentBone defines the parent (can be null if the bone is the root)
  14052. * @param localMatrix defines the local matrix
  14053. * @param restPose defines the rest pose matrix
  14054. * @param baseMatrix defines the base matrix
  14055. * @param index defines index of the bone in the hiearchy
  14056. */
  14057. constructor(
  14058. /**
  14059. * defines the bone name
  14060. */
  14061. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14062. /**
  14063. * Gets the current object class name.
  14064. * @return the class name
  14065. */
  14066. getClassName(): string;
  14067. /**
  14068. * Gets the parent skeleton
  14069. * @returns a skeleton
  14070. */
  14071. getSkeleton(): Skeleton;
  14072. /**
  14073. * Gets parent bone
  14074. * @returns a bone or null if the bone is the root of the bone hierarchy
  14075. */
  14076. getParent(): Nullable<Bone>;
  14077. /**
  14078. * Returns an array containing the root bones
  14079. * @returns an array containing the root bones
  14080. */
  14081. getChildren(): Array<Bone>;
  14082. /**
  14083. * Gets the node index in matrix array generated for rendering
  14084. * @returns the node index
  14085. */
  14086. getIndex(): number;
  14087. /**
  14088. * Sets the parent bone
  14089. * @param parent defines the parent (can be null if the bone is the root)
  14090. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14091. */
  14092. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14093. /**
  14094. * Gets the local matrix
  14095. * @returns a matrix
  14096. */
  14097. getLocalMatrix(): Matrix;
  14098. /**
  14099. * Gets the base matrix (initial matrix which remains unchanged)
  14100. * @returns a matrix
  14101. */
  14102. getBaseMatrix(): Matrix;
  14103. /**
  14104. * Gets the rest pose matrix
  14105. * @returns a matrix
  14106. */
  14107. getRestPose(): Matrix;
  14108. /**
  14109. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14110. */
  14111. getWorldMatrix(): Matrix;
  14112. /**
  14113. * Sets the local matrix to rest pose matrix
  14114. */
  14115. returnToRest(): void;
  14116. /**
  14117. * Gets the inverse of the absolute transform matrix.
  14118. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14119. * @returns a matrix
  14120. */
  14121. getInvertedAbsoluteTransform(): Matrix;
  14122. /**
  14123. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14124. * @returns a matrix
  14125. */
  14126. getAbsoluteTransform(): Matrix;
  14127. /**
  14128. * Links with the given transform node.
  14129. * The local matrix of this bone is copied from the transform node every frame.
  14130. * @param transformNode defines the transform node to link to
  14131. */
  14132. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14133. /**
  14134. * Gets the node used to drive the bone's transformation
  14135. * @returns a transform node or null
  14136. */
  14137. getTransformNode(): Nullable<TransformNode>;
  14138. /** Gets or sets current position (in local space) */
  14139. get position(): Vector3;
  14140. set position(newPosition: Vector3);
  14141. /** Gets or sets current rotation (in local space) */
  14142. get rotation(): Vector3;
  14143. set rotation(newRotation: Vector3);
  14144. /** Gets or sets current rotation quaternion (in local space) */
  14145. get rotationQuaternion(): Quaternion;
  14146. set rotationQuaternion(newRotation: Quaternion);
  14147. /** Gets or sets current scaling (in local space) */
  14148. get scaling(): Vector3;
  14149. set scaling(newScaling: Vector3);
  14150. /**
  14151. * Gets the animation properties override
  14152. */
  14153. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14154. private _decompose;
  14155. private _compose;
  14156. /**
  14157. * Update the base and local matrices
  14158. * @param matrix defines the new base or local matrix
  14159. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14160. * @param updateLocalMatrix defines if the local matrix should be updated
  14161. */
  14162. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14163. /** @hidden */
  14164. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14165. /**
  14166. * Flag the bone as dirty (Forcing it to update everything)
  14167. */
  14168. markAsDirty(): void;
  14169. /** @hidden */
  14170. _markAsDirtyAndCompose(): void;
  14171. private _markAsDirtyAndDecompose;
  14172. /**
  14173. * Translate the bone in local or world space
  14174. * @param vec The amount to translate the bone
  14175. * @param space The space that the translation is in
  14176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14177. */
  14178. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14179. /**
  14180. * Set the postion of the bone in local or world space
  14181. * @param position The position to set the bone
  14182. * @param space The space that the position is in
  14183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14184. */
  14185. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14186. /**
  14187. * Set the absolute position of the bone (world space)
  14188. * @param position The position to set the bone
  14189. * @param mesh The mesh that this bone is attached to
  14190. */
  14191. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14192. /**
  14193. * Scale the bone on the x, y and z axes (in local space)
  14194. * @param x The amount to scale the bone on the x axis
  14195. * @param y The amount to scale the bone on the y axis
  14196. * @param z The amount to scale the bone on the z axis
  14197. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14198. */
  14199. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14200. /**
  14201. * Set the bone scaling in local space
  14202. * @param scale defines the scaling vector
  14203. */
  14204. setScale(scale: Vector3): void;
  14205. /**
  14206. * Gets the current scaling in local space
  14207. * @returns the current scaling vector
  14208. */
  14209. getScale(): Vector3;
  14210. /**
  14211. * Gets the current scaling in local space and stores it in a target vector
  14212. * @param result defines the target vector
  14213. */
  14214. getScaleToRef(result: Vector3): void;
  14215. /**
  14216. * Set the yaw, pitch, and roll of the bone in local or world space
  14217. * @param yaw The rotation of the bone on the y axis
  14218. * @param pitch The rotation of the bone on the x axis
  14219. * @param roll The rotation of the bone on the z axis
  14220. * @param space The space that the axes of rotation are in
  14221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14222. */
  14223. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14224. /**
  14225. * Add a rotation to the bone on an axis in local or world space
  14226. * @param axis The axis to rotate the bone on
  14227. * @param amount The amount to rotate the bone
  14228. * @param space The space that the axis is in
  14229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14230. */
  14231. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14232. /**
  14233. * Set the rotation of the bone to a particular axis angle in local or world space
  14234. * @param axis The axis to rotate the bone on
  14235. * @param angle The angle that the bone should be rotated to
  14236. * @param space The space that the axis is in
  14237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14238. */
  14239. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14240. /**
  14241. * Set the euler rotation of the bone in local of world space
  14242. * @param rotation The euler rotation that the bone should be set to
  14243. * @param space The space that the rotation is in
  14244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14245. */
  14246. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14247. /**
  14248. * Set the quaternion rotation of the bone in local of world space
  14249. * @param quat The quaternion rotation that the bone should be set to
  14250. * @param space The space that the rotation is in
  14251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14252. */
  14253. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14254. /**
  14255. * Set the rotation matrix of the bone in local of world space
  14256. * @param rotMat The rotation matrix that the bone should be set to
  14257. * @param space The space that the rotation is in
  14258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14259. */
  14260. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14261. private _rotateWithMatrix;
  14262. private _getNegativeRotationToRef;
  14263. /**
  14264. * Get the position of the bone in local or world space
  14265. * @param space The space that the returned position is in
  14266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14267. * @returns The position of the bone
  14268. */
  14269. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14270. /**
  14271. * Copy the position of the bone to a vector3 in local or world space
  14272. * @param space The space that the returned position is in
  14273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14274. * @param result The vector3 to copy the position to
  14275. */
  14276. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14277. /**
  14278. * Get the absolute position of the bone (world space)
  14279. * @param mesh The mesh that this bone is attached to
  14280. * @returns The absolute position of the bone
  14281. */
  14282. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14283. /**
  14284. * Copy the absolute position of the bone (world space) to the result param
  14285. * @param mesh The mesh that this bone is attached to
  14286. * @param result The vector3 to copy the absolute position to
  14287. */
  14288. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14289. /**
  14290. * Compute the absolute transforms of this bone and its children
  14291. */
  14292. computeAbsoluteTransforms(): void;
  14293. /**
  14294. * Get the world direction from an axis that is in the local space of the bone
  14295. * @param localAxis The local direction that is used to compute the world direction
  14296. * @param mesh The mesh that this bone is attached to
  14297. * @returns The world direction
  14298. */
  14299. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14300. /**
  14301. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14302. * @param localAxis The local direction that is used to compute the world direction
  14303. * @param mesh The mesh that this bone is attached to
  14304. * @param result The vector3 that the world direction will be copied to
  14305. */
  14306. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14307. /**
  14308. * Get the euler rotation of the bone in local or world space
  14309. * @param space The space that the rotation should be in
  14310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14311. * @returns The euler rotation
  14312. */
  14313. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14314. /**
  14315. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14316. * @param space The space that the rotation should be in
  14317. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14318. * @param result The vector3 that the rotation should be copied to
  14319. */
  14320. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14321. /**
  14322. * Get the quaternion rotation of the bone in either local or world space
  14323. * @param space The space that the rotation should be in
  14324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14325. * @returns The quaternion rotation
  14326. */
  14327. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14328. /**
  14329. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14330. * @param space The space that the rotation should be in
  14331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14332. * @param result The quaternion that the rotation should be copied to
  14333. */
  14334. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14335. /**
  14336. * Get the rotation matrix of the bone in local or world space
  14337. * @param space The space that the rotation should be in
  14338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14339. * @returns The rotation matrix
  14340. */
  14341. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14342. /**
  14343. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14344. * @param space The space that the rotation should be in
  14345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14346. * @param result The quaternion that the rotation should be copied to
  14347. */
  14348. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14349. /**
  14350. * Get the world position of a point that is in the local space of the bone
  14351. * @param position The local position
  14352. * @param mesh The mesh that this bone is attached to
  14353. * @returns The world position
  14354. */
  14355. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14356. /**
  14357. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14358. * @param position The local position
  14359. * @param mesh The mesh that this bone is attached to
  14360. * @param result The vector3 that the world position should be copied to
  14361. */
  14362. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14363. /**
  14364. * Get the local position of a point that is in world space
  14365. * @param position The world position
  14366. * @param mesh The mesh that this bone is attached to
  14367. * @returns The local position
  14368. */
  14369. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14370. /**
  14371. * Get the local position of a point that is in world space and copy it to the result param
  14372. * @param position The world position
  14373. * @param mesh The mesh that this bone is attached to
  14374. * @param result The vector3 that the local position should be copied to
  14375. */
  14376. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14377. }
  14378. }
  14379. declare module "babylonjs/Meshes/transformNode" {
  14380. import { DeepImmutable } from "babylonjs/types";
  14381. import { Observable } from "babylonjs/Misc/observable";
  14382. import { Nullable } from "babylonjs/types";
  14383. import { Camera } from "babylonjs/Cameras/camera";
  14384. import { Scene } from "babylonjs/scene";
  14385. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14386. import { Node } from "babylonjs/node";
  14387. import { Bone } from "babylonjs/Bones/bone";
  14388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14389. import { Space } from "babylonjs/Maths/math.axis";
  14390. /**
  14391. * 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.
  14392. * @see https://doc.babylonjs.com/how_to/transformnode
  14393. */
  14394. export class TransformNode extends Node {
  14395. /**
  14396. * Object will not rotate to face the camera
  14397. */
  14398. static BILLBOARDMODE_NONE: number;
  14399. /**
  14400. * Object will rotate to face the camera but only on the x axis
  14401. */
  14402. static BILLBOARDMODE_X: number;
  14403. /**
  14404. * Object will rotate to face the camera but only on the y axis
  14405. */
  14406. static BILLBOARDMODE_Y: number;
  14407. /**
  14408. * Object will rotate to face the camera but only on the z axis
  14409. */
  14410. static BILLBOARDMODE_Z: number;
  14411. /**
  14412. * Object will rotate to face the camera
  14413. */
  14414. static BILLBOARDMODE_ALL: number;
  14415. /**
  14416. * Object will rotate to face the camera's position instead of orientation
  14417. */
  14418. static BILLBOARDMODE_USE_POSITION: number;
  14419. private _forward;
  14420. private _forwardInverted;
  14421. private _up;
  14422. private _right;
  14423. private _rightInverted;
  14424. private _position;
  14425. private _rotation;
  14426. private _rotationQuaternion;
  14427. protected _scaling: Vector3;
  14428. protected _isDirty: boolean;
  14429. private _transformToBoneReferal;
  14430. private _isAbsoluteSynced;
  14431. private _billboardMode;
  14432. /**
  14433. * Gets or sets the billboard mode. Default is 0.
  14434. *
  14435. * | Value | Type | Description |
  14436. * | --- | --- | --- |
  14437. * | 0 | BILLBOARDMODE_NONE | |
  14438. * | 1 | BILLBOARDMODE_X | |
  14439. * | 2 | BILLBOARDMODE_Y | |
  14440. * | 4 | BILLBOARDMODE_Z | |
  14441. * | 7 | BILLBOARDMODE_ALL | |
  14442. *
  14443. */
  14444. get billboardMode(): number;
  14445. set billboardMode(value: number);
  14446. private _preserveParentRotationForBillboard;
  14447. /**
  14448. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14449. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14450. */
  14451. get preserveParentRotationForBillboard(): boolean;
  14452. set preserveParentRotationForBillboard(value: boolean);
  14453. /**
  14454. * 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
  14455. */
  14456. scalingDeterminant: number;
  14457. private _infiniteDistance;
  14458. /**
  14459. * Gets or sets the distance of the object to max, often used by skybox
  14460. */
  14461. get infiniteDistance(): boolean;
  14462. set infiniteDistance(value: boolean);
  14463. /**
  14464. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14465. * By default the system will update normals to compensate
  14466. */
  14467. ignoreNonUniformScaling: boolean;
  14468. /**
  14469. * 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
  14470. */
  14471. reIntegrateRotationIntoRotationQuaternion: boolean;
  14472. /** @hidden */
  14473. _poseMatrix: Nullable<Matrix>;
  14474. /** @hidden */
  14475. _localMatrix: Matrix;
  14476. private _usePivotMatrix;
  14477. private _absolutePosition;
  14478. private _absoluteScaling;
  14479. private _absoluteRotationQuaternion;
  14480. private _pivotMatrix;
  14481. private _pivotMatrixInverse;
  14482. protected _postMultiplyPivotMatrix: boolean;
  14483. protected _isWorldMatrixFrozen: boolean;
  14484. /** @hidden */
  14485. _indexInSceneTransformNodesArray: number;
  14486. /**
  14487. * An event triggered after the world matrix is updated
  14488. */
  14489. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14490. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14491. /**
  14492. * Gets a string identifying the name of the class
  14493. * @returns "TransformNode" string
  14494. */
  14495. getClassName(): string;
  14496. /**
  14497. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14498. */
  14499. get position(): Vector3;
  14500. set position(newPosition: Vector3);
  14501. /**
  14502. * 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)).
  14503. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14504. */
  14505. get rotation(): Vector3;
  14506. set rotation(newRotation: Vector3);
  14507. /**
  14508. * 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)).
  14509. */
  14510. get scaling(): Vector3;
  14511. set scaling(newScaling: Vector3);
  14512. /**
  14513. * 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).
  14514. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14515. */
  14516. get rotationQuaternion(): Nullable<Quaternion>;
  14517. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14518. /**
  14519. * The forward direction of that transform in world space.
  14520. */
  14521. get forward(): Vector3;
  14522. /**
  14523. * The up direction of that transform in world space.
  14524. */
  14525. get up(): Vector3;
  14526. /**
  14527. * The right direction of that transform in world space.
  14528. */
  14529. get right(): Vector3;
  14530. /**
  14531. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14532. * @param matrix the matrix to copy the pose from
  14533. * @returns this TransformNode.
  14534. */
  14535. updatePoseMatrix(matrix: Matrix): TransformNode;
  14536. /**
  14537. * Returns the mesh Pose matrix.
  14538. * @returns the pose matrix
  14539. */
  14540. getPoseMatrix(): Matrix;
  14541. /** @hidden */
  14542. _isSynchronized(): boolean;
  14543. /** @hidden */
  14544. _initCache(): void;
  14545. /**
  14546. * Flag the transform node as dirty (Forcing it to update everything)
  14547. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14548. * @returns this transform node
  14549. */
  14550. markAsDirty(property: string): TransformNode;
  14551. /**
  14552. * Returns the current mesh absolute position.
  14553. * Returns a Vector3.
  14554. */
  14555. get absolutePosition(): Vector3;
  14556. /**
  14557. * Returns the current mesh absolute scaling.
  14558. * Returns a Vector3.
  14559. */
  14560. get absoluteScaling(): Vector3;
  14561. /**
  14562. * Returns the current mesh absolute rotation.
  14563. * Returns a Quaternion.
  14564. */
  14565. get absoluteRotationQuaternion(): Quaternion;
  14566. /**
  14567. * Sets a new matrix to apply before all other transformation
  14568. * @param matrix defines the transform matrix
  14569. * @returns the current TransformNode
  14570. */
  14571. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14572. /**
  14573. * Sets a new pivot matrix to the current node
  14574. * @param matrix defines the new pivot matrix to use
  14575. * @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
  14576. * @returns the current TransformNode
  14577. */
  14578. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14579. /**
  14580. * Returns the mesh pivot matrix.
  14581. * Default : Identity.
  14582. * @returns the matrix
  14583. */
  14584. getPivotMatrix(): Matrix;
  14585. /**
  14586. * Instantiate (when possible) or clone that node with its hierarchy
  14587. * @param newParent defines the new parent to use for the instance (or clone)
  14588. * @param options defines options to configure how copy is done
  14589. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14590. * @returns an instance (or a clone) of the current node with its hiearchy
  14591. */
  14592. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14593. doNotInstantiate: boolean;
  14594. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14595. /**
  14596. * Prevents the World matrix to be computed any longer
  14597. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14598. * @returns the TransformNode.
  14599. */
  14600. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14601. /**
  14602. * Allows back the World matrix computation.
  14603. * @returns the TransformNode.
  14604. */
  14605. unfreezeWorldMatrix(): this;
  14606. /**
  14607. * True if the World matrix has been frozen.
  14608. */
  14609. get isWorldMatrixFrozen(): boolean;
  14610. /**
  14611. * Retuns the mesh absolute position in the World.
  14612. * @returns a Vector3.
  14613. */
  14614. getAbsolutePosition(): Vector3;
  14615. /**
  14616. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14617. * @param absolutePosition the absolute position to set
  14618. * @returns the TransformNode.
  14619. */
  14620. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14621. /**
  14622. * Sets the mesh position in its local space.
  14623. * @param vector3 the position to set in localspace
  14624. * @returns the TransformNode.
  14625. */
  14626. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14627. /**
  14628. * Returns the mesh position in the local space from the current World matrix values.
  14629. * @returns a new Vector3.
  14630. */
  14631. getPositionExpressedInLocalSpace(): Vector3;
  14632. /**
  14633. * Translates the mesh along the passed Vector3 in its local space.
  14634. * @param vector3 the distance to translate in localspace
  14635. * @returns the TransformNode.
  14636. */
  14637. locallyTranslate(vector3: Vector3): TransformNode;
  14638. private static _lookAtVectorCache;
  14639. /**
  14640. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14641. * @param targetPoint the position (must be in same space as current mesh) to look at
  14642. * @param yawCor optional yaw (y-axis) correction in radians
  14643. * @param pitchCor optional pitch (x-axis) correction in radians
  14644. * @param rollCor optional roll (z-axis) correction in radians
  14645. * @param space the choosen space of the target
  14646. * @returns the TransformNode.
  14647. */
  14648. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14649. /**
  14650. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14651. * This Vector3 is expressed in the World space.
  14652. * @param localAxis axis to rotate
  14653. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14654. */
  14655. getDirection(localAxis: Vector3): Vector3;
  14656. /**
  14657. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14658. * localAxis is expressed in the mesh local space.
  14659. * result is computed in the Wordl space from the mesh World matrix.
  14660. * @param localAxis axis to rotate
  14661. * @param result the resulting transformnode
  14662. * @returns this TransformNode.
  14663. */
  14664. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14665. /**
  14666. * Sets this transform node rotation to the given local axis.
  14667. * @param localAxis the axis in local space
  14668. * @param yawCor optional yaw (y-axis) correction in radians
  14669. * @param pitchCor optional pitch (x-axis) correction in radians
  14670. * @param rollCor optional roll (z-axis) correction in radians
  14671. * @returns this TransformNode
  14672. */
  14673. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14674. /**
  14675. * Sets a new pivot point to the current node
  14676. * @param point defines the new pivot point to use
  14677. * @param space defines if the point is in world or local space (local by default)
  14678. * @returns the current TransformNode
  14679. */
  14680. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14681. /**
  14682. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14683. * @returns the pivot point
  14684. */
  14685. getPivotPoint(): Vector3;
  14686. /**
  14687. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14688. * @param result the vector3 to store the result
  14689. * @returns this TransformNode.
  14690. */
  14691. getPivotPointToRef(result: Vector3): TransformNode;
  14692. /**
  14693. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14694. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14695. */
  14696. getAbsolutePivotPoint(): Vector3;
  14697. /**
  14698. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14699. * @param result vector3 to store the result
  14700. * @returns this TransformNode.
  14701. */
  14702. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14703. /**
  14704. * Defines the passed node as the parent of the current node.
  14705. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14706. * @see https://doc.babylonjs.com/how_to/parenting
  14707. * @param node the node ot set as the parent
  14708. * @returns this TransformNode.
  14709. */
  14710. setParent(node: Nullable<Node>): TransformNode;
  14711. private _nonUniformScaling;
  14712. /**
  14713. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14714. */
  14715. get nonUniformScaling(): boolean;
  14716. /** @hidden */
  14717. _updateNonUniformScalingState(value: boolean): boolean;
  14718. /**
  14719. * Attach the current TransformNode to another TransformNode associated with a bone
  14720. * @param bone Bone affecting the TransformNode
  14721. * @param affectedTransformNode TransformNode associated with the bone
  14722. * @returns this object
  14723. */
  14724. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14725. /**
  14726. * Detach the transform node if its associated with a bone
  14727. * @returns this object
  14728. */
  14729. detachFromBone(): TransformNode;
  14730. private static _rotationAxisCache;
  14731. /**
  14732. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14733. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14734. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14735. * The passed axis is also normalized.
  14736. * @param axis the axis to rotate around
  14737. * @param amount the amount to rotate in radians
  14738. * @param space Space to rotate in (Default: local)
  14739. * @returns the TransformNode.
  14740. */
  14741. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14742. /**
  14743. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14744. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14745. * The passed axis is also normalized. .
  14746. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14747. * @param point the point to rotate around
  14748. * @param axis the axis to rotate around
  14749. * @param amount the amount to rotate in radians
  14750. * @returns the TransformNode
  14751. */
  14752. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14753. /**
  14754. * Translates the mesh along the axis vector for the passed distance in the given space.
  14755. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14756. * @param axis the axis to translate in
  14757. * @param distance the distance to translate
  14758. * @param space Space to rotate in (Default: local)
  14759. * @returns the TransformNode.
  14760. */
  14761. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14762. /**
  14763. * Adds a rotation step to the mesh current rotation.
  14764. * x, y, z are Euler angles expressed in radians.
  14765. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14766. * This means this rotation is made in the mesh local space only.
  14767. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14768. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14769. * ```javascript
  14770. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14771. * ```
  14772. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14773. * 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.
  14774. * @param x Rotation to add
  14775. * @param y Rotation to add
  14776. * @param z Rotation to add
  14777. * @returns the TransformNode.
  14778. */
  14779. addRotation(x: number, y: number, z: number): TransformNode;
  14780. /**
  14781. * @hidden
  14782. */
  14783. protected _getEffectiveParent(): Nullable<Node>;
  14784. /**
  14785. * Computes the world matrix of the node
  14786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14787. * @returns the world matrix
  14788. */
  14789. computeWorldMatrix(force?: boolean): Matrix;
  14790. protected _afterComputeWorldMatrix(): void;
  14791. /**
  14792. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14793. * @param func callback function to add
  14794. *
  14795. * @returns the TransformNode.
  14796. */
  14797. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14798. /**
  14799. * Removes a registered callback function.
  14800. * @param func callback function to remove
  14801. * @returns the TransformNode.
  14802. */
  14803. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14804. /**
  14805. * Gets the position of the current mesh in camera space
  14806. * @param camera defines the camera to use
  14807. * @returns a position
  14808. */
  14809. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14810. /**
  14811. * Returns the distance from the mesh to the active camera
  14812. * @param camera defines the camera to use
  14813. * @returns the distance
  14814. */
  14815. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14816. /**
  14817. * Clone the current transform node
  14818. * @param name Name of the new clone
  14819. * @param newParent New parent for the clone
  14820. * @param doNotCloneChildren Do not clone children hierarchy
  14821. * @returns the new transform node
  14822. */
  14823. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14824. /**
  14825. * Serializes the objects information.
  14826. * @param currentSerializationObject defines the object to serialize in
  14827. * @returns the serialized object
  14828. */
  14829. serialize(currentSerializationObject?: any): any;
  14830. /**
  14831. * Returns a new TransformNode object parsed from the source provided.
  14832. * @param parsedTransformNode is the source.
  14833. * @param scene the scne the object belongs to
  14834. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14835. * @returns a new TransformNode object parsed from the source provided.
  14836. */
  14837. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14838. /**
  14839. * Get all child-transformNodes of this node
  14840. * @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
  14841. * @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
  14842. * @returns an array of TransformNode
  14843. */
  14844. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14845. /**
  14846. * Releases resources associated with this transform node.
  14847. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14848. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14849. */
  14850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14851. /**
  14852. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14853. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14854. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14855. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14856. * @returns the current mesh
  14857. */
  14858. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14859. private _syncAbsoluteScalingAndRotation;
  14860. }
  14861. }
  14862. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14863. import { Observable } from "babylonjs/Misc/observable";
  14864. import { Nullable } from "babylonjs/types";
  14865. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14866. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14868. import { Ray } from "babylonjs/Culling/ray";
  14869. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14870. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14871. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14872. /**
  14873. * Defines the types of pose enabled controllers that are supported
  14874. */
  14875. export enum PoseEnabledControllerType {
  14876. /**
  14877. * HTC Vive
  14878. */
  14879. VIVE = 0,
  14880. /**
  14881. * Oculus Rift
  14882. */
  14883. OCULUS = 1,
  14884. /**
  14885. * Windows mixed reality
  14886. */
  14887. WINDOWS = 2,
  14888. /**
  14889. * Samsung gear VR
  14890. */
  14891. GEAR_VR = 3,
  14892. /**
  14893. * Google Daydream
  14894. */
  14895. DAYDREAM = 4,
  14896. /**
  14897. * Generic
  14898. */
  14899. GENERIC = 5
  14900. }
  14901. /**
  14902. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14903. */
  14904. export interface MutableGamepadButton {
  14905. /**
  14906. * Value of the button/trigger
  14907. */
  14908. value: number;
  14909. /**
  14910. * If the button/trigger is currently touched
  14911. */
  14912. touched: boolean;
  14913. /**
  14914. * If the button/trigger is currently pressed
  14915. */
  14916. pressed: boolean;
  14917. }
  14918. /**
  14919. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14920. * @hidden
  14921. */
  14922. export interface ExtendedGamepadButton extends GamepadButton {
  14923. /**
  14924. * If the button/trigger is currently pressed
  14925. */
  14926. readonly pressed: boolean;
  14927. /**
  14928. * If the button/trigger is currently touched
  14929. */
  14930. readonly touched: boolean;
  14931. /**
  14932. * Value of the button/trigger
  14933. */
  14934. readonly value: number;
  14935. }
  14936. /** @hidden */
  14937. export interface _GamePadFactory {
  14938. /**
  14939. * Returns wether or not the current gamepad can be created for this type of controller.
  14940. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14941. * @returns true if it can be created, otherwise false
  14942. */
  14943. canCreate(gamepadInfo: any): boolean;
  14944. /**
  14945. * Creates a new instance of the Gamepad.
  14946. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14947. * @returns the new gamepad instance
  14948. */
  14949. create(gamepadInfo: any): Gamepad;
  14950. }
  14951. /**
  14952. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14953. */
  14954. export class PoseEnabledControllerHelper {
  14955. /** @hidden */
  14956. static _ControllerFactories: _GamePadFactory[];
  14957. /** @hidden */
  14958. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14959. /**
  14960. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14961. * @param vrGamepad the gamepad to initialized
  14962. * @returns a vr controller of the type the gamepad identified as
  14963. */
  14964. static InitiateController(vrGamepad: any): Gamepad;
  14965. }
  14966. /**
  14967. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14968. */
  14969. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14970. /**
  14971. * If the controller is used in a webXR session
  14972. */
  14973. isXR: boolean;
  14974. private _deviceRoomPosition;
  14975. private _deviceRoomRotationQuaternion;
  14976. /**
  14977. * The device position in babylon space
  14978. */
  14979. devicePosition: Vector3;
  14980. /**
  14981. * The device rotation in babylon space
  14982. */
  14983. deviceRotationQuaternion: Quaternion;
  14984. /**
  14985. * The scale factor of the device in babylon space
  14986. */
  14987. deviceScaleFactor: number;
  14988. /**
  14989. * (Likely devicePosition should be used instead) The device position in its room space
  14990. */
  14991. position: Vector3;
  14992. /**
  14993. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14994. */
  14995. rotationQuaternion: Quaternion;
  14996. /**
  14997. * The type of controller (Eg. Windows mixed reality)
  14998. */
  14999. controllerType: PoseEnabledControllerType;
  15000. protected _calculatedPosition: Vector3;
  15001. private _calculatedRotation;
  15002. /**
  15003. * The raw pose from the device
  15004. */
  15005. rawPose: DevicePose;
  15006. private _trackPosition;
  15007. private _maxRotationDistFromHeadset;
  15008. private _draggedRoomRotation;
  15009. /**
  15010. * @hidden
  15011. */
  15012. _disableTrackPosition(fixedPosition: Vector3): void;
  15013. /**
  15014. * Internal, the mesh attached to the controller
  15015. * @hidden
  15016. */
  15017. _mesh: Nullable<AbstractMesh>;
  15018. private _poseControlledCamera;
  15019. private _leftHandSystemQuaternion;
  15020. /**
  15021. * Internal, matrix used to convert room space to babylon space
  15022. * @hidden
  15023. */
  15024. _deviceToWorld: Matrix;
  15025. /**
  15026. * Node to be used when casting a ray from the controller
  15027. * @hidden
  15028. */
  15029. _pointingPoseNode: Nullable<TransformNode>;
  15030. /**
  15031. * Name of the child mesh that can be used to cast a ray from the controller
  15032. */
  15033. static readonly POINTING_POSE: string;
  15034. /**
  15035. * Creates a new PoseEnabledController from a gamepad
  15036. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15037. */
  15038. constructor(browserGamepad: any);
  15039. private _workingMatrix;
  15040. /**
  15041. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15042. */
  15043. update(): void;
  15044. /**
  15045. * Updates only the pose device and mesh without doing any button event checking
  15046. */
  15047. protected _updatePoseAndMesh(): void;
  15048. /**
  15049. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15050. * @param poseData raw pose fromthe device
  15051. */
  15052. updateFromDevice(poseData: DevicePose): void;
  15053. /**
  15054. * @hidden
  15055. */
  15056. _meshAttachedObservable: Observable<AbstractMesh>;
  15057. /**
  15058. * Attaches a mesh to the controller
  15059. * @param mesh the mesh to be attached
  15060. */
  15061. attachToMesh(mesh: AbstractMesh): void;
  15062. /**
  15063. * Attaches the controllers mesh to a camera
  15064. * @param camera the camera the mesh should be attached to
  15065. */
  15066. attachToPoseControlledCamera(camera: TargetCamera): void;
  15067. /**
  15068. * Disposes of the controller
  15069. */
  15070. dispose(): void;
  15071. /**
  15072. * The mesh that is attached to the controller
  15073. */
  15074. get mesh(): Nullable<AbstractMesh>;
  15075. /**
  15076. * Gets the ray of the controller in the direction the controller is pointing
  15077. * @param length the length the resulting ray should be
  15078. * @returns a ray in the direction the controller is pointing
  15079. */
  15080. getForwardRay(length?: number): Ray;
  15081. }
  15082. }
  15083. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15084. import { Observable } from "babylonjs/Misc/observable";
  15085. import { Scene } from "babylonjs/scene";
  15086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15087. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15088. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15089. import { Nullable } from "babylonjs/types";
  15090. /**
  15091. * Defines the WebVRController object that represents controllers tracked in 3D space
  15092. */
  15093. export abstract class WebVRController extends PoseEnabledController {
  15094. /**
  15095. * Internal, the default controller model for the controller
  15096. */
  15097. protected _defaultModel: Nullable<AbstractMesh>;
  15098. /**
  15099. * Fired when the trigger state has changed
  15100. */
  15101. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15102. /**
  15103. * Fired when the main button state has changed
  15104. */
  15105. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15106. /**
  15107. * Fired when the secondary button state has changed
  15108. */
  15109. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15110. /**
  15111. * Fired when the pad state has changed
  15112. */
  15113. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15114. /**
  15115. * Fired when controllers stick values have changed
  15116. */
  15117. onPadValuesChangedObservable: Observable<StickValues>;
  15118. /**
  15119. * Array of button availible on the controller
  15120. */
  15121. protected _buttons: Array<MutableGamepadButton>;
  15122. private _onButtonStateChange;
  15123. /**
  15124. * Fired when a controller button's state has changed
  15125. * @param callback the callback containing the button that was modified
  15126. */
  15127. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15128. /**
  15129. * X and Y axis corresponding to the controllers joystick
  15130. */
  15131. pad: StickValues;
  15132. /**
  15133. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15134. */
  15135. hand: string;
  15136. /**
  15137. * The default controller model for the controller
  15138. */
  15139. get defaultModel(): Nullable<AbstractMesh>;
  15140. /**
  15141. * Creates a new WebVRController from a gamepad
  15142. * @param vrGamepad the gamepad that the WebVRController should be created from
  15143. */
  15144. constructor(vrGamepad: any);
  15145. /**
  15146. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15147. */
  15148. update(): void;
  15149. /**
  15150. * Function to be called when a button is modified
  15151. */
  15152. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15153. /**
  15154. * Loads a mesh and attaches it to the controller
  15155. * @param scene the scene the mesh should be added to
  15156. * @param meshLoaded callback for when the mesh has been loaded
  15157. */
  15158. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15159. private _setButtonValue;
  15160. private _changes;
  15161. private _checkChanges;
  15162. /**
  15163. * Disposes of th webVRCOntroller
  15164. */
  15165. dispose(): void;
  15166. }
  15167. }
  15168. declare module "babylonjs/Lights/hemisphericLight" {
  15169. import { Nullable } from "babylonjs/types";
  15170. import { Scene } from "babylonjs/scene";
  15171. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15172. import { Color3 } from "babylonjs/Maths/math.color";
  15173. import { Effect } from "babylonjs/Materials/effect";
  15174. import { Light } from "babylonjs/Lights/light";
  15175. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15176. /**
  15177. * The HemisphericLight simulates the ambient environment light,
  15178. * so the passed direction is the light reflection direction, not the incoming direction.
  15179. */
  15180. export class HemisphericLight extends Light {
  15181. /**
  15182. * The groundColor is the light in the opposite direction to the one specified during creation.
  15183. * 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.
  15184. */
  15185. groundColor: Color3;
  15186. /**
  15187. * The light reflection direction, not the incoming direction.
  15188. */
  15189. direction: Vector3;
  15190. /**
  15191. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15192. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15193. * The HemisphericLight can't cast shadows.
  15194. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15195. * @param name The friendly name of the light
  15196. * @param direction The direction of the light reflection
  15197. * @param scene The scene the light belongs to
  15198. */
  15199. constructor(name: string, direction: Vector3, scene: Scene);
  15200. protected _buildUniformLayout(): void;
  15201. /**
  15202. * Returns the string "HemisphericLight".
  15203. * @return The class name
  15204. */
  15205. getClassName(): string;
  15206. /**
  15207. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15208. * Returns the updated direction.
  15209. * @param target The target the direction should point to
  15210. * @return The computed direction
  15211. */
  15212. setDirectionToTarget(target: Vector3): Vector3;
  15213. /**
  15214. * Returns the shadow generator associated to the light.
  15215. * @returns Always null for hemispheric lights because it does not support shadows.
  15216. */
  15217. getShadowGenerator(): Nullable<IShadowGenerator>;
  15218. /**
  15219. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15220. * @param effect The effect to update
  15221. * @param lightIndex The index of the light in the effect to update
  15222. * @returns The hemispheric light
  15223. */
  15224. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15225. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15226. /**
  15227. * Computes the world matrix of the node
  15228. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15229. * @param useWasUpdatedFlag defines a reserved property
  15230. * @returns the world matrix
  15231. */
  15232. computeWorldMatrix(): Matrix;
  15233. /**
  15234. * Returns the integer 3.
  15235. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15236. */
  15237. getTypeID(): number;
  15238. /**
  15239. * Prepares the list of defines specific to the light type.
  15240. * @param defines the list of defines
  15241. * @param lightIndex defines the index of the light for the effect
  15242. */
  15243. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15244. }
  15245. }
  15246. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15247. /** @hidden */
  15248. export var vrMultiviewToSingleviewPixelShader: {
  15249. name: string;
  15250. shader: string;
  15251. };
  15252. }
  15253. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15254. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15255. import { Scene } from "babylonjs/scene";
  15256. /**
  15257. * Renders to multiple views with a single draw call
  15258. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15259. */
  15260. export class MultiviewRenderTarget extends RenderTargetTexture {
  15261. /**
  15262. * Creates a multiview render target
  15263. * @param scene scene used with the render target
  15264. * @param size the size of the render target (used for each view)
  15265. */
  15266. constructor(scene: Scene, size?: number | {
  15267. width: number;
  15268. height: number;
  15269. } | {
  15270. ratio: number;
  15271. });
  15272. /**
  15273. * @hidden
  15274. * @param faceIndex the face index, if its a cube texture
  15275. */
  15276. _bindFrameBuffer(faceIndex?: number): void;
  15277. /**
  15278. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15279. * @returns the view count
  15280. */
  15281. getViewCount(): number;
  15282. }
  15283. }
  15284. declare module "babylonjs/Maths/math.frustum" {
  15285. import { Matrix } from "babylonjs/Maths/math.vector";
  15286. import { DeepImmutable } from "babylonjs/types";
  15287. import { Plane } from "babylonjs/Maths/math.plane";
  15288. /**
  15289. * Represents a camera frustum
  15290. */
  15291. export class Frustum {
  15292. /**
  15293. * Gets the planes representing the frustum
  15294. * @param transform matrix to be applied to the returned planes
  15295. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15296. */
  15297. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15298. /**
  15299. * Gets the near frustum plane transformed by the transform matrix
  15300. * @param transform transformation matrix to be applied to the resulting frustum plane
  15301. * @param frustumPlane the resuling frustum plane
  15302. */
  15303. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15304. /**
  15305. * Gets the far frustum plane transformed by the transform matrix
  15306. * @param transform transformation matrix to be applied to the resulting frustum plane
  15307. * @param frustumPlane the resuling frustum plane
  15308. */
  15309. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15310. /**
  15311. * Gets the left frustum plane transformed by the transform matrix
  15312. * @param transform transformation matrix to be applied to the resulting frustum plane
  15313. * @param frustumPlane the resuling frustum plane
  15314. */
  15315. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15316. /**
  15317. * Gets the right frustum plane transformed by the transform matrix
  15318. * @param transform transformation matrix to be applied to the resulting frustum plane
  15319. * @param frustumPlane the resuling frustum plane
  15320. */
  15321. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15322. /**
  15323. * Gets the top frustum plane transformed by the transform matrix
  15324. * @param transform transformation matrix to be applied to the resulting frustum plane
  15325. * @param frustumPlane the resuling frustum plane
  15326. */
  15327. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15328. /**
  15329. * Gets the bottom frustum plane transformed by the transform matrix
  15330. * @param transform transformation matrix to be applied to the resulting frustum plane
  15331. * @param frustumPlane the resuling frustum plane
  15332. */
  15333. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15334. /**
  15335. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15336. * @param transform transformation matrix to be applied to the resulting frustum planes
  15337. * @param frustumPlanes the resuling frustum planes
  15338. */
  15339. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15340. }
  15341. }
  15342. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15343. import { Camera } from "babylonjs/Cameras/camera";
  15344. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15345. import { Nullable } from "babylonjs/types";
  15346. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15347. import { Matrix } from "babylonjs/Maths/math.vector";
  15348. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15349. module "babylonjs/Engines/engine" {
  15350. interface Engine {
  15351. /**
  15352. * Creates a new multiview render target
  15353. * @param width defines the width of the texture
  15354. * @param height defines the height of the texture
  15355. * @returns the created multiview texture
  15356. */
  15357. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15358. /**
  15359. * Binds a multiview framebuffer to be drawn to
  15360. * @param multiviewTexture texture to bind
  15361. */
  15362. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15363. }
  15364. }
  15365. module "babylonjs/Cameras/camera" {
  15366. interface Camera {
  15367. /**
  15368. * @hidden
  15369. * 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)
  15370. */
  15371. _useMultiviewToSingleView: boolean;
  15372. /**
  15373. * @hidden
  15374. * 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)
  15375. */
  15376. _multiviewTexture: Nullable<RenderTargetTexture>;
  15377. /**
  15378. * @hidden
  15379. * ensures the multiview texture of the camera exists and has the specified width/height
  15380. * @param width height to set on the multiview texture
  15381. * @param height width to set on the multiview texture
  15382. */
  15383. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15384. }
  15385. }
  15386. module "babylonjs/scene" {
  15387. interface Scene {
  15388. /** @hidden */
  15389. _transformMatrixR: Matrix;
  15390. /** @hidden */
  15391. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15392. /** @hidden */
  15393. _createMultiviewUbo(): void;
  15394. /** @hidden */
  15395. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15396. /** @hidden */
  15397. _renderMultiviewToSingleView(camera: Camera): void;
  15398. }
  15399. }
  15400. }
  15401. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15402. import { Camera } from "babylonjs/Cameras/camera";
  15403. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15404. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15405. import "babylonjs/Engines/Extensions/engine.multiview";
  15406. /**
  15407. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15408. * This will not be used for webXR as it supports displaying texture arrays directly
  15409. */
  15410. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15411. /**
  15412. * Initializes a VRMultiviewToSingleview
  15413. * @param name name of the post process
  15414. * @param camera camera to be applied to
  15415. * @param scaleFactor scaling factor to the size of the output texture
  15416. */
  15417. constructor(name: string, camera: Camera, scaleFactor: number);
  15418. }
  15419. }
  15420. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15421. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15422. import { Nullable } from "babylonjs/types";
  15423. import { Size } from "babylonjs/Maths/math.size";
  15424. import { Observable } from "babylonjs/Misc/observable";
  15425. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15426. /**
  15427. * Interface used to define additional presentation attributes
  15428. */
  15429. export interface IVRPresentationAttributes {
  15430. /**
  15431. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15432. */
  15433. highRefreshRate: boolean;
  15434. /**
  15435. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15436. */
  15437. foveationLevel: number;
  15438. }
  15439. module "babylonjs/Engines/engine" {
  15440. interface Engine {
  15441. /** @hidden */
  15442. _vrDisplay: any;
  15443. /** @hidden */
  15444. _vrSupported: boolean;
  15445. /** @hidden */
  15446. _oldSize: Size;
  15447. /** @hidden */
  15448. _oldHardwareScaleFactor: number;
  15449. /** @hidden */
  15450. _vrExclusivePointerMode: boolean;
  15451. /** @hidden */
  15452. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15453. /** @hidden */
  15454. _onVRDisplayPointerRestricted: () => void;
  15455. /** @hidden */
  15456. _onVRDisplayPointerUnrestricted: () => void;
  15457. /** @hidden */
  15458. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15459. /** @hidden */
  15460. _onVrDisplayDisconnect: Nullable<() => void>;
  15461. /** @hidden */
  15462. _onVrDisplayPresentChange: Nullable<() => void>;
  15463. /**
  15464. * Observable signaled when VR display mode changes
  15465. */
  15466. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15467. /**
  15468. * Observable signaled when VR request present is complete
  15469. */
  15470. onVRRequestPresentComplete: Observable<boolean>;
  15471. /**
  15472. * Observable signaled when VR request present starts
  15473. */
  15474. onVRRequestPresentStart: Observable<Engine>;
  15475. /**
  15476. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15477. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15478. */
  15479. isInVRExclusivePointerMode: boolean;
  15480. /**
  15481. * Gets a boolean indicating if a webVR device was detected
  15482. * @returns true if a webVR device was detected
  15483. */
  15484. isVRDevicePresent(): boolean;
  15485. /**
  15486. * Gets the current webVR device
  15487. * @returns the current webVR device (or null)
  15488. */
  15489. getVRDevice(): any;
  15490. /**
  15491. * Initializes a webVR display and starts listening to display change events
  15492. * The onVRDisplayChangedObservable will be notified upon these changes
  15493. * @returns A promise containing a VRDisplay and if vr is supported
  15494. */
  15495. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15496. /** @hidden */
  15497. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15498. /**
  15499. * Gets or sets the presentation attributes used to configure VR rendering
  15500. */
  15501. vrPresentationAttributes?: IVRPresentationAttributes;
  15502. /**
  15503. * Call this function to switch to webVR mode
  15504. * Will do nothing if webVR is not supported or if there is no webVR device
  15505. * @param options the webvr options provided to the camera. mainly used for multiview
  15506. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15507. */
  15508. enableVR(options: WebVROptions): void;
  15509. /** @hidden */
  15510. _onVRFullScreenTriggered(): void;
  15511. }
  15512. }
  15513. }
  15514. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15515. import { Nullable } from "babylonjs/types";
  15516. import { Observable } from "babylonjs/Misc/observable";
  15517. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15518. import { Scene } from "babylonjs/scene";
  15519. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15520. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15521. import { Node } from "babylonjs/node";
  15522. import { Ray } from "babylonjs/Culling/ray";
  15523. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15524. import "babylonjs/Engines/Extensions/engine.webVR";
  15525. /**
  15526. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15527. * IMPORTANT!! The data is right-hand data.
  15528. * @export
  15529. * @interface DevicePose
  15530. */
  15531. export interface DevicePose {
  15532. /**
  15533. * The position of the device, values in array are [x,y,z].
  15534. */
  15535. readonly position: Nullable<Float32Array>;
  15536. /**
  15537. * The linearVelocity of the device, values in array are [x,y,z].
  15538. */
  15539. readonly linearVelocity: Nullable<Float32Array>;
  15540. /**
  15541. * The linearAcceleration of the device, values in array are [x,y,z].
  15542. */
  15543. readonly linearAcceleration: Nullable<Float32Array>;
  15544. /**
  15545. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15546. */
  15547. readonly orientation: Nullable<Float32Array>;
  15548. /**
  15549. * The angularVelocity of the device, values in array are [x,y,z].
  15550. */
  15551. readonly angularVelocity: Nullable<Float32Array>;
  15552. /**
  15553. * The angularAcceleration of the device, values in array are [x,y,z].
  15554. */
  15555. readonly angularAcceleration: Nullable<Float32Array>;
  15556. }
  15557. /**
  15558. * Interface representing a pose controlled object in Babylon.
  15559. * A pose controlled object has both regular pose values as well as pose values
  15560. * from an external device such as a VR head mounted display
  15561. */
  15562. export interface PoseControlled {
  15563. /**
  15564. * The position of the object in babylon space.
  15565. */
  15566. position: Vector3;
  15567. /**
  15568. * The rotation quaternion of the object in babylon space.
  15569. */
  15570. rotationQuaternion: Quaternion;
  15571. /**
  15572. * The position of the device in babylon space.
  15573. */
  15574. devicePosition?: Vector3;
  15575. /**
  15576. * The rotation quaternion of the device in babylon space.
  15577. */
  15578. deviceRotationQuaternion: Quaternion;
  15579. /**
  15580. * The raw pose coming from the device.
  15581. */
  15582. rawPose: Nullable<DevicePose>;
  15583. /**
  15584. * The scale of the device to be used when translating from device space to babylon space.
  15585. */
  15586. deviceScaleFactor: number;
  15587. /**
  15588. * Updates the poseControlled values based on the input device pose.
  15589. * @param poseData the pose data to update the object with
  15590. */
  15591. updateFromDevice(poseData: DevicePose): void;
  15592. }
  15593. /**
  15594. * Set of options to customize the webVRCamera
  15595. */
  15596. export interface WebVROptions {
  15597. /**
  15598. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15599. */
  15600. trackPosition?: boolean;
  15601. /**
  15602. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15603. */
  15604. positionScale?: number;
  15605. /**
  15606. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15607. */
  15608. displayName?: string;
  15609. /**
  15610. * Should the native controller meshes be initialized. (default: true)
  15611. */
  15612. controllerMeshes?: boolean;
  15613. /**
  15614. * Creating a default HemiLight only on controllers. (default: true)
  15615. */
  15616. defaultLightingOnControllers?: boolean;
  15617. /**
  15618. * If you don't want to use the default VR button of the helper. (default: false)
  15619. */
  15620. useCustomVRButton?: boolean;
  15621. /**
  15622. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15623. */
  15624. customVRButton?: HTMLButtonElement;
  15625. /**
  15626. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15627. */
  15628. rayLength?: number;
  15629. /**
  15630. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15631. */
  15632. defaultHeight?: number;
  15633. /**
  15634. * If multiview should be used if availible (default: false)
  15635. */
  15636. useMultiview?: boolean;
  15637. }
  15638. /**
  15639. * This represents a WebVR camera.
  15640. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15641. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15642. */
  15643. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15644. private webVROptions;
  15645. /**
  15646. * @hidden
  15647. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15648. */
  15649. _vrDevice: any;
  15650. /**
  15651. * The rawPose of the vrDevice.
  15652. */
  15653. rawPose: Nullable<DevicePose>;
  15654. private _onVREnabled;
  15655. private _specsVersion;
  15656. private _attached;
  15657. private _frameData;
  15658. protected _descendants: Array<Node>;
  15659. private _deviceRoomPosition;
  15660. /** @hidden */
  15661. _deviceRoomRotationQuaternion: Quaternion;
  15662. private _standingMatrix;
  15663. /**
  15664. * Represents device position in babylon space.
  15665. */
  15666. devicePosition: Vector3;
  15667. /**
  15668. * Represents device rotation in babylon space.
  15669. */
  15670. deviceRotationQuaternion: Quaternion;
  15671. /**
  15672. * The scale of the device to be used when translating from device space to babylon space.
  15673. */
  15674. deviceScaleFactor: number;
  15675. private _deviceToWorld;
  15676. private _worldToDevice;
  15677. /**
  15678. * References to the webVR controllers for the vrDevice.
  15679. */
  15680. controllers: Array<WebVRController>;
  15681. /**
  15682. * Emits an event when a controller is attached.
  15683. */
  15684. onControllersAttachedObservable: Observable<WebVRController[]>;
  15685. /**
  15686. * Emits an event when a controller's mesh has been loaded;
  15687. */
  15688. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15689. /**
  15690. * Emits an event when the HMD's pose has been updated.
  15691. */
  15692. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15693. private _poseSet;
  15694. /**
  15695. * If the rig cameras be used as parent instead of this camera.
  15696. */
  15697. rigParenting: boolean;
  15698. private _lightOnControllers;
  15699. private _defaultHeight?;
  15700. /**
  15701. * Instantiates a WebVRFreeCamera.
  15702. * @param name The name of the WebVRFreeCamera
  15703. * @param position The starting anchor position for the camera
  15704. * @param scene The scene the camera belongs to
  15705. * @param webVROptions a set of customizable options for the webVRCamera
  15706. */
  15707. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15708. /**
  15709. * Gets the device distance from the ground in meters.
  15710. * @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.
  15711. */
  15712. deviceDistanceToRoomGround(): number;
  15713. /**
  15714. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15715. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15716. */
  15717. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15718. /**
  15719. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15720. * @returns A promise with a boolean set to if the standing matrix is supported.
  15721. */
  15722. useStandingMatrixAsync(): Promise<boolean>;
  15723. /**
  15724. * Disposes the camera
  15725. */
  15726. dispose(): void;
  15727. /**
  15728. * Gets a vrController by name.
  15729. * @param name The name of the controller to retreive
  15730. * @returns the controller matching the name specified or null if not found
  15731. */
  15732. getControllerByName(name: string): Nullable<WebVRController>;
  15733. private _leftController;
  15734. /**
  15735. * The controller corresponding to the users left hand.
  15736. */
  15737. get leftController(): Nullable<WebVRController>;
  15738. private _rightController;
  15739. /**
  15740. * The controller corresponding to the users right hand.
  15741. */
  15742. get rightController(): Nullable<WebVRController>;
  15743. /**
  15744. * Casts a ray forward from the vrCamera's gaze.
  15745. * @param length Length of the ray (default: 100)
  15746. * @returns the ray corresponding to the gaze
  15747. */
  15748. getForwardRay(length?: number): Ray;
  15749. /**
  15750. * @hidden
  15751. * Updates the camera based on device's frame data
  15752. */
  15753. _checkInputs(): void;
  15754. /**
  15755. * Updates the poseControlled values based on the input device pose.
  15756. * @param poseData Pose coming from the device
  15757. */
  15758. updateFromDevice(poseData: DevicePose): void;
  15759. private _htmlElementAttached;
  15760. private _detachIfAttached;
  15761. /**
  15762. * WebVR's attach control will start broadcasting frames to the device.
  15763. * Note that in certain browsers (chrome for example) this function must be called
  15764. * within a user-interaction callback. Example:
  15765. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15766. *
  15767. * @param element html element to attach the vrDevice to
  15768. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15769. */
  15770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15771. /**
  15772. * Detaches the camera from the html element and disables VR
  15773. *
  15774. * @param element html element to detach from
  15775. */
  15776. detachControl(element: HTMLElement): void;
  15777. /**
  15778. * @returns the name of this class
  15779. */
  15780. getClassName(): string;
  15781. /**
  15782. * Calls resetPose on the vrDisplay
  15783. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15784. */
  15785. resetToCurrentRotation(): void;
  15786. /**
  15787. * @hidden
  15788. * Updates the rig cameras (left and right eye)
  15789. */
  15790. _updateRigCameras(): void;
  15791. private _workingVector;
  15792. private _oneVector;
  15793. private _workingMatrix;
  15794. private updateCacheCalled;
  15795. private _correctPositionIfNotTrackPosition;
  15796. /**
  15797. * @hidden
  15798. * Updates the cached values of the camera
  15799. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15800. */
  15801. _updateCache(ignoreParentClass?: boolean): void;
  15802. /**
  15803. * @hidden
  15804. * Get current device position in babylon world
  15805. */
  15806. _computeDevicePosition(): void;
  15807. /**
  15808. * Updates the current device position and rotation in the babylon world
  15809. */
  15810. update(): void;
  15811. /**
  15812. * @hidden
  15813. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15814. * @returns an identity matrix
  15815. */
  15816. _getViewMatrix(): Matrix;
  15817. private _tmpMatrix;
  15818. /**
  15819. * This function is called by the two RIG cameras.
  15820. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15821. * @hidden
  15822. */
  15823. _getWebVRViewMatrix(): Matrix;
  15824. /** @hidden */
  15825. _getWebVRProjectionMatrix(): Matrix;
  15826. private _onGamepadConnectedObserver;
  15827. private _onGamepadDisconnectedObserver;
  15828. private _updateCacheWhenTrackingDisabledObserver;
  15829. /**
  15830. * Initializes the controllers and their meshes
  15831. */
  15832. initControllers(): void;
  15833. }
  15834. }
  15835. declare module "babylonjs/PostProcesses/postProcess" {
  15836. import { Nullable } from "babylonjs/types";
  15837. import { SmartArray } from "babylonjs/Misc/smartArray";
  15838. import { Observable } from "babylonjs/Misc/observable";
  15839. import { Vector2 } from "babylonjs/Maths/math.vector";
  15840. import { Camera } from "babylonjs/Cameras/camera";
  15841. import { Effect } from "babylonjs/Materials/effect";
  15842. import "babylonjs/Shaders/postprocess.vertex";
  15843. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15844. import { Engine } from "babylonjs/Engines/engine";
  15845. import { Color4 } from "babylonjs/Maths/math.color";
  15846. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15847. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15848. /**
  15849. * Size options for a post process
  15850. */
  15851. export type PostProcessOptions = {
  15852. width: number;
  15853. height: number;
  15854. };
  15855. /**
  15856. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15857. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15858. */
  15859. export class PostProcess {
  15860. /** Name of the PostProcess. */
  15861. name: string;
  15862. /**
  15863. * Gets or sets the unique id of the post process
  15864. */
  15865. uniqueId: number;
  15866. /**
  15867. * Width of the texture to apply the post process on
  15868. */
  15869. width: number;
  15870. /**
  15871. * Height of the texture to apply the post process on
  15872. */
  15873. height: number;
  15874. /**
  15875. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15876. * @hidden
  15877. */
  15878. _outputTexture: Nullable<InternalTexture>;
  15879. /**
  15880. * Sampling mode used by the shader
  15881. * See https://doc.babylonjs.com/classes/3.1/texture
  15882. */
  15883. renderTargetSamplingMode: number;
  15884. /**
  15885. * Clear color to use when screen clearing
  15886. */
  15887. clearColor: Color4;
  15888. /**
  15889. * If the buffer needs to be cleared before applying the post process. (default: true)
  15890. * Should be set to false if shader will overwrite all previous pixels.
  15891. */
  15892. autoClear: boolean;
  15893. /**
  15894. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15895. */
  15896. alphaMode: number;
  15897. /**
  15898. * Sets the setAlphaBlendConstants of the babylon engine
  15899. */
  15900. alphaConstants: Color4;
  15901. /**
  15902. * Animations to be used for the post processing
  15903. */
  15904. animations: import("babylonjs/Animations/animation").Animation[];
  15905. /**
  15906. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15907. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15908. */
  15909. enablePixelPerfectMode: boolean;
  15910. /**
  15911. * Force the postprocess to be applied without taking in account viewport
  15912. */
  15913. forceFullscreenViewport: boolean;
  15914. /**
  15915. * List of inspectable custom properties (used by the Inspector)
  15916. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15917. */
  15918. inspectableCustomProperties: IInspectable[];
  15919. /**
  15920. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15921. *
  15922. * | Value | Type | Description |
  15923. * | ----- | ----------------------------------- | ----------- |
  15924. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15925. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15926. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15927. *
  15928. */
  15929. scaleMode: number;
  15930. /**
  15931. * Force textures to be a power of two (default: false)
  15932. */
  15933. alwaysForcePOT: boolean;
  15934. private _samples;
  15935. /**
  15936. * Number of sample textures (default: 1)
  15937. */
  15938. get samples(): number;
  15939. set samples(n: number);
  15940. /**
  15941. * Modify the scale of the post process to be the same as the viewport (default: false)
  15942. */
  15943. adaptScaleToCurrentViewport: boolean;
  15944. private _camera;
  15945. private _scene;
  15946. private _engine;
  15947. private _options;
  15948. private _reusable;
  15949. private _textureType;
  15950. private _textureFormat;
  15951. /**
  15952. * Smart array of input and output textures for the post process.
  15953. * @hidden
  15954. */
  15955. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15956. /**
  15957. * The index in _textures that corresponds to the output texture.
  15958. * @hidden
  15959. */
  15960. _currentRenderTextureInd: number;
  15961. private _effect;
  15962. private _samplers;
  15963. private _fragmentUrl;
  15964. private _vertexUrl;
  15965. private _parameters;
  15966. private _scaleRatio;
  15967. protected _indexParameters: any;
  15968. private _shareOutputWithPostProcess;
  15969. private _texelSize;
  15970. private _forcedOutputTexture;
  15971. /**
  15972. * Returns the fragment url or shader name used in the post process.
  15973. * @returns the fragment url or name in the shader store.
  15974. */
  15975. getEffectName(): string;
  15976. /**
  15977. * An event triggered when the postprocess is activated.
  15978. */
  15979. onActivateObservable: Observable<Camera>;
  15980. private _onActivateObserver;
  15981. /**
  15982. * A function that is added to the onActivateObservable
  15983. */
  15984. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15985. /**
  15986. * An event triggered when the postprocess changes its size.
  15987. */
  15988. onSizeChangedObservable: Observable<PostProcess>;
  15989. private _onSizeChangedObserver;
  15990. /**
  15991. * A function that is added to the onSizeChangedObservable
  15992. */
  15993. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15994. /**
  15995. * An event triggered when the postprocess applies its effect.
  15996. */
  15997. onApplyObservable: Observable<Effect>;
  15998. private _onApplyObserver;
  15999. /**
  16000. * A function that is added to the onApplyObservable
  16001. */
  16002. set onApply(callback: (effect: Effect) => void);
  16003. /**
  16004. * An event triggered before rendering the postprocess
  16005. */
  16006. onBeforeRenderObservable: Observable<Effect>;
  16007. private _onBeforeRenderObserver;
  16008. /**
  16009. * A function that is added to the onBeforeRenderObservable
  16010. */
  16011. set onBeforeRender(callback: (effect: Effect) => void);
  16012. /**
  16013. * An event triggered after rendering the postprocess
  16014. */
  16015. onAfterRenderObservable: Observable<Effect>;
  16016. private _onAfterRenderObserver;
  16017. /**
  16018. * A function that is added to the onAfterRenderObservable
  16019. */
  16020. set onAfterRender(callback: (efect: Effect) => void);
  16021. /**
  16022. * 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
  16023. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16024. */
  16025. get inputTexture(): InternalTexture;
  16026. set inputTexture(value: InternalTexture);
  16027. /**
  16028. * Gets the camera which post process is applied to.
  16029. * @returns The camera the post process is applied to.
  16030. */
  16031. getCamera(): Camera;
  16032. /**
  16033. * Gets the texel size of the postprocess.
  16034. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16035. */
  16036. get texelSize(): Vector2;
  16037. /**
  16038. * Creates a new instance PostProcess
  16039. * @param name The name of the PostProcess.
  16040. * @param fragmentUrl The url of the fragment shader to be used.
  16041. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16042. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16043. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16044. * @param camera The camera to apply the render pass to.
  16045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16046. * @param engine The engine which the post process will be applied. (default: current engine)
  16047. * @param reusable If the post process can be reused on the same frame. (default: false)
  16048. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16049. * @param textureType Type of textures used when performing the post process. (default: 0)
  16050. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16051. * @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
  16052. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16053. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  16054. */
  16055. constructor(
  16056. /** Name of the PostProcess. */
  16057. 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);
  16058. /**
  16059. * Gets a string idenfifying the name of the class
  16060. * @returns "PostProcess" string
  16061. */
  16062. getClassName(): string;
  16063. /**
  16064. * Gets the engine which this post process belongs to.
  16065. * @returns The engine the post process was enabled with.
  16066. */
  16067. getEngine(): Engine;
  16068. /**
  16069. * The effect that is created when initializing the post process.
  16070. * @returns The created effect corresponding the the postprocess.
  16071. */
  16072. getEffect(): Effect;
  16073. /**
  16074. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16075. * @param postProcess The post process to share the output with.
  16076. * @returns This post process.
  16077. */
  16078. shareOutputWith(postProcess: PostProcess): PostProcess;
  16079. /**
  16080. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16081. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16082. */
  16083. useOwnOutput(): void;
  16084. /**
  16085. * Updates the effect with the current post process compile time values and recompiles the shader.
  16086. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16087. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16088. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16089. * @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
  16090. * @param onCompiled Called when the shader has been compiled.
  16091. * @param onError Called if there is an error when compiling a shader.
  16092. */
  16093. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16094. /**
  16095. * The post process is reusable if it can be used multiple times within one frame.
  16096. * @returns If the post process is reusable
  16097. */
  16098. isReusable(): boolean;
  16099. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16100. markTextureDirty(): void;
  16101. /**
  16102. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16103. * 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.
  16104. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16105. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16106. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16107. * @returns The target texture that was bound to be written to.
  16108. */
  16109. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16110. /**
  16111. * If the post process is supported.
  16112. */
  16113. get isSupported(): boolean;
  16114. /**
  16115. * The aspect ratio of the output texture.
  16116. */
  16117. get aspectRatio(): number;
  16118. /**
  16119. * Get a value indicating if the post-process is ready to be used
  16120. * @returns true if the post-process is ready (shader is compiled)
  16121. */
  16122. isReady(): boolean;
  16123. /**
  16124. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16125. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16126. */
  16127. apply(): Nullable<Effect>;
  16128. private _disposeTextures;
  16129. /**
  16130. * Disposes the post process.
  16131. * @param camera The camera to dispose the post process on.
  16132. */
  16133. dispose(camera?: Camera): void;
  16134. }
  16135. }
  16136. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16137. /** @hidden */
  16138. export var kernelBlurVaryingDeclaration: {
  16139. name: string;
  16140. shader: string;
  16141. };
  16142. }
  16143. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16144. /** @hidden */
  16145. export var kernelBlurFragment: {
  16146. name: string;
  16147. shader: string;
  16148. };
  16149. }
  16150. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16151. /** @hidden */
  16152. export var kernelBlurFragment2: {
  16153. name: string;
  16154. shader: string;
  16155. };
  16156. }
  16157. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16158. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16159. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16160. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16161. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16162. /** @hidden */
  16163. export var kernelBlurPixelShader: {
  16164. name: string;
  16165. shader: string;
  16166. };
  16167. }
  16168. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16169. /** @hidden */
  16170. export var kernelBlurVertex: {
  16171. name: string;
  16172. shader: string;
  16173. };
  16174. }
  16175. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16176. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16177. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16178. /** @hidden */
  16179. export var kernelBlurVertexShader: {
  16180. name: string;
  16181. shader: string;
  16182. };
  16183. }
  16184. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16185. import { Vector2 } from "babylonjs/Maths/math.vector";
  16186. import { Nullable } from "babylonjs/types";
  16187. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16188. import { Camera } from "babylonjs/Cameras/camera";
  16189. import { Effect } from "babylonjs/Materials/effect";
  16190. import { Engine } from "babylonjs/Engines/engine";
  16191. import "babylonjs/Shaders/kernelBlur.fragment";
  16192. import "babylonjs/Shaders/kernelBlur.vertex";
  16193. /**
  16194. * The Blur Post Process which blurs an image based on a kernel and direction.
  16195. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16196. */
  16197. export class BlurPostProcess extends PostProcess {
  16198. /** The direction in which to blur the image. */
  16199. direction: Vector2;
  16200. private blockCompilation;
  16201. protected _kernel: number;
  16202. protected _idealKernel: number;
  16203. protected _packedFloat: boolean;
  16204. private _staticDefines;
  16205. /**
  16206. * Sets the length in pixels of the blur sample region
  16207. */
  16208. set kernel(v: number);
  16209. /**
  16210. * Gets the length in pixels of the blur sample region
  16211. */
  16212. get kernel(): number;
  16213. /**
  16214. * Sets wether or not the blur needs to unpack/repack floats
  16215. */
  16216. set packedFloat(v: boolean);
  16217. /**
  16218. * Gets wether or not the blur is unpacking/repacking floats
  16219. */
  16220. get packedFloat(): boolean;
  16221. /**
  16222. * Creates a new instance BlurPostProcess
  16223. * @param name The name of the effect.
  16224. * @param direction The direction in which to blur the image.
  16225. * @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.
  16226. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16227. * @param camera The camera to apply the render pass to.
  16228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16229. * @param engine The engine which the post process will be applied. (default: current engine)
  16230. * @param reusable If the post process can be reused on the same frame. (default: false)
  16231. * @param textureType Type of textures used when performing the post process. (default: 0)
  16232. * @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)
  16233. */
  16234. constructor(name: string,
  16235. /** The direction in which to blur the image. */
  16236. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16237. /**
  16238. * Updates the effect with the current post process compile time values and recompiles the shader.
  16239. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16240. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16241. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16242. * @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
  16243. * @param onCompiled Called when the shader has been compiled.
  16244. * @param onError Called if there is an error when compiling a shader.
  16245. */
  16246. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16247. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16248. /**
  16249. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16250. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16251. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16252. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16253. * The gaps between physical kernels are compensated for in the weighting of the samples
  16254. * @param idealKernel Ideal blur kernel.
  16255. * @return Nearest best kernel.
  16256. */
  16257. protected _nearestBestKernel(idealKernel: number): number;
  16258. /**
  16259. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16260. * @param x The point on the Gaussian distribution to sample.
  16261. * @return the value of the Gaussian function at x.
  16262. */
  16263. protected _gaussianWeight(x: number): number;
  16264. /**
  16265. * Generates a string that can be used as a floating point number in GLSL.
  16266. * @param x Value to print.
  16267. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16268. * @return GLSL float string.
  16269. */
  16270. protected _glslFloat(x: number, decimalFigures?: number): string;
  16271. }
  16272. }
  16273. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16274. import { Scene } from "babylonjs/scene";
  16275. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16276. import { Plane } from "babylonjs/Maths/math.plane";
  16277. /**
  16278. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16279. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16280. * You can then easily use it as a reflectionTexture on a flat surface.
  16281. * In case the surface is not a plane, please consider relying on reflection probes.
  16282. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16283. */
  16284. export class MirrorTexture extends RenderTargetTexture {
  16285. private scene;
  16286. /**
  16287. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16288. * 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.
  16289. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16290. */
  16291. mirrorPlane: Plane;
  16292. /**
  16293. * Define the blur ratio used to blur the reflection if needed.
  16294. */
  16295. set blurRatio(value: number);
  16296. get blurRatio(): number;
  16297. /**
  16298. * Define the adaptive blur kernel used to blur the reflection if needed.
  16299. * This will autocompute the closest best match for the `blurKernel`
  16300. */
  16301. set adaptiveBlurKernel(value: number);
  16302. /**
  16303. * Define the blur kernel used to blur the reflection if needed.
  16304. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16305. */
  16306. set blurKernel(value: number);
  16307. /**
  16308. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16309. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16310. */
  16311. set blurKernelX(value: number);
  16312. get blurKernelX(): number;
  16313. /**
  16314. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16315. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16316. */
  16317. set blurKernelY(value: number);
  16318. get blurKernelY(): number;
  16319. private _autoComputeBlurKernel;
  16320. protected _onRatioRescale(): void;
  16321. private _updateGammaSpace;
  16322. private _imageProcessingConfigChangeObserver;
  16323. private _transformMatrix;
  16324. private _mirrorMatrix;
  16325. private _savedViewMatrix;
  16326. private _blurX;
  16327. private _blurY;
  16328. private _adaptiveBlurKernel;
  16329. private _blurKernelX;
  16330. private _blurKernelY;
  16331. private _blurRatio;
  16332. /**
  16333. * Instantiates a Mirror Texture.
  16334. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16335. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16336. * You can then easily use it as a reflectionTexture on a flat surface.
  16337. * In case the surface is not a plane, please consider relying on reflection probes.
  16338. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16339. * @param name
  16340. * @param size
  16341. * @param scene
  16342. * @param generateMipMaps
  16343. * @param type
  16344. * @param samplingMode
  16345. * @param generateDepthBuffer
  16346. */
  16347. constructor(name: string, size: number | {
  16348. width: number;
  16349. height: number;
  16350. } | {
  16351. ratio: number;
  16352. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16353. private _preparePostProcesses;
  16354. /**
  16355. * Clone the mirror texture.
  16356. * @returns the cloned texture
  16357. */
  16358. clone(): MirrorTexture;
  16359. /**
  16360. * Serialize the texture to a JSON representation you could use in Parse later on
  16361. * @returns the serialized JSON representation
  16362. */
  16363. serialize(): any;
  16364. /**
  16365. * Dispose the texture and release its associated resources.
  16366. */
  16367. dispose(): void;
  16368. }
  16369. }
  16370. declare module "babylonjs/Materials/Textures/texture" {
  16371. import { Observable } from "babylonjs/Misc/observable";
  16372. import { Nullable } from "babylonjs/types";
  16373. import { Matrix } from "babylonjs/Maths/math.vector";
  16374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16375. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16376. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16377. import { Scene } from "babylonjs/scene";
  16378. /**
  16379. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16380. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16381. */
  16382. export class Texture extends BaseTexture {
  16383. /**
  16384. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16385. */
  16386. static SerializeBuffers: boolean;
  16387. /** @hidden */
  16388. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16389. /** @hidden */
  16390. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16391. /** @hidden */
  16392. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16393. /** nearest is mag = nearest and min = nearest and mip = linear */
  16394. static readonly NEAREST_SAMPLINGMODE: number;
  16395. /** nearest is mag = nearest and min = nearest and mip = linear */
  16396. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16397. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16398. static readonly BILINEAR_SAMPLINGMODE: number;
  16399. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16400. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16401. /** Trilinear is mag = linear and min = linear and mip = linear */
  16402. static readonly TRILINEAR_SAMPLINGMODE: number;
  16403. /** Trilinear is mag = linear and min = linear and mip = linear */
  16404. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16405. /** mag = nearest and min = nearest and mip = nearest */
  16406. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16407. /** mag = nearest and min = linear and mip = nearest */
  16408. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16409. /** mag = nearest and min = linear and mip = linear */
  16410. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16411. /** mag = nearest and min = linear and mip = none */
  16412. static readonly NEAREST_LINEAR: number;
  16413. /** mag = nearest and min = nearest and mip = none */
  16414. static readonly NEAREST_NEAREST: number;
  16415. /** mag = linear and min = nearest and mip = nearest */
  16416. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16417. /** mag = linear and min = nearest and mip = linear */
  16418. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16419. /** mag = linear and min = linear and mip = none */
  16420. static readonly LINEAR_LINEAR: number;
  16421. /** mag = linear and min = nearest and mip = none */
  16422. static readonly LINEAR_NEAREST: number;
  16423. /** Explicit coordinates mode */
  16424. static readonly EXPLICIT_MODE: number;
  16425. /** Spherical coordinates mode */
  16426. static readonly SPHERICAL_MODE: number;
  16427. /** Planar coordinates mode */
  16428. static readonly PLANAR_MODE: number;
  16429. /** Cubic coordinates mode */
  16430. static readonly CUBIC_MODE: number;
  16431. /** Projection coordinates mode */
  16432. static readonly PROJECTION_MODE: number;
  16433. /** Inverse Cubic coordinates mode */
  16434. static readonly SKYBOX_MODE: number;
  16435. /** Inverse Cubic coordinates mode */
  16436. static readonly INVCUBIC_MODE: number;
  16437. /** Equirectangular coordinates mode */
  16438. static readonly EQUIRECTANGULAR_MODE: number;
  16439. /** Equirectangular Fixed coordinates mode */
  16440. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16441. /** Equirectangular Fixed Mirrored coordinates mode */
  16442. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16443. /** Texture is not repeating outside of 0..1 UVs */
  16444. static readonly CLAMP_ADDRESSMODE: number;
  16445. /** Texture is repeating outside of 0..1 UVs */
  16446. static readonly WRAP_ADDRESSMODE: number;
  16447. /** Texture is repeating and mirrored */
  16448. static readonly MIRROR_ADDRESSMODE: number;
  16449. /**
  16450. * 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
  16451. */
  16452. static UseSerializedUrlIfAny: boolean;
  16453. /**
  16454. * Define the url of the texture.
  16455. */
  16456. url: Nullable<string>;
  16457. /**
  16458. * Define an offset on the texture to offset the u coordinates of the UVs
  16459. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16460. */
  16461. uOffset: number;
  16462. /**
  16463. * Define an offset on the texture to offset the v coordinates of the UVs
  16464. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16465. */
  16466. vOffset: number;
  16467. /**
  16468. * Define an offset on the texture to scale the u coordinates of the UVs
  16469. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16470. */
  16471. uScale: number;
  16472. /**
  16473. * Define an offset on the texture to scale the v coordinates of the UVs
  16474. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16475. */
  16476. vScale: number;
  16477. /**
  16478. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16479. * @see http://doc.babylonjs.com/how_to/more_materials
  16480. */
  16481. uAng: number;
  16482. /**
  16483. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16484. * @see http://doc.babylonjs.com/how_to/more_materials
  16485. */
  16486. vAng: number;
  16487. /**
  16488. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16489. * @see http://doc.babylonjs.com/how_to/more_materials
  16490. */
  16491. wAng: number;
  16492. /**
  16493. * Defines the center of rotation (U)
  16494. */
  16495. uRotationCenter: number;
  16496. /**
  16497. * Defines the center of rotation (V)
  16498. */
  16499. vRotationCenter: number;
  16500. /**
  16501. * Defines the center of rotation (W)
  16502. */
  16503. wRotationCenter: number;
  16504. /**
  16505. * Are mip maps generated for this texture or not.
  16506. */
  16507. get noMipmap(): boolean;
  16508. /**
  16509. * List of inspectable custom properties (used by the Inspector)
  16510. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16511. */
  16512. inspectableCustomProperties: Nullable<IInspectable[]>;
  16513. private _noMipmap;
  16514. /** @hidden */
  16515. _invertY: boolean;
  16516. private _rowGenerationMatrix;
  16517. private _cachedTextureMatrix;
  16518. private _projectionModeMatrix;
  16519. private _t0;
  16520. private _t1;
  16521. private _t2;
  16522. private _cachedUOffset;
  16523. private _cachedVOffset;
  16524. private _cachedUScale;
  16525. private _cachedVScale;
  16526. private _cachedUAng;
  16527. private _cachedVAng;
  16528. private _cachedWAng;
  16529. private _cachedProjectionMatrixId;
  16530. private _cachedCoordinatesMode;
  16531. /** @hidden */
  16532. protected _initialSamplingMode: number;
  16533. /** @hidden */
  16534. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16535. private _deleteBuffer;
  16536. protected _format: Nullable<number>;
  16537. private _delayedOnLoad;
  16538. private _delayedOnError;
  16539. private _mimeType?;
  16540. /**
  16541. * Observable triggered once the texture has been loaded.
  16542. */
  16543. onLoadObservable: Observable<Texture>;
  16544. protected _isBlocking: boolean;
  16545. /**
  16546. * Is the texture preventing material to render while loading.
  16547. * If false, a default texture will be used instead of the loading one during the preparation step.
  16548. */
  16549. set isBlocking(value: boolean);
  16550. get isBlocking(): boolean;
  16551. /**
  16552. * Get the current sampling mode associated with the texture.
  16553. */
  16554. get samplingMode(): number;
  16555. /**
  16556. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16557. */
  16558. get invertY(): boolean;
  16559. /**
  16560. * Instantiates a new texture.
  16561. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16562. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16563. * @param url defines the url of the picture to load as a texture
  16564. * @param scene defines the scene or engine the texture will belong to
  16565. * @param noMipmap defines if the texture will require mip maps or not
  16566. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16567. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16568. * @param onLoad defines a callback triggered when the texture has been loaded
  16569. * @param onError defines a callback triggered when an error occurred during the loading session
  16570. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16571. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16572. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16573. * @param mimeType defines an optional mime type information
  16574. */
  16575. 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);
  16576. /**
  16577. * Update the url (and optional buffer) of this texture if url was null during construction.
  16578. * @param url the url of the texture
  16579. * @param buffer the buffer of the texture (defaults to null)
  16580. * @param onLoad callback called when the texture is loaded (defaults to null)
  16581. */
  16582. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16583. /**
  16584. * Finish the loading sequence of a texture flagged as delayed load.
  16585. * @hidden
  16586. */
  16587. delayLoad(): void;
  16588. private _prepareRowForTextureGeneration;
  16589. /**
  16590. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16591. * @returns the transform matrix of the texture.
  16592. */
  16593. getTextureMatrix(uBase?: number): Matrix;
  16594. /**
  16595. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16596. * @returns The reflection texture transform
  16597. */
  16598. getReflectionTextureMatrix(): Matrix;
  16599. /**
  16600. * Clones the texture.
  16601. * @returns the cloned texture
  16602. */
  16603. clone(): Texture;
  16604. /**
  16605. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16606. * @returns The JSON representation of the texture
  16607. */
  16608. serialize(): any;
  16609. /**
  16610. * Get the current class name of the texture useful for serialization or dynamic coding.
  16611. * @returns "Texture"
  16612. */
  16613. getClassName(): string;
  16614. /**
  16615. * Dispose the texture and release its associated resources.
  16616. */
  16617. dispose(): void;
  16618. /**
  16619. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16620. * @param parsedTexture Define the JSON representation of the texture
  16621. * @param scene Define the scene the parsed texture should be instantiated in
  16622. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16623. * @returns The parsed texture if successful
  16624. */
  16625. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16626. /**
  16627. * Creates a texture from its base 64 representation.
  16628. * @param data Define the base64 payload without the data: prefix
  16629. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16630. * @param scene Define the scene the texture should belong to
  16631. * @param noMipmap Forces the texture to not create mip map information if true
  16632. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16633. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16634. * @param onLoad define a callback triggered when the texture has been loaded
  16635. * @param onError define a callback triggered when an error occurred during the loading session
  16636. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16637. * @returns the created texture
  16638. */
  16639. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16640. /**
  16641. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16642. * @param data Define the base64 payload without the data: prefix
  16643. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16644. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16645. * @param scene Define the scene the texture should belong to
  16646. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16647. * @param noMipmap Forces the texture to not create mip map information if true
  16648. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16649. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16650. * @param onLoad define a callback triggered when the texture has been loaded
  16651. * @param onError define a callback triggered when an error occurred during the loading session
  16652. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16653. * @returns the created texture
  16654. */
  16655. 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;
  16656. }
  16657. }
  16658. declare module "babylonjs/PostProcesses/postProcessManager" {
  16659. import { Nullable } from "babylonjs/types";
  16660. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16661. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16662. import { Scene } from "babylonjs/scene";
  16663. /**
  16664. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16665. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16666. */
  16667. export class PostProcessManager {
  16668. private _scene;
  16669. private _indexBuffer;
  16670. private _vertexBuffers;
  16671. /**
  16672. * Creates a new instance PostProcess
  16673. * @param scene The scene that the post process is associated with.
  16674. */
  16675. constructor(scene: Scene);
  16676. private _prepareBuffers;
  16677. private _buildIndexBuffer;
  16678. /**
  16679. * Rebuilds the vertex buffers of the manager.
  16680. * @hidden
  16681. */
  16682. _rebuild(): void;
  16683. /**
  16684. * Prepares a frame to be run through a post process.
  16685. * @param sourceTexture The input texture to the post procesess. (default: null)
  16686. * @param postProcesses An array of post processes to be run. (default: null)
  16687. * @returns True if the post processes were able to be run.
  16688. * @hidden
  16689. */
  16690. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16691. /**
  16692. * Manually render a set of post processes to a texture.
  16693. * @param postProcesses An array of post processes to be run.
  16694. * @param targetTexture The target texture to render to.
  16695. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16696. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16697. * @param lodLevel defines which lod of the texture to render to
  16698. */
  16699. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16700. /**
  16701. * Finalize the result of the output of the postprocesses.
  16702. * @param doNotPresent If true the result will not be displayed to the screen.
  16703. * @param targetTexture The target texture to render to.
  16704. * @param faceIndex The index of the face to bind the target texture to.
  16705. * @param postProcesses The array of post processes to render.
  16706. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16707. * @hidden
  16708. */
  16709. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16710. /**
  16711. * Disposes of the post process manager.
  16712. */
  16713. dispose(): void;
  16714. }
  16715. }
  16716. declare module "babylonjs/Misc/gradients" {
  16717. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16718. /** Interface used by value gradients (color, factor, ...) */
  16719. export interface IValueGradient {
  16720. /**
  16721. * Gets or sets the gradient value (between 0 and 1)
  16722. */
  16723. gradient: number;
  16724. }
  16725. /** Class used to store color4 gradient */
  16726. export class ColorGradient implements IValueGradient {
  16727. /**
  16728. * Gets or sets the gradient value (between 0 and 1)
  16729. */
  16730. gradient: number;
  16731. /**
  16732. * Gets or sets first associated color
  16733. */
  16734. color1: Color4;
  16735. /**
  16736. * Gets or sets second associated color
  16737. */
  16738. color2?: Color4;
  16739. /**
  16740. * Will get a color picked randomly between color1 and color2.
  16741. * If color2 is undefined then color1 will be used
  16742. * @param result defines the target Color4 to store the result in
  16743. */
  16744. getColorToRef(result: Color4): void;
  16745. }
  16746. /** Class used to store color 3 gradient */
  16747. export class Color3Gradient implements IValueGradient {
  16748. /**
  16749. * Gets or sets the gradient value (between 0 and 1)
  16750. */
  16751. gradient: number;
  16752. /**
  16753. * Gets or sets the associated color
  16754. */
  16755. color: Color3;
  16756. }
  16757. /** Class used to store factor gradient */
  16758. export class FactorGradient implements IValueGradient {
  16759. /**
  16760. * Gets or sets the gradient value (between 0 and 1)
  16761. */
  16762. gradient: number;
  16763. /**
  16764. * Gets or sets first associated factor
  16765. */
  16766. factor1: number;
  16767. /**
  16768. * Gets or sets second associated factor
  16769. */
  16770. factor2?: number;
  16771. /**
  16772. * Will get a number picked randomly between factor1 and factor2.
  16773. * If factor2 is undefined then factor1 will be used
  16774. * @returns the picked number
  16775. */
  16776. getFactor(): number;
  16777. }
  16778. /**
  16779. * Helper used to simplify some generic gradient tasks
  16780. */
  16781. export class GradientHelper {
  16782. /**
  16783. * Gets the current gradient from an array of IValueGradient
  16784. * @param ratio defines the current ratio to get
  16785. * @param gradients defines the array of IValueGradient
  16786. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16787. */
  16788. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16789. }
  16790. }
  16791. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16792. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16793. import { Nullable } from "babylonjs/types";
  16794. module "babylonjs/Engines/thinEngine" {
  16795. interface ThinEngine {
  16796. /**
  16797. * Creates a dynamic texture
  16798. * @param width defines the width of the texture
  16799. * @param height defines the height of the texture
  16800. * @param generateMipMaps defines if the engine should generate the mip levels
  16801. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16802. * @returns the dynamic texture inside an InternalTexture
  16803. */
  16804. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16805. /**
  16806. * Update the content of a dynamic texture
  16807. * @param texture defines the texture to update
  16808. * @param canvas defines the canvas containing the source
  16809. * @param invertY defines if data must be stored with Y axis inverted
  16810. * @param premulAlpha defines if alpha is stored as premultiplied
  16811. * @param format defines the format of the data
  16812. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16813. */
  16814. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16815. }
  16816. }
  16817. }
  16818. declare module "babylonjs/Misc/canvasGenerator" {
  16819. /**
  16820. * Helper class used to generate a canvas to manipulate images
  16821. */
  16822. export class CanvasGenerator {
  16823. /**
  16824. * Create a new canvas (or offscreen canvas depending on the context)
  16825. * @param width defines the expected width
  16826. * @param height defines the expected height
  16827. * @return a new canvas or offscreen canvas
  16828. */
  16829. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16830. }
  16831. }
  16832. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16833. import { Scene } from "babylonjs/scene";
  16834. import { Texture } from "babylonjs/Materials/Textures/texture";
  16835. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16836. /**
  16837. * A class extending Texture allowing drawing on a texture
  16838. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16839. */
  16840. export class DynamicTexture extends Texture {
  16841. private _generateMipMaps;
  16842. private _canvas;
  16843. private _context;
  16844. private _engine;
  16845. /**
  16846. * Creates a DynamicTexture
  16847. * @param name defines the name of the texture
  16848. * @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
  16849. * @param scene defines the scene where you want the texture
  16850. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16851. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16852. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16853. */
  16854. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16855. /**
  16856. * Get the current class name of the texture useful for serialization or dynamic coding.
  16857. * @returns "DynamicTexture"
  16858. */
  16859. getClassName(): string;
  16860. /**
  16861. * Gets the current state of canRescale
  16862. */
  16863. get canRescale(): boolean;
  16864. private _recreate;
  16865. /**
  16866. * Scales the texture
  16867. * @param ratio the scale factor to apply to both width and height
  16868. */
  16869. scale(ratio: number): void;
  16870. /**
  16871. * Resizes the texture
  16872. * @param width the new width
  16873. * @param height the new height
  16874. */
  16875. scaleTo(width: number, height: number): void;
  16876. /**
  16877. * Gets the context of the canvas used by the texture
  16878. * @returns the canvas context of the dynamic texture
  16879. */
  16880. getContext(): CanvasRenderingContext2D;
  16881. /**
  16882. * Clears the texture
  16883. */
  16884. clear(): void;
  16885. /**
  16886. * Updates the texture
  16887. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16888. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16889. */
  16890. update(invertY?: boolean, premulAlpha?: boolean): void;
  16891. /**
  16892. * Draws text onto the texture
  16893. * @param text defines the text to be drawn
  16894. * @param x defines the placement of the text from the left
  16895. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16896. * @param font defines the font to be used with font-style, font-size, font-name
  16897. * @param color defines the color used for the text
  16898. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16899. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16900. * @param update defines whether texture is immediately update (default is true)
  16901. */
  16902. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16903. /**
  16904. * Clones the texture
  16905. * @returns the clone of the texture.
  16906. */
  16907. clone(): DynamicTexture;
  16908. /**
  16909. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16910. * @returns a serialized dynamic texture object
  16911. */
  16912. serialize(): any;
  16913. /** @hidden */
  16914. _rebuild(): void;
  16915. }
  16916. }
  16917. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16918. import { Scene } from "babylonjs/scene";
  16919. import { ISceneComponent } from "babylonjs/sceneComponent";
  16920. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16921. module "babylonjs/abstractScene" {
  16922. interface AbstractScene {
  16923. /**
  16924. * The list of procedural textures added to the scene
  16925. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16926. */
  16927. proceduralTextures: Array<ProceduralTexture>;
  16928. }
  16929. }
  16930. /**
  16931. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16932. * in a given scene.
  16933. */
  16934. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16935. /**
  16936. * The component name helpfull to identify the component in the list of scene components.
  16937. */
  16938. readonly name: string;
  16939. /**
  16940. * The scene the component belongs to.
  16941. */
  16942. scene: Scene;
  16943. /**
  16944. * Creates a new instance of the component for the given scene
  16945. * @param scene Defines the scene to register the component in
  16946. */
  16947. constructor(scene: Scene);
  16948. /**
  16949. * Registers the component in a given scene
  16950. */
  16951. register(): void;
  16952. /**
  16953. * Rebuilds the elements related to this component in case of
  16954. * context lost for instance.
  16955. */
  16956. rebuild(): void;
  16957. /**
  16958. * Disposes the component and the associated ressources.
  16959. */
  16960. dispose(): void;
  16961. private _beforeClear;
  16962. }
  16963. }
  16964. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16965. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16966. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16967. module "babylonjs/Engines/thinEngine" {
  16968. interface ThinEngine {
  16969. /**
  16970. * Creates a new render target cube texture
  16971. * @param size defines the size of the texture
  16972. * @param options defines the options used to create the texture
  16973. * @returns a new render target cube texture stored in an InternalTexture
  16974. */
  16975. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16976. }
  16977. }
  16978. }
  16979. declare module "babylonjs/Shaders/procedural.vertex" {
  16980. /** @hidden */
  16981. export var proceduralVertexShader: {
  16982. name: string;
  16983. shader: string;
  16984. };
  16985. }
  16986. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16987. import { Observable } from "babylonjs/Misc/observable";
  16988. import { Nullable } from "babylonjs/types";
  16989. import { Scene } from "babylonjs/scene";
  16990. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16991. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16992. import { Effect } from "babylonjs/Materials/effect";
  16993. import { Texture } from "babylonjs/Materials/Textures/texture";
  16994. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16995. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16996. import "babylonjs/Shaders/procedural.vertex";
  16997. /**
  16998. * 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.
  16999. * This is the base class of any Procedural texture and contains most of the shareable code.
  17000. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17001. */
  17002. export class ProceduralTexture extends Texture {
  17003. isCube: boolean;
  17004. /**
  17005. * Define if the texture is enabled or not (disabled texture will not render)
  17006. */
  17007. isEnabled: boolean;
  17008. /**
  17009. * Define if the texture must be cleared before rendering (default is true)
  17010. */
  17011. autoClear: boolean;
  17012. /**
  17013. * Callback called when the texture is generated
  17014. */
  17015. onGenerated: () => void;
  17016. /**
  17017. * Event raised when the texture is generated
  17018. */
  17019. onGeneratedObservable: Observable<ProceduralTexture>;
  17020. /** @hidden */
  17021. _generateMipMaps: boolean;
  17022. /** @hidden **/
  17023. _effect: Effect;
  17024. /** @hidden */
  17025. _textures: {
  17026. [key: string]: Texture;
  17027. };
  17028. private _size;
  17029. private _currentRefreshId;
  17030. private _frameId;
  17031. private _refreshRate;
  17032. private _vertexBuffers;
  17033. private _indexBuffer;
  17034. private _uniforms;
  17035. private _samplers;
  17036. private _fragment;
  17037. private _floats;
  17038. private _ints;
  17039. private _floatsArrays;
  17040. private _colors3;
  17041. private _colors4;
  17042. private _vectors2;
  17043. private _vectors3;
  17044. private _matrices;
  17045. private _fallbackTexture;
  17046. private _fallbackTextureUsed;
  17047. private _engine;
  17048. private _cachedDefines;
  17049. private _contentUpdateId;
  17050. private _contentData;
  17051. /**
  17052. * Instantiates a new procedural texture.
  17053. * 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.
  17054. * This is the base class of any Procedural texture and contains most of the shareable code.
  17055. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17056. * @param name Define the name of the texture
  17057. * @param size Define the size of the texture to create
  17058. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17059. * @param scene Define the scene the texture belongs to
  17060. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17061. * @param generateMipMaps Define if the texture should creates mip maps or not
  17062. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17063. */
  17064. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17065. /**
  17066. * The effect that is created when initializing the post process.
  17067. * @returns The created effect corresponding the the postprocess.
  17068. */
  17069. getEffect(): Effect;
  17070. /**
  17071. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17072. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17073. */
  17074. getContent(): Nullable<ArrayBufferView>;
  17075. private _createIndexBuffer;
  17076. /** @hidden */
  17077. _rebuild(): void;
  17078. /**
  17079. * Resets the texture in order to recreate its associated resources.
  17080. * This can be called in case of context loss
  17081. */
  17082. reset(): void;
  17083. protected _getDefines(): string;
  17084. /**
  17085. * Is the texture ready to be used ? (rendered at least once)
  17086. * @returns true if ready, otherwise, false.
  17087. */
  17088. isReady(): boolean;
  17089. /**
  17090. * Resets the refresh counter of the texture and start bak from scratch.
  17091. * Could be useful to regenerate the texture if it is setup to render only once.
  17092. */
  17093. resetRefreshCounter(): void;
  17094. /**
  17095. * Set the fragment shader to use in order to render the texture.
  17096. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17097. */
  17098. setFragment(fragment: any): void;
  17099. /**
  17100. * Define the refresh rate of the texture or the rendering frequency.
  17101. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17102. */
  17103. get refreshRate(): number;
  17104. set refreshRate(value: number);
  17105. /** @hidden */
  17106. _shouldRender(): boolean;
  17107. /**
  17108. * Get the size the texture is rendering at.
  17109. * @returns the size (texture is always squared)
  17110. */
  17111. getRenderSize(): number;
  17112. /**
  17113. * Resize the texture to new value.
  17114. * @param size Define the new size the texture should have
  17115. * @param generateMipMaps Define whether the new texture should create mip maps
  17116. */
  17117. resize(size: number, generateMipMaps: boolean): void;
  17118. private _checkUniform;
  17119. /**
  17120. * Set a texture in the shader program used to render.
  17121. * @param name Define the name of the uniform samplers as defined in the shader
  17122. * @param texture Define the texture to bind to this sampler
  17123. * @return the texture itself allowing "fluent" like uniform updates
  17124. */
  17125. setTexture(name: string, texture: Texture): ProceduralTexture;
  17126. /**
  17127. * Set a float in the shader.
  17128. * @param name Define the name of the uniform as defined in the shader
  17129. * @param value Define the value to give to the uniform
  17130. * @return the texture itself allowing "fluent" like uniform updates
  17131. */
  17132. setFloat(name: string, value: number): ProceduralTexture;
  17133. /**
  17134. * Set a int in the shader.
  17135. * @param name Define the name of the uniform as defined in the shader
  17136. * @param value Define the value to give to the uniform
  17137. * @return the texture itself allowing "fluent" like uniform updates
  17138. */
  17139. setInt(name: string, value: number): ProceduralTexture;
  17140. /**
  17141. * Set an array of floats in the shader.
  17142. * @param name Define the name of the uniform as defined in the shader
  17143. * @param value Define the value to give to the uniform
  17144. * @return the texture itself allowing "fluent" like uniform updates
  17145. */
  17146. setFloats(name: string, value: number[]): ProceduralTexture;
  17147. /**
  17148. * Set a vec3 in the shader from a Color3.
  17149. * @param name Define the name of the uniform as defined in the shader
  17150. * @param value Define the value to give to the uniform
  17151. * @return the texture itself allowing "fluent" like uniform updates
  17152. */
  17153. setColor3(name: string, value: Color3): ProceduralTexture;
  17154. /**
  17155. * Set a vec4 in the shader from a Color4.
  17156. * @param name Define the name of the uniform as defined in the shader
  17157. * @param value Define the value to give to the uniform
  17158. * @return the texture itself allowing "fluent" like uniform updates
  17159. */
  17160. setColor4(name: string, value: Color4): ProceduralTexture;
  17161. /**
  17162. * Set a vec2 in the shader from a Vector2.
  17163. * @param name Define the name of the uniform as defined in the shader
  17164. * @param value Define the value to give to the uniform
  17165. * @return the texture itself allowing "fluent" like uniform updates
  17166. */
  17167. setVector2(name: string, value: Vector2): ProceduralTexture;
  17168. /**
  17169. * Set a vec3 in the shader from a Vector3.
  17170. * @param name Define the name of the uniform as defined in the shader
  17171. * @param value Define the value to give to the uniform
  17172. * @return the texture itself allowing "fluent" like uniform updates
  17173. */
  17174. setVector3(name: string, value: Vector3): ProceduralTexture;
  17175. /**
  17176. * Set a mat4 in the shader from a MAtrix.
  17177. * @param name Define the name of the uniform as defined in the shader
  17178. * @param value Define the value to give to the uniform
  17179. * @return the texture itself allowing "fluent" like uniform updates
  17180. */
  17181. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17182. /**
  17183. * Render the texture to its associated render target.
  17184. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17185. */
  17186. render(useCameraPostProcess?: boolean): void;
  17187. /**
  17188. * Clone the texture.
  17189. * @returns the cloned texture
  17190. */
  17191. clone(): ProceduralTexture;
  17192. /**
  17193. * Dispose the texture and release its asoociated resources.
  17194. */
  17195. dispose(): void;
  17196. }
  17197. }
  17198. declare module "babylonjs/Particles/baseParticleSystem" {
  17199. import { Nullable } from "babylonjs/types";
  17200. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17202. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17203. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17204. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17205. import { Scene } from "babylonjs/scene";
  17206. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17207. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17208. import { Texture } from "babylonjs/Materials/Textures/texture";
  17209. import { Color4 } from "babylonjs/Maths/math.color";
  17210. import { Animation } from "babylonjs/Animations/animation";
  17211. /**
  17212. * This represents the base class for particle system in Babylon.
  17213. * 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.
  17214. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17215. * @example https://doc.babylonjs.com/babylon101/particles
  17216. */
  17217. export class BaseParticleSystem {
  17218. /**
  17219. * Source color is added to the destination color without alpha affecting the result
  17220. */
  17221. static BLENDMODE_ONEONE: number;
  17222. /**
  17223. * Blend current color and particle color using particle’s alpha
  17224. */
  17225. static BLENDMODE_STANDARD: number;
  17226. /**
  17227. * Add current color and particle color multiplied by particle’s alpha
  17228. */
  17229. static BLENDMODE_ADD: number;
  17230. /**
  17231. * Multiply current color with particle color
  17232. */
  17233. static BLENDMODE_MULTIPLY: number;
  17234. /**
  17235. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17236. */
  17237. static BLENDMODE_MULTIPLYADD: number;
  17238. /**
  17239. * List of animations used by the particle system.
  17240. */
  17241. animations: Animation[];
  17242. /**
  17243. * The id of the Particle system.
  17244. */
  17245. id: string;
  17246. /**
  17247. * The friendly name of the Particle system.
  17248. */
  17249. name: string;
  17250. /**
  17251. * The rendering group used by the Particle system to chose when to render.
  17252. */
  17253. renderingGroupId: number;
  17254. /**
  17255. * The emitter represents the Mesh or position we are attaching the particle system to.
  17256. */
  17257. emitter: Nullable<AbstractMesh | Vector3>;
  17258. /**
  17259. * The maximum number of particles to emit per frame
  17260. */
  17261. emitRate: number;
  17262. /**
  17263. * If you want to launch only a few particles at once, that can be done, as well.
  17264. */
  17265. manualEmitCount: number;
  17266. /**
  17267. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17268. */
  17269. updateSpeed: number;
  17270. /**
  17271. * The amount of time the particle system is running (depends of the overall update speed).
  17272. */
  17273. targetStopDuration: number;
  17274. /**
  17275. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17276. */
  17277. disposeOnStop: boolean;
  17278. /**
  17279. * Minimum power of emitting particles.
  17280. */
  17281. minEmitPower: number;
  17282. /**
  17283. * Maximum power of emitting particles.
  17284. */
  17285. maxEmitPower: number;
  17286. /**
  17287. * Minimum life time of emitting particles.
  17288. */
  17289. minLifeTime: number;
  17290. /**
  17291. * Maximum life time of emitting particles.
  17292. */
  17293. maxLifeTime: number;
  17294. /**
  17295. * Minimum Size of emitting particles.
  17296. */
  17297. minSize: number;
  17298. /**
  17299. * Maximum Size of emitting particles.
  17300. */
  17301. maxSize: number;
  17302. /**
  17303. * Minimum scale of emitting particles on X axis.
  17304. */
  17305. minScaleX: number;
  17306. /**
  17307. * Maximum scale of emitting particles on X axis.
  17308. */
  17309. maxScaleX: number;
  17310. /**
  17311. * Minimum scale of emitting particles on Y axis.
  17312. */
  17313. minScaleY: number;
  17314. /**
  17315. * Maximum scale of emitting particles on Y axis.
  17316. */
  17317. maxScaleY: number;
  17318. /**
  17319. * Gets or sets the minimal initial rotation in radians.
  17320. */
  17321. minInitialRotation: number;
  17322. /**
  17323. * Gets or sets the maximal initial rotation in radians.
  17324. */
  17325. maxInitialRotation: number;
  17326. /**
  17327. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17328. */
  17329. minAngularSpeed: number;
  17330. /**
  17331. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17332. */
  17333. maxAngularSpeed: number;
  17334. /**
  17335. * The texture used to render each particle. (this can be a spritesheet)
  17336. */
  17337. particleTexture: Nullable<Texture>;
  17338. /**
  17339. * The layer mask we are rendering the particles through.
  17340. */
  17341. layerMask: number;
  17342. /**
  17343. * This can help using your own shader to render the particle system.
  17344. * The according effect will be created
  17345. */
  17346. customShader: any;
  17347. /**
  17348. * By default particle system starts as soon as they are created. This prevents the
  17349. * automatic start to happen and let you decide when to start emitting particles.
  17350. */
  17351. preventAutoStart: boolean;
  17352. private _noiseTexture;
  17353. /**
  17354. * Gets or sets a texture used to add random noise to particle positions
  17355. */
  17356. get noiseTexture(): Nullable<ProceduralTexture>;
  17357. set noiseTexture(value: Nullable<ProceduralTexture>);
  17358. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17359. noiseStrength: Vector3;
  17360. /**
  17361. * Callback triggered when the particle animation is ending.
  17362. */
  17363. onAnimationEnd: Nullable<() => void>;
  17364. /**
  17365. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17366. */
  17367. blendMode: number;
  17368. /**
  17369. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17370. * to override the particles.
  17371. */
  17372. forceDepthWrite: boolean;
  17373. /** 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 */
  17374. preWarmCycles: number;
  17375. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17376. preWarmStepOffset: number;
  17377. /**
  17378. * 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)
  17379. */
  17380. spriteCellChangeSpeed: number;
  17381. /**
  17382. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17383. */
  17384. startSpriteCellID: number;
  17385. /**
  17386. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17387. */
  17388. endSpriteCellID: number;
  17389. /**
  17390. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17391. */
  17392. spriteCellWidth: number;
  17393. /**
  17394. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17395. */
  17396. spriteCellHeight: number;
  17397. /**
  17398. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17399. */
  17400. spriteRandomStartCell: boolean;
  17401. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17402. translationPivot: Vector2;
  17403. /** @hidden */
  17404. protected _isAnimationSheetEnabled: boolean;
  17405. /**
  17406. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17407. */
  17408. beginAnimationOnStart: boolean;
  17409. /**
  17410. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17411. */
  17412. beginAnimationFrom: number;
  17413. /**
  17414. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17415. */
  17416. beginAnimationTo: number;
  17417. /**
  17418. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17419. */
  17420. beginAnimationLoop: boolean;
  17421. /**
  17422. * Gets or sets a world offset applied to all particles
  17423. */
  17424. worldOffset: Vector3;
  17425. /**
  17426. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17427. */
  17428. get isAnimationSheetEnabled(): boolean;
  17429. set isAnimationSheetEnabled(value: boolean);
  17430. /**
  17431. * Get hosting scene
  17432. * @returns the scene
  17433. */
  17434. getScene(): Scene;
  17435. /**
  17436. * You can use gravity if you want to give an orientation to your particles.
  17437. */
  17438. gravity: Vector3;
  17439. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17440. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17441. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17442. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17443. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17444. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17445. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17446. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17447. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17448. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17449. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17450. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17451. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17452. /**
  17453. * Defines the delay in milliseconds before starting the system (0 by default)
  17454. */
  17455. startDelay: number;
  17456. /**
  17457. * Gets the current list of drag gradients.
  17458. * You must use addDragGradient and removeDragGradient to udpate this list
  17459. * @returns the list of drag gradients
  17460. */
  17461. getDragGradients(): Nullable<Array<FactorGradient>>;
  17462. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17463. limitVelocityDamping: number;
  17464. /**
  17465. * Gets the current list of limit velocity gradients.
  17466. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17467. * @returns the list of limit velocity gradients
  17468. */
  17469. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17470. /**
  17471. * Gets the current list of color gradients.
  17472. * You must use addColorGradient and removeColorGradient to udpate this list
  17473. * @returns the list of color gradients
  17474. */
  17475. getColorGradients(): Nullable<Array<ColorGradient>>;
  17476. /**
  17477. * Gets the current list of size gradients.
  17478. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17479. * @returns the list of size gradients
  17480. */
  17481. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17482. /**
  17483. * Gets the current list of color remap gradients.
  17484. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17485. * @returns the list of color remap gradients
  17486. */
  17487. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17488. /**
  17489. * Gets the current list of alpha remap gradients.
  17490. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17491. * @returns the list of alpha remap gradients
  17492. */
  17493. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17494. /**
  17495. * Gets the current list of life time gradients.
  17496. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17497. * @returns the list of life time gradients
  17498. */
  17499. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17500. /**
  17501. * Gets the current list of angular speed gradients.
  17502. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17503. * @returns the list of angular speed gradients
  17504. */
  17505. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17506. /**
  17507. * Gets the current list of velocity gradients.
  17508. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17509. * @returns the list of velocity gradients
  17510. */
  17511. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17512. /**
  17513. * Gets the current list of start size gradients.
  17514. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17515. * @returns the list of start size gradients
  17516. */
  17517. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17518. /**
  17519. * Gets the current list of emit rate gradients.
  17520. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17521. * @returns the list of emit rate gradients
  17522. */
  17523. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17524. /**
  17525. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17526. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17527. */
  17528. get direction1(): Vector3;
  17529. set direction1(value: Vector3);
  17530. /**
  17531. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17532. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17533. */
  17534. get direction2(): Vector3;
  17535. set direction2(value: Vector3);
  17536. /**
  17537. * 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.
  17538. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17539. */
  17540. get minEmitBox(): Vector3;
  17541. set minEmitBox(value: Vector3);
  17542. /**
  17543. * 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.
  17544. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17545. */
  17546. get maxEmitBox(): Vector3;
  17547. set maxEmitBox(value: Vector3);
  17548. /**
  17549. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17550. */
  17551. color1: Color4;
  17552. /**
  17553. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17554. */
  17555. color2: Color4;
  17556. /**
  17557. * Color the particle will have at the end of its lifetime
  17558. */
  17559. colorDead: Color4;
  17560. /**
  17561. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17562. */
  17563. textureMask: Color4;
  17564. /**
  17565. * The particle emitter type defines the emitter used by the particle system.
  17566. * It can be for example box, sphere, or cone...
  17567. */
  17568. particleEmitterType: IParticleEmitterType;
  17569. /** @hidden */
  17570. _isSubEmitter: boolean;
  17571. /**
  17572. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17573. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17574. */
  17575. billboardMode: number;
  17576. protected _isBillboardBased: boolean;
  17577. /**
  17578. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17579. */
  17580. get isBillboardBased(): boolean;
  17581. set isBillboardBased(value: boolean);
  17582. /**
  17583. * The scene the particle system belongs to.
  17584. */
  17585. protected _scene: Scene;
  17586. /**
  17587. * Local cache of defines for image processing.
  17588. */
  17589. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17590. /**
  17591. * Default configuration related to image processing available in the standard Material.
  17592. */
  17593. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17594. /**
  17595. * Gets the image processing configuration used either in this material.
  17596. */
  17597. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17598. /**
  17599. * Sets the Default image processing configuration used either in the this material.
  17600. *
  17601. * If sets to null, the scene one is in use.
  17602. */
  17603. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17604. /**
  17605. * Attaches a new image processing configuration to the Standard Material.
  17606. * @param configuration
  17607. */
  17608. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17609. /** @hidden */
  17610. protected _reset(): void;
  17611. /** @hidden */
  17612. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17613. /**
  17614. * Instantiates a particle system.
  17615. * 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.
  17616. * @param name The name of the particle system
  17617. */
  17618. constructor(name: string);
  17619. /**
  17620. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17621. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17622. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17623. * @returns the emitter
  17624. */
  17625. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17626. /**
  17627. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17628. * @param radius The radius of the hemisphere to emit from
  17629. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17630. * @returns the emitter
  17631. */
  17632. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17633. /**
  17634. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17635. * @param radius The radius of the sphere to emit from
  17636. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17637. * @returns the emitter
  17638. */
  17639. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17640. /**
  17641. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17642. * @param radius The radius of the sphere to emit from
  17643. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17644. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17645. * @returns the emitter
  17646. */
  17647. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17648. /**
  17649. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17650. * @param radius The radius of the emission cylinder
  17651. * @param height The height of the emission cylinder
  17652. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17653. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17654. * @returns the emitter
  17655. */
  17656. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17657. /**
  17658. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17659. * @param radius The radius of the cylinder to emit from
  17660. * @param height The height of the emission cylinder
  17661. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17662. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17663. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17664. * @returns the emitter
  17665. */
  17666. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17667. /**
  17668. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17669. * @param radius The radius of the cone to emit from
  17670. * @param angle The base angle of the cone
  17671. * @returns the emitter
  17672. */
  17673. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17674. /**
  17675. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17678. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17679. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17680. * @returns the emitter
  17681. */
  17682. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17683. }
  17684. }
  17685. declare module "babylonjs/Particles/subEmitter" {
  17686. import { Scene } from "babylonjs/scene";
  17687. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17688. /**
  17689. * Type of sub emitter
  17690. */
  17691. export enum SubEmitterType {
  17692. /**
  17693. * Attached to the particle over it's lifetime
  17694. */
  17695. ATTACHED = 0,
  17696. /**
  17697. * Created when the particle dies
  17698. */
  17699. END = 1
  17700. }
  17701. /**
  17702. * Sub emitter class used to emit particles from an existing particle
  17703. */
  17704. export class SubEmitter {
  17705. /**
  17706. * the particle system to be used by the sub emitter
  17707. */
  17708. particleSystem: ParticleSystem;
  17709. /**
  17710. * Type of the submitter (Default: END)
  17711. */
  17712. type: SubEmitterType;
  17713. /**
  17714. * 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)
  17715. * Note: This only is supported when using an emitter of type Mesh
  17716. */
  17717. inheritDirection: boolean;
  17718. /**
  17719. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17720. */
  17721. inheritedVelocityAmount: number;
  17722. /**
  17723. * Creates a sub emitter
  17724. * @param particleSystem the particle system to be used by the sub emitter
  17725. */
  17726. constructor(
  17727. /**
  17728. * the particle system to be used by the sub emitter
  17729. */
  17730. particleSystem: ParticleSystem);
  17731. /**
  17732. * Clones the sub emitter
  17733. * @returns the cloned sub emitter
  17734. */
  17735. clone(): SubEmitter;
  17736. /**
  17737. * Serialize current object to a JSON object
  17738. * @returns the serialized object
  17739. */
  17740. serialize(): any;
  17741. /** @hidden */
  17742. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17743. /**
  17744. * Creates a new SubEmitter from a serialized JSON version
  17745. * @param serializationObject defines the JSON object to read from
  17746. * @param scene defines the hosting scene
  17747. * @param rootUrl defines the rootUrl for data loading
  17748. * @returns a new SubEmitter
  17749. */
  17750. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17751. /** Release associated resources */
  17752. dispose(): void;
  17753. }
  17754. }
  17755. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17756. /** @hidden */
  17757. export var clipPlaneFragmentDeclaration: {
  17758. name: string;
  17759. shader: string;
  17760. };
  17761. }
  17762. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17763. /** @hidden */
  17764. export var imageProcessingDeclaration: {
  17765. name: string;
  17766. shader: string;
  17767. };
  17768. }
  17769. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17770. /** @hidden */
  17771. export var imageProcessingFunctions: {
  17772. name: string;
  17773. shader: string;
  17774. };
  17775. }
  17776. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17777. /** @hidden */
  17778. export var clipPlaneFragment: {
  17779. name: string;
  17780. shader: string;
  17781. };
  17782. }
  17783. declare module "babylonjs/Shaders/particles.fragment" {
  17784. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17785. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17786. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17787. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17788. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17789. /** @hidden */
  17790. export var particlesPixelShader: {
  17791. name: string;
  17792. shader: string;
  17793. };
  17794. }
  17795. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17796. /** @hidden */
  17797. export var clipPlaneVertexDeclaration: {
  17798. name: string;
  17799. shader: string;
  17800. };
  17801. }
  17802. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17803. /** @hidden */
  17804. export var clipPlaneVertex: {
  17805. name: string;
  17806. shader: string;
  17807. };
  17808. }
  17809. declare module "babylonjs/Shaders/particles.vertex" {
  17810. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17811. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17812. /** @hidden */
  17813. export var particlesVertexShader: {
  17814. name: string;
  17815. shader: string;
  17816. };
  17817. }
  17818. declare module "babylonjs/Particles/particleSystem" {
  17819. import { Nullable } from "babylonjs/types";
  17820. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17821. import { Observable } from "babylonjs/Misc/observable";
  17822. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17823. import { Effect } from "babylonjs/Materials/effect";
  17824. import { Scene, IDisposable } from "babylonjs/scene";
  17825. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17826. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17827. import { Particle } from "babylonjs/Particles/particle";
  17828. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17829. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17830. import "babylonjs/Shaders/particles.fragment";
  17831. import "babylonjs/Shaders/particles.vertex";
  17832. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17833. /**
  17834. * This represents a particle system in Babylon.
  17835. * 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.
  17836. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17837. * @example https://doc.babylonjs.com/babylon101/particles
  17838. */
  17839. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17840. /**
  17841. * Billboard mode will only apply to Y axis
  17842. */
  17843. static readonly BILLBOARDMODE_Y: number;
  17844. /**
  17845. * Billboard mode will apply to all axes
  17846. */
  17847. static readonly BILLBOARDMODE_ALL: number;
  17848. /**
  17849. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17850. */
  17851. static readonly BILLBOARDMODE_STRETCHED: number;
  17852. /**
  17853. * This function can be defined to provide custom update for active particles.
  17854. * This function will be called instead of regular update (age, position, color, etc.).
  17855. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17856. */
  17857. updateFunction: (particles: Particle[]) => void;
  17858. private _emitterWorldMatrix;
  17859. /**
  17860. * This function can be defined to specify initial direction for every new particle.
  17861. * It by default use the emitterType defined function
  17862. */
  17863. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17864. /**
  17865. * This function can be defined to specify initial position for every new particle.
  17866. * It by default use the emitterType defined function
  17867. */
  17868. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17869. /**
  17870. * @hidden
  17871. */
  17872. _inheritedVelocityOffset: Vector3;
  17873. /**
  17874. * An event triggered when the system is disposed
  17875. */
  17876. onDisposeObservable: Observable<ParticleSystem>;
  17877. private _onDisposeObserver;
  17878. /**
  17879. * Sets a callback that will be triggered when the system is disposed
  17880. */
  17881. set onDispose(callback: () => void);
  17882. private _particles;
  17883. private _epsilon;
  17884. private _capacity;
  17885. private _stockParticles;
  17886. private _newPartsExcess;
  17887. private _vertexData;
  17888. private _vertexBuffer;
  17889. private _vertexBuffers;
  17890. private _spriteBuffer;
  17891. private _indexBuffer;
  17892. private _effect;
  17893. private _customEffect;
  17894. private _cachedDefines;
  17895. private _scaledColorStep;
  17896. private _colorDiff;
  17897. private _scaledDirection;
  17898. private _scaledGravity;
  17899. private _currentRenderId;
  17900. private _alive;
  17901. private _useInstancing;
  17902. private _started;
  17903. private _stopped;
  17904. private _actualFrame;
  17905. private _scaledUpdateSpeed;
  17906. private _vertexBufferSize;
  17907. /** @hidden */
  17908. _currentEmitRateGradient: Nullable<FactorGradient>;
  17909. /** @hidden */
  17910. _currentEmitRate1: number;
  17911. /** @hidden */
  17912. _currentEmitRate2: number;
  17913. /** @hidden */
  17914. _currentStartSizeGradient: Nullable<FactorGradient>;
  17915. /** @hidden */
  17916. _currentStartSize1: number;
  17917. /** @hidden */
  17918. _currentStartSize2: number;
  17919. private readonly _rawTextureWidth;
  17920. private _rampGradientsTexture;
  17921. private _useRampGradients;
  17922. /** Gets or sets a boolean indicating that ramp gradients must be used
  17923. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17924. */
  17925. get useRampGradients(): boolean;
  17926. set useRampGradients(value: boolean);
  17927. /**
  17928. * 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.
  17929. * 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: [])
  17930. */
  17931. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17932. private _subEmitters;
  17933. /**
  17934. * @hidden
  17935. * If the particle systems emitter should be disposed when the particle system is disposed
  17936. */
  17937. _disposeEmitterOnDispose: boolean;
  17938. /**
  17939. * The current active Sub-systems, this property is used by the root particle system only.
  17940. */
  17941. activeSubSystems: Array<ParticleSystem>;
  17942. private _rootParticleSystem;
  17943. /**
  17944. * Gets the current list of active particles
  17945. */
  17946. get particles(): Particle[];
  17947. /**
  17948. * Returns the string "ParticleSystem"
  17949. * @returns a string containing the class name
  17950. */
  17951. getClassName(): string;
  17952. /**
  17953. * Instantiates a particle system.
  17954. * 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.
  17955. * @param name The name of the particle system
  17956. * @param capacity The max number of particles alive at the same time
  17957. * @param scene The scene the particle system belongs to
  17958. * @param customEffect a custom effect used to change the way particles are rendered by default
  17959. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17960. * @param epsilon Offset used to render the particles
  17961. */
  17962. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17963. private _addFactorGradient;
  17964. private _removeFactorGradient;
  17965. /**
  17966. * Adds a new life time gradient
  17967. * @param gradient defines the gradient to use (between 0 and 1)
  17968. * @param factor defines the life time factor to affect to the specified gradient
  17969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17970. * @returns the current particle system
  17971. */
  17972. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17973. /**
  17974. * Remove a specific life time gradient
  17975. * @param gradient defines the gradient to remove
  17976. * @returns the current particle system
  17977. */
  17978. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17979. /**
  17980. * Adds a new size gradient
  17981. * @param gradient defines the gradient to use (between 0 and 1)
  17982. * @param factor defines the size factor to affect to the specified gradient
  17983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17984. * @returns the current particle system
  17985. */
  17986. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17987. /**
  17988. * Remove a specific size gradient
  17989. * @param gradient defines the gradient to remove
  17990. * @returns the current particle system
  17991. */
  17992. removeSizeGradient(gradient: number): IParticleSystem;
  17993. /**
  17994. * Adds a new color remap gradient
  17995. * @param gradient defines the gradient to use (between 0 and 1)
  17996. * @param min defines the color remap minimal range
  17997. * @param max defines the color remap maximal range
  17998. * @returns the current particle system
  17999. */
  18000. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18001. /**
  18002. * Remove a specific color remap gradient
  18003. * @param gradient defines the gradient to remove
  18004. * @returns the current particle system
  18005. */
  18006. removeColorRemapGradient(gradient: number): IParticleSystem;
  18007. /**
  18008. * Adds a new alpha remap gradient
  18009. * @param gradient defines the gradient to use (between 0 and 1)
  18010. * @param min defines the alpha remap minimal range
  18011. * @param max defines the alpha remap maximal range
  18012. * @returns the current particle system
  18013. */
  18014. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18015. /**
  18016. * Remove a specific alpha remap gradient
  18017. * @param gradient defines the gradient to remove
  18018. * @returns the current particle system
  18019. */
  18020. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18021. /**
  18022. * Adds a new angular speed gradient
  18023. * @param gradient defines the gradient to use (between 0 and 1)
  18024. * @param factor defines the angular speed to affect to the specified gradient
  18025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18026. * @returns the current particle system
  18027. */
  18028. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18029. /**
  18030. * Remove a specific angular speed gradient
  18031. * @param gradient defines the gradient to remove
  18032. * @returns the current particle system
  18033. */
  18034. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18035. /**
  18036. * Adds a new velocity gradient
  18037. * @param gradient defines the gradient to use (between 0 and 1)
  18038. * @param factor defines the velocity to affect to the specified gradient
  18039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18040. * @returns the current particle system
  18041. */
  18042. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18043. /**
  18044. * Remove a specific velocity gradient
  18045. * @param gradient defines the gradient to remove
  18046. * @returns the current particle system
  18047. */
  18048. removeVelocityGradient(gradient: number): IParticleSystem;
  18049. /**
  18050. * Adds a new limit velocity gradient
  18051. * @param gradient defines the gradient to use (between 0 and 1)
  18052. * @param factor defines the limit velocity value to affect to the specified gradient
  18053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18054. * @returns the current particle system
  18055. */
  18056. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18057. /**
  18058. * Remove a specific limit velocity gradient
  18059. * @param gradient defines the gradient to remove
  18060. * @returns the current particle system
  18061. */
  18062. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18063. /**
  18064. * Adds a new drag gradient
  18065. * @param gradient defines the gradient to use (between 0 and 1)
  18066. * @param factor defines the drag value to affect to the specified gradient
  18067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18068. * @returns the current particle system
  18069. */
  18070. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18071. /**
  18072. * Remove a specific drag gradient
  18073. * @param gradient defines the gradient to remove
  18074. * @returns the current particle system
  18075. */
  18076. removeDragGradient(gradient: number): IParticleSystem;
  18077. /**
  18078. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18079. * @param gradient defines the gradient to use (between 0 and 1)
  18080. * @param factor defines the emit rate value to affect to the specified gradient
  18081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18082. * @returns the current particle system
  18083. */
  18084. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18085. /**
  18086. * Remove a specific emit rate gradient
  18087. * @param gradient defines the gradient to remove
  18088. * @returns the current particle system
  18089. */
  18090. removeEmitRateGradient(gradient: number): IParticleSystem;
  18091. /**
  18092. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18093. * @param gradient defines the gradient to use (between 0 and 1)
  18094. * @param factor defines the start size value to affect to the specified gradient
  18095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18096. * @returns the current particle system
  18097. */
  18098. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18099. /**
  18100. * Remove a specific start size gradient
  18101. * @param gradient defines the gradient to remove
  18102. * @returns the current particle system
  18103. */
  18104. removeStartSizeGradient(gradient: number): IParticleSystem;
  18105. private _createRampGradientTexture;
  18106. /**
  18107. * Gets the current list of ramp gradients.
  18108. * You must use addRampGradient and removeRampGradient to udpate this list
  18109. * @returns the list of ramp gradients
  18110. */
  18111. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18112. /**
  18113. * Adds a new ramp gradient used to remap particle colors
  18114. * @param gradient defines the gradient to use (between 0 and 1)
  18115. * @param color defines the color to affect to the specified gradient
  18116. * @returns the current particle system
  18117. */
  18118. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18119. /**
  18120. * Remove a specific ramp gradient
  18121. * @param gradient defines the gradient to remove
  18122. * @returns the current particle system
  18123. */
  18124. removeRampGradient(gradient: number): ParticleSystem;
  18125. /**
  18126. * Adds a new color gradient
  18127. * @param gradient defines the gradient to use (between 0 and 1)
  18128. * @param color1 defines the color to affect to the specified gradient
  18129. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18130. * @returns this particle system
  18131. */
  18132. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18133. /**
  18134. * Remove a specific color gradient
  18135. * @param gradient defines the gradient to remove
  18136. * @returns this particle system
  18137. */
  18138. removeColorGradient(gradient: number): IParticleSystem;
  18139. private _fetchR;
  18140. protected _reset(): void;
  18141. private _resetEffect;
  18142. private _createVertexBuffers;
  18143. private _createIndexBuffer;
  18144. /**
  18145. * Gets the maximum number of particles active at the same time.
  18146. * @returns The max number of active particles.
  18147. */
  18148. getCapacity(): number;
  18149. /**
  18150. * Gets whether there are still active particles in the system.
  18151. * @returns True if it is alive, otherwise false.
  18152. */
  18153. isAlive(): boolean;
  18154. /**
  18155. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18156. * @returns True if it has been started, otherwise false.
  18157. */
  18158. isStarted(): boolean;
  18159. private _prepareSubEmitterInternalArray;
  18160. /**
  18161. * Starts the particle system and begins to emit
  18162. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18163. */
  18164. start(delay?: number): void;
  18165. /**
  18166. * Stops the particle system.
  18167. * @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.
  18168. */
  18169. stop(stopSubEmitters?: boolean): void;
  18170. /**
  18171. * Remove all active particles
  18172. */
  18173. reset(): void;
  18174. /**
  18175. * @hidden (for internal use only)
  18176. */
  18177. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18178. /**
  18179. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18180. * Its lifetime will start back at 0.
  18181. */
  18182. recycleParticle: (particle: Particle) => void;
  18183. private _stopSubEmitters;
  18184. private _createParticle;
  18185. private _removeFromRoot;
  18186. private _emitFromParticle;
  18187. private _update;
  18188. /** @hidden */
  18189. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18190. /** @hidden */
  18191. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18192. /** @hidden */
  18193. private _getEffect;
  18194. /**
  18195. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18196. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18197. */
  18198. animate(preWarmOnly?: boolean): void;
  18199. private _appendParticleVertices;
  18200. /**
  18201. * Rebuilds the particle system.
  18202. */
  18203. rebuild(): void;
  18204. /**
  18205. * Is this system ready to be used/rendered
  18206. * @return true if the system is ready
  18207. */
  18208. isReady(): boolean;
  18209. private _render;
  18210. /**
  18211. * Renders the particle system in its current state.
  18212. * @returns the current number of particles
  18213. */
  18214. render(): number;
  18215. /**
  18216. * Disposes the particle system and free the associated resources
  18217. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18218. */
  18219. dispose(disposeTexture?: boolean): void;
  18220. /**
  18221. * Clones the particle system.
  18222. * @param name The name of the cloned object
  18223. * @param newEmitter The new emitter to use
  18224. * @returns the cloned particle system
  18225. */
  18226. clone(name: string, newEmitter: any): ParticleSystem;
  18227. /**
  18228. * Serializes the particle system to a JSON object.
  18229. * @returns the JSON object
  18230. */
  18231. serialize(): any;
  18232. /** @hidden */
  18233. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18234. /** @hidden */
  18235. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18236. /**
  18237. * Parses a JSON object to create a particle system.
  18238. * @param parsedParticleSystem The JSON object to parse
  18239. * @param scene The scene to create the particle system in
  18240. * @param rootUrl The root url to use to load external dependencies like texture
  18241. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18242. * @returns the Parsed particle system
  18243. */
  18244. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18245. }
  18246. }
  18247. declare module "babylonjs/Particles/particle" {
  18248. import { Nullable } from "babylonjs/types";
  18249. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18250. import { Color4 } from "babylonjs/Maths/math.color";
  18251. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18252. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18253. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18254. /**
  18255. * A particle represents one of the element emitted by a particle system.
  18256. * This is mainly define by its coordinates, direction, velocity and age.
  18257. */
  18258. export class Particle {
  18259. /**
  18260. * The particle system the particle belongs to.
  18261. */
  18262. particleSystem: ParticleSystem;
  18263. private static _Count;
  18264. /**
  18265. * Unique ID of the particle
  18266. */
  18267. id: number;
  18268. /**
  18269. * The world position of the particle in the scene.
  18270. */
  18271. position: Vector3;
  18272. /**
  18273. * The world direction of the particle in the scene.
  18274. */
  18275. direction: Vector3;
  18276. /**
  18277. * The color of the particle.
  18278. */
  18279. color: Color4;
  18280. /**
  18281. * The color change of the particle per step.
  18282. */
  18283. colorStep: Color4;
  18284. /**
  18285. * Defines how long will the life of the particle be.
  18286. */
  18287. lifeTime: number;
  18288. /**
  18289. * The current age of the particle.
  18290. */
  18291. age: number;
  18292. /**
  18293. * The current size of the particle.
  18294. */
  18295. size: number;
  18296. /**
  18297. * The current scale of the particle.
  18298. */
  18299. scale: Vector2;
  18300. /**
  18301. * The current angle of the particle.
  18302. */
  18303. angle: number;
  18304. /**
  18305. * Defines how fast is the angle changing.
  18306. */
  18307. angularSpeed: number;
  18308. /**
  18309. * Defines the cell index used by the particle to be rendered from a sprite.
  18310. */
  18311. cellIndex: number;
  18312. /**
  18313. * The information required to support color remapping
  18314. */
  18315. remapData: Vector4;
  18316. /** @hidden */
  18317. _randomCellOffset?: number;
  18318. /** @hidden */
  18319. _initialDirection: Nullable<Vector3>;
  18320. /** @hidden */
  18321. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18322. /** @hidden */
  18323. _initialStartSpriteCellID: number;
  18324. /** @hidden */
  18325. _initialEndSpriteCellID: number;
  18326. /** @hidden */
  18327. _currentColorGradient: Nullable<ColorGradient>;
  18328. /** @hidden */
  18329. _currentColor1: Color4;
  18330. /** @hidden */
  18331. _currentColor2: Color4;
  18332. /** @hidden */
  18333. _currentSizeGradient: Nullable<FactorGradient>;
  18334. /** @hidden */
  18335. _currentSize1: number;
  18336. /** @hidden */
  18337. _currentSize2: number;
  18338. /** @hidden */
  18339. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18340. /** @hidden */
  18341. _currentAngularSpeed1: number;
  18342. /** @hidden */
  18343. _currentAngularSpeed2: number;
  18344. /** @hidden */
  18345. _currentVelocityGradient: Nullable<FactorGradient>;
  18346. /** @hidden */
  18347. _currentVelocity1: number;
  18348. /** @hidden */
  18349. _currentVelocity2: number;
  18350. /** @hidden */
  18351. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18352. /** @hidden */
  18353. _currentLimitVelocity1: number;
  18354. /** @hidden */
  18355. _currentLimitVelocity2: number;
  18356. /** @hidden */
  18357. _currentDragGradient: Nullable<FactorGradient>;
  18358. /** @hidden */
  18359. _currentDrag1: number;
  18360. /** @hidden */
  18361. _currentDrag2: number;
  18362. /** @hidden */
  18363. _randomNoiseCoordinates1: Vector3;
  18364. /** @hidden */
  18365. _randomNoiseCoordinates2: Vector3;
  18366. /**
  18367. * Creates a new instance Particle
  18368. * @param particleSystem the particle system the particle belongs to
  18369. */
  18370. constructor(
  18371. /**
  18372. * The particle system the particle belongs to.
  18373. */
  18374. particleSystem: ParticleSystem);
  18375. private updateCellInfoFromSystem;
  18376. /**
  18377. * Defines how the sprite cell index is updated for the particle
  18378. */
  18379. updateCellIndex(): void;
  18380. /** @hidden */
  18381. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18382. /** @hidden */
  18383. _inheritParticleInfoToSubEmitters(): void;
  18384. /** @hidden */
  18385. _reset(): void;
  18386. /**
  18387. * Copy the properties of particle to another one.
  18388. * @param other the particle to copy the information to.
  18389. */
  18390. copyTo(other: Particle): void;
  18391. }
  18392. }
  18393. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18394. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18395. import { Effect } from "babylonjs/Materials/effect";
  18396. import { Particle } from "babylonjs/Particles/particle";
  18397. /**
  18398. * Particle emitter represents a volume emitting particles.
  18399. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18400. */
  18401. export interface IParticleEmitterType {
  18402. /**
  18403. * Called by the particle System when the direction is computed for the created particle.
  18404. * @param worldMatrix is the world matrix of the particle system
  18405. * @param directionToUpdate is the direction vector to update with the result
  18406. * @param particle is the particle we are computed the direction for
  18407. */
  18408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18409. /**
  18410. * Called by the particle System when the position is computed for the created particle.
  18411. * @param worldMatrix is the world matrix of the particle system
  18412. * @param positionToUpdate is the position vector to update with the result
  18413. * @param particle is the particle we are computed the position for
  18414. */
  18415. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18416. /**
  18417. * Clones the current emitter and returns a copy of it
  18418. * @returns the new emitter
  18419. */
  18420. clone(): IParticleEmitterType;
  18421. /**
  18422. * Called by the GPUParticleSystem to setup the update shader
  18423. * @param effect defines the update shader
  18424. */
  18425. applyToShader(effect: Effect): void;
  18426. /**
  18427. * Returns a string to use to update the GPU particles update shader
  18428. * @returns the effect defines string
  18429. */
  18430. getEffectDefines(): string;
  18431. /**
  18432. * Returns a string representing the class name
  18433. * @returns a string containing the class name
  18434. */
  18435. getClassName(): string;
  18436. /**
  18437. * Serializes the particle system to a JSON object.
  18438. * @returns the JSON object
  18439. */
  18440. serialize(): any;
  18441. /**
  18442. * Parse properties from a JSON object
  18443. * @param serializationObject defines the JSON object
  18444. */
  18445. parse(serializationObject: any): void;
  18446. }
  18447. }
  18448. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18449. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18450. import { Effect } from "babylonjs/Materials/effect";
  18451. import { Particle } from "babylonjs/Particles/particle";
  18452. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18453. /**
  18454. * Particle emitter emitting particles from the inside of a box.
  18455. * It emits the particles randomly between 2 given directions.
  18456. */
  18457. export class BoxParticleEmitter implements IParticleEmitterType {
  18458. /**
  18459. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18460. */
  18461. direction1: Vector3;
  18462. /**
  18463. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18464. */
  18465. direction2: Vector3;
  18466. /**
  18467. * 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.
  18468. */
  18469. minEmitBox: Vector3;
  18470. /**
  18471. * 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.
  18472. */
  18473. maxEmitBox: Vector3;
  18474. /**
  18475. * Creates a new instance BoxParticleEmitter
  18476. */
  18477. constructor();
  18478. /**
  18479. * Called by the particle System when the direction is computed for the created particle.
  18480. * @param worldMatrix is the world matrix of the particle system
  18481. * @param directionToUpdate is the direction vector to update with the result
  18482. * @param particle is the particle we are computed the direction for
  18483. */
  18484. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18485. /**
  18486. * Called by the particle System when the position is computed for the created particle.
  18487. * @param worldMatrix is the world matrix of the particle system
  18488. * @param positionToUpdate is the position vector to update with the result
  18489. * @param particle is the particle we are computed the position for
  18490. */
  18491. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18492. /**
  18493. * Clones the current emitter and returns a copy of it
  18494. * @returns the new emitter
  18495. */
  18496. clone(): BoxParticleEmitter;
  18497. /**
  18498. * Called by the GPUParticleSystem to setup the update shader
  18499. * @param effect defines the update shader
  18500. */
  18501. applyToShader(effect: Effect): void;
  18502. /**
  18503. * Returns a string to use to update the GPU particles update shader
  18504. * @returns a string containng the defines string
  18505. */
  18506. getEffectDefines(): string;
  18507. /**
  18508. * Returns the string "BoxParticleEmitter"
  18509. * @returns a string containing the class name
  18510. */
  18511. getClassName(): string;
  18512. /**
  18513. * Serializes the particle system to a JSON object.
  18514. * @returns the JSON object
  18515. */
  18516. serialize(): any;
  18517. /**
  18518. * Parse properties from a JSON object
  18519. * @param serializationObject defines the JSON object
  18520. */
  18521. parse(serializationObject: any): void;
  18522. }
  18523. }
  18524. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18525. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18526. import { Effect } from "babylonjs/Materials/effect";
  18527. import { Particle } from "babylonjs/Particles/particle";
  18528. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18529. /**
  18530. * Particle emitter emitting particles from the inside of a cone.
  18531. * It emits the particles alongside the cone volume from the base to the particle.
  18532. * The emission direction might be randomized.
  18533. */
  18534. export class ConeParticleEmitter implements IParticleEmitterType {
  18535. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18536. directionRandomizer: number;
  18537. private _radius;
  18538. private _angle;
  18539. private _height;
  18540. /**
  18541. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18542. */
  18543. radiusRange: number;
  18544. /**
  18545. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18546. */
  18547. heightRange: number;
  18548. /**
  18549. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18550. */
  18551. emitFromSpawnPointOnly: boolean;
  18552. /**
  18553. * Gets or sets the radius of the emission cone
  18554. */
  18555. get radius(): number;
  18556. set radius(value: number);
  18557. /**
  18558. * Gets or sets the angle of the emission cone
  18559. */
  18560. get angle(): number;
  18561. set angle(value: number);
  18562. private _buildHeight;
  18563. /**
  18564. * Creates a new instance ConeParticleEmitter
  18565. * @param radius the radius of the emission cone (1 by default)
  18566. * @param angle the cone base angle (PI by default)
  18567. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18568. */
  18569. constructor(radius?: number, angle?: number,
  18570. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18571. directionRandomizer?: number);
  18572. /**
  18573. * Called by the particle System when the direction is computed for the created particle.
  18574. * @param worldMatrix is the world matrix of the particle system
  18575. * @param directionToUpdate is the direction vector to update with the result
  18576. * @param particle is the particle we are computed the direction for
  18577. */
  18578. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18579. /**
  18580. * Called by the particle System when the position is computed for the created particle.
  18581. * @param worldMatrix is the world matrix of the particle system
  18582. * @param positionToUpdate is the position vector to update with the result
  18583. * @param particle is the particle we are computed the position for
  18584. */
  18585. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18586. /**
  18587. * Clones the current emitter and returns a copy of it
  18588. * @returns the new emitter
  18589. */
  18590. clone(): ConeParticleEmitter;
  18591. /**
  18592. * Called by the GPUParticleSystem to setup the update shader
  18593. * @param effect defines the update shader
  18594. */
  18595. applyToShader(effect: Effect): void;
  18596. /**
  18597. * Returns a string to use to update the GPU particles update shader
  18598. * @returns a string containng the defines string
  18599. */
  18600. getEffectDefines(): string;
  18601. /**
  18602. * Returns the string "ConeParticleEmitter"
  18603. * @returns a string containing the class name
  18604. */
  18605. getClassName(): string;
  18606. /**
  18607. * Serializes the particle system to a JSON object.
  18608. * @returns the JSON object
  18609. */
  18610. serialize(): any;
  18611. /**
  18612. * Parse properties from a JSON object
  18613. * @param serializationObject defines the JSON object
  18614. */
  18615. parse(serializationObject: any): void;
  18616. }
  18617. }
  18618. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18619. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18620. import { Effect } from "babylonjs/Materials/effect";
  18621. import { Particle } from "babylonjs/Particles/particle";
  18622. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18623. /**
  18624. * Particle emitter emitting particles from the inside of a cylinder.
  18625. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18626. */
  18627. export class CylinderParticleEmitter implements IParticleEmitterType {
  18628. /**
  18629. * The radius of the emission cylinder.
  18630. */
  18631. radius: number;
  18632. /**
  18633. * The height of the emission cylinder.
  18634. */
  18635. height: number;
  18636. /**
  18637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18638. */
  18639. radiusRange: number;
  18640. /**
  18641. * How much to randomize the particle direction [0-1].
  18642. */
  18643. directionRandomizer: number;
  18644. /**
  18645. * Creates a new instance CylinderParticleEmitter
  18646. * @param radius the radius of the emission cylinder (1 by default)
  18647. * @param height the height of the emission cylinder (1 by default)
  18648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18649. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18650. */
  18651. constructor(
  18652. /**
  18653. * The radius of the emission cylinder.
  18654. */
  18655. radius?: number,
  18656. /**
  18657. * The height of the emission cylinder.
  18658. */
  18659. height?: number,
  18660. /**
  18661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18662. */
  18663. radiusRange?: number,
  18664. /**
  18665. * How much to randomize the particle direction [0-1].
  18666. */
  18667. directionRandomizer?: number);
  18668. /**
  18669. * Called by the particle System when the direction is computed for the created particle.
  18670. * @param worldMatrix is the world matrix of the particle system
  18671. * @param directionToUpdate is the direction vector to update with the result
  18672. * @param particle is the particle we are computed the direction for
  18673. */
  18674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18675. /**
  18676. * Called by the particle System when the position is computed for the created particle.
  18677. * @param worldMatrix is the world matrix of the particle system
  18678. * @param positionToUpdate is the position vector to update with the result
  18679. * @param particle is the particle we are computed the position for
  18680. */
  18681. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18682. /**
  18683. * Clones the current emitter and returns a copy of it
  18684. * @returns the new emitter
  18685. */
  18686. clone(): CylinderParticleEmitter;
  18687. /**
  18688. * Called by the GPUParticleSystem to setup the update shader
  18689. * @param effect defines the update shader
  18690. */
  18691. applyToShader(effect: Effect): void;
  18692. /**
  18693. * Returns a string to use to update the GPU particles update shader
  18694. * @returns a string containng the defines string
  18695. */
  18696. getEffectDefines(): string;
  18697. /**
  18698. * Returns the string "CylinderParticleEmitter"
  18699. * @returns a string containing the class name
  18700. */
  18701. getClassName(): string;
  18702. /**
  18703. * Serializes the particle system to a JSON object.
  18704. * @returns the JSON object
  18705. */
  18706. serialize(): any;
  18707. /**
  18708. * Parse properties from a JSON object
  18709. * @param serializationObject defines the JSON object
  18710. */
  18711. parse(serializationObject: any): void;
  18712. }
  18713. /**
  18714. * Particle emitter emitting particles from the inside of a cylinder.
  18715. * It emits the particles randomly between two vectors.
  18716. */
  18717. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18718. /**
  18719. * The min limit of the emission direction.
  18720. */
  18721. direction1: Vector3;
  18722. /**
  18723. * The max limit of the emission direction.
  18724. */
  18725. direction2: Vector3;
  18726. /**
  18727. * Creates a new instance CylinderDirectedParticleEmitter
  18728. * @param radius the radius of the emission cylinder (1 by default)
  18729. * @param height the height of the emission cylinder (1 by default)
  18730. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18731. * @param direction1 the min limit of the emission direction (up vector by default)
  18732. * @param direction2 the max limit of the emission direction (up vector by default)
  18733. */
  18734. constructor(radius?: number, height?: number, radiusRange?: number,
  18735. /**
  18736. * The min limit of the emission direction.
  18737. */
  18738. direction1?: Vector3,
  18739. /**
  18740. * The max limit of the emission direction.
  18741. */
  18742. direction2?: Vector3);
  18743. /**
  18744. * Called by the particle System when the direction is computed for the created particle.
  18745. * @param worldMatrix is the world matrix of the particle system
  18746. * @param directionToUpdate is the direction vector to update with the result
  18747. * @param particle is the particle we are computed the direction for
  18748. */
  18749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18750. /**
  18751. * Clones the current emitter and returns a copy of it
  18752. * @returns the new emitter
  18753. */
  18754. clone(): CylinderDirectedParticleEmitter;
  18755. /**
  18756. * Called by the GPUParticleSystem to setup the update shader
  18757. * @param effect defines the update shader
  18758. */
  18759. applyToShader(effect: Effect): void;
  18760. /**
  18761. * Returns a string to use to update the GPU particles update shader
  18762. * @returns a string containng the defines string
  18763. */
  18764. getEffectDefines(): string;
  18765. /**
  18766. * Returns the string "CylinderDirectedParticleEmitter"
  18767. * @returns a string containing the class name
  18768. */
  18769. getClassName(): string;
  18770. /**
  18771. * Serializes the particle system to a JSON object.
  18772. * @returns the JSON object
  18773. */
  18774. serialize(): any;
  18775. /**
  18776. * Parse properties from a JSON object
  18777. * @param serializationObject defines the JSON object
  18778. */
  18779. parse(serializationObject: any): void;
  18780. }
  18781. }
  18782. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18783. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18784. import { Effect } from "babylonjs/Materials/effect";
  18785. import { Particle } from "babylonjs/Particles/particle";
  18786. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18787. /**
  18788. * Particle emitter emitting particles from the inside of a hemisphere.
  18789. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18790. */
  18791. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18792. /**
  18793. * The radius of the emission hemisphere.
  18794. */
  18795. radius: number;
  18796. /**
  18797. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18798. */
  18799. radiusRange: number;
  18800. /**
  18801. * How much to randomize the particle direction [0-1].
  18802. */
  18803. directionRandomizer: number;
  18804. /**
  18805. * Creates a new instance HemisphericParticleEmitter
  18806. * @param radius the radius of the emission hemisphere (1 by default)
  18807. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18808. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18809. */
  18810. constructor(
  18811. /**
  18812. * The radius of the emission hemisphere.
  18813. */
  18814. radius?: number,
  18815. /**
  18816. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18817. */
  18818. radiusRange?: number,
  18819. /**
  18820. * How much to randomize the particle direction [0-1].
  18821. */
  18822. directionRandomizer?: number);
  18823. /**
  18824. * Called by the particle System when the direction is computed for the created particle.
  18825. * @param worldMatrix is the world matrix of the particle system
  18826. * @param directionToUpdate is the direction vector to update with the result
  18827. * @param particle is the particle we are computed the direction for
  18828. */
  18829. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18830. /**
  18831. * Called by the particle System when the position is computed for the created particle.
  18832. * @param worldMatrix is the world matrix of the particle system
  18833. * @param positionToUpdate is the position vector to update with the result
  18834. * @param particle is the particle we are computed the position for
  18835. */
  18836. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18837. /**
  18838. * Clones the current emitter and returns a copy of it
  18839. * @returns the new emitter
  18840. */
  18841. clone(): HemisphericParticleEmitter;
  18842. /**
  18843. * Called by the GPUParticleSystem to setup the update shader
  18844. * @param effect defines the update shader
  18845. */
  18846. applyToShader(effect: Effect): void;
  18847. /**
  18848. * Returns a string to use to update the GPU particles update shader
  18849. * @returns a string containng the defines string
  18850. */
  18851. getEffectDefines(): string;
  18852. /**
  18853. * Returns the string "HemisphericParticleEmitter"
  18854. * @returns a string containing the class name
  18855. */
  18856. getClassName(): string;
  18857. /**
  18858. * Serializes the particle system to a JSON object.
  18859. * @returns the JSON object
  18860. */
  18861. serialize(): any;
  18862. /**
  18863. * Parse properties from a JSON object
  18864. * @param serializationObject defines the JSON object
  18865. */
  18866. parse(serializationObject: any): void;
  18867. }
  18868. }
  18869. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18870. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18871. import { Effect } from "babylonjs/Materials/effect";
  18872. import { Particle } from "babylonjs/Particles/particle";
  18873. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18874. /**
  18875. * Particle emitter emitting particles from a point.
  18876. * It emits the particles randomly between 2 given directions.
  18877. */
  18878. export class PointParticleEmitter implements IParticleEmitterType {
  18879. /**
  18880. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18881. */
  18882. direction1: Vector3;
  18883. /**
  18884. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18885. */
  18886. direction2: Vector3;
  18887. /**
  18888. * Creates a new instance PointParticleEmitter
  18889. */
  18890. constructor();
  18891. /**
  18892. * Called by the particle System when the direction is computed for the created particle.
  18893. * @param worldMatrix is the world matrix of the particle system
  18894. * @param directionToUpdate is the direction vector to update with the result
  18895. * @param particle is the particle we are computed the direction for
  18896. */
  18897. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18898. /**
  18899. * Called by the particle System when the position is computed for the created particle.
  18900. * @param worldMatrix is the world matrix of the particle system
  18901. * @param positionToUpdate is the position vector to update with the result
  18902. * @param particle is the particle we are computed the position for
  18903. */
  18904. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18905. /**
  18906. * Clones the current emitter and returns a copy of it
  18907. * @returns the new emitter
  18908. */
  18909. clone(): PointParticleEmitter;
  18910. /**
  18911. * Called by the GPUParticleSystem to setup the update shader
  18912. * @param effect defines the update shader
  18913. */
  18914. applyToShader(effect: Effect): void;
  18915. /**
  18916. * Returns a string to use to update the GPU particles update shader
  18917. * @returns a string containng the defines string
  18918. */
  18919. getEffectDefines(): string;
  18920. /**
  18921. * Returns the string "PointParticleEmitter"
  18922. * @returns a string containing the class name
  18923. */
  18924. getClassName(): string;
  18925. /**
  18926. * Serializes the particle system to a JSON object.
  18927. * @returns the JSON object
  18928. */
  18929. serialize(): any;
  18930. /**
  18931. * Parse properties from a JSON object
  18932. * @param serializationObject defines the JSON object
  18933. */
  18934. parse(serializationObject: any): void;
  18935. }
  18936. }
  18937. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18938. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18939. import { Effect } from "babylonjs/Materials/effect";
  18940. import { Particle } from "babylonjs/Particles/particle";
  18941. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18942. /**
  18943. * Particle emitter emitting particles from the inside of a sphere.
  18944. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18945. */
  18946. export class SphereParticleEmitter implements IParticleEmitterType {
  18947. /**
  18948. * The radius of the emission sphere.
  18949. */
  18950. radius: number;
  18951. /**
  18952. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18953. */
  18954. radiusRange: number;
  18955. /**
  18956. * How much to randomize the particle direction [0-1].
  18957. */
  18958. directionRandomizer: number;
  18959. /**
  18960. * Creates a new instance SphereParticleEmitter
  18961. * @param radius the radius of the emission sphere (1 by default)
  18962. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18963. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18964. */
  18965. constructor(
  18966. /**
  18967. * The radius of the emission sphere.
  18968. */
  18969. radius?: number,
  18970. /**
  18971. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18972. */
  18973. radiusRange?: number,
  18974. /**
  18975. * How much to randomize the particle direction [0-1].
  18976. */
  18977. directionRandomizer?: number);
  18978. /**
  18979. * Called by the particle System when the direction is computed for the created particle.
  18980. * @param worldMatrix is the world matrix of the particle system
  18981. * @param directionToUpdate is the direction vector to update with the result
  18982. * @param particle is the particle we are computed the direction for
  18983. */
  18984. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18985. /**
  18986. * Called by the particle System when the position is computed for the created particle.
  18987. * @param worldMatrix is the world matrix of the particle system
  18988. * @param positionToUpdate is the position vector to update with the result
  18989. * @param particle is the particle we are computed the position for
  18990. */
  18991. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18992. /**
  18993. * Clones the current emitter and returns a copy of it
  18994. * @returns the new emitter
  18995. */
  18996. clone(): SphereParticleEmitter;
  18997. /**
  18998. * Called by the GPUParticleSystem to setup the update shader
  18999. * @param effect defines the update shader
  19000. */
  19001. applyToShader(effect: Effect): void;
  19002. /**
  19003. * Returns a string to use to update the GPU particles update shader
  19004. * @returns a string containng the defines string
  19005. */
  19006. getEffectDefines(): string;
  19007. /**
  19008. * Returns the string "SphereParticleEmitter"
  19009. * @returns a string containing the class name
  19010. */
  19011. getClassName(): string;
  19012. /**
  19013. * Serializes the particle system to a JSON object.
  19014. * @returns the JSON object
  19015. */
  19016. serialize(): any;
  19017. /**
  19018. * Parse properties from a JSON object
  19019. * @param serializationObject defines the JSON object
  19020. */
  19021. parse(serializationObject: any): void;
  19022. }
  19023. /**
  19024. * Particle emitter emitting particles from the inside of a sphere.
  19025. * It emits the particles randomly between two vectors.
  19026. */
  19027. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19028. /**
  19029. * The min limit of the emission direction.
  19030. */
  19031. direction1: Vector3;
  19032. /**
  19033. * The max limit of the emission direction.
  19034. */
  19035. direction2: Vector3;
  19036. /**
  19037. * Creates a new instance SphereDirectedParticleEmitter
  19038. * @param radius the radius of the emission sphere (1 by default)
  19039. * @param direction1 the min limit of the emission direction (up vector by default)
  19040. * @param direction2 the max limit of the emission direction (up vector by default)
  19041. */
  19042. constructor(radius?: number,
  19043. /**
  19044. * The min limit of the emission direction.
  19045. */
  19046. direction1?: Vector3,
  19047. /**
  19048. * The max limit of the emission direction.
  19049. */
  19050. direction2?: Vector3);
  19051. /**
  19052. * Called by the particle System when the direction is computed for the created particle.
  19053. * @param worldMatrix is the world matrix of the particle system
  19054. * @param directionToUpdate is the direction vector to update with the result
  19055. * @param particle is the particle we are computed the direction for
  19056. */
  19057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19058. /**
  19059. * Clones the current emitter and returns a copy of it
  19060. * @returns the new emitter
  19061. */
  19062. clone(): SphereDirectedParticleEmitter;
  19063. /**
  19064. * Called by the GPUParticleSystem to setup the update shader
  19065. * @param effect defines the update shader
  19066. */
  19067. applyToShader(effect: Effect): void;
  19068. /**
  19069. * Returns a string to use to update the GPU particles update shader
  19070. * @returns a string containng the defines string
  19071. */
  19072. getEffectDefines(): string;
  19073. /**
  19074. * Returns the string "SphereDirectedParticleEmitter"
  19075. * @returns a string containing the class name
  19076. */
  19077. getClassName(): string;
  19078. /**
  19079. * Serializes the particle system to a JSON object.
  19080. * @returns the JSON object
  19081. */
  19082. serialize(): any;
  19083. /**
  19084. * Parse properties from a JSON object
  19085. * @param serializationObject defines the JSON object
  19086. */
  19087. parse(serializationObject: any): void;
  19088. }
  19089. }
  19090. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  19091. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19092. import { Effect } from "babylonjs/Materials/effect";
  19093. import { Particle } from "babylonjs/Particles/particle";
  19094. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19095. import { Nullable } from "babylonjs/types";
  19096. /**
  19097. * Particle emitter emitting particles from a custom list of positions.
  19098. */
  19099. export class CustomParticleEmitter implements IParticleEmitterType {
  19100. /**
  19101. * Gets or sets the position generator that will create the inital position of each particle.
  19102. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19103. */
  19104. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  19105. /**
  19106. * Gets or sets the destination generator that will create the final destination of each particle.
  19107. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19108. */
  19109. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  19110. /**
  19111. * Creates a new instance CustomParticleEmitter
  19112. */
  19113. constructor();
  19114. /**
  19115. * Called by the particle System when the direction is computed for the created particle.
  19116. * @param worldMatrix is the world matrix of the particle system
  19117. * @param directionToUpdate is the direction vector to update with the result
  19118. * @param particle is the particle we are computed the direction for
  19119. */
  19120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19121. /**
  19122. * Called by the particle System when the position is computed for the created particle.
  19123. * @param worldMatrix is the world matrix of the particle system
  19124. * @param positionToUpdate is the position vector to update with the result
  19125. * @param particle is the particle we are computed the position for
  19126. */
  19127. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19128. /**
  19129. * Clones the current emitter and returns a copy of it
  19130. * @returns the new emitter
  19131. */
  19132. clone(): CustomParticleEmitter;
  19133. /**
  19134. * Called by the GPUParticleSystem to setup the update shader
  19135. * @param effect defines the update shader
  19136. */
  19137. applyToShader(effect: Effect): void;
  19138. /**
  19139. * Returns a string to use to update the GPU particles update shader
  19140. * @returns a string containng the defines string
  19141. */
  19142. getEffectDefines(): string;
  19143. /**
  19144. * Returns the string "PointParticleEmitter"
  19145. * @returns a string containing the class name
  19146. */
  19147. getClassName(): string;
  19148. /**
  19149. * Serializes the particle system to a JSON object.
  19150. * @returns the JSON object
  19151. */
  19152. serialize(): any;
  19153. /**
  19154. * Parse properties from a JSON object
  19155. * @param serializationObject defines the JSON object
  19156. */
  19157. parse(serializationObject: any): void;
  19158. }
  19159. }
  19160. declare module "babylonjs/Particles/EmitterTypes/index" {
  19161. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19162. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19163. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19164. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19165. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19166. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19167. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19168. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  19169. }
  19170. declare module "babylonjs/Particles/IParticleSystem" {
  19171. import { Nullable } from "babylonjs/types";
  19172. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19173. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19175. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19176. import { Texture } from "babylonjs/Materials/Textures/texture";
  19177. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19178. import { Scene } from "babylonjs/scene";
  19179. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19180. import { Animation } from "babylonjs/Animations/animation";
  19181. /**
  19182. * Interface representing a particle system in Babylon.js.
  19183. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19184. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19185. */
  19186. export interface IParticleSystem {
  19187. /**
  19188. * List of animations used by the particle system.
  19189. */
  19190. animations: Animation[];
  19191. /**
  19192. * The id of the Particle system.
  19193. */
  19194. id: string;
  19195. /**
  19196. * The name of the Particle system.
  19197. */
  19198. name: string;
  19199. /**
  19200. * The emitter represents the Mesh or position we are attaching the particle system to.
  19201. */
  19202. emitter: Nullable<AbstractMesh | Vector3>;
  19203. /**
  19204. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19205. */
  19206. isBillboardBased: boolean;
  19207. /**
  19208. * The rendering group used by the Particle system to chose when to render.
  19209. */
  19210. renderingGroupId: number;
  19211. /**
  19212. * The layer mask we are rendering the particles through.
  19213. */
  19214. layerMask: number;
  19215. /**
  19216. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19217. */
  19218. updateSpeed: number;
  19219. /**
  19220. * The amount of time the particle system is running (depends of the overall update speed).
  19221. */
  19222. targetStopDuration: number;
  19223. /**
  19224. * The texture used to render each particle. (this can be a spritesheet)
  19225. */
  19226. particleTexture: Nullable<Texture>;
  19227. /**
  19228. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19229. */
  19230. blendMode: number;
  19231. /**
  19232. * Minimum life time of emitting particles.
  19233. */
  19234. minLifeTime: number;
  19235. /**
  19236. * Maximum life time of emitting particles.
  19237. */
  19238. maxLifeTime: number;
  19239. /**
  19240. * Minimum Size of emitting particles.
  19241. */
  19242. minSize: number;
  19243. /**
  19244. * Maximum Size of emitting particles.
  19245. */
  19246. maxSize: number;
  19247. /**
  19248. * Minimum scale of emitting particles on X axis.
  19249. */
  19250. minScaleX: number;
  19251. /**
  19252. * Maximum scale of emitting particles on X axis.
  19253. */
  19254. maxScaleX: number;
  19255. /**
  19256. * Minimum scale of emitting particles on Y axis.
  19257. */
  19258. minScaleY: number;
  19259. /**
  19260. * Maximum scale of emitting particles on Y axis.
  19261. */
  19262. maxScaleY: number;
  19263. /**
  19264. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19265. */
  19266. color1: Color4;
  19267. /**
  19268. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19269. */
  19270. color2: Color4;
  19271. /**
  19272. * Color the particle will have at the end of its lifetime.
  19273. */
  19274. colorDead: Color4;
  19275. /**
  19276. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19277. */
  19278. emitRate: number;
  19279. /**
  19280. * You can use gravity if you want to give an orientation to your particles.
  19281. */
  19282. gravity: Vector3;
  19283. /**
  19284. * Minimum power of emitting particles.
  19285. */
  19286. minEmitPower: number;
  19287. /**
  19288. * Maximum power of emitting particles.
  19289. */
  19290. maxEmitPower: number;
  19291. /**
  19292. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19293. */
  19294. minAngularSpeed: number;
  19295. /**
  19296. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19297. */
  19298. maxAngularSpeed: number;
  19299. /**
  19300. * Gets or sets the minimal initial rotation in radians.
  19301. */
  19302. minInitialRotation: number;
  19303. /**
  19304. * Gets or sets the maximal initial rotation in radians.
  19305. */
  19306. maxInitialRotation: number;
  19307. /**
  19308. * The particle emitter type defines the emitter used by the particle system.
  19309. * It can be for example box, sphere, or cone...
  19310. */
  19311. particleEmitterType: Nullable<IParticleEmitterType>;
  19312. /**
  19313. * Defines the delay in milliseconds before starting the system (0 by default)
  19314. */
  19315. startDelay: number;
  19316. /**
  19317. * 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
  19318. */
  19319. preWarmCycles: number;
  19320. /**
  19321. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19322. */
  19323. preWarmStepOffset: number;
  19324. /**
  19325. * 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)
  19326. */
  19327. spriteCellChangeSpeed: number;
  19328. /**
  19329. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19330. */
  19331. startSpriteCellID: number;
  19332. /**
  19333. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19334. */
  19335. endSpriteCellID: number;
  19336. /**
  19337. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19338. */
  19339. spriteCellWidth: number;
  19340. /**
  19341. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19342. */
  19343. spriteCellHeight: number;
  19344. /**
  19345. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19346. */
  19347. spriteRandomStartCell: boolean;
  19348. /**
  19349. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19350. */
  19351. isAnimationSheetEnabled: boolean;
  19352. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19353. translationPivot: Vector2;
  19354. /**
  19355. * Gets or sets a texture used to add random noise to particle positions
  19356. */
  19357. noiseTexture: Nullable<BaseTexture>;
  19358. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19359. noiseStrength: Vector3;
  19360. /**
  19361. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19362. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19363. */
  19364. billboardMode: number;
  19365. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19366. limitVelocityDamping: number;
  19367. /**
  19368. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19369. */
  19370. beginAnimationOnStart: boolean;
  19371. /**
  19372. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19373. */
  19374. beginAnimationFrom: number;
  19375. /**
  19376. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19377. */
  19378. beginAnimationTo: number;
  19379. /**
  19380. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19381. */
  19382. beginAnimationLoop: boolean;
  19383. /**
  19384. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19385. */
  19386. disposeOnStop: boolean;
  19387. /**
  19388. * Gets the maximum number of particles active at the same time.
  19389. * @returns The max number of active particles.
  19390. */
  19391. getCapacity(): number;
  19392. /**
  19393. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19394. * @returns True if it has been started, otherwise false.
  19395. */
  19396. isStarted(): boolean;
  19397. /**
  19398. * Animates the particle system for this frame.
  19399. */
  19400. animate(): void;
  19401. /**
  19402. * Renders the particle system in its current state.
  19403. * @returns the current number of particles
  19404. */
  19405. render(): number;
  19406. /**
  19407. * Dispose the particle system and frees its associated resources.
  19408. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19409. */
  19410. dispose(disposeTexture?: boolean): void;
  19411. /**
  19412. * Clones the particle system.
  19413. * @param name The name of the cloned object
  19414. * @param newEmitter The new emitter to use
  19415. * @returns the cloned particle system
  19416. */
  19417. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19418. /**
  19419. * Serializes the particle system to a JSON object.
  19420. * @returns the JSON object
  19421. */
  19422. serialize(): any;
  19423. /**
  19424. * Rebuild the particle system
  19425. */
  19426. rebuild(): void;
  19427. /**
  19428. * Starts the particle system and begins to emit
  19429. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19430. */
  19431. start(delay?: number): void;
  19432. /**
  19433. * Stops the particle system.
  19434. */
  19435. stop(): void;
  19436. /**
  19437. * Remove all active particles
  19438. */
  19439. reset(): void;
  19440. /**
  19441. * Is this system ready to be used/rendered
  19442. * @return true if the system is ready
  19443. */
  19444. isReady(): boolean;
  19445. /**
  19446. * Adds a new color gradient
  19447. * @param gradient defines the gradient to use (between 0 and 1)
  19448. * @param color1 defines the color to affect to the specified gradient
  19449. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19450. * @returns the current particle system
  19451. */
  19452. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19453. /**
  19454. * Remove a specific color gradient
  19455. * @param gradient defines the gradient to remove
  19456. * @returns the current particle system
  19457. */
  19458. removeColorGradient(gradient: number): IParticleSystem;
  19459. /**
  19460. * Adds a new size gradient
  19461. * @param gradient defines the gradient to use (between 0 and 1)
  19462. * @param factor defines the size factor to affect to the specified gradient
  19463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19464. * @returns the current particle system
  19465. */
  19466. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19467. /**
  19468. * Remove a specific size gradient
  19469. * @param gradient defines the gradient to remove
  19470. * @returns the current particle system
  19471. */
  19472. removeSizeGradient(gradient: number): IParticleSystem;
  19473. /**
  19474. * Gets the current list of color gradients.
  19475. * You must use addColorGradient and removeColorGradient to udpate this list
  19476. * @returns the list of color gradients
  19477. */
  19478. getColorGradients(): Nullable<Array<ColorGradient>>;
  19479. /**
  19480. * Gets the current list of size gradients.
  19481. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19482. * @returns the list of size gradients
  19483. */
  19484. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19485. /**
  19486. * Gets the current list of angular speed gradients.
  19487. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19488. * @returns the list of angular speed gradients
  19489. */
  19490. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19491. /**
  19492. * Adds a new angular speed gradient
  19493. * @param gradient defines the gradient to use (between 0 and 1)
  19494. * @param factor defines the angular speed to affect to the specified gradient
  19495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19496. * @returns the current particle system
  19497. */
  19498. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19499. /**
  19500. * Remove a specific angular speed gradient
  19501. * @param gradient defines the gradient to remove
  19502. * @returns the current particle system
  19503. */
  19504. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19505. /**
  19506. * Gets the current list of velocity gradients.
  19507. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19508. * @returns the list of velocity gradients
  19509. */
  19510. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19511. /**
  19512. * Adds a new velocity gradient
  19513. * @param gradient defines the gradient to use (between 0 and 1)
  19514. * @param factor defines the velocity to affect to the specified gradient
  19515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19516. * @returns the current particle system
  19517. */
  19518. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19519. /**
  19520. * Remove a specific velocity gradient
  19521. * @param gradient defines the gradient to remove
  19522. * @returns the current particle system
  19523. */
  19524. removeVelocityGradient(gradient: number): IParticleSystem;
  19525. /**
  19526. * Gets the current list of limit velocity gradients.
  19527. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19528. * @returns the list of limit velocity gradients
  19529. */
  19530. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19531. /**
  19532. * Adds a new limit velocity gradient
  19533. * @param gradient defines the gradient to use (between 0 and 1)
  19534. * @param factor defines the limit velocity to affect to the specified gradient
  19535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19536. * @returns the current particle system
  19537. */
  19538. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19539. /**
  19540. * Remove a specific limit velocity gradient
  19541. * @param gradient defines the gradient to remove
  19542. * @returns the current particle system
  19543. */
  19544. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19545. /**
  19546. * Adds a new drag gradient
  19547. * @param gradient defines the gradient to use (between 0 and 1)
  19548. * @param factor defines the drag to affect to the specified gradient
  19549. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19550. * @returns the current particle system
  19551. */
  19552. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19553. /**
  19554. * Remove a specific drag gradient
  19555. * @param gradient defines the gradient to remove
  19556. * @returns the current particle system
  19557. */
  19558. removeDragGradient(gradient: number): IParticleSystem;
  19559. /**
  19560. * Gets the current list of drag gradients.
  19561. * You must use addDragGradient and removeDragGradient to udpate this list
  19562. * @returns the list of drag gradients
  19563. */
  19564. getDragGradients(): Nullable<Array<FactorGradient>>;
  19565. /**
  19566. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19567. * @param gradient defines the gradient to use (between 0 and 1)
  19568. * @param factor defines the emit rate to affect to the specified gradient
  19569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19570. * @returns the current particle system
  19571. */
  19572. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19573. /**
  19574. * Remove a specific emit rate gradient
  19575. * @param gradient defines the gradient to remove
  19576. * @returns the current particle system
  19577. */
  19578. removeEmitRateGradient(gradient: number): IParticleSystem;
  19579. /**
  19580. * Gets the current list of emit rate gradients.
  19581. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19582. * @returns the list of emit rate gradients
  19583. */
  19584. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19585. /**
  19586. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19587. * @param gradient defines the gradient to use (between 0 and 1)
  19588. * @param factor defines the start size to affect to the specified gradient
  19589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19590. * @returns the current particle system
  19591. */
  19592. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19593. /**
  19594. * Remove a specific start size gradient
  19595. * @param gradient defines the gradient to remove
  19596. * @returns the current particle system
  19597. */
  19598. removeStartSizeGradient(gradient: number): IParticleSystem;
  19599. /**
  19600. * Gets the current list of start size gradients.
  19601. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19602. * @returns the list of start size gradients
  19603. */
  19604. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19605. /**
  19606. * Adds a new life time gradient
  19607. * @param gradient defines the gradient to use (between 0 and 1)
  19608. * @param factor defines the life time factor to affect to the specified gradient
  19609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19610. * @returns the current particle system
  19611. */
  19612. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19613. /**
  19614. * Remove a specific life time gradient
  19615. * @param gradient defines the gradient to remove
  19616. * @returns the current particle system
  19617. */
  19618. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19619. /**
  19620. * Gets the current list of life time gradients.
  19621. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19622. * @returns the list of life time gradients
  19623. */
  19624. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19625. /**
  19626. * Gets the current list of color gradients.
  19627. * You must use addColorGradient and removeColorGradient to udpate this list
  19628. * @returns the list of color gradients
  19629. */
  19630. getColorGradients(): Nullable<Array<ColorGradient>>;
  19631. /**
  19632. * Adds a new ramp gradient used to remap particle colors
  19633. * @param gradient defines the gradient to use (between 0 and 1)
  19634. * @param color defines the color to affect to the specified gradient
  19635. * @returns the current particle system
  19636. */
  19637. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19638. /**
  19639. * Gets the current list of ramp gradients.
  19640. * You must use addRampGradient and removeRampGradient to udpate this list
  19641. * @returns the list of ramp gradients
  19642. */
  19643. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19644. /** Gets or sets a boolean indicating that ramp gradients must be used
  19645. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19646. */
  19647. useRampGradients: boolean;
  19648. /**
  19649. * Adds a new color remap gradient
  19650. * @param gradient defines the gradient to use (between 0 and 1)
  19651. * @param min defines the color remap minimal range
  19652. * @param max defines the color remap maximal range
  19653. * @returns the current particle system
  19654. */
  19655. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19656. /**
  19657. * Gets the current list of color remap gradients.
  19658. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19659. * @returns the list of color remap gradients
  19660. */
  19661. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19662. /**
  19663. * Adds a new alpha remap gradient
  19664. * @param gradient defines the gradient to use (between 0 and 1)
  19665. * @param min defines the alpha remap minimal range
  19666. * @param max defines the alpha remap maximal range
  19667. * @returns the current particle system
  19668. */
  19669. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19670. /**
  19671. * Gets the current list of alpha remap gradients.
  19672. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19673. * @returns the list of alpha remap gradients
  19674. */
  19675. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19676. /**
  19677. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19678. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19679. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19680. * @returns the emitter
  19681. */
  19682. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19683. /**
  19684. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19685. * @param radius The radius of the hemisphere to emit from
  19686. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19687. * @returns the emitter
  19688. */
  19689. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19690. /**
  19691. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19692. * @param radius The radius of the sphere to emit from
  19693. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19694. * @returns the emitter
  19695. */
  19696. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19697. /**
  19698. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19699. * @param radius The radius of the sphere to emit from
  19700. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19701. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19702. * @returns the emitter
  19703. */
  19704. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19705. /**
  19706. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19707. * @param radius The radius of the emission cylinder
  19708. * @param height The height of the emission cylinder
  19709. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19710. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19711. * @returns the emitter
  19712. */
  19713. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19714. /**
  19715. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19716. * @param radius The radius of the cylinder to emit from
  19717. * @param height The height of the emission cylinder
  19718. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19719. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19720. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19721. * @returns the emitter
  19722. */
  19723. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19724. /**
  19725. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19726. * @param radius The radius of the cone to emit from
  19727. * @param angle The base angle of the cone
  19728. * @returns the emitter
  19729. */
  19730. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19731. /**
  19732. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19733. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19734. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19735. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19736. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19737. * @returns the emitter
  19738. */
  19739. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19740. /**
  19741. * Get hosting scene
  19742. * @returns the scene
  19743. */
  19744. getScene(): Scene;
  19745. }
  19746. }
  19747. declare module "babylonjs/Meshes/instancedMesh" {
  19748. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19749. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19750. import { Camera } from "babylonjs/Cameras/camera";
  19751. import { Node } from "babylonjs/node";
  19752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19753. import { Mesh } from "babylonjs/Meshes/mesh";
  19754. import { Material } from "babylonjs/Materials/material";
  19755. import { Skeleton } from "babylonjs/Bones/skeleton";
  19756. import { Light } from "babylonjs/Lights/light";
  19757. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19758. /**
  19759. * Creates an instance based on a source mesh.
  19760. */
  19761. export class InstancedMesh extends AbstractMesh {
  19762. private _sourceMesh;
  19763. private _currentLOD;
  19764. /** @hidden */
  19765. _indexInSourceMeshInstanceArray: number;
  19766. constructor(name: string, source: Mesh);
  19767. /**
  19768. * Returns the string "InstancedMesh".
  19769. */
  19770. getClassName(): string;
  19771. /** Gets the list of lights affecting that mesh */
  19772. get lightSources(): Light[];
  19773. _resyncLightSources(): void;
  19774. _resyncLightSource(light: Light): void;
  19775. _removeLightSource(light: Light, dispose: boolean): void;
  19776. /**
  19777. * If the source mesh receives shadows
  19778. */
  19779. get receiveShadows(): boolean;
  19780. /**
  19781. * The material of the source mesh
  19782. */
  19783. get material(): Nullable<Material>;
  19784. /**
  19785. * Visibility of the source mesh
  19786. */
  19787. get visibility(): number;
  19788. /**
  19789. * Skeleton of the source mesh
  19790. */
  19791. get skeleton(): Nullable<Skeleton>;
  19792. /**
  19793. * Rendering ground id of the source mesh
  19794. */
  19795. get renderingGroupId(): number;
  19796. set renderingGroupId(value: number);
  19797. /**
  19798. * Returns the total number of vertices (integer).
  19799. */
  19800. getTotalVertices(): number;
  19801. /**
  19802. * Returns a positive integer : the total number of indices in this mesh geometry.
  19803. * @returns the numner of indices or zero if the mesh has no geometry.
  19804. */
  19805. getTotalIndices(): number;
  19806. /**
  19807. * The source mesh of the instance
  19808. */
  19809. get sourceMesh(): Mesh;
  19810. /**
  19811. * Is this node ready to be used/rendered
  19812. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19813. * @return {boolean} is it ready
  19814. */
  19815. isReady(completeCheck?: boolean): boolean;
  19816. /**
  19817. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19818. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19819. * @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.
  19820. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19821. */
  19822. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19823. /**
  19824. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19825. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19826. * The `data` are either a numeric array either a Float32Array.
  19827. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19828. * 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).
  19829. * Note that a new underlying VertexBuffer object is created each call.
  19830. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19831. *
  19832. * Possible `kind` values :
  19833. * - VertexBuffer.PositionKind
  19834. * - VertexBuffer.UVKind
  19835. * - VertexBuffer.UV2Kind
  19836. * - VertexBuffer.UV3Kind
  19837. * - VertexBuffer.UV4Kind
  19838. * - VertexBuffer.UV5Kind
  19839. * - VertexBuffer.UV6Kind
  19840. * - VertexBuffer.ColorKind
  19841. * - VertexBuffer.MatricesIndicesKind
  19842. * - VertexBuffer.MatricesIndicesExtraKind
  19843. * - VertexBuffer.MatricesWeightsKind
  19844. * - VertexBuffer.MatricesWeightsExtraKind
  19845. *
  19846. * Returns the Mesh.
  19847. */
  19848. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19849. /**
  19850. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19851. * If the mesh has no geometry, it is simply returned as it is.
  19852. * The `data` are either a numeric array either a Float32Array.
  19853. * No new underlying VertexBuffer object is created.
  19854. * 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.
  19855. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19856. *
  19857. * Possible `kind` values :
  19858. * - VertexBuffer.PositionKind
  19859. * - VertexBuffer.UVKind
  19860. * - VertexBuffer.UV2Kind
  19861. * - VertexBuffer.UV3Kind
  19862. * - VertexBuffer.UV4Kind
  19863. * - VertexBuffer.UV5Kind
  19864. * - VertexBuffer.UV6Kind
  19865. * - VertexBuffer.ColorKind
  19866. * - VertexBuffer.MatricesIndicesKind
  19867. * - VertexBuffer.MatricesIndicesExtraKind
  19868. * - VertexBuffer.MatricesWeightsKind
  19869. * - VertexBuffer.MatricesWeightsExtraKind
  19870. *
  19871. * Returns the Mesh.
  19872. */
  19873. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19874. /**
  19875. * Sets the mesh indices.
  19876. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19877. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19878. * This method creates a new index buffer each call.
  19879. * Returns the Mesh.
  19880. */
  19881. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19882. /**
  19883. * Boolean : True if the mesh owns the requested kind of data.
  19884. */
  19885. isVerticesDataPresent(kind: string): boolean;
  19886. /**
  19887. * Returns an array of indices (IndicesArray).
  19888. */
  19889. getIndices(): Nullable<IndicesArray>;
  19890. get _positions(): Nullable<Vector3[]>;
  19891. /**
  19892. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19893. * This means the mesh underlying bounding box and sphere are recomputed.
  19894. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19895. * @returns the current mesh
  19896. */
  19897. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19898. /** @hidden */
  19899. _preActivate(): InstancedMesh;
  19900. /** @hidden */
  19901. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19902. /** @hidden */
  19903. _postActivate(): void;
  19904. getWorldMatrix(): Matrix;
  19905. get isAnInstance(): boolean;
  19906. /**
  19907. * Returns the current associated LOD AbstractMesh.
  19908. */
  19909. getLOD(camera: Camera): AbstractMesh;
  19910. /** @hidden */
  19911. _syncSubMeshes(): InstancedMesh;
  19912. /** @hidden */
  19913. _generatePointsArray(): boolean;
  19914. /**
  19915. * Creates a new InstancedMesh from the current mesh.
  19916. * - name (string) : the cloned mesh name
  19917. * - newParent (optional Node) : the optional Node to parent the clone to.
  19918. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19919. *
  19920. * Returns the clone.
  19921. */
  19922. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19923. /**
  19924. * Disposes the InstancedMesh.
  19925. * Returns nothing.
  19926. */
  19927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19928. }
  19929. module "babylonjs/Meshes/mesh" {
  19930. interface Mesh {
  19931. /**
  19932. * Register a custom buffer that will be instanced
  19933. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19934. * @param kind defines the buffer kind
  19935. * @param stride defines the stride in floats
  19936. */
  19937. registerInstancedBuffer(kind: string, stride: number): void;
  19938. /** @hidden */
  19939. _userInstancedBuffersStorage: {
  19940. data: {
  19941. [key: string]: Float32Array;
  19942. };
  19943. sizes: {
  19944. [key: string]: number;
  19945. };
  19946. vertexBuffers: {
  19947. [key: string]: Nullable<VertexBuffer>;
  19948. };
  19949. strides: {
  19950. [key: string]: number;
  19951. };
  19952. };
  19953. }
  19954. }
  19955. module "babylonjs/Meshes/abstractMesh" {
  19956. interface AbstractMesh {
  19957. /**
  19958. * Object used to store instanced buffers defined by user
  19959. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19960. */
  19961. instancedBuffers: {
  19962. [key: string]: any;
  19963. };
  19964. }
  19965. }
  19966. }
  19967. declare module "babylonjs/Materials/shaderMaterial" {
  19968. import { Scene } from "babylonjs/scene";
  19969. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19971. import { Mesh } from "babylonjs/Meshes/mesh";
  19972. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19974. import { Texture } from "babylonjs/Materials/Textures/texture";
  19975. import { Material } from "babylonjs/Materials/material";
  19976. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19977. /**
  19978. * Defines the options associated with the creation of a shader material.
  19979. */
  19980. export interface IShaderMaterialOptions {
  19981. /**
  19982. * Does the material work in alpha blend mode
  19983. */
  19984. needAlphaBlending: boolean;
  19985. /**
  19986. * Does the material work in alpha test mode
  19987. */
  19988. needAlphaTesting: boolean;
  19989. /**
  19990. * The list of attribute names used in the shader
  19991. */
  19992. attributes: string[];
  19993. /**
  19994. * The list of unifrom names used in the shader
  19995. */
  19996. uniforms: string[];
  19997. /**
  19998. * The list of UBO names used in the shader
  19999. */
  20000. uniformBuffers: string[];
  20001. /**
  20002. * The list of sampler names used in the shader
  20003. */
  20004. samplers: string[];
  20005. /**
  20006. * The list of defines used in the shader
  20007. */
  20008. defines: string[];
  20009. }
  20010. /**
  20011. * 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.
  20012. *
  20013. * This returned material effects how the mesh will look based on the code in the shaders.
  20014. *
  20015. * @see http://doc.babylonjs.com/how_to/shader_material
  20016. */
  20017. export class ShaderMaterial extends Material {
  20018. private _shaderPath;
  20019. private _options;
  20020. private _textures;
  20021. private _textureArrays;
  20022. private _floats;
  20023. private _ints;
  20024. private _floatsArrays;
  20025. private _colors3;
  20026. private _colors3Arrays;
  20027. private _colors4;
  20028. private _colors4Arrays;
  20029. private _vectors2;
  20030. private _vectors3;
  20031. private _vectors4;
  20032. private _matrices;
  20033. private _matrixArrays;
  20034. private _matrices3x3;
  20035. private _matrices2x2;
  20036. private _vectors2Arrays;
  20037. private _vectors3Arrays;
  20038. private _vectors4Arrays;
  20039. private _cachedWorldViewMatrix;
  20040. private _cachedWorldViewProjectionMatrix;
  20041. private _renderId;
  20042. private _multiview;
  20043. /**
  20044. * Instantiate a new shader material.
  20045. * 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.
  20046. * This returned material effects how the mesh will look based on the code in the shaders.
  20047. * @see http://doc.babylonjs.com/how_to/shader_material
  20048. * @param name Define the name of the material in the scene
  20049. * @param scene Define the scene the material belongs to
  20050. * @param shaderPath Defines the route to the shader code in one of three ways:
  20051. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  20052. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  20053. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  20054. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  20055. * @param options Define the options used to create the shader
  20056. */
  20057. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  20058. /**
  20059. * Gets the shader path used to define the shader code
  20060. * It can be modified to trigger a new compilation
  20061. */
  20062. get shaderPath(): any;
  20063. /**
  20064. * Sets the shader path used to define the shader code
  20065. * It can be modified to trigger a new compilation
  20066. */
  20067. set shaderPath(shaderPath: any);
  20068. /**
  20069. * Gets the options used to compile the shader.
  20070. * They can be modified to trigger a new compilation
  20071. */
  20072. get options(): IShaderMaterialOptions;
  20073. /**
  20074. * Gets the current class name of the material e.g. "ShaderMaterial"
  20075. * Mainly use in serialization.
  20076. * @returns the class name
  20077. */
  20078. getClassName(): string;
  20079. /**
  20080. * Specifies if the material will require alpha blending
  20081. * @returns a boolean specifying if alpha blending is needed
  20082. */
  20083. needAlphaBlending(): boolean;
  20084. /**
  20085. * Specifies if this material should be rendered in alpha test mode
  20086. * @returns a boolean specifying if an alpha test is needed.
  20087. */
  20088. needAlphaTesting(): boolean;
  20089. private _checkUniform;
  20090. /**
  20091. * Set a texture in the shader.
  20092. * @param name Define the name of the uniform samplers as defined in the shader
  20093. * @param texture Define the texture to bind to this sampler
  20094. * @return the material itself allowing "fluent" like uniform updates
  20095. */
  20096. setTexture(name: string, texture: Texture): ShaderMaterial;
  20097. /**
  20098. * Set a texture array in the shader.
  20099. * @param name Define the name of the uniform sampler array as defined in the shader
  20100. * @param textures Define the list of textures to bind to this sampler
  20101. * @return the material itself allowing "fluent" like uniform updates
  20102. */
  20103. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20104. /**
  20105. * Set a float in the shader.
  20106. * @param name Define the name of the uniform as defined in the shader
  20107. * @param value Define the value to give to the uniform
  20108. * @return the material itself allowing "fluent" like uniform updates
  20109. */
  20110. setFloat(name: string, value: number): ShaderMaterial;
  20111. /**
  20112. * Set a int in the shader.
  20113. * @param name Define the name of the uniform as defined in the shader
  20114. * @param value Define the value to give to the uniform
  20115. * @return the material itself allowing "fluent" like uniform updates
  20116. */
  20117. setInt(name: string, value: number): ShaderMaterial;
  20118. /**
  20119. * Set an array of floats in the shader.
  20120. * @param name Define the name of the uniform as defined in the shader
  20121. * @param value Define the value to give to the uniform
  20122. * @return the material itself allowing "fluent" like uniform updates
  20123. */
  20124. setFloats(name: string, value: number[]): ShaderMaterial;
  20125. /**
  20126. * Set a vec3 in the shader from a Color3.
  20127. * @param name Define the name of the uniform as defined in the shader
  20128. * @param value Define the value to give to the uniform
  20129. * @return the material itself allowing "fluent" like uniform updates
  20130. */
  20131. setColor3(name: string, value: Color3): ShaderMaterial;
  20132. /**
  20133. * Set a vec3 array in the shader from a Color3 array.
  20134. * @param name Define the name of the uniform as defined in the shader
  20135. * @param value Define the value to give to the uniform
  20136. * @return the material itself allowing "fluent" like uniform updates
  20137. */
  20138. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20139. /**
  20140. * Set a vec4 in the shader from a Color4.
  20141. * @param name Define the name of the uniform as defined in the shader
  20142. * @param value Define the value to give to the uniform
  20143. * @return the material itself allowing "fluent" like uniform updates
  20144. */
  20145. setColor4(name: string, value: Color4): ShaderMaterial;
  20146. /**
  20147. * Set a vec4 array in the shader from a Color4 array.
  20148. * @param name Define the name of the uniform as defined in the shader
  20149. * @param value Define the value to give to the uniform
  20150. * @return the material itself allowing "fluent" like uniform updates
  20151. */
  20152. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20153. /**
  20154. * Set a vec2 in the shader from a Vector2.
  20155. * @param name Define the name of the uniform as defined in the shader
  20156. * @param value Define the value to give to the uniform
  20157. * @return the material itself allowing "fluent" like uniform updates
  20158. */
  20159. setVector2(name: string, value: Vector2): ShaderMaterial;
  20160. /**
  20161. * Set a vec3 in the shader from a Vector3.
  20162. * @param name Define the name of the uniform as defined in the shader
  20163. * @param value Define the value to give to the uniform
  20164. * @return the material itself allowing "fluent" like uniform updates
  20165. */
  20166. setVector3(name: string, value: Vector3): ShaderMaterial;
  20167. /**
  20168. * Set a vec4 in the shader from a Vector4.
  20169. * @param name Define the name of the uniform as defined in the shader
  20170. * @param value Define the value to give to the uniform
  20171. * @return the material itself allowing "fluent" like uniform updates
  20172. */
  20173. setVector4(name: string, value: Vector4): ShaderMaterial;
  20174. /**
  20175. * Set a mat4 in the shader from a Matrix.
  20176. * @param name Define the name of the uniform as defined in the shader
  20177. * @param value Define the value to give to the uniform
  20178. * @return the material itself allowing "fluent" like uniform updates
  20179. */
  20180. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20181. /**
  20182. * Set a float32Array in the shader from a matrix array.
  20183. * @param name Define the name of the uniform as defined in the shader
  20184. * @param value Define the value to give to the uniform
  20185. * @return the material itself allowing "fluent" like uniform updates
  20186. */
  20187. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20188. /**
  20189. * Set a mat3 in the shader from a Float32Array.
  20190. * @param name Define the name of the uniform as defined in the shader
  20191. * @param value Define the value to give to the uniform
  20192. * @return the material itself allowing "fluent" like uniform updates
  20193. */
  20194. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20195. /**
  20196. * Set a mat2 in the shader from a Float32Array.
  20197. * @param name Define the name of the uniform as defined in the shader
  20198. * @param value Define the value to give to the uniform
  20199. * @return the material itself allowing "fluent" like uniform updates
  20200. */
  20201. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20202. /**
  20203. * Set a vec2 array in the shader from a number array.
  20204. * @param name Define the name of the uniform as defined in the shader
  20205. * @param value Define the value to give to the uniform
  20206. * @return the material itself allowing "fluent" like uniform updates
  20207. */
  20208. setArray2(name: string, value: number[]): ShaderMaterial;
  20209. /**
  20210. * Set a vec3 array in the shader from a number array.
  20211. * @param name Define the name of the uniform as defined in the shader
  20212. * @param value Define the value to give to the uniform
  20213. * @return the material itself allowing "fluent" like uniform updates
  20214. */
  20215. setArray3(name: string, value: number[]): ShaderMaterial;
  20216. /**
  20217. * Set a vec4 array in the shader from a number array.
  20218. * @param name Define the name of the uniform as defined in the shader
  20219. * @param value Define the value to give to the uniform
  20220. * @return the material itself allowing "fluent" like uniform updates
  20221. */
  20222. setArray4(name: string, value: number[]): ShaderMaterial;
  20223. private _checkCache;
  20224. /**
  20225. * Specifies that the submesh is ready to be used
  20226. * @param mesh defines the mesh to check
  20227. * @param subMesh defines which submesh to check
  20228. * @param useInstances specifies that instances should be used
  20229. * @returns a boolean indicating that the submesh is ready or not
  20230. */
  20231. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20232. /**
  20233. * Checks if the material is ready to render the requested mesh
  20234. * @param mesh Define the mesh to render
  20235. * @param useInstances Define whether or not the material is used with instances
  20236. * @returns true if ready, otherwise false
  20237. */
  20238. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20239. /**
  20240. * Binds the world matrix to the material
  20241. * @param world defines the world transformation matrix
  20242. */
  20243. bindOnlyWorldMatrix(world: Matrix): void;
  20244. /**
  20245. * Binds the material to the mesh
  20246. * @param world defines the world transformation matrix
  20247. * @param mesh defines the mesh to bind the material to
  20248. */
  20249. bind(world: Matrix, mesh?: Mesh): void;
  20250. /**
  20251. * Gets the active textures from the material
  20252. * @returns an array of textures
  20253. */
  20254. getActiveTextures(): BaseTexture[];
  20255. /**
  20256. * Specifies if the material uses a texture
  20257. * @param texture defines the texture to check against the material
  20258. * @returns a boolean specifying if the material uses the texture
  20259. */
  20260. hasTexture(texture: BaseTexture): boolean;
  20261. /**
  20262. * Makes a duplicate of the material, and gives it a new name
  20263. * @param name defines the new name for the duplicated material
  20264. * @returns the cloned material
  20265. */
  20266. clone(name: string): ShaderMaterial;
  20267. /**
  20268. * Disposes the material
  20269. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20270. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20271. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20272. */
  20273. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20274. /**
  20275. * Serializes this material in a JSON representation
  20276. * @returns the serialized material object
  20277. */
  20278. serialize(): any;
  20279. /**
  20280. * Creates a shader material from parsed shader material data
  20281. * @param source defines the JSON represnetation of the material
  20282. * @param scene defines the hosting scene
  20283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20284. * @returns a new material
  20285. */
  20286. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20287. }
  20288. }
  20289. declare module "babylonjs/Shaders/color.fragment" {
  20290. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20291. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20292. /** @hidden */
  20293. export var colorPixelShader: {
  20294. name: string;
  20295. shader: string;
  20296. };
  20297. }
  20298. declare module "babylonjs/Shaders/color.vertex" {
  20299. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20300. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20301. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20302. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20303. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20304. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20305. /** @hidden */
  20306. export var colorVertexShader: {
  20307. name: string;
  20308. shader: string;
  20309. };
  20310. }
  20311. declare module "babylonjs/Meshes/linesMesh" {
  20312. import { Nullable } from "babylonjs/types";
  20313. import { Scene } from "babylonjs/scene";
  20314. import { Color3 } from "babylonjs/Maths/math.color";
  20315. import { Node } from "babylonjs/node";
  20316. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20317. import { Mesh } from "babylonjs/Meshes/mesh";
  20318. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20319. import { Effect } from "babylonjs/Materials/effect";
  20320. import { Material } from "babylonjs/Materials/material";
  20321. import "babylonjs/Shaders/color.fragment";
  20322. import "babylonjs/Shaders/color.vertex";
  20323. /**
  20324. * Line mesh
  20325. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20326. */
  20327. export class LinesMesh extends Mesh {
  20328. /**
  20329. * If vertex color should be applied to the mesh
  20330. */
  20331. readonly useVertexColor?: boolean | undefined;
  20332. /**
  20333. * If vertex alpha should be applied to the mesh
  20334. */
  20335. readonly useVertexAlpha?: boolean | undefined;
  20336. /**
  20337. * Color of the line (Default: White)
  20338. */
  20339. color: Color3;
  20340. /**
  20341. * Alpha of the line (Default: 1)
  20342. */
  20343. alpha: number;
  20344. /**
  20345. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20346. * This margin is expressed in world space coordinates, so its value may vary.
  20347. * Default value is 0.1
  20348. */
  20349. intersectionThreshold: number;
  20350. private _colorShader;
  20351. private color4;
  20352. /**
  20353. * Creates a new LinesMesh
  20354. * @param name defines the name
  20355. * @param scene defines the hosting scene
  20356. * @param parent defines the parent mesh if any
  20357. * @param source defines the optional source LinesMesh used to clone data from
  20358. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20359. * When false, achieved by calling a clone(), also passing False.
  20360. * This will make creation of children, recursive.
  20361. * @param useVertexColor defines if this LinesMesh supports vertex color
  20362. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20363. */
  20364. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20365. /**
  20366. * If vertex color should be applied to the mesh
  20367. */
  20368. useVertexColor?: boolean | undefined,
  20369. /**
  20370. * If vertex alpha should be applied to the mesh
  20371. */
  20372. useVertexAlpha?: boolean | undefined);
  20373. private _addClipPlaneDefine;
  20374. private _removeClipPlaneDefine;
  20375. isReady(): boolean;
  20376. /**
  20377. * Returns the string "LineMesh"
  20378. */
  20379. getClassName(): string;
  20380. /**
  20381. * @hidden
  20382. */
  20383. get material(): Material;
  20384. /**
  20385. * @hidden
  20386. */
  20387. set material(value: Material);
  20388. /**
  20389. * @hidden
  20390. */
  20391. get checkCollisions(): boolean;
  20392. /** @hidden */
  20393. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20394. /** @hidden */
  20395. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20396. /**
  20397. * Disposes of the line mesh
  20398. * @param doNotRecurse If children should be disposed
  20399. */
  20400. dispose(doNotRecurse?: boolean): void;
  20401. /**
  20402. * Returns a new LineMesh object cloned from the current one.
  20403. */
  20404. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  20405. /**
  20406. * Creates a new InstancedLinesMesh object from the mesh model.
  20407. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20408. * @param name defines the name of the new instance
  20409. * @returns a new InstancedLinesMesh
  20410. */
  20411. createInstance(name: string): InstancedLinesMesh;
  20412. }
  20413. /**
  20414. * Creates an instance based on a source LinesMesh
  20415. */
  20416. export class InstancedLinesMesh extends InstancedMesh {
  20417. /**
  20418. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20419. * This margin is expressed in world space coordinates, so its value may vary.
  20420. * Initilized with the intersectionThreshold value of the source LinesMesh
  20421. */
  20422. intersectionThreshold: number;
  20423. constructor(name: string, source: LinesMesh);
  20424. /**
  20425. * Returns the string "InstancedLinesMesh".
  20426. */
  20427. getClassName(): string;
  20428. }
  20429. }
  20430. declare module "babylonjs/Shaders/line.fragment" {
  20431. /** @hidden */
  20432. export var linePixelShader: {
  20433. name: string;
  20434. shader: string;
  20435. };
  20436. }
  20437. declare module "babylonjs/Shaders/line.vertex" {
  20438. /** @hidden */
  20439. export var lineVertexShader: {
  20440. name: string;
  20441. shader: string;
  20442. };
  20443. }
  20444. declare module "babylonjs/Rendering/edgesRenderer" {
  20445. import { Nullable } from "babylonjs/types";
  20446. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20448. import { Vector3 } from "babylonjs/Maths/math.vector";
  20449. import { IDisposable } from "babylonjs/scene";
  20450. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20451. import "babylonjs/Shaders/line.fragment";
  20452. import "babylonjs/Shaders/line.vertex";
  20453. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20454. module "babylonjs/Meshes/abstractMesh" {
  20455. interface AbstractMesh {
  20456. /**
  20457. * Gets the edgesRenderer associated with the mesh
  20458. */
  20459. edgesRenderer: Nullable<EdgesRenderer>;
  20460. }
  20461. }
  20462. module "babylonjs/Meshes/linesMesh" {
  20463. interface LinesMesh {
  20464. /**
  20465. * Enables the edge rendering mode on the mesh.
  20466. * This mode makes the mesh edges visible
  20467. * @param epsilon defines the maximal distance between two angles to detect a face
  20468. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20469. * @returns the currentAbstractMesh
  20470. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20471. */
  20472. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20473. }
  20474. }
  20475. module "babylonjs/Meshes/linesMesh" {
  20476. interface InstancedLinesMesh {
  20477. /**
  20478. * Enables the edge rendering mode on the mesh.
  20479. * This mode makes the mesh edges visible
  20480. * @param epsilon defines the maximal distance between two angles to detect a face
  20481. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20482. * @returns the current InstancedLinesMesh
  20483. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20484. */
  20485. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20486. }
  20487. }
  20488. /**
  20489. * Defines the minimum contract an Edges renderer should follow.
  20490. */
  20491. export interface IEdgesRenderer extends IDisposable {
  20492. /**
  20493. * Gets or sets a boolean indicating if the edgesRenderer is active
  20494. */
  20495. isEnabled: boolean;
  20496. /**
  20497. * Renders the edges of the attached mesh,
  20498. */
  20499. render(): void;
  20500. /**
  20501. * Checks wether or not the edges renderer is ready to render.
  20502. * @return true if ready, otherwise false.
  20503. */
  20504. isReady(): boolean;
  20505. }
  20506. /**
  20507. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20508. */
  20509. export class EdgesRenderer implements IEdgesRenderer {
  20510. /**
  20511. * Define the size of the edges with an orthographic camera
  20512. */
  20513. edgesWidthScalerForOrthographic: number;
  20514. /**
  20515. * Define the size of the edges with a perspective camera
  20516. */
  20517. edgesWidthScalerForPerspective: number;
  20518. protected _source: AbstractMesh;
  20519. protected _linesPositions: number[];
  20520. protected _linesNormals: number[];
  20521. protected _linesIndices: number[];
  20522. protected _epsilon: number;
  20523. protected _indicesCount: number;
  20524. protected _lineShader: ShaderMaterial;
  20525. protected _ib: DataBuffer;
  20526. protected _buffers: {
  20527. [key: string]: Nullable<VertexBuffer>;
  20528. };
  20529. protected _checkVerticesInsteadOfIndices: boolean;
  20530. private _meshRebuildObserver;
  20531. private _meshDisposeObserver;
  20532. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20533. isEnabled: boolean;
  20534. /**
  20535. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20536. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20537. * @param source Mesh used to create edges
  20538. * @param epsilon sum of angles in adjacency to check for edge
  20539. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20540. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20541. */
  20542. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20543. protected _prepareRessources(): void;
  20544. /** @hidden */
  20545. _rebuild(): void;
  20546. /**
  20547. * Releases the required resources for the edges renderer
  20548. */
  20549. dispose(): void;
  20550. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20551. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20552. /**
  20553. * Checks if the pair of p0 and p1 is en edge
  20554. * @param faceIndex
  20555. * @param edge
  20556. * @param faceNormals
  20557. * @param p0
  20558. * @param p1
  20559. * @private
  20560. */
  20561. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20562. /**
  20563. * push line into the position, normal and index buffer
  20564. * @protected
  20565. */
  20566. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20567. /**
  20568. * Generates lines edges from adjacencjes
  20569. * @private
  20570. */
  20571. _generateEdgesLines(): void;
  20572. /**
  20573. * Checks wether or not the edges renderer is ready to render.
  20574. * @return true if ready, otherwise false.
  20575. */
  20576. isReady(): boolean;
  20577. /**
  20578. * Renders the edges of the attached mesh,
  20579. */
  20580. render(): void;
  20581. }
  20582. /**
  20583. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20584. */
  20585. export class LineEdgesRenderer extends EdgesRenderer {
  20586. /**
  20587. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20588. * @param source LineMesh used to generate edges
  20589. * @param epsilon not important (specified angle for edge detection)
  20590. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20591. */
  20592. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20593. /**
  20594. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20595. */
  20596. _generateEdgesLines(): void;
  20597. }
  20598. }
  20599. declare module "babylonjs/Rendering/renderingGroup" {
  20600. import { SmartArray } from "babylonjs/Misc/smartArray";
  20601. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20603. import { Nullable } from "babylonjs/types";
  20604. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20605. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20606. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20607. import { Material } from "babylonjs/Materials/material";
  20608. import { Scene } from "babylonjs/scene";
  20609. /**
  20610. * This represents the object necessary to create a rendering group.
  20611. * This is exclusively used and created by the rendering manager.
  20612. * To modify the behavior, you use the available helpers in your scene or meshes.
  20613. * @hidden
  20614. */
  20615. export class RenderingGroup {
  20616. index: number;
  20617. private static _zeroVector;
  20618. private _scene;
  20619. private _opaqueSubMeshes;
  20620. private _transparentSubMeshes;
  20621. private _alphaTestSubMeshes;
  20622. private _depthOnlySubMeshes;
  20623. private _particleSystems;
  20624. private _spriteManagers;
  20625. private _opaqueSortCompareFn;
  20626. private _alphaTestSortCompareFn;
  20627. private _transparentSortCompareFn;
  20628. private _renderOpaque;
  20629. private _renderAlphaTest;
  20630. private _renderTransparent;
  20631. /** @hidden */
  20632. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20633. onBeforeTransparentRendering: () => void;
  20634. /**
  20635. * Set the opaque sort comparison function.
  20636. * If null the sub meshes will be render in the order they were created
  20637. */
  20638. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20639. /**
  20640. * Set the alpha test sort comparison function.
  20641. * If null the sub meshes will be render in the order they were created
  20642. */
  20643. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20644. /**
  20645. * Set the transparent sort comparison function.
  20646. * If null the sub meshes will be render in the order they were created
  20647. */
  20648. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20649. /**
  20650. * Creates a new rendering group.
  20651. * @param index The rendering group index
  20652. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20653. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20654. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20655. */
  20656. 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>);
  20657. /**
  20658. * Render all the sub meshes contained in the group.
  20659. * @param customRenderFunction Used to override the default render behaviour of the group.
  20660. * @returns true if rendered some submeshes.
  20661. */
  20662. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20663. /**
  20664. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20665. * @param subMeshes The submeshes to render
  20666. */
  20667. private renderOpaqueSorted;
  20668. /**
  20669. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20670. * @param subMeshes The submeshes to render
  20671. */
  20672. private renderAlphaTestSorted;
  20673. /**
  20674. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20675. * @param subMeshes The submeshes to render
  20676. */
  20677. private renderTransparentSorted;
  20678. /**
  20679. * Renders the submeshes in a specified order.
  20680. * @param subMeshes The submeshes to sort before render
  20681. * @param sortCompareFn The comparison function use to sort
  20682. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20683. * @param transparent Specifies to activate blending if true
  20684. */
  20685. private static renderSorted;
  20686. /**
  20687. * Renders the submeshes in the order they were dispatched (no sort applied).
  20688. * @param subMeshes The submeshes to render
  20689. */
  20690. private static renderUnsorted;
  20691. /**
  20692. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20693. * are rendered back to front if in the same alpha index.
  20694. *
  20695. * @param a The first submesh
  20696. * @param b The second submesh
  20697. * @returns The result of the comparison
  20698. */
  20699. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20700. /**
  20701. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20702. * are rendered back to front.
  20703. *
  20704. * @param a The first submesh
  20705. * @param b The second submesh
  20706. * @returns The result of the comparison
  20707. */
  20708. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20709. /**
  20710. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20711. * are rendered front to back (prevent overdraw).
  20712. *
  20713. * @param a The first submesh
  20714. * @param b The second submesh
  20715. * @returns The result of the comparison
  20716. */
  20717. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20718. /**
  20719. * Resets the different lists of submeshes to prepare a new frame.
  20720. */
  20721. prepare(): void;
  20722. dispose(): void;
  20723. /**
  20724. * Inserts the submesh in its correct queue depending on its material.
  20725. * @param subMesh The submesh to dispatch
  20726. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20727. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20728. */
  20729. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20730. dispatchSprites(spriteManager: ISpriteManager): void;
  20731. dispatchParticles(particleSystem: IParticleSystem): void;
  20732. private _renderParticles;
  20733. private _renderSprites;
  20734. }
  20735. }
  20736. declare module "babylonjs/Rendering/renderingManager" {
  20737. import { Nullable } from "babylonjs/types";
  20738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20740. import { SmartArray } from "babylonjs/Misc/smartArray";
  20741. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20742. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20743. import { Material } from "babylonjs/Materials/material";
  20744. import { Scene } from "babylonjs/scene";
  20745. import { Camera } from "babylonjs/Cameras/camera";
  20746. /**
  20747. * Interface describing the different options available in the rendering manager
  20748. * regarding Auto Clear between groups.
  20749. */
  20750. export interface IRenderingManagerAutoClearSetup {
  20751. /**
  20752. * Defines whether or not autoclear is enable.
  20753. */
  20754. autoClear: boolean;
  20755. /**
  20756. * Defines whether or not to autoclear the depth buffer.
  20757. */
  20758. depth: boolean;
  20759. /**
  20760. * Defines whether or not to autoclear the stencil buffer.
  20761. */
  20762. stencil: boolean;
  20763. }
  20764. /**
  20765. * This class is used by the onRenderingGroupObservable
  20766. */
  20767. export class RenderingGroupInfo {
  20768. /**
  20769. * The Scene that being rendered
  20770. */
  20771. scene: Scene;
  20772. /**
  20773. * The camera currently used for the rendering pass
  20774. */
  20775. camera: Nullable<Camera>;
  20776. /**
  20777. * The ID of the renderingGroup being processed
  20778. */
  20779. renderingGroupId: number;
  20780. }
  20781. /**
  20782. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20783. * It is enable to manage the different groups as well as the different necessary sort functions.
  20784. * This should not be used directly aside of the few static configurations
  20785. */
  20786. export class RenderingManager {
  20787. /**
  20788. * The max id used for rendering groups (not included)
  20789. */
  20790. static MAX_RENDERINGGROUPS: number;
  20791. /**
  20792. * The min id used for rendering groups (included)
  20793. */
  20794. static MIN_RENDERINGGROUPS: number;
  20795. /**
  20796. * Used to globally prevent autoclearing scenes.
  20797. */
  20798. static AUTOCLEAR: boolean;
  20799. /**
  20800. * @hidden
  20801. */
  20802. _useSceneAutoClearSetup: boolean;
  20803. private _scene;
  20804. private _renderingGroups;
  20805. private _depthStencilBufferAlreadyCleaned;
  20806. private _autoClearDepthStencil;
  20807. private _customOpaqueSortCompareFn;
  20808. private _customAlphaTestSortCompareFn;
  20809. private _customTransparentSortCompareFn;
  20810. private _renderingGroupInfo;
  20811. /**
  20812. * Instantiates a new rendering group for a particular scene
  20813. * @param scene Defines the scene the groups belongs to
  20814. */
  20815. constructor(scene: Scene);
  20816. private _clearDepthStencilBuffer;
  20817. /**
  20818. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20819. * @hidden
  20820. */
  20821. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20822. /**
  20823. * Resets the different information of the group to prepare a new frame
  20824. * @hidden
  20825. */
  20826. reset(): void;
  20827. /**
  20828. * Dispose and release the group and its associated resources.
  20829. * @hidden
  20830. */
  20831. dispose(): void;
  20832. /**
  20833. * Clear the info related to rendering groups preventing retention points during dispose.
  20834. */
  20835. freeRenderingGroups(): void;
  20836. private _prepareRenderingGroup;
  20837. /**
  20838. * Add a sprite manager to the rendering manager in order to render it this frame.
  20839. * @param spriteManager Define the sprite manager to render
  20840. */
  20841. dispatchSprites(spriteManager: ISpriteManager): void;
  20842. /**
  20843. * Add a particle system to the rendering manager in order to render it this frame.
  20844. * @param particleSystem Define the particle system to render
  20845. */
  20846. dispatchParticles(particleSystem: IParticleSystem): void;
  20847. /**
  20848. * Add a submesh to the manager in order to render it this frame
  20849. * @param subMesh The submesh to dispatch
  20850. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20851. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20852. */
  20853. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20854. /**
  20855. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20856. * This allowed control for front to back rendering or reversly depending of the special needs.
  20857. *
  20858. * @param renderingGroupId The rendering group id corresponding to its index
  20859. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20860. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20861. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20862. */
  20863. 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;
  20864. /**
  20865. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20866. *
  20867. * @param renderingGroupId The rendering group id corresponding to its index
  20868. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20869. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20870. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20871. */
  20872. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20873. /**
  20874. * Gets the current auto clear configuration for one rendering group of the rendering
  20875. * manager.
  20876. * @param index the rendering group index to get the information for
  20877. * @returns The auto clear setup for the requested rendering group
  20878. */
  20879. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20880. }
  20881. }
  20882. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20883. import { Observable } from "babylonjs/Misc/observable";
  20884. import { SmartArray } from "babylonjs/Misc/smartArray";
  20885. import { Nullable, Immutable } from "babylonjs/types";
  20886. import { Camera } from "babylonjs/Cameras/camera";
  20887. import { Scene } from "babylonjs/scene";
  20888. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20889. import { Color4 } from "babylonjs/Maths/math.color";
  20890. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20892. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20894. import { Texture } from "babylonjs/Materials/Textures/texture";
  20895. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20896. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20897. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20898. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20899. import { Engine } from "babylonjs/Engines/engine";
  20900. /**
  20901. * This Helps creating a texture that will be created from a camera in your scene.
  20902. * It is basically a dynamic texture that could be used to create special effects for instance.
  20903. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20904. */
  20905. export class RenderTargetTexture extends Texture {
  20906. isCube: boolean;
  20907. /**
  20908. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20909. */
  20910. static readonly REFRESHRATE_RENDER_ONCE: number;
  20911. /**
  20912. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20913. */
  20914. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20915. /**
  20916. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20917. * the central point of your effect and can save a lot of performances.
  20918. */
  20919. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20920. /**
  20921. * Use this predicate to dynamically define the list of mesh you want to render.
  20922. * If set, the renderList property will be overwritten.
  20923. */
  20924. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20925. private _renderList;
  20926. /**
  20927. * Use this list to define the list of mesh you want to render.
  20928. */
  20929. get renderList(): Nullable<Array<AbstractMesh>>;
  20930. set renderList(value: Nullable<Array<AbstractMesh>>);
  20931. /**
  20932. * Use this function to overload the renderList array at rendering time.
  20933. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20934. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20935. * the cube (if the RTT is a cube, else layerOrFace=0).
  20936. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20937. */
  20938. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20939. private _hookArray;
  20940. /**
  20941. * Define if particles should be rendered in your texture.
  20942. */
  20943. renderParticles: boolean;
  20944. /**
  20945. * Define if sprites should be rendered in your texture.
  20946. */
  20947. renderSprites: boolean;
  20948. /**
  20949. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20950. */
  20951. coordinatesMode: number;
  20952. /**
  20953. * Define the camera used to render the texture.
  20954. */
  20955. activeCamera: Nullable<Camera>;
  20956. /**
  20957. * Override the render function of the texture with your own one.
  20958. */
  20959. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20960. /**
  20961. * Define if camera post processes should be use while rendering the texture.
  20962. */
  20963. useCameraPostProcesses: boolean;
  20964. /**
  20965. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20966. */
  20967. ignoreCameraViewport: boolean;
  20968. private _postProcessManager;
  20969. private _postProcesses;
  20970. private _resizeObserver;
  20971. /**
  20972. * An event triggered when the texture is unbind.
  20973. */
  20974. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20975. /**
  20976. * An event triggered when the texture is unbind.
  20977. */
  20978. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20979. private _onAfterUnbindObserver;
  20980. /**
  20981. * Set a after unbind callback in the texture.
  20982. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20983. */
  20984. set onAfterUnbind(callback: () => void);
  20985. /**
  20986. * An event triggered before rendering the texture
  20987. */
  20988. onBeforeRenderObservable: Observable<number>;
  20989. private _onBeforeRenderObserver;
  20990. /**
  20991. * Set a before render callback in the texture.
  20992. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20993. */
  20994. set onBeforeRender(callback: (faceIndex: number) => void);
  20995. /**
  20996. * An event triggered after rendering the texture
  20997. */
  20998. onAfterRenderObservable: Observable<number>;
  20999. private _onAfterRenderObserver;
  21000. /**
  21001. * Set a after render callback in the texture.
  21002. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21003. */
  21004. set onAfterRender(callback: (faceIndex: number) => void);
  21005. /**
  21006. * An event triggered after the texture clear
  21007. */
  21008. onClearObservable: Observable<Engine>;
  21009. private _onClearObserver;
  21010. /**
  21011. * Set a clear callback in the texture.
  21012. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21013. */
  21014. set onClear(callback: (Engine: Engine) => void);
  21015. /**
  21016. * An event triggered when the texture is resized.
  21017. */
  21018. onResizeObservable: Observable<RenderTargetTexture>;
  21019. /**
  21020. * Define the clear color of the Render Target if it should be different from the scene.
  21021. */
  21022. clearColor: Color4;
  21023. protected _size: number | {
  21024. width: number;
  21025. height: number;
  21026. layers?: number;
  21027. };
  21028. protected _initialSizeParameter: number | {
  21029. width: number;
  21030. height: number;
  21031. } | {
  21032. ratio: number;
  21033. };
  21034. protected _sizeRatio: Nullable<number>;
  21035. /** @hidden */
  21036. _generateMipMaps: boolean;
  21037. protected _renderingManager: RenderingManager;
  21038. /** @hidden */
  21039. _waitingRenderList: string[];
  21040. protected _doNotChangeAspectRatio: boolean;
  21041. protected _currentRefreshId: number;
  21042. protected _refreshRate: number;
  21043. protected _textureMatrix: Matrix;
  21044. protected _samples: number;
  21045. protected _renderTargetOptions: RenderTargetCreationOptions;
  21046. /**
  21047. * Gets render target creation options that were used.
  21048. */
  21049. get renderTargetOptions(): RenderTargetCreationOptions;
  21050. protected _engine: Engine;
  21051. protected _onRatioRescale(): void;
  21052. /**
  21053. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21054. * It must define where the camera used to render the texture is set
  21055. */
  21056. boundingBoxPosition: Vector3;
  21057. private _boundingBoxSize;
  21058. /**
  21059. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21060. * When defined, the cubemap will switch to local mode
  21061. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21062. * @example https://www.babylonjs-playground.com/#RNASML
  21063. */
  21064. set boundingBoxSize(value: Vector3);
  21065. get boundingBoxSize(): Vector3;
  21066. /**
  21067. * In case the RTT has been created with a depth texture, get the associated
  21068. * depth texture.
  21069. * Otherwise, return null.
  21070. */
  21071. get depthStencilTexture(): Nullable<InternalTexture>;
  21072. /**
  21073. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21074. * or used a shadow, depth texture...
  21075. * @param name The friendly name of the texture
  21076. * @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)
  21077. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21078. * @param generateMipMaps True if mip maps need to be generated after render.
  21079. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21080. * @param type The type of the buffer in the RTT (int, half float, float...)
  21081. * @param isCube True if a cube texture needs to be created
  21082. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21083. * @param generateDepthBuffer True to generate a depth buffer
  21084. * @param generateStencilBuffer True to generate a stencil buffer
  21085. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21086. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21087. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21088. */
  21089. constructor(name: string, size: number | {
  21090. width: number;
  21091. height: number;
  21092. layers?: number;
  21093. } | {
  21094. ratio: number;
  21095. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21096. /**
  21097. * Creates a depth stencil texture.
  21098. * This is only available in WebGL 2 or with the depth texture extension available.
  21099. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21100. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21101. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21102. */
  21103. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21104. private _processSizeParameter;
  21105. /**
  21106. * Define the number of samples to use in case of MSAA.
  21107. * It defaults to one meaning no MSAA has been enabled.
  21108. */
  21109. get samples(): number;
  21110. set samples(value: number);
  21111. /**
  21112. * Resets the refresh counter of the texture and start bak from scratch.
  21113. * Could be useful to regenerate the texture if it is setup to render only once.
  21114. */
  21115. resetRefreshCounter(): void;
  21116. /**
  21117. * Define the refresh rate of the texture or the rendering frequency.
  21118. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21119. */
  21120. get refreshRate(): number;
  21121. set refreshRate(value: number);
  21122. /**
  21123. * Adds a post process to the render target rendering passes.
  21124. * @param postProcess define the post process to add
  21125. */
  21126. addPostProcess(postProcess: PostProcess): void;
  21127. /**
  21128. * Clear all the post processes attached to the render target
  21129. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21130. */
  21131. clearPostProcesses(dispose?: boolean): void;
  21132. /**
  21133. * Remove one of the post process from the list of attached post processes to the texture
  21134. * @param postProcess define the post process to remove from the list
  21135. */
  21136. removePostProcess(postProcess: PostProcess): void;
  21137. /** @hidden */
  21138. _shouldRender(): boolean;
  21139. /**
  21140. * Gets the actual render size of the texture.
  21141. * @returns the width of the render size
  21142. */
  21143. getRenderSize(): number;
  21144. /**
  21145. * Gets the actual render width of the texture.
  21146. * @returns the width of the render size
  21147. */
  21148. getRenderWidth(): number;
  21149. /**
  21150. * Gets the actual render height of the texture.
  21151. * @returns the height of the render size
  21152. */
  21153. getRenderHeight(): number;
  21154. /**
  21155. * Gets the actual number of layers of the texture.
  21156. * @returns the number of layers
  21157. */
  21158. getRenderLayers(): number;
  21159. /**
  21160. * Get if the texture can be rescaled or not.
  21161. */
  21162. get canRescale(): boolean;
  21163. /**
  21164. * Resize the texture using a ratio.
  21165. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21166. */
  21167. scale(ratio: number): void;
  21168. /**
  21169. * Get the texture reflection matrix used to rotate/transform the reflection.
  21170. * @returns the reflection matrix
  21171. */
  21172. getReflectionTextureMatrix(): Matrix;
  21173. /**
  21174. * Resize the texture to a new desired size.
  21175. * Be carrefull as it will recreate all the data in the new texture.
  21176. * @param size Define the new size. It can be:
  21177. * - a number for squared texture,
  21178. * - an object containing { width: number, height: number }
  21179. * - or an object containing a ratio { ratio: number }
  21180. */
  21181. resize(size: number | {
  21182. width: number;
  21183. height: number;
  21184. } | {
  21185. ratio: number;
  21186. }): void;
  21187. private _defaultRenderListPrepared;
  21188. /**
  21189. * Renders all the objects from the render list into the texture.
  21190. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21191. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21192. */
  21193. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21194. private _bestReflectionRenderTargetDimension;
  21195. private _prepareRenderingManager;
  21196. /**
  21197. * @hidden
  21198. * @param faceIndex face index to bind to if this is a cubetexture
  21199. * @param layer defines the index of the texture to bind in the array
  21200. */
  21201. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21202. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21203. private renderToTarget;
  21204. /**
  21205. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21206. * This allowed control for front to back rendering or reversly depending of the special needs.
  21207. *
  21208. * @param renderingGroupId The rendering group id corresponding to its index
  21209. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21210. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21211. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21212. */
  21213. 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;
  21214. /**
  21215. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21216. *
  21217. * @param renderingGroupId The rendering group id corresponding to its index
  21218. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21219. */
  21220. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21221. /**
  21222. * Clones the texture.
  21223. * @returns the cloned texture
  21224. */
  21225. clone(): RenderTargetTexture;
  21226. /**
  21227. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21228. * @returns The JSON representation of the texture
  21229. */
  21230. serialize(): any;
  21231. /**
  21232. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21233. */
  21234. disposeFramebufferObjects(): void;
  21235. /**
  21236. * Dispose the texture and release its associated resources.
  21237. */
  21238. dispose(): void;
  21239. /** @hidden */
  21240. _rebuild(): void;
  21241. /**
  21242. * Clear the info related to rendering groups preventing retention point in material dispose.
  21243. */
  21244. freeRenderingGroups(): void;
  21245. /**
  21246. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21247. * @returns the view count
  21248. */
  21249. getViewCount(): number;
  21250. }
  21251. }
  21252. declare module "babylonjs/Materials/material" {
  21253. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21254. import { SmartArray } from "babylonjs/Misc/smartArray";
  21255. import { Observable } from "babylonjs/Misc/observable";
  21256. import { Nullable } from "babylonjs/types";
  21257. import { Scene } from "babylonjs/scene";
  21258. import { Matrix } from "babylonjs/Maths/math.vector";
  21259. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21261. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21262. import { Effect } from "babylonjs/Materials/effect";
  21263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21265. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21266. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21267. import { Mesh } from "babylonjs/Meshes/mesh";
  21268. import { Animation } from "babylonjs/Animations/animation";
  21269. /**
  21270. * Options for compiling materials.
  21271. */
  21272. export interface IMaterialCompilationOptions {
  21273. /**
  21274. * Defines whether clip planes are enabled.
  21275. */
  21276. clipPlane: boolean;
  21277. /**
  21278. * Defines whether instances are enabled.
  21279. */
  21280. useInstances: boolean;
  21281. }
  21282. /**
  21283. * Base class for the main features of a material in Babylon.js
  21284. */
  21285. export class Material implements IAnimatable {
  21286. /**
  21287. * Returns the triangle fill mode
  21288. */
  21289. static readonly TriangleFillMode: number;
  21290. /**
  21291. * Returns the wireframe mode
  21292. */
  21293. static readonly WireFrameFillMode: number;
  21294. /**
  21295. * Returns the point fill mode
  21296. */
  21297. static readonly PointFillMode: number;
  21298. /**
  21299. * Returns the point list draw mode
  21300. */
  21301. static readonly PointListDrawMode: number;
  21302. /**
  21303. * Returns the line list draw mode
  21304. */
  21305. static readonly LineListDrawMode: number;
  21306. /**
  21307. * Returns the line loop draw mode
  21308. */
  21309. static readonly LineLoopDrawMode: number;
  21310. /**
  21311. * Returns the line strip draw mode
  21312. */
  21313. static readonly LineStripDrawMode: number;
  21314. /**
  21315. * Returns the triangle strip draw mode
  21316. */
  21317. static readonly TriangleStripDrawMode: number;
  21318. /**
  21319. * Returns the triangle fan draw mode
  21320. */
  21321. static readonly TriangleFanDrawMode: number;
  21322. /**
  21323. * Stores the clock-wise side orientation
  21324. */
  21325. static readonly ClockWiseSideOrientation: number;
  21326. /**
  21327. * Stores the counter clock-wise side orientation
  21328. */
  21329. static readonly CounterClockWiseSideOrientation: number;
  21330. /**
  21331. * The dirty texture flag value
  21332. */
  21333. static readonly TextureDirtyFlag: number;
  21334. /**
  21335. * The dirty light flag value
  21336. */
  21337. static readonly LightDirtyFlag: number;
  21338. /**
  21339. * The dirty fresnel flag value
  21340. */
  21341. static readonly FresnelDirtyFlag: number;
  21342. /**
  21343. * The dirty attribute flag value
  21344. */
  21345. static readonly AttributesDirtyFlag: number;
  21346. /**
  21347. * The dirty misc flag value
  21348. */
  21349. static readonly MiscDirtyFlag: number;
  21350. /**
  21351. * The all dirty flag value
  21352. */
  21353. static readonly AllDirtyFlag: number;
  21354. /**
  21355. * The ID of the material
  21356. */
  21357. id: string;
  21358. /**
  21359. * Gets or sets the unique id of the material
  21360. */
  21361. uniqueId: number;
  21362. /**
  21363. * The name of the material
  21364. */
  21365. name: string;
  21366. /**
  21367. * Gets or sets user defined metadata
  21368. */
  21369. metadata: any;
  21370. /**
  21371. * For internal use only. Please do not use.
  21372. */
  21373. reservedDataStore: any;
  21374. /**
  21375. * Specifies if the ready state should be checked on each call
  21376. */
  21377. checkReadyOnEveryCall: boolean;
  21378. /**
  21379. * Specifies if the ready state should be checked once
  21380. */
  21381. checkReadyOnlyOnce: boolean;
  21382. /**
  21383. * The state of the material
  21384. */
  21385. state: string;
  21386. /**
  21387. * The alpha value of the material
  21388. */
  21389. protected _alpha: number;
  21390. /**
  21391. * List of inspectable custom properties (used by the Inspector)
  21392. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21393. */
  21394. inspectableCustomProperties: IInspectable[];
  21395. /**
  21396. * Sets the alpha value of the material
  21397. */
  21398. set alpha(value: number);
  21399. /**
  21400. * Gets the alpha value of the material
  21401. */
  21402. get alpha(): number;
  21403. /**
  21404. * Specifies if back face culling is enabled
  21405. */
  21406. protected _backFaceCulling: boolean;
  21407. /**
  21408. * Sets the back-face culling state
  21409. */
  21410. set backFaceCulling(value: boolean);
  21411. /**
  21412. * Gets the back-face culling state
  21413. */
  21414. get backFaceCulling(): boolean;
  21415. /**
  21416. * Stores the value for side orientation
  21417. */
  21418. sideOrientation: number;
  21419. /**
  21420. * Callback triggered when the material is compiled
  21421. */
  21422. onCompiled: Nullable<(effect: Effect) => void>;
  21423. /**
  21424. * Callback triggered when an error occurs
  21425. */
  21426. onError: Nullable<(effect: Effect, errors: string) => void>;
  21427. /**
  21428. * Callback triggered to get the render target textures
  21429. */
  21430. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21431. /**
  21432. * Gets a boolean indicating that current material needs to register RTT
  21433. */
  21434. get hasRenderTargetTextures(): boolean;
  21435. /**
  21436. * Specifies if the material should be serialized
  21437. */
  21438. doNotSerialize: boolean;
  21439. /**
  21440. * @hidden
  21441. */
  21442. _storeEffectOnSubMeshes: boolean;
  21443. /**
  21444. * Stores the animations for the material
  21445. */
  21446. animations: Nullable<Array<Animation>>;
  21447. /**
  21448. * An event triggered when the material is disposed
  21449. */
  21450. onDisposeObservable: Observable<Material>;
  21451. /**
  21452. * An observer which watches for dispose events
  21453. */
  21454. private _onDisposeObserver;
  21455. private _onUnBindObservable;
  21456. /**
  21457. * Called during a dispose event
  21458. */
  21459. set onDispose(callback: () => void);
  21460. private _onBindObservable;
  21461. /**
  21462. * An event triggered when the material is bound
  21463. */
  21464. get onBindObservable(): Observable<AbstractMesh>;
  21465. /**
  21466. * An observer which watches for bind events
  21467. */
  21468. private _onBindObserver;
  21469. /**
  21470. * Called during a bind event
  21471. */
  21472. set onBind(callback: (Mesh: AbstractMesh) => void);
  21473. /**
  21474. * An event triggered when the material is unbound
  21475. */
  21476. get onUnBindObservable(): Observable<Material>;
  21477. /**
  21478. * Stores the value of the alpha mode
  21479. */
  21480. private _alphaMode;
  21481. /**
  21482. * Sets the value of the alpha mode.
  21483. *
  21484. * | Value | Type | Description |
  21485. * | --- | --- | --- |
  21486. * | 0 | ALPHA_DISABLE | |
  21487. * | 1 | ALPHA_ADD | |
  21488. * | 2 | ALPHA_COMBINE | |
  21489. * | 3 | ALPHA_SUBTRACT | |
  21490. * | 4 | ALPHA_MULTIPLY | |
  21491. * | 5 | ALPHA_MAXIMIZED | |
  21492. * | 6 | ALPHA_ONEONE | |
  21493. * | 7 | ALPHA_PREMULTIPLIED | |
  21494. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21495. * | 9 | ALPHA_INTERPOLATE | |
  21496. * | 10 | ALPHA_SCREENMODE | |
  21497. *
  21498. */
  21499. set alphaMode(value: number);
  21500. /**
  21501. * Gets the value of the alpha mode
  21502. */
  21503. get alphaMode(): number;
  21504. /**
  21505. * Stores the state of the need depth pre-pass value
  21506. */
  21507. private _needDepthPrePass;
  21508. /**
  21509. * Sets the need depth pre-pass value
  21510. */
  21511. set needDepthPrePass(value: boolean);
  21512. /**
  21513. * Gets the depth pre-pass value
  21514. */
  21515. get needDepthPrePass(): boolean;
  21516. /**
  21517. * Specifies if depth writing should be disabled
  21518. */
  21519. disableDepthWrite: boolean;
  21520. /**
  21521. * Specifies if depth writing should be forced
  21522. */
  21523. forceDepthWrite: boolean;
  21524. /**
  21525. * Specifies the depth function that should be used. 0 means the default engine function
  21526. */
  21527. depthFunction: number;
  21528. /**
  21529. * Specifies if there should be a separate pass for culling
  21530. */
  21531. separateCullingPass: boolean;
  21532. /**
  21533. * Stores the state specifing if fog should be enabled
  21534. */
  21535. private _fogEnabled;
  21536. /**
  21537. * Sets the state for enabling fog
  21538. */
  21539. set fogEnabled(value: boolean);
  21540. /**
  21541. * Gets the value of the fog enabled state
  21542. */
  21543. get fogEnabled(): boolean;
  21544. /**
  21545. * Stores the size of points
  21546. */
  21547. pointSize: number;
  21548. /**
  21549. * Stores the z offset value
  21550. */
  21551. zOffset: number;
  21552. /**
  21553. * Gets a value specifying if wireframe mode is enabled
  21554. */
  21555. get wireframe(): boolean;
  21556. /**
  21557. * Sets the state of wireframe mode
  21558. */
  21559. set wireframe(value: boolean);
  21560. /**
  21561. * Gets the value specifying if point clouds are enabled
  21562. */
  21563. get pointsCloud(): boolean;
  21564. /**
  21565. * Sets the state of point cloud mode
  21566. */
  21567. set pointsCloud(value: boolean);
  21568. /**
  21569. * Gets the material fill mode
  21570. */
  21571. get fillMode(): number;
  21572. /**
  21573. * Sets the material fill mode
  21574. */
  21575. set fillMode(value: number);
  21576. /**
  21577. * @hidden
  21578. * Stores the effects for the material
  21579. */
  21580. _effect: Nullable<Effect>;
  21581. /**
  21582. * Specifies if uniform buffers should be used
  21583. */
  21584. private _useUBO;
  21585. /**
  21586. * Stores a reference to the scene
  21587. */
  21588. private _scene;
  21589. /**
  21590. * Stores the fill mode state
  21591. */
  21592. private _fillMode;
  21593. /**
  21594. * Specifies if the depth write state should be cached
  21595. */
  21596. private _cachedDepthWriteState;
  21597. /**
  21598. * Specifies if the depth function state should be cached
  21599. */
  21600. private _cachedDepthFunctionState;
  21601. /**
  21602. * Stores the uniform buffer
  21603. */
  21604. protected _uniformBuffer: UniformBuffer;
  21605. /** @hidden */
  21606. _indexInSceneMaterialArray: number;
  21607. /** @hidden */
  21608. meshMap: Nullable<{
  21609. [id: string]: AbstractMesh | undefined;
  21610. }>;
  21611. /**
  21612. * Creates a material instance
  21613. * @param name defines the name of the material
  21614. * @param scene defines the scene to reference
  21615. * @param doNotAdd specifies if the material should be added to the scene
  21616. */
  21617. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21618. /**
  21619. * Returns a string representation of the current material
  21620. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21621. * @returns a string with material information
  21622. */
  21623. toString(fullDetails?: boolean): string;
  21624. /**
  21625. * Gets the class name of the material
  21626. * @returns a string with the class name of the material
  21627. */
  21628. getClassName(): string;
  21629. /**
  21630. * Specifies if updates for the material been locked
  21631. */
  21632. get isFrozen(): boolean;
  21633. /**
  21634. * Locks updates for the material
  21635. */
  21636. freeze(): void;
  21637. /**
  21638. * Unlocks updates for the material
  21639. */
  21640. unfreeze(): void;
  21641. /**
  21642. * Specifies if the material is ready to be used
  21643. * @param mesh defines the mesh to check
  21644. * @param useInstances specifies if instances should be used
  21645. * @returns a boolean indicating if the material is ready to be used
  21646. */
  21647. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21648. /**
  21649. * Specifies that the submesh is ready to be used
  21650. * @param mesh defines the mesh to check
  21651. * @param subMesh defines which submesh to check
  21652. * @param useInstances specifies that instances should be used
  21653. * @returns a boolean indicating that the submesh is ready or not
  21654. */
  21655. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21656. /**
  21657. * Returns the material effect
  21658. * @returns the effect associated with the material
  21659. */
  21660. getEffect(): Nullable<Effect>;
  21661. /**
  21662. * Returns the current scene
  21663. * @returns a Scene
  21664. */
  21665. getScene(): Scene;
  21666. /**
  21667. * Specifies if the material will require alpha blending
  21668. * @returns a boolean specifying if alpha blending is needed
  21669. */
  21670. needAlphaBlending(): boolean;
  21671. /**
  21672. * Specifies if the mesh will require alpha blending
  21673. * @param mesh defines the mesh to check
  21674. * @returns a boolean specifying if alpha blending is needed for the mesh
  21675. */
  21676. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21677. /**
  21678. * Specifies if this material should be rendered in alpha test mode
  21679. * @returns a boolean specifying if an alpha test is needed.
  21680. */
  21681. needAlphaTesting(): boolean;
  21682. /**
  21683. * Gets the texture used for the alpha test
  21684. * @returns the texture to use for alpha testing
  21685. */
  21686. getAlphaTestTexture(): Nullable<BaseTexture>;
  21687. /**
  21688. * Marks the material to indicate that it needs to be re-calculated
  21689. */
  21690. markDirty(): void;
  21691. /** @hidden */
  21692. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21693. /**
  21694. * Binds the material to the mesh
  21695. * @param world defines the world transformation matrix
  21696. * @param mesh defines the mesh to bind the material to
  21697. */
  21698. bind(world: Matrix, mesh?: Mesh): void;
  21699. /**
  21700. * Binds the submesh to the material
  21701. * @param world defines the world transformation matrix
  21702. * @param mesh defines the mesh containing the submesh
  21703. * @param subMesh defines the submesh to bind the material to
  21704. */
  21705. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21706. /**
  21707. * Binds the world matrix to the material
  21708. * @param world defines the world transformation matrix
  21709. */
  21710. bindOnlyWorldMatrix(world: Matrix): void;
  21711. /**
  21712. * Binds the scene's uniform buffer to the effect.
  21713. * @param effect defines the effect to bind to the scene uniform buffer
  21714. * @param sceneUbo defines the uniform buffer storing scene data
  21715. */
  21716. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21717. /**
  21718. * Binds the view matrix to the effect
  21719. * @param effect defines the effect to bind the view matrix to
  21720. */
  21721. bindView(effect: Effect): void;
  21722. /**
  21723. * Binds the view projection matrix to the effect
  21724. * @param effect defines the effect to bind the view projection matrix to
  21725. */
  21726. bindViewProjection(effect: Effect): void;
  21727. /**
  21728. * Specifies if material alpha testing should be turned on for the mesh
  21729. * @param mesh defines the mesh to check
  21730. */
  21731. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21732. /**
  21733. * Processes to execute after binding the material to a mesh
  21734. * @param mesh defines the rendered mesh
  21735. */
  21736. protected _afterBind(mesh?: Mesh): void;
  21737. /**
  21738. * Unbinds the material from the mesh
  21739. */
  21740. unbind(): void;
  21741. /**
  21742. * Gets the active textures from the material
  21743. * @returns an array of textures
  21744. */
  21745. getActiveTextures(): BaseTexture[];
  21746. /**
  21747. * Specifies if the material uses a texture
  21748. * @param texture defines the texture to check against the material
  21749. * @returns a boolean specifying if the material uses the texture
  21750. */
  21751. hasTexture(texture: BaseTexture): boolean;
  21752. /**
  21753. * Makes a duplicate of the material, and gives it a new name
  21754. * @param name defines the new name for the duplicated material
  21755. * @returns the cloned material
  21756. */
  21757. clone(name: string): Nullable<Material>;
  21758. /**
  21759. * Gets the meshes bound to the material
  21760. * @returns an array of meshes bound to the material
  21761. */
  21762. getBindedMeshes(): AbstractMesh[];
  21763. /**
  21764. * Force shader compilation
  21765. * @param mesh defines the mesh associated with this material
  21766. * @param onCompiled defines a function to execute once the material is compiled
  21767. * @param options defines the options to configure the compilation
  21768. * @param onError defines a function to execute if the material fails compiling
  21769. */
  21770. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21771. /**
  21772. * Force shader compilation
  21773. * @param mesh defines the mesh that will use this material
  21774. * @param options defines additional options for compiling the shaders
  21775. * @returns a promise that resolves when the compilation completes
  21776. */
  21777. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21778. private static readonly _AllDirtyCallBack;
  21779. private static readonly _ImageProcessingDirtyCallBack;
  21780. private static readonly _TextureDirtyCallBack;
  21781. private static readonly _FresnelDirtyCallBack;
  21782. private static readonly _MiscDirtyCallBack;
  21783. private static readonly _LightsDirtyCallBack;
  21784. private static readonly _AttributeDirtyCallBack;
  21785. private static _FresnelAndMiscDirtyCallBack;
  21786. private static _TextureAndMiscDirtyCallBack;
  21787. private static readonly _DirtyCallbackArray;
  21788. private static readonly _RunDirtyCallBacks;
  21789. /**
  21790. * Marks a define in the material to indicate that it needs to be re-computed
  21791. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21792. */
  21793. markAsDirty(flag: number): void;
  21794. /**
  21795. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21796. * @param func defines a function which checks material defines against the submeshes
  21797. */
  21798. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21799. /**
  21800. * Indicates that we need to re-calculated for all submeshes
  21801. */
  21802. protected _markAllSubMeshesAsAllDirty(): void;
  21803. /**
  21804. * Indicates that image processing needs to be re-calculated for all submeshes
  21805. */
  21806. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21807. /**
  21808. * Indicates that textures need to be re-calculated for all submeshes
  21809. */
  21810. protected _markAllSubMeshesAsTexturesDirty(): void;
  21811. /**
  21812. * Indicates that fresnel needs to be re-calculated for all submeshes
  21813. */
  21814. protected _markAllSubMeshesAsFresnelDirty(): void;
  21815. /**
  21816. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21817. */
  21818. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21819. /**
  21820. * Indicates that lights need to be re-calculated for all submeshes
  21821. */
  21822. protected _markAllSubMeshesAsLightsDirty(): void;
  21823. /**
  21824. * Indicates that attributes need to be re-calculated for all submeshes
  21825. */
  21826. protected _markAllSubMeshesAsAttributesDirty(): void;
  21827. /**
  21828. * Indicates that misc needs to be re-calculated for all submeshes
  21829. */
  21830. protected _markAllSubMeshesAsMiscDirty(): void;
  21831. /**
  21832. * Indicates that textures and misc need to be re-calculated for all submeshes
  21833. */
  21834. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21835. /**
  21836. * Disposes the material
  21837. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21838. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21839. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21840. */
  21841. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21842. /** @hidden */
  21843. private releaseVertexArrayObject;
  21844. /**
  21845. * Serializes this material
  21846. * @returns the serialized material object
  21847. */
  21848. serialize(): any;
  21849. /**
  21850. * Creates a material from parsed material data
  21851. * @param parsedMaterial defines parsed material data
  21852. * @param scene defines the hosting scene
  21853. * @param rootUrl defines the root URL to use to load textures
  21854. * @returns a new material
  21855. */
  21856. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21857. }
  21858. }
  21859. declare module "babylonjs/Materials/multiMaterial" {
  21860. import { Nullable } from "babylonjs/types";
  21861. import { Scene } from "babylonjs/scene";
  21862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21863. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21864. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21865. import { Material } from "babylonjs/Materials/material";
  21866. /**
  21867. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21868. * separate meshes. This can be use to improve performances.
  21869. * @see http://doc.babylonjs.com/how_to/multi_materials
  21870. */
  21871. export class MultiMaterial extends Material {
  21872. private _subMaterials;
  21873. /**
  21874. * Gets or Sets the list of Materials used within the multi material.
  21875. * They need to be ordered according to the submeshes order in the associated mesh
  21876. */
  21877. get subMaterials(): Nullable<Material>[];
  21878. set subMaterials(value: Nullable<Material>[]);
  21879. /**
  21880. * Function used to align with Node.getChildren()
  21881. * @returns the list of Materials used within the multi material
  21882. */
  21883. getChildren(): Nullable<Material>[];
  21884. /**
  21885. * Instantiates a new Multi Material
  21886. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21887. * separate meshes. This can be use to improve performances.
  21888. * @see http://doc.babylonjs.com/how_to/multi_materials
  21889. * @param name Define the name in the scene
  21890. * @param scene Define the scene the material belongs to
  21891. */
  21892. constructor(name: string, scene: Scene);
  21893. private _hookArray;
  21894. /**
  21895. * Get one of the submaterial by its index in the submaterials array
  21896. * @param index The index to look the sub material at
  21897. * @returns The Material if the index has been defined
  21898. */
  21899. getSubMaterial(index: number): Nullable<Material>;
  21900. /**
  21901. * Get the list of active textures for the whole sub materials list.
  21902. * @returns All the textures that will be used during the rendering
  21903. */
  21904. getActiveTextures(): BaseTexture[];
  21905. /**
  21906. * Gets the current class name of the material e.g. "MultiMaterial"
  21907. * Mainly use in serialization.
  21908. * @returns the class name
  21909. */
  21910. getClassName(): string;
  21911. /**
  21912. * Checks if the material is ready to render the requested sub mesh
  21913. * @param mesh Define the mesh the submesh belongs to
  21914. * @param subMesh Define the sub mesh to look readyness for
  21915. * @param useInstances Define whether or not the material is used with instances
  21916. * @returns true if ready, otherwise false
  21917. */
  21918. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21919. /**
  21920. * Clones the current material and its related sub materials
  21921. * @param name Define the name of the newly cloned material
  21922. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21923. * @returns the cloned material
  21924. */
  21925. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21926. /**
  21927. * Serializes the materials into a JSON representation.
  21928. * @returns the JSON representation
  21929. */
  21930. serialize(): any;
  21931. /**
  21932. * Dispose the material and release its associated resources
  21933. * @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)
  21934. * @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)
  21935. * @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)
  21936. */
  21937. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21938. /**
  21939. * Creates a MultiMaterial from parsed MultiMaterial data.
  21940. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21941. * @param scene defines the hosting scene
  21942. * @returns a new MultiMaterial
  21943. */
  21944. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21945. }
  21946. }
  21947. declare module "babylonjs/Meshes/subMesh" {
  21948. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21949. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21950. import { Engine } from "babylonjs/Engines/engine";
  21951. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21952. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21953. import { Effect } from "babylonjs/Materials/effect";
  21954. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21955. import { Plane } from "babylonjs/Maths/math.plane";
  21956. import { Collider } from "babylonjs/Collisions/collider";
  21957. import { Material } from "babylonjs/Materials/material";
  21958. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21960. import { Mesh } from "babylonjs/Meshes/mesh";
  21961. import { Ray } from "babylonjs/Culling/ray";
  21962. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21963. /**
  21964. * Base class for submeshes
  21965. */
  21966. export class BaseSubMesh {
  21967. /** @hidden */
  21968. _materialDefines: Nullable<MaterialDefines>;
  21969. /** @hidden */
  21970. _materialEffect: Nullable<Effect>;
  21971. /**
  21972. * Gets material defines used by the effect associated to the sub mesh
  21973. */
  21974. get materialDefines(): Nullable<MaterialDefines>;
  21975. /**
  21976. * Sets material defines used by the effect associated to the sub mesh
  21977. */
  21978. set materialDefines(defines: Nullable<MaterialDefines>);
  21979. /**
  21980. * Gets associated effect
  21981. */
  21982. get effect(): Nullable<Effect>;
  21983. /**
  21984. * Sets associated effect (effect used to render this submesh)
  21985. * @param effect defines the effect to associate with
  21986. * @param defines defines the set of defines used to compile this effect
  21987. */
  21988. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21989. }
  21990. /**
  21991. * Defines a subdivision inside a mesh
  21992. */
  21993. export class SubMesh extends BaseSubMesh implements ICullable {
  21994. /** the material index to use */
  21995. materialIndex: number;
  21996. /** vertex index start */
  21997. verticesStart: number;
  21998. /** vertices count */
  21999. verticesCount: number;
  22000. /** index start */
  22001. indexStart: number;
  22002. /** indices count */
  22003. indexCount: number;
  22004. /** @hidden */
  22005. _linesIndexCount: number;
  22006. private _mesh;
  22007. private _renderingMesh;
  22008. private _boundingInfo;
  22009. private _linesIndexBuffer;
  22010. /** @hidden */
  22011. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22012. /** @hidden */
  22013. _trianglePlanes: Plane[];
  22014. /** @hidden */
  22015. _lastColliderTransformMatrix: Nullable<Matrix>;
  22016. /** @hidden */
  22017. _renderId: number;
  22018. /** @hidden */
  22019. _alphaIndex: number;
  22020. /** @hidden */
  22021. _distanceToCamera: number;
  22022. /** @hidden */
  22023. _id: number;
  22024. private _currentMaterial;
  22025. /**
  22026. * Add a new submesh to a mesh
  22027. * @param materialIndex defines the material index to use
  22028. * @param verticesStart defines vertex index start
  22029. * @param verticesCount defines vertices count
  22030. * @param indexStart defines index start
  22031. * @param indexCount defines indices count
  22032. * @param mesh defines the parent mesh
  22033. * @param renderingMesh defines an optional rendering mesh
  22034. * @param createBoundingBox defines if bounding box should be created for this submesh
  22035. * @returns the new submesh
  22036. */
  22037. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22038. /**
  22039. * Creates a new submesh
  22040. * @param materialIndex defines the material index to use
  22041. * @param verticesStart defines vertex index start
  22042. * @param verticesCount defines vertices count
  22043. * @param indexStart defines index start
  22044. * @param indexCount defines indices count
  22045. * @param mesh defines the parent mesh
  22046. * @param renderingMesh defines an optional rendering mesh
  22047. * @param createBoundingBox defines if bounding box should be created for this submesh
  22048. */
  22049. constructor(
  22050. /** the material index to use */
  22051. materialIndex: number,
  22052. /** vertex index start */
  22053. verticesStart: number,
  22054. /** vertices count */
  22055. verticesCount: number,
  22056. /** index start */
  22057. indexStart: number,
  22058. /** indices count */
  22059. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22060. /**
  22061. * Returns true if this submesh covers the entire parent mesh
  22062. * @ignorenaming
  22063. */
  22064. get IsGlobal(): boolean;
  22065. /**
  22066. * Returns the submesh BoudingInfo object
  22067. * @returns current bounding info (or mesh's one if the submesh is global)
  22068. */
  22069. getBoundingInfo(): BoundingInfo;
  22070. /**
  22071. * Sets the submesh BoundingInfo
  22072. * @param boundingInfo defines the new bounding info to use
  22073. * @returns the SubMesh
  22074. */
  22075. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22076. /**
  22077. * Returns the mesh of the current submesh
  22078. * @return the parent mesh
  22079. */
  22080. getMesh(): AbstractMesh;
  22081. /**
  22082. * Returns the rendering mesh of the submesh
  22083. * @returns the rendering mesh (could be different from parent mesh)
  22084. */
  22085. getRenderingMesh(): Mesh;
  22086. /**
  22087. * Returns the submesh material
  22088. * @returns null or the current material
  22089. */
  22090. getMaterial(): Nullable<Material>;
  22091. /**
  22092. * Sets a new updated BoundingInfo object to the submesh
  22093. * @param data defines an optional position array to use to determine the bounding info
  22094. * @returns the SubMesh
  22095. */
  22096. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22097. /** @hidden */
  22098. _checkCollision(collider: Collider): boolean;
  22099. /**
  22100. * Updates the submesh BoundingInfo
  22101. * @param world defines the world matrix to use to update the bounding info
  22102. * @returns the submesh
  22103. */
  22104. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22105. /**
  22106. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22107. * @param frustumPlanes defines the frustum planes
  22108. * @returns true if the submesh is intersecting with the frustum
  22109. */
  22110. isInFrustum(frustumPlanes: Plane[]): boolean;
  22111. /**
  22112. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22113. * @param frustumPlanes defines the frustum planes
  22114. * @returns true if the submesh is inside the frustum
  22115. */
  22116. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22117. /**
  22118. * Renders the submesh
  22119. * @param enableAlphaMode defines if alpha needs to be used
  22120. * @returns the submesh
  22121. */
  22122. render(enableAlphaMode: boolean): SubMesh;
  22123. /**
  22124. * @hidden
  22125. */
  22126. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22127. /**
  22128. * Checks if the submesh intersects with a ray
  22129. * @param ray defines the ray to test
  22130. * @returns true is the passed ray intersects the submesh bounding box
  22131. */
  22132. canIntersects(ray: Ray): boolean;
  22133. /**
  22134. * Intersects current submesh with a ray
  22135. * @param ray defines the ray to test
  22136. * @param positions defines mesh's positions array
  22137. * @param indices defines mesh's indices array
  22138. * @param fastCheck defines if only bounding info should be used
  22139. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22140. * @returns intersection info or null if no intersection
  22141. */
  22142. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22143. /** @hidden */
  22144. private _intersectLines;
  22145. /** @hidden */
  22146. private _intersectUnIndexedLines;
  22147. /** @hidden */
  22148. private _intersectTriangles;
  22149. /** @hidden */
  22150. private _intersectUnIndexedTriangles;
  22151. /** @hidden */
  22152. _rebuild(): void;
  22153. /**
  22154. * Creates a new submesh from the passed mesh
  22155. * @param newMesh defines the new hosting mesh
  22156. * @param newRenderingMesh defines an optional rendering mesh
  22157. * @returns the new submesh
  22158. */
  22159. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22160. /**
  22161. * Release associated resources
  22162. */
  22163. dispose(): void;
  22164. /**
  22165. * Gets the class name
  22166. * @returns the string "SubMesh".
  22167. */
  22168. getClassName(): string;
  22169. /**
  22170. * Creates a new submesh from indices data
  22171. * @param materialIndex the index of the main mesh material
  22172. * @param startIndex the index where to start the copy in the mesh indices array
  22173. * @param indexCount the number of indices to copy then from the startIndex
  22174. * @param mesh the main mesh to create the submesh from
  22175. * @param renderingMesh the optional rendering mesh
  22176. * @returns a new submesh
  22177. */
  22178. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22179. }
  22180. }
  22181. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22182. /**
  22183. * Class used to represent data loading progression
  22184. */
  22185. export class SceneLoaderFlags {
  22186. private static _ForceFullSceneLoadingForIncremental;
  22187. private static _ShowLoadingScreen;
  22188. private static _CleanBoneMatrixWeights;
  22189. private static _loggingLevel;
  22190. /**
  22191. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22192. */
  22193. static get ForceFullSceneLoadingForIncremental(): boolean;
  22194. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22195. /**
  22196. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22197. */
  22198. static get ShowLoadingScreen(): boolean;
  22199. static set ShowLoadingScreen(value: boolean);
  22200. /**
  22201. * Defines the current logging level (while loading the scene)
  22202. * @ignorenaming
  22203. */
  22204. static get loggingLevel(): number;
  22205. static set loggingLevel(value: number);
  22206. /**
  22207. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22208. */
  22209. static get CleanBoneMatrixWeights(): boolean;
  22210. static set CleanBoneMatrixWeights(value: boolean);
  22211. }
  22212. }
  22213. declare module "babylonjs/Meshes/geometry" {
  22214. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22215. import { Scene } from "babylonjs/scene";
  22216. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22217. import { Engine } from "babylonjs/Engines/engine";
  22218. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22219. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22220. import { Effect } from "babylonjs/Materials/effect";
  22221. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22222. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22223. import { Mesh } from "babylonjs/Meshes/mesh";
  22224. /**
  22225. * Class used to store geometry data (vertex buffers + index buffer)
  22226. */
  22227. export class Geometry implements IGetSetVerticesData {
  22228. /**
  22229. * Gets or sets the ID of the geometry
  22230. */
  22231. id: string;
  22232. /**
  22233. * Gets or sets the unique ID of the geometry
  22234. */
  22235. uniqueId: number;
  22236. /**
  22237. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22238. */
  22239. delayLoadState: number;
  22240. /**
  22241. * Gets the file containing the data to load when running in delay load state
  22242. */
  22243. delayLoadingFile: Nullable<string>;
  22244. /**
  22245. * Callback called when the geometry is updated
  22246. */
  22247. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22248. private _scene;
  22249. private _engine;
  22250. private _meshes;
  22251. private _totalVertices;
  22252. /** @hidden */
  22253. _indices: IndicesArray;
  22254. /** @hidden */
  22255. _vertexBuffers: {
  22256. [key: string]: VertexBuffer;
  22257. };
  22258. private _isDisposed;
  22259. private _extend;
  22260. private _boundingBias;
  22261. /** @hidden */
  22262. _delayInfo: Array<string>;
  22263. private _indexBuffer;
  22264. private _indexBufferIsUpdatable;
  22265. /** @hidden */
  22266. _boundingInfo: Nullable<BoundingInfo>;
  22267. /** @hidden */
  22268. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22269. /** @hidden */
  22270. _softwareSkinningFrameId: number;
  22271. private _vertexArrayObjects;
  22272. private _updatable;
  22273. /** @hidden */
  22274. _positions: Nullable<Vector3[]>;
  22275. /**
  22276. * 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
  22277. */
  22278. get boundingBias(): Vector2;
  22279. /**
  22280. * 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
  22281. */
  22282. set boundingBias(value: Vector2);
  22283. /**
  22284. * Static function used to attach a new empty geometry to a mesh
  22285. * @param mesh defines the mesh to attach the geometry to
  22286. * @returns the new Geometry
  22287. */
  22288. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22289. /**
  22290. * Creates a new geometry
  22291. * @param id defines the unique ID
  22292. * @param scene defines the hosting scene
  22293. * @param vertexData defines the VertexData used to get geometry data
  22294. * @param updatable defines if geometry must be updatable (false by default)
  22295. * @param mesh defines the mesh that will be associated with the geometry
  22296. */
  22297. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22298. /**
  22299. * Gets the current extend of the geometry
  22300. */
  22301. get extend(): {
  22302. minimum: Vector3;
  22303. maximum: Vector3;
  22304. };
  22305. /**
  22306. * Gets the hosting scene
  22307. * @returns the hosting Scene
  22308. */
  22309. getScene(): Scene;
  22310. /**
  22311. * Gets the hosting engine
  22312. * @returns the hosting Engine
  22313. */
  22314. getEngine(): Engine;
  22315. /**
  22316. * Defines if the geometry is ready to use
  22317. * @returns true if the geometry is ready to be used
  22318. */
  22319. isReady(): boolean;
  22320. /**
  22321. * Gets a value indicating that the geometry should not be serialized
  22322. */
  22323. get doNotSerialize(): boolean;
  22324. /** @hidden */
  22325. _rebuild(): void;
  22326. /**
  22327. * Affects all geometry data in one call
  22328. * @param vertexData defines the geometry data
  22329. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22330. */
  22331. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22332. /**
  22333. * Set specific vertex data
  22334. * @param kind defines the data kind (Position, normal, etc...)
  22335. * @param data defines the vertex data to use
  22336. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22337. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22338. */
  22339. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22340. /**
  22341. * Removes a specific vertex data
  22342. * @param kind defines the data kind (Position, normal, etc...)
  22343. */
  22344. removeVerticesData(kind: string): void;
  22345. /**
  22346. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22347. * @param buffer defines the vertex buffer to use
  22348. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22349. */
  22350. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22351. /**
  22352. * Update a specific vertex buffer
  22353. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22354. * It will do nothing if the buffer is not updatable
  22355. * @param kind defines the data kind (Position, normal, etc...)
  22356. * @param data defines the data to use
  22357. * @param offset defines the offset in the target buffer where to store the data
  22358. * @param useBytes set to true if the offset is in bytes
  22359. */
  22360. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22361. /**
  22362. * Update a specific vertex buffer
  22363. * This function will create a new buffer if the current one is not updatable
  22364. * @param kind defines the data kind (Position, normal, etc...)
  22365. * @param data defines the data to use
  22366. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22367. */
  22368. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22369. private _updateBoundingInfo;
  22370. /** @hidden */
  22371. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22372. /**
  22373. * Gets total number of vertices
  22374. * @returns the total number of vertices
  22375. */
  22376. getTotalVertices(): number;
  22377. /**
  22378. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22379. * @param kind defines the data kind (Position, normal, etc...)
  22380. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22381. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22382. * @returns a float array containing vertex data
  22383. */
  22384. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22385. /**
  22386. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22387. * @param kind defines the data kind (Position, normal, etc...)
  22388. * @returns true if the vertex buffer with the specified kind is updatable
  22389. */
  22390. isVertexBufferUpdatable(kind: string): boolean;
  22391. /**
  22392. * Gets a specific vertex buffer
  22393. * @param kind defines the data kind (Position, normal, etc...)
  22394. * @returns a VertexBuffer
  22395. */
  22396. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22397. /**
  22398. * Returns all vertex buffers
  22399. * @return an object holding all vertex buffers indexed by kind
  22400. */
  22401. getVertexBuffers(): Nullable<{
  22402. [key: string]: VertexBuffer;
  22403. }>;
  22404. /**
  22405. * Gets a boolean indicating if specific vertex buffer is present
  22406. * @param kind defines the data kind (Position, normal, etc...)
  22407. * @returns true if data is present
  22408. */
  22409. isVerticesDataPresent(kind: string): boolean;
  22410. /**
  22411. * Gets a list of all attached data kinds (Position, normal, etc...)
  22412. * @returns a list of string containing all kinds
  22413. */
  22414. getVerticesDataKinds(): string[];
  22415. /**
  22416. * Update index buffer
  22417. * @param indices defines the indices to store in the index buffer
  22418. * @param offset defines the offset in the target buffer where to store the data
  22419. * @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)
  22420. */
  22421. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22422. /**
  22423. * Creates a new index buffer
  22424. * @param indices defines the indices to store in the index buffer
  22425. * @param totalVertices defines the total number of vertices (could be null)
  22426. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22427. */
  22428. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22429. /**
  22430. * Return the total number of indices
  22431. * @returns the total number of indices
  22432. */
  22433. getTotalIndices(): number;
  22434. /**
  22435. * Gets the index buffer array
  22436. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22437. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22438. * @returns the index buffer array
  22439. */
  22440. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22441. /**
  22442. * Gets the index buffer
  22443. * @return the index buffer
  22444. */
  22445. getIndexBuffer(): Nullable<DataBuffer>;
  22446. /** @hidden */
  22447. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22448. /**
  22449. * Release the associated resources for a specific mesh
  22450. * @param mesh defines the source mesh
  22451. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22452. */
  22453. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22454. /**
  22455. * Apply current geometry to a given mesh
  22456. * @param mesh defines the mesh to apply geometry to
  22457. */
  22458. applyToMesh(mesh: Mesh): void;
  22459. private _updateExtend;
  22460. private _applyToMesh;
  22461. private notifyUpdate;
  22462. /**
  22463. * Load the geometry if it was flagged as delay loaded
  22464. * @param scene defines the hosting scene
  22465. * @param onLoaded defines a callback called when the geometry is loaded
  22466. */
  22467. load(scene: Scene, onLoaded?: () => void): void;
  22468. private _queueLoad;
  22469. /**
  22470. * Invert the geometry to move from a right handed system to a left handed one.
  22471. */
  22472. toLeftHanded(): void;
  22473. /** @hidden */
  22474. _resetPointsArrayCache(): void;
  22475. /** @hidden */
  22476. _generatePointsArray(): boolean;
  22477. /**
  22478. * Gets a value indicating if the geometry is disposed
  22479. * @returns true if the geometry was disposed
  22480. */
  22481. isDisposed(): boolean;
  22482. private _disposeVertexArrayObjects;
  22483. /**
  22484. * Free all associated resources
  22485. */
  22486. dispose(): void;
  22487. /**
  22488. * Clone the current geometry into a new geometry
  22489. * @param id defines the unique ID of the new geometry
  22490. * @returns a new geometry object
  22491. */
  22492. copy(id: string): Geometry;
  22493. /**
  22494. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22495. * @return a JSON representation of the current geometry data (without the vertices data)
  22496. */
  22497. serialize(): any;
  22498. private toNumberArray;
  22499. /**
  22500. * Serialize all vertices data into a JSON oject
  22501. * @returns a JSON representation of the current geometry data
  22502. */
  22503. serializeVerticeData(): any;
  22504. /**
  22505. * Extracts a clone of a mesh geometry
  22506. * @param mesh defines the source mesh
  22507. * @param id defines the unique ID of the new geometry object
  22508. * @returns the new geometry object
  22509. */
  22510. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22511. /**
  22512. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22513. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22514. * Be aware Math.random() could cause collisions, but:
  22515. * "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"
  22516. * @returns a string containing a new GUID
  22517. */
  22518. static RandomId(): string;
  22519. /** @hidden */
  22520. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22521. private static _CleanMatricesWeights;
  22522. /**
  22523. * Create a new geometry from persisted data (Using .babylon file format)
  22524. * @param parsedVertexData defines the persisted data
  22525. * @param scene defines the hosting scene
  22526. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22527. * @returns the new geometry object
  22528. */
  22529. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22530. }
  22531. }
  22532. declare module "babylonjs/Meshes/mesh.vertexData" {
  22533. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22534. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22535. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22536. import { Geometry } from "babylonjs/Meshes/geometry";
  22537. import { Mesh } from "babylonjs/Meshes/mesh";
  22538. /**
  22539. * Define an interface for all classes that will get and set the data on vertices
  22540. */
  22541. export interface IGetSetVerticesData {
  22542. /**
  22543. * Gets a boolean indicating if specific vertex data is present
  22544. * @param kind defines the vertex data kind to use
  22545. * @returns true is data kind is present
  22546. */
  22547. isVerticesDataPresent(kind: string): boolean;
  22548. /**
  22549. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22550. * @param kind defines the data kind (Position, normal, etc...)
  22551. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22552. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22553. * @returns a float array containing vertex data
  22554. */
  22555. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22556. /**
  22557. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22558. * @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.
  22559. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22560. * @returns the indices array or an empty array if the mesh has no geometry
  22561. */
  22562. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22563. /**
  22564. * Set specific vertex data
  22565. * @param kind defines the data kind (Position, normal, etc...)
  22566. * @param data defines the vertex data to use
  22567. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22568. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22569. */
  22570. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22571. /**
  22572. * Update a specific associated vertex buffer
  22573. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22574. * - VertexBuffer.PositionKind
  22575. * - VertexBuffer.UVKind
  22576. * - VertexBuffer.UV2Kind
  22577. * - VertexBuffer.UV3Kind
  22578. * - VertexBuffer.UV4Kind
  22579. * - VertexBuffer.UV5Kind
  22580. * - VertexBuffer.UV6Kind
  22581. * - VertexBuffer.ColorKind
  22582. * - VertexBuffer.MatricesIndicesKind
  22583. * - VertexBuffer.MatricesIndicesExtraKind
  22584. * - VertexBuffer.MatricesWeightsKind
  22585. * - VertexBuffer.MatricesWeightsExtraKind
  22586. * @param data defines the data source
  22587. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22588. * @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)
  22589. */
  22590. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22591. /**
  22592. * Creates a new index buffer
  22593. * @param indices defines the indices to store in the index buffer
  22594. * @param totalVertices defines the total number of vertices (could be null)
  22595. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22596. */
  22597. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22598. }
  22599. /**
  22600. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22601. */
  22602. export class VertexData {
  22603. /**
  22604. * Mesh side orientation : usually the external or front surface
  22605. */
  22606. static readonly FRONTSIDE: number;
  22607. /**
  22608. * Mesh side orientation : usually the internal or back surface
  22609. */
  22610. static readonly BACKSIDE: number;
  22611. /**
  22612. * Mesh side orientation : both internal and external or front and back surfaces
  22613. */
  22614. static readonly DOUBLESIDE: number;
  22615. /**
  22616. * Mesh side orientation : by default, `FRONTSIDE`
  22617. */
  22618. static readonly DEFAULTSIDE: number;
  22619. /**
  22620. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22621. */
  22622. positions: Nullable<FloatArray>;
  22623. /**
  22624. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22625. */
  22626. normals: Nullable<FloatArray>;
  22627. /**
  22628. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22629. */
  22630. tangents: Nullable<FloatArray>;
  22631. /**
  22632. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22633. */
  22634. uvs: Nullable<FloatArray>;
  22635. /**
  22636. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22637. */
  22638. uvs2: Nullable<FloatArray>;
  22639. /**
  22640. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22641. */
  22642. uvs3: Nullable<FloatArray>;
  22643. /**
  22644. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22645. */
  22646. uvs4: Nullable<FloatArray>;
  22647. /**
  22648. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22649. */
  22650. uvs5: Nullable<FloatArray>;
  22651. /**
  22652. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22653. */
  22654. uvs6: Nullable<FloatArray>;
  22655. /**
  22656. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22657. */
  22658. colors: Nullable<FloatArray>;
  22659. /**
  22660. * 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).
  22661. */
  22662. matricesIndices: Nullable<FloatArray>;
  22663. /**
  22664. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22665. */
  22666. matricesWeights: Nullable<FloatArray>;
  22667. /**
  22668. * An array extending the number of possible indices
  22669. */
  22670. matricesIndicesExtra: Nullable<FloatArray>;
  22671. /**
  22672. * An array extending the number of possible weights when the number of indices is extended
  22673. */
  22674. matricesWeightsExtra: Nullable<FloatArray>;
  22675. /**
  22676. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22677. */
  22678. indices: Nullable<IndicesArray>;
  22679. /**
  22680. * Uses the passed data array to set the set the values for the specified kind of data
  22681. * @param data a linear array of floating numbers
  22682. * @param kind the type of data that is being set, eg positions, colors etc
  22683. */
  22684. set(data: FloatArray, kind: string): void;
  22685. /**
  22686. * Associates the vertexData to the passed Mesh.
  22687. * Sets it as updatable or not (default `false`)
  22688. * @param mesh the mesh the vertexData is applied to
  22689. * @param updatable when used and having the value true allows new data to update the vertexData
  22690. * @returns the VertexData
  22691. */
  22692. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22693. /**
  22694. * Associates the vertexData to the passed Geometry.
  22695. * Sets it as updatable or not (default `false`)
  22696. * @param geometry the geometry the vertexData is applied to
  22697. * @param updatable when used and having the value true allows new data to update the vertexData
  22698. * @returns VertexData
  22699. */
  22700. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22701. /**
  22702. * Updates the associated mesh
  22703. * @param mesh the mesh to be updated
  22704. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22705. * @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
  22706. * @returns VertexData
  22707. */
  22708. updateMesh(mesh: Mesh): VertexData;
  22709. /**
  22710. * Updates the associated geometry
  22711. * @param geometry the geometry to be updated
  22712. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22713. * @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
  22714. * @returns VertexData.
  22715. */
  22716. updateGeometry(geometry: Geometry): VertexData;
  22717. private _applyTo;
  22718. private _update;
  22719. /**
  22720. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22721. * @param matrix the transforming matrix
  22722. * @returns the VertexData
  22723. */
  22724. transform(matrix: Matrix): VertexData;
  22725. /**
  22726. * Merges the passed VertexData into the current one
  22727. * @param other the VertexData to be merged into the current one
  22728. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22729. * @returns the modified VertexData
  22730. */
  22731. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22732. private _mergeElement;
  22733. private _validate;
  22734. /**
  22735. * Serializes the VertexData
  22736. * @returns a serialized object
  22737. */
  22738. serialize(): any;
  22739. /**
  22740. * Extracts the vertexData from a mesh
  22741. * @param mesh the mesh from which to extract the VertexData
  22742. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22743. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22744. * @returns the object VertexData associated to the passed mesh
  22745. */
  22746. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22747. /**
  22748. * Extracts the vertexData from the geometry
  22749. * @param geometry the geometry from which to extract the VertexData
  22750. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22751. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22752. * @returns the object VertexData associated to the passed mesh
  22753. */
  22754. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22755. private static _ExtractFrom;
  22756. /**
  22757. * Creates the VertexData for a Ribbon
  22758. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22759. * * pathArray array of paths, each of which an array of successive Vector3
  22760. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22761. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22762. * * 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
  22763. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22764. * * 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)
  22765. * * 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)
  22766. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22767. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22768. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22769. * @returns the VertexData of the ribbon
  22770. */
  22771. static CreateRibbon(options: {
  22772. pathArray: Vector3[][];
  22773. closeArray?: boolean;
  22774. closePath?: boolean;
  22775. offset?: number;
  22776. sideOrientation?: number;
  22777. frontUVs?: Vector4;
  22778. backUVs?: Vector4;
  22779. invertUV?: boolean;
  22780. uvs?: Vector2[];
  22781. colors?: Color4[];
  22782. }): VertexData;
  22783. /**
  22784. * Creates the VertexData for a box
  22785. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22786. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22787. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22788. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22789. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22790. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22791. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22793. * * 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)
  22794. * * 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)
  22795. * @returns the VertexData of the box
  22796. */
  22797. static CreateBox(options: {
  22798. size?: number;
  22799. width?: number;
  22800. height?: number;
  22801. depth?: number;
  22802. faceUV?: Vector4[];
  22803. faceColors?: Color4[];
  22804. sideOrientation?: number;
  22805. frontUVs?: Vector4;
  22806. backUVs?: Vector4;
  22807. }): VertexData;
  22808. /**
  22809. * Creates the VertexData for a tiled box
  22810. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22811. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22812. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22813. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22814. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22815. * @returns the VertexData of the box
  22816. */
  22817. static CreateTiledBox(options: {
  22818. pattern?: number;
  22819. width?: number;
  22820. height?: number;
  22821. depth?: number;
  22822. tileSize?: number;
  22823. tileWidth?: number;
  22824. tileHeight?: number;
  22825. alignHorizontal?: number;
  22826. alignVertical?: number;
  22827. faceUV?: Vector4[];
  22828. faceColors?: Color4[];
  22829. sideOrientation?: number;
  22830. }): VertexData;
  22831. /**
  22832. * Creates the VertexData for a tiled plane
  22833. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22834. * * pattern a limited pattern arrangement depending on the number
  22835. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22836. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22837. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22839. * * 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)
  22840. * * 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)
  22841. * @returns the VertexData of the tiled plane
  22842. */
  22843. static CreateTiledPlane(options: {
  22844. pattern?: number;
  22845. tileSize?: number;
  22846. tileWidth?: number;
  22847. tileHeight?: number;
  22848. size?: number;
  22849. width?: number;
  22850. height?: number;
  22851. alignHorizontal?: number;
  22852. alignVertical?: number;
  22853. sideOrientation?: number;
  22854. frontUVs?: Vector4;
  22855. backUVs?: Vector4;
  22856. }): VertexData;
  22857. /**
  22858. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22859. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22860. * * segments sets the number of horizontal strips optional, default 32
  22861. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22862. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22863. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22864. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22865. * * 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
  22866. * * 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
  22867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22868. * * 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)
  22869. * * 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)
  22870. * @returns the VertexData of the ellipsoid
  22871. */
  22872. static CreateSphere(options: {
  22873. segments?: number;
  22874. diameter?: number;
  22875. diameterX?: number;
  22876. diameterY?: number;
  22877. diameterZ?: number;
  22878. arc?: number;
  22879. slice?: number;
  22880. sideOrientation?: number;
  22881. frontUVs?: Vector4;
  22882. backUVs?: Vector4;
  22883. }): VertexData;
  22884. /**
  22885. * Creates the VertexData for a cylinder, cone or prism
  22886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22887. * * height sets the height (y direction) of the cylinder, optional, default 2
  22888. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22889. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22890. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22891. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22892. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22893. * * 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
  22894. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22895. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22896. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22897. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22898. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22899. * * 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)
  22900. * * 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)
  22901. * @returns the VertexData of the cylinder, cone or prism
  22902. */
  22903. static CreateCylinder(options: {
  22904. height?: number;
  22905. diameterTop?: number;
  22906. diameterBottom?: number;
  22907. diameter?: number;
  22908. tessellation?: number;
  22909. subdivisions?: number;
  22910. arc?: number;
  22911. faceColors?: Color4[];
  22912. faceUV?: Vector4[];
  22913. hasRings?: boolean;
  22914. enclose?: boolean;
  22915. sideOrientation?: number;
  22916. frontUVs?: Vector4;
  22917. backUVs?: Vector4;
  22918. }): VertexData;
  22919. /**
  22920. * Creates the VertexData for a torus
  22921. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22922. * * diameter the diameter of the torus, optional default 1
  22923. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22924. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22926. * * 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)
  22927. * * 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)
  22928. * @returns the VertexData of the torus
  22929. */
  22930. static CreateTorus(options: {
  22931. diameter?: number;
  22932. thickness?: number;
  22933. tessellation?: number;
  22934. sideOrientation?: number;
  22935. frontUVs?: Vector4;
  22936. backUVs?: Vector4;
  22937. }): VertexData;
  22938. /**
  22939. * Creates the VertexData of the LineSystem
  22940. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22941. * - lines an array of lines, each line being an array of successive Vector3
  22942. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22943. * @returns the VertexData of the LineSystem
  22944. */
  22945. static CreateLineSystem(options: {
  22946. lines: Vector3[][];
  22947. colors?: Nullable<Color4[][]>;
  22948. }): VertexData;
  22949. /**
  22950. * Create the VertexData for a DashedLines
  22951. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22952. * - points an array successive Vector3
  22953. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22954. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22955. * - dashNb the intended total number of dashes, optional, default 200
  22956. * @returns the VertexData for the DashedLines
  22957. */
  22958. static CreateDashedLines(options: {
  22959. points: Vector3[];
  22960. dashSize?: number;
  22961. gapSize?: number;
  22962. dashNb?: number;
  22963. }): VertexData;
  22964. /**
  22965. * Creates the VertexData for a Ground
  22966. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22967. * - width the width (x direction) of the ground, optional, default 1
  22968. * - height the height (z direction) of the ground, optional, default 1
  22969. * - subdivisions the number of subdivisions per side, optional, default 1
  22970. * @returns the VertexData of the Ground
  22971. */
  22972. static CreateGround(options: {
  22973. width?: number;
  22974. height?: number;
  22975. subdivisions?: number;
  22976. subdivisionsX?: number;
  22977. subdivisionsY?: number;
  22978. }): VertexData;
  22979. /**
  22980. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22981. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22982. * * xmin the ground minimum X coordinate, optional, default -1
  22983. * * zmin the ground minimum Z coordinate, optional, default -1
  22984. * * xmax the ground maximum X coordinate, optional, default 1
  22985. * * zmax the ground maximum Z coordinate, optional, default 1
  22986. * * 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}
  22987. * * 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}
  22988. * @returns the VertexData of the TiledGround
  22989. */
  22990. static CreateTiledGround(options: {
  22991. xmin: number;
  22992. zmin: number;
  22993. xmax: number;
  22994. zmax: number;
  22995. subdivisions?: {
  22996. w: number;
  22997. h: number;
  22998. };
  22999. precision?: {
  23000. w: number;
  23001. h: number;
  23002. };
  23003. }): VertexData;
  23004. /**
  23005. * Creates the VertexData of the Ground designed from a heightmap
  23006. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23007. * * width the width (x direction) of the ground
  23008. * * height the height (z direction) of the ground
  23009. * * subdivisions the number of subdivisions per side
  23010. * * minHeight the minimum altitude on the ground, optional, default 0
  23011. * * maxHeight the maximum altitude on the ground, optional default 1
  23012. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23013. * * buffer the array holding the image color data
  23014. * * bufferWidth the width of image
  23015. * * bufferHeight the height of image
  23016. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23017. * @returns the VertexData of the Ground designed from a heightmap
  23018. */
  23019. static CreateGroundFromHeightMap(options: {
  23020. width: number;
  23021. height: number;
  23022. subdivisions: number;
  23023. minHeight: number;
  23024. maxHeight: number;
  23025. colorFilter: Color3;
  23026. buffer: Uint8Array;
  23027. bufferWidth: number;
  23028. bufferHeight: number;
  23029. alphaFilter: number;
  23030. }): VertexData;
  23031. /**
  23032. * Creates the VertexData for a Plane
  23033. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23034. * * size sets the width and height of the plane to the value of size, optional default 1
  23035. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23036. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23038. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23039. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23040. * @returns the VertexData of the box
  23041. */
  23042. static CreatePlane(options: {
  23043. size?: number;
  23044. width?: number;
  23045. height?: number;
  23046. sideOrientation?: number;
  23047. frontUVs?: Vector4;
  23048. backUVs?: Vector4;
  23049. }): VertexData;
  23050. /**
  23051. * Creates the VertexData of the Disc or regular Polygon
  23052. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23053. * * radius the radius of the disc, optional default 0.5
  23054. * * tessellation the number of polygon sides, optional, default 64
  23055. * * 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
  23056. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23057. * * 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)
  23058. * * 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)
  23059. * @returns the VertexData of the box
  23060. */
  23061. static CreateDisc(options: {
  23062. radius?: number;
  23063. tessellation?: number;
  23064. arc?: number;
  23065. sideOrientation?: number;
  23066. frontUVs?: Vector4;
  23067. backUVs?: Vector4;
  23068. }): VertexData;
  23069. /**
  23070. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23071. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23072. * @param polygon a mesh built from polygonTriangulation.build()
  23073. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23074. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23075. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23076. * @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)
  23077. * @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)
  23078. * @returns the VertexData of the Polygon
  23079. */
  23080. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23081. /**
  23082. * Creates the VertexData of the IcoSphere
  23083. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23084. * * radius the radius of the IcoSphere, optional default 1
  23085. * * radiusX allows stretching in the x direction, optional, default radius
  23086. * * radiusY allows stretching in the y direction, optional, default radius
  23087. * * radiusZ allows stretching in the z direction, optional, default radius
  23088. * * flat when true creates a flat shaded mesh, optional, default true
  23089. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23091. * * 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)
  23092. * * 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)
  23093. * @returns the VertexData of the IcoSphere
  23094. */
  23095. static CreateIcoSphere(options: {
  23096. radius?: number;
  23097. radiusX?: number;
  23098. radiusY?: number;
  23099. radiusZ?: number;
  23100. flat?: boolean;
  23101. subdivisions?: number;
  23102. sideOrientation?: number;
  23103. frontUVs?: Vector4;
  23104. backUVs?: Vector4;
  23105. }): VertexData;
  23106. /**
  23107. * Creates the VertexData for a Polyhedron
  23108. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23109. * * type provided types are:
  23110. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23111. * * 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)
  23112. * * size the size of the IcoSphere, optional default 1
  23113. * * sizeX allows stretching in the x direction, optional, default size
  23114. * * sizeY allows stretching in the y direction, optional, default size
  23115. * * sizeZ allows stretching in the z direction, optional, default size
  23116. * * 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
  23117. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23118. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23119. * * flat when true creates a flat shaded mesh, optional, default true
  23120. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23122. * * 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)
  23123. * * 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)
  23124. * @returns the VertexData of the Polyhedron
  23125. */
  23126. static CreatePolyhedron(options: {
  23127. type?: number;
  23128. size?: number;
  23129. sizeX?: number;
  23130. sizeY?: number;
  23131. sizeZ?: number;
  23132. custom?: any;
  23133. faceUV?: Vector4[];
  23134. faceColors?: Color4[];
  23135. flat?: boolean;
  23136. sideOrientation?: number;
  23137. frontUVs?: Vector4;
  23138. backUVs?: Vector4;
  23139. }): VertexData;
  23140. /**
  23141. * Creates the VertexData for a TorusKnot
  23142. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23143. * * radius the radius of the torus knot, optional, default 2
  23144. * * tube the thickness of the tube, optional, default 0.5
  23145. * * radialSegments the number of sides on each tube segments, optional, default 32
  23146. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23147. * * p the number of windings around the z axis, optional, default 2
  23148. * * q the number of windings around the x axis, optional, default 3
  23149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23150. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23151. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23152. * @returns the VertexData of the Torus Knot
  23153. */
  23154. static CreateTorusKnot(options: {
  23155. radius?: number;
  23156. tube?: number;
  23157. radialSegments?: number;
  23158. tubularSegments?: number;
  23159. p?: number;
  23160. q?: number;
  23161. sideOrientation?: number;
  23162. frontUVs?: Vector4;
  23163. backUVs?: Vector4;
  23164. }): VertexData;
  23165. /**
  23166. * Compute normals for given positions and indices
  23167. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23168. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23169. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23170. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23171. * * facetNormals : optional array of facet normals (vector3)
  23172. * * facetPositions : optional array of facet positions (vector3)
  23173. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23174. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23175. * * bInfo : optional bounding info, required for facetPartitioning computation
  23176. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23177. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23178. * * useRightHandedSystem: optional boolean to for right handed system computation
  23179. * * depthSort : optional boolean to enable the facet depth sort computation
  23180. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23181. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23182. */
  23183. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23184. facetNormals?: any;
  23185. facetPositions?: any;
  23186. facetPartitioning?: any;
  23187. ratio?: number;
  23188. bInfo?: any;
  23189. bbSize?: Vector3;
  23190. subDiv?: any;
  23191. useRightHandedSystem?: boolean;
  23192. depthSort?: boolean;
  23193. distanceTo?: Vector3;
  23194. depthSortedFacets?: any;
  23195. }): void;
  23196. /** @hidden */
  23197. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23198. /**
  23199. * Applies VertexData created from the imported parameters to the geometry
  23200. * @param parsedVertexData the parsed data from an imported file
  23201. * @param geometry the geometry to apply the VertexData to
  23202. */
  23203. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23204. }
  23205. }
  23206. declare module "babylonjs/Morph/morphTarget" {
  23207. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23208. import { Observable } from "babylonjs/Misc/observable";
  23209. import { Nullable, FloatArray } from "babylonjs/types";
  23210. import { Scene } from "babylonjs/scene";
  23211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23212. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23213. /**
  23214. * Defines a target to use with MorphTargetManager
  23215. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23216. */
  23217. export class MorphTarget implements IAnimatable {
  23218. /** defines the name of the target */
  23219. name: string;
  23220. /**
  23221. * Gets or sets the list of animations
  23222. */
  23223. animations: import("babylonjs/Animations/animation").Animation[];
  23224. private _scene;
  23225. private _positions;
  23226. private _normals;
  23227. private _tangents;
  23228. private _uvs;
  23229. private _influence;
  23230. private _uniqueId;
  23231. /**
  23232. * Observable raised when the influence changes
  23233. */
  23234. onInfluenceChanged: Observable<boolean>;
  23235. /** @hidden */
  23236. _onDataLayoutChanged: Observable<void>;
  23237. /**
  23238. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23239. */
  23240. get influence(): number;
  23241. set influence(influence: number);
  23242. /**
  23243. * Gets or sets the id of the morph Target
  23244. */
  23245. id: string;
  23246. private _animationPropertiesOverride;
  23247. /**
  23248. * Gets or sets the animation properties override
  23249. */
  23250. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23251. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23252. /**
  23253. * Creates a new MorphTarget
  23254. * @param name defines the name of the target
  23255. * @param influence defines the influence to use
  23256. * @param scene defines the scene the morphtarget belongs to
  23257. */
  23258. constructor(
  23259. /** defines the name of the target */
  23260. name: string, influence?: number, scene?: Nullable<Scene>);
  23261. /**
  23262. * Gets the unique ID of this manager
  23263. */
  23264. get uniqueId(): number;
  23265. /**
  23266. * Gets a boolean defining if the target contains position data
  23267. */
  23268. get hasPositions(): boolean;
  23269. /**
  23270. * Gets a boolean defining if the target contains normal data
  23271. */
  23272. get hasNormals(): boolean;
  23273. /**
  23274. * Gets a boolean defining if the target contains tangent data
  23275. */
  23276. get hasTangents(): boolean;
  23277. /**
  23278. * Gets a boolean defining if the target contains texture coordinates data
  23279. */
  23280. get hasUVs(): boolean;
  23281. /**
  23282. * Affects position data to this target
  23283. * @param data defines the position data to use
  23284. */
  23285. setPositions(data: Nullable<FloatArray>): void;
  23286. /**
  23287. * Gets the position data stored in this target
  23288. * @returns a FloatArray containing the position data (or null if not present)
  23289. */
  23290. getPositions(): Nullable<FloatArray>;
  23291. /**
  23292. * Affects normal data to this target
  23293. * @param data defines the normal data to use
  23294. */
  23295. setNormals(data: Nullable<FloatArray>): void;
  23296. /**
  23297. * Gets the normal data stored in this target
  23298. * @returns a FloatArray containing the normal data (or null if not present)
  23299. */
  23300. getNormals(): Nullable<FloatArray>;
  23301. /**
  23302. * Affects tangent data to this target
  23303. * @param data defines the tangent data to use
  23304. */
  23305. setTangents(data: Nullable<FloatArray>): void;
  23306. /**
  23307. * Gets the tangent data stored in this target
  23308. * @returns a FloatArray containing the tangent data (or null if not present)
  23309. */
  23310. getTangents(): Nullable<FloatArray>;
  23311. /**
  23312. * Affects texture coordinates data to this target
  23313. * @param data defines the texture coordinates data to use
  23314. */
  23315. setUVs(data: Nullable<FloatArray>): void;
  23316. /**
  23317. * Gets the texture coordinates data stored in this target
  23318. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23319. */
  23320. getUVs(): Nullable<FloatArray>;
  23321. /**
  23322. * Clone the current target
  23323. * @returns a new MorphTarget
  23324. */
  23325. clone(): MorphTarget;
  23326. /**
  23327. * Serializes the current target into a Serialization object
  23328. * @returns the serialized object
  23329. */
  23330. serialize(): any;
  23331. /**
  23332. * Returns the string "MorphTarget"
  23333. * @returns "MorphTarget"
  23334. */
  23335. getClassName(): string;
  23336. /**
  23337. * Creates a new target from serialized data
  23338. * @param serializationObject defines the serialized data to use
  23339. * @returns a new MorphTarget
  23340. */
  23341. static Parse(serializationObject: any): MorphTarget;
  23342. /**
  23343. * Creates a MorphTarget from mesh data
  23344. * @param mesh defines the source mesh
  23345. * @param name defines the name to use for the new target
  23346. * @param influence defines the influence to attach to the target
  23347. * @returns a new MorphTarget
  23348. */
  23349. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23350. }
  23351. }
  23352. declare module "babylonjs/Morph/morphTargetManager" {
  23353. import { Nullable } from "babylonjs/types";
  23354. import { Scene } from "babylonjs/scene";
  23355. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23356. /**
  23357. * This class is used to deform meshes using morphing between different targets
  23358. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23359. */
  23360. export class MorphTargetManager {
  23361. private _targets;
  23362. private _targetInfluenceChangedObservers;
  23363. private _targetDataLayoutChangedObservers;
  23364. private _activeTargets;
  23365. private _scene;
  23366. private _influences;
  23367. private _supportsNormals;
  23368. private _supportsTangents;
  23369. private _supportsUVs;
  23370. private _vertexCount;
  23371. private _uniqueId;
  23372. private _tempInfluences;
  23373. /**
  23374. * Gets or sets a boolean indicating if normals must be morphed
  23375. */
  23376. enableNormalMorphing: boolean;
  23377. /**
  23378. * Gets or sets a boolean indicating if tangents must be morphed
  23379. */
  23380. enableTangentMorphing: boolean;
  23381. /**
  23382. * Gets or sets a boolean indicating if UV must be morphed
  23383. */
  23384. enableUVMorphing: boolean;
  23385. /**
  23386. * Creates a new MorphTargetManager
  23387. * @param scene defines the current scene
  23388. */
  23389. constructor(scene?: Nullable<Scene>);
  23390. /**
  23391. * Gets the unique ID of this manager
  23392. */
  23393. get uniqueId(): number;
  23394. /**
  23395. * Gets the number of vertices handled by this manager
  23396. */
  23397. get vertexCount(): number;
  23398. /**
  23399. * Gets a boolean indicating if this manager supports morphing of normals
  23400. */
  23401. get supportsNormals(): boolean;
  23402. /**
  23403. * Gets a boolean indicating if this manager supports morphing of tangents
  23404. */
  23405. get supportsTangents(): boolean;
  23406. /**
  23407. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23408. */
  23409. get supportsUVs(): boolean;
  23410. /**
  23411. * Gets the number of targets stored in this manager
  23412. */
  23413. get numTargets(): number;
  23414. /**
  23415. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23416. */
  23417. get numInfluencers(): number;
  23418. /**
  23419. * Gets the list of influences (one per target)
  23420. */
  23421. get influences(): Float32Array;
  23422. /**
  23423. * Gets the active target at specified index. An active target is a target with an influence > 0
  23424. * @param index defines the index to check
  23425. * @returns the requested target
  23426. */
  23427. getActiveTarget(index: number): MorphTarget;
  23428. /**
  23429. * Gets the target at specified index
  23430. * @param index defines the index to check
  23431. * @returns the requested target
  23432. */
  23433. getTarget(index: number): MorphTarget;
  23434. /**
  23435. * Add a new target to this manager
  23436. * @param target defines the target to add
  23437. */
  23438. addTarget(target: MorphTarget): void;
  23439. /**
  23440. * Removes a target from the manager
  23441. * @param target defines the target to remove
  23442. */
  23443. removeTarget(target: MorphTarget): void;
  23444. /**
  23445. * Clone the current manager
  23446. * @returns a new MorphTargetManager
  23447. */
  23448. clone(): MorphTargetManager;
  23449. /**
  23450. * Serializes the current manager into a Serialization object
  23451. * @returns the serialized object
  23452. */
  23453. serialize(): any;
  23454. private _syncActiveTargets;
  23455. /**
  23456. * Syncrhonize the targets with all the meshes using this morph target manager
  23457. */
  23458. synchronize(): void;
  23459. /**
  23460. * Creates a new MorphTargetManager from serialized data
  23461. * @param serializationObject defines the serialized data
  23462. * @param scene defines the hosting scene
  23463. * @returns the new MorphTargetManager
  23464. */
  23465. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23466. }
  23467. }
  23468. declare module "babylonjs/Meshes/meshLODLevel" {
  23469. import { Mesh } from "babylonjs/Meshes/mesh";
  23470. import { Nullable } from "babylonjs/types";
  23471. /**
  23472. * Class used to represent a specific level of detail of a mesh
  23473. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23474. */
  23475. export class MeshLODLevel {
  23476. /** Defines the distance where this level should start being displayed */
  23477. distance: number;
  23478. /** Defines the mesh to use to render this level */
  23479. mesh: Nullable<Mesh>;
  23480. /**
  23481. * Creates a new LOD level
  23482. * @param distance defines the distance where this level should star being displayed
  23483. * @param mesh defines the mesh to use to render this level
  23484. */
  23485. constructor(
  23486. /** Defines the distance where this level should start being displayed */
  23487. distance: number,
  23488. /** Defines the mesh to use to render this level */
  23489. mesh: Nullable<Mesh>);
  23490. }
  23491. }
  23492. declare module "babylonjs/Meshes/groundMesh" {
  23493. import { Scene } from "babylonjs/scene";
  23494. import { Vector3 } from "babylonjs/Maths/math.vector";
  23495. import { Mesh } from "babylonjs/Meshes/mesh";
  23496. /**
  23497. * Mesh representing the gorund
  23498. */
  23499. export class GroundMesh extends Mesh {
  23500. /** If octree should be generated */
  23501. generateOctree: boolean;
  23502. private _heightQuads;
  23503. /** @hidden */
  23504. _subdivisionsX: number;
  23505. /** @hidden */
  23506. _subdivisionsY: number;
  23507. /** @hidden */
  23508. _width: number;
  23509. /** @hidden */
  23510. _height: number;
  23511. /** @hidden */
  23512. _minX: number;
  23513. /** @hidden */
  23514. _maxX: number;
  23515. /** @hidden */
  23516. _minZ: number;
  23517. /** @hidden */
  23518. _maxZ: number;
  23519. constructor(name: string, scene: Scene);
  23520. /**
  23521. * "GroundMesh"
  23522. * @returns "GroundMesh"
  23523. */
  23524. getClassName(): string;
  23525. /**
  23526. * The minimum of x and y subdivisions
  23527. */
  23528. get subdivisions(): number;
  23529. /**
  23530. * X subdivisions
  23531. */
  23532. get subdivisionsX(): number;
  23533. /**
  23534. * Y subdivisions
  23535. */
  23536. get subdivisionsY(): number;
  23537. /**
  23538. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23539. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23540. * @param chunksCount the number of subdivisions for x and y
  23541. * @param octreeBlocksSize (Default: 32)
  23542. */
  23543. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23544. /**
  23545. * Returns a height (y) value in the Worl system :
  23546. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23547. * @param x x coordinate
  23548. * @param z z coordinate
  23549. * @returns the ground y position if (x, z) are outside the ground surface.
  23550. */
  23551. getHeightAtCoordinates(x: number, z: number): number;
  23552. /**
  23553. * Returns a normalized vector (Vector3) orthogonal to the ground
  23554. * at the ground coordinates (x, z) expressed in the World system.
  23555. * @param x x coordinate
  23556. * @param z z coordinate
  23557. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23558. */
  23559. getNormalAtCoordinates(x: number, z: number): Vector3;
  23560. /**
  23561. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23562. * at the ground coordinates (x, z) expressed in the World system.
  23563. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23564. * @param x x coordinate
  23565. * @param z z coordinate
  23566. * @param ref vector to store the result
  23567. * @returns the GroundMesh.
  23568. */
  23569. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23570. /**
  23571. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23572. * if the ground has been updated.
  23573. * This can be used in the render loop.
  23574. * @returns the GroundMesh.
  23575. */
  23576. updateCoordinateHeights(): GroundMesh;
  23577. private _getFacetAt;
  23578. private _initHeightQuads;
  23579. private _computeHeightQuads;
  23580. /**
  23581. * Serializes this ground mesh
  23582. * @param serializationObject object to write serialization to
  23583. */
  23584. serialize(serializationObject: any): void;
  23585. /**
  23586. * Parses a serialized ground mesh
  23587. * @param parsedMesh the serialized mesh
  23588. * @param scene the scene to create the ground mesh in
  23589. * @returns the created ground mesh
  23590. */
  23591. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23592. }
  23593. }
  23594. declare module "babylonjs/Physics/physicsJoint" {
  23595. import { Vector3 } from "babylonjs/Maths/math.vector";
  23596. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23597. /**
  23598. * Interface for Physics-Joint data
  23599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23600. */
  23601. export interface PhysicsJointData {
  23602. /**
  23603. * The main pivot of the joint
  23604. */
  23605. mainPivot?: Vector3;
  23606. /**
  23607. * The connected pivot of the joint
  23608. */
  23609. connectedPivot?: Vector3;
  23610. /**
  23611. * The main axis of the joint
  23612. */
  23613. mainAxis?: Vector3;
  23614. /**
  23615. * The connected axis of the joint
  23616. */
  23617. connectedAxis?: Vector3;
  23618. /**
  23619. * The collision of the joint
  23620. */
  23621. collision?: boolean;
  23622. /**
  23623. * Native Oimo/Cannon/Energy data
  23624. */
  23625. nativeParams?: any;
  23626. }
  23627. /**
  23628. * This is a holder class for the physics joint created by the physics plugin
  23629. * It holds a set of functions to control the underlying joint
  23630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23631. */
  23632. export class PhysicsJoint {
  23633. /**
  23634. * The type of the physics joint
  23635. */
  23636. type: number;
  23637. /**
  23638. * The data for the physics joint
  23639. */
  23640. jointData: PhysicsJointData;
  23641. private _physicsJoint;
  23642. protected _physicsPlugin: IPhysicsEnginePlugin;
  23643. /**
  23644. * Initializes the physics joint
  23645. * @param type The type of the physics joint
  23646. * @param jointData The data for the physics joint
  23647. */
  23648. constructor(
  23649. /**
  23650. * The type of the physics joint
  23651. */
  23652. type: number,
  23653. /**
  23654. * The data for the physics joint
  23655. */
  23656. jointData: PhysicsJointData);
  23657. /**
  23658. * Gets the physics joint
  23659. */
  23660. get physicsJoint(): any;
  23661. /**
  23662. * Sets the physics joint
  23663. */
  23664. set physicsJoint(newJoint: any);
  23665. /**
  23666. * Sets the physics plugin
  23667. */
  23668. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23669. /**
  23670. * Execute a function that is physics-plugin specific.
  23671. * @param {Function} func the function that will be executed.
  23672. * It accepts two parameters: the physics world and the physics joint
  23673. */
  23674. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23675. /**
  23676. * Distance-Joint type
  23677. */
  23678. static DistanceJoint: number;
  23679. /**
  23680. * Hinge-Joint type
  23681. */
  23682. static HingeJoint: number;
  23683. /**
  23684. * Ball-and-Socket joint type
  23685. */
  23686. static BallAndSocketJoint: number;
  23687. /**
  23688. * Wheel-Joint type
  23689. */
  23690. static WheelJoint: number;
  23691. /**
  23692. * Slider-Joint type
  23693. */
  23694. static SliderJoint: number;
  23695. /**
  23696. * Prismatic-Joint type
  23697. */
  23698. static PrismaticJoint: number;
  23699. /**
  23700. * Universal-Joint type
  23701. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23702. */
  23703. static UniversalJoint: number;
  23704. /**
  23705. * Hinge-Joint 2 type
  23706. */
  23707. static Hinge2Joint: number;
  23708. /**
  23709. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23710. */
  23711. static PointToPointJoint: number;
  23712. /**
  23713. * Spring-Joint type
  23714. */
  23715. static SpringJoint: number;
  23716. /**
  23717. * Lock-Joint type
  23718. */
  23719. static LockJoint: number;
  23720. }
  23721. /**
  23722. * A class representing a physics distance joint
  23723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23724. */
  23725. export class DistanceJoint extends PhysicsJoint {
  23726. /**
  23727. *
  23728. * @param jointData The data for the Distance-Joint
  23729. */
  23730. constructor(jointData: DistanceJointData);
  23731. /**
  23732. * Update the predefined distance.
  23733. * @param maxDistance The maximum preferred distance
  23734. * @param minDistance The minimum preferred distance
  23735. */
  23736. updateDistance(maxDistance: number, minDistance?: number): void;
  23737. }
  23738. /**
  23739. * Represents a Motor-Enabled Joint
  23740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23741. */
  23742. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23743. /**
  23744. * Initializes the Motor-Enabled Joint
  23745. * @param type The type of the joint
  23746. * @param jointData The physica joint data for the joint
  23747. */
  23748. constructor(type: number, jointData: PhysicsJointData);
  23749. /**
  23750. * Set the motor values.
  23751. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23752. * @param force the force to apply
  23753. * @param maxForce max force for this motor.
  23754. */
  23755. setMotor(force?: number, maxForce?: number): void;
  23756. /**
  23757. * Set the motor's limits.
  23758. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23759. * @param upperLimit The upper limit of the motor
  23760. * @param lowerLimit The lower limit of the motor
  23761. */
  23762. setLimit(upperLimit: number, lowerLimit?: number): void;
  23763. }
  23764. /**
  23765. * This class represents a single physics Hinge-Joint
  23766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23767. */
  23768. export class HingeJoint extends MotorEnabledJoint {
  23769. /**
  23770. * Initializes the Hinge-Joint
  23771. * @param jointData The joint data for the Hinge-Joint
  23772. */
  23773. constructor(jointData: PhysicsJointData);
  23774. /**
  23775. * Set the motor values.
  23776. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23777. * @param {number} force the force to apply
  23778. * @param {number} maxForce max force for this motor.
  23779. */
  23780. setMotor(force?: number, maxForce?: number): void;
  23781. /**
  23782. * Set the motor's limits.
  23783. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23784. * @param upperLimit The upper limit of the motor
  23785. * @param lowerLimit The lower limit of the motor
  23786. */
  23787. setLimit(upperLimit: number, lowerLimit?: number): void;
  23788. }
  23789. /**
  23790. * This class represents a dual hinge physics joint (same as wheel joint)
  23791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23792. */
  23793. export class Hinge2Joint extends MotorEnabledJoint {
  23794. /**
  23795. * Initializes the Hinge2-Joint
  23796. * @param jointData The joint data for the Hinge2-Joint
  23797. */
  23798. constructor(jointData: PhysicsJointData);
  23799. /**
  23800. * Set the motor values.
  23801. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23802. * @param {number} targetSpeed the speed the motor is to reach
  23803. * @param {number} maxForce max force for this motor.
  23804. * @param {motorIndex} the motor's index, 0 or 1.
  23805. */
  23806. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23807. /**
  23808. * Set the motor limits.
  23809. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23810. * @param {number} upperLimit the upper limit
  23811. * @param {number} lowerLimit lower limit
  23812. * @param {motorIndex} the motor's index, 0 or 1.
  23813. */
  23814. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23815. }
  23816. /**
  23817. * Interface for a motor enabled joint
  23818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23819. */
  23820. export interface IMotorEnabledJoint {
  23821. /**
  23822. * Physics joint
  23823. */
  23824. physicsJoint: any;
  23825. /**
  23826. * Sets the motor of the motor-enabled joint
  23827. * @param force The force of the motor
  23828. * @param maxForce The maximum force of the motor
  23829. * @param motorIndex The index of the motor
  23830. */
  23831. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23832. /**
  23833. * Sets the limit of the motor
  23834. * @param upperLimit The upper limit of the motor
  23835. * @param lowerLimit The lower limit of the motor
  23836. * @param motorIndex The index of the motor
  23837. */
  23838. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23839. }
  23840. /**
  23841. * Joint data for a Distance-Joint
  23842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23843. */
  23844. export interface DistanceJointData extends PhysicsJointData {
  23845. /**
  23846. * Max distance the 2 joint objects can be apart
  23847. */
  23848. maxDistance: number;
  23849. }
  23850. /**
  23851. * Joint data from a spring joint
  23852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23853. */
  23854. export interface SpringJointData extends PhysicsJointData {
  23855. /**
  23856. * Length of the spring
  23857. */
  23858. length: number;
  23859. /**
  23860. * Stiffness of the spring
  23861. */
  23862. stiffness: number;
  23863. /**
  23864. * Damping of the spring
  23865. */
  23866. damping: number;
  23867. /** this callback will be called when applying the force to the impostors. */
  23868. forceApplicationCallback: () => void;
  23869. }
  23870. }
  23871. declare module "babylonjs/Physics/physicsRaycastResult" {
  23872. import { Vector3 } from "babylonjs/Maths/math.vector";
  23873. /**
  23874. * Holds the data for the raycast result
  23875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23876. */
  23877. export class PhysicsRaycastResult {
  23878. private _hasHit;
  23879. private _hitDistance;
  23880. private _hitNormalWorld;
  23881. private _hitPointWorld;
  23882. private _rayFromWorld;
  23883. private _rayToWorld;
  23884. /**
  23885. * Gets if there was a hit
  23886. */
  23887. get hasHit(): boolean;
  23888. /**
  23889. * Gets the distance from the hit
  23890. */
  23891. get hitDistance(): number;
  23892. /**
  23893. * Gets the hit normal/direction in the world
  23894. */
  23895. get hitNormalWorld(): Vector3;
  23896. /**
  23897. * Gets the hit point in the world
  23898. */
  23899. get hitPointWorld(): Vector3;
  23900. /**
  23901. * Gets the ray "start point" of the ray in the world
  23902. */
  23903. get rayFromWorld(): Vector3;
  23904. /**
  23905. * Gets the ray "end point" of the ray in the world
  23906. */
  23907. get rayToWorld(): Vector3;
  23908. /**
  23909. * Sets the hit data (normal & point in world space)
  23910. * @param hitNormalWorld defines the normal in world space
  23911. * @param hitPointWorld defines the point in world space
  23912. */
  23913. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23914. /**
  23915. * Sets the distance from the start point to the hit point
  23916. * @param distance
  23917. */
  23918. setHitDistance(distance: number): void;
  23919. /**
  23920. * Calculates the distance manually
  23921. */
  23922. calculateHitDistance(): void;
  23923. /**
  23924. * Resets all the values to default
  23925. * @param from The from point on world space
  23926. * @param to The to point on world space
  23927. */
  23928. reset(from?: Vector3, to?: Vector3): void;
  23929. }
  23930. /**
  23931. * Interface for the size containing width and height
  23932. */
  23933. interface IXYZ {
  23934. /**
  23935. * X
  23936. */
  23937. x: number;
  23938. /**
  23939. * Y
  23940. */
  23941. y: number;
  23942. /**
  23943. * Z
  23944. */
  23945. z: number;
  23946. }
  23947. }
  23948. declare module "babylonjs/Physics/IPhysicsEngine" {
  23949. import { Nullable } from "babylonjs/types";
  23950. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23952. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23953. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23954. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23955. /**
  23956. * Interface used to describe a physics joint
  23957. */
  23958. export interface PhysicsImpostorJoint {
  23959. /** Defines the main impostor to which the joint is linked */
  23960. mainImpostor: PhysicsImpostor;
  23961. /** Defines the impostor that is connected to the main impostor using this joint */
  23962. connectedImpostor: PhysicsImpostor;
  23963. /** Defines the joint itself */
  23964. joint: PhysicsJoint;
  23965. }
  23966. /** @hidden */
  23967. export interface IPhysicsEnginePlugin {
  23968. world: any;
  23969. name: string;
  23970. setGravity(gravity: Vector3): void;
  23971. setTimeStep(timeStep: number): void;
  23972. getTimeStep(): number;
  23973. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23974. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23975. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23976. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23977. removePhysicsBody(impostor: PhysicsImpostor): void;
  23978. generateJoint(joint: PhysicsImpostorJoint): void;
  23979. removeJoint(joint: PhysicsImpostorJoint): void;
  23980. isSupported(): boolean;
  23981. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23982. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23983. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23984. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23985. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23986. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23987. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23988. getBodyMass(impostor: PhysicsImpostor): number;
  23989. getBodyFriction(impostor: PhysicsImpostor): number;
  23990. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23991. getBodyRestitution(impostor: PhysicsImpostor): number;
  23992. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23993. getBodyPressure?(impostor: PhysicsImpostor): number;
  23994. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23995. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23996. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23997. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23998. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23999. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24000. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24001. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24002. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24003. sleepBody(impostor: PhysicsImpostor): void;
  24004. wakeUpBody(impostor: PhysicsImpostor): void;
  24005. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24006. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24007. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24008. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24009. getRadius(impostor: PhysicsImpostor): number;
  24010. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24011. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24012. dispose(): void;
  24013. }
  24014. /**
  24015. * Interface used to define a physics engine
  24016. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24017. */
  24018. export interface IPhysicsEngine {
  24019. /**
  24020. * Gets the gravity vector used by the simulation
  24021. */
  24022. gravity: Vector3;
  24023. /**
  24024. * Sets the gravity vector used by the simulation
  24025. * @param gravity defines the gravity vector to use
  24026. */
  24027. setGravity(gravity: Vector3): void;
  24028. /**
  24029. * Set the time step of the physics engine.
  24030. * Default is 1/60.
  24031. * To slow it down, enter 1/600 for example.
  24032. * To speed it up, 1/30
  24033. * @param newTimeStep the new timestep to apply to this world.
  24034. */
  24035. setTimeStep(newTimeStep: number): void;
  24036. /**
  24037. * Get the time step of the physics engine.
  24038. * @returns the current time step
  24039. */
  24040. getTimeStep(): number;
  24041. /**
  24042. * Set the sub time step of the physics engine.
  24043. * Default is 0 meaning there is no sub steps
  24044. * To increase physics resolution precision, set a small value (like 1 ms)
  24045. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24046. */
  24047. setSubTimeStep(subTimeStep: number): void;
  24048. /**
  24049. * Get the sub time step of the physics engine.
  24050. * @returns the current sub time step
  24051. */
  24052. getSubTimeStep(): number;
  24053. /**
  24054. * Release all resources
  24055. */
  24056. dispose(): void;
  24057. /**
  24058. * Gets the name of the current physics plugin
  24059. * @returns the name of the plugin
  24060. */
  24061. getPhysicsPluginName(): string;
  24062. /**
  24063. * Adding a new impostor for the impostor tracking.
  24064. * This will be done by the impostor itself.
  24065. * @param impostor the impostor to add
  24066. */
  24067. addImpostor(impostor: PhysicsImpostor): void;
  24068. /**
  24069. * Remove an impostor from the engine.
  24070. * This impostor and its mesh will not longer be updated by the physics engine.
  24071. * @param impostor the impostor to remove
  24072. */
  24073. removeImpostor(impostor: PhysicsImpostor): void;
  24074. /**
  24075. * Add a joint to the physics engine
  24076. * @param mainImpostor defines the main impostor to which the joint is added.
  24077. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24078. * @param joint defines the joint that will connect both impostors.
  24079. */
  24080. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24081. /**
  24082. * Removes a joint from the simulation
  24083. * @param mainImpostor defines the impostor used with the joint
  24084. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24085. * @param joint defines the joint to remove
  24086. */
  24087. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24088. /**
  24089. * Gets the current plugin used to run the simulation
  24090. * @returns current plugin
  24091. */
  24092. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24093. /**
  24094. * Gets the list of physic impostors
  24095. * @returns an array of PhysicsImpostor
  24096. */
  24097. getImpostors(): Array<PhysicsImpostor>;
  24098. /**
  24099. * Gets the impostor for a physics enabled object
  24100. * @param object defines the object impersonated by the impostor
  24101. * @returns the PhysicsImpostor or null if not found
  24102. */
  24103. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24104. /**
  24105. * Gets the impostor for a physics body object
  24106. * @param body defines physics body used by the impostor
  24107. * @returns the PhysicsImpostor or null if not found
  24108. */
  24109. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24110. /**
  24111. * Does a raycast in the physics world
  24112. * @param from when should the ray start?
  24113. * @param to when should the ray end?
  24114. * @returns PhysicsRaycastResult
  24115. */
  24116. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24117. /**
  24118. * Called by the scene. No need to call it.
  24119. * @param delta defines the timespam between frames
  24120. */
  24121. _step(delta: number): void;
  24122. }
  24123. }
  24124. declare module "babylonjs/Physics/physicsImpostor" {
  24125. import { Nullable, IndicesArray } from "babylonjs/types";
  24126. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24127. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24129. import { Scene } from "babylonjs/scene";
  24130. import { Bone } from "babylonjs/Bones/bone";
  24131. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24132. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24133. import { Space } from "babylonjs/Maths/math.axis";
  24134. /**
  24135. * The interface for the physics imposter parameters
  24136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24137. */
  24138. export interface PhysicsImpostorParameters {
  24139. /**
  24140. * The mass of the physics imposter
  24141. */
  24142. mass: number;
  24143. /**
  24144. * The friction of the physics imposter
  24145. */
  24146. friction?: number;
  24147. /**
  24148. * The coefficient of restitution of the physics imposter
  24149. */
  24150. restitution?: number;
  24151. /**
  24152. * The native options of the physics imposter
  24153. */
  24154. nativeOptions?: any;
  24155. /**
  24156. * Specifies if the parent should be ignored
  24157. */
  24158. ignoreParent?: boolean;
  24159. /**
  24160. * Specifies if bi-directional transformations should be disabled
  24161. */
  24162. disableBidirectionalTransformation?: boolean;
  24163. /**
  24164. * The pressure inside the physics imposter, soft object only
  24165. */
  24166. pressure?: number;
  24167. /**
  24168. * The stiffness the physics imposter, soft object only
  24169. */
  24170. stiffness?: number;
  24171. /**
  24172. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24173. */
  24174. velocityIterations?: number;
  24175. /**
  24176. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24177. */
  24178. positionIterations?: number;
  24179. /**
  24180. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24181. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24182. * Add to fix multiple points
  24183. */
  24184. fixedPoints?: number;
  24185. /**
  24186. * The collision margin around a soft object
  24187. */
  24188. margin?: number;
  24189. /**
  24190. * The collision margin around a soft object
  24191. */
  24192. damping?: number;
  24193. /**
  24194. * The path for a rope based on an extrusion
  24195. */
  24196. path?: any;
  24197. /**
  24198. * The shape of an extrusion used for a rope based on an extrusion
  24199. */
  24200. shape?: any;
  24201. }
  24202. /**
  24203. * Interface for a physics-enabled object
  24204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24205. */
  24206. export interface IPhysicsEnabledObject {
  24207. /**
  24208. * The position of the physics-enabled object
  24209. */
  24210. position: Vector3;
  24211. /**
  24212. * The rotation of the physics-enabled object
  24213. */
  24214. rotationQuaternion: Nullable<Quaternion>;
  24215. /**
  24216. * The scale of the physics-enabled object
  24217. */
  24218. scaling: Vector3;
  24219. /**
  24220. * The rotation of the physics-enabled object
  24221. */
  24222. rotation?: Vector3;
  24223. /**
  24224. * The parent of the physics-enabled object
  24225. */
  24226. parent?: any;
  24227. /**
  24228. * The bounding info of the physics-enabled object
  24229. * @returns The bounding info of the physics-enabled object
  24230. */
  24231. getBoundingInfo(): BoundingInfo;
  24232. /**
  24233. * Computes the world matrix
  24234. * @param force Specifies if the world matrix should be computed by force
  24235. * @returns A world matrix
  24236. */
  24237. computeWorldMatrix(force: boolean): Matrix;
  24238. /**
  24239. * Gets the world matrix
  24240. * @returns A world matrix
  24241. */
  24242. getWorldMatrix?(): Matrix;
  24243. /**
  24244. * Gets the child meshes
  24245. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24246. * @returns An array of abstract meshes
  24247. */
  24248. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24249. /**
  24250. * Gets the vertex data
  24251. * @param kind The type of vertex data
  24252. * @returns A nullable array of numbers, or a float32 array
  24253. */
  24254. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24255. /**
  24256. * Gets the indices from the mesh
  24257. * @returns A nullable array of index arrays
  24258. */
  24259. getIndices?(): Nullable<IndicesArray>;
  24260. /**
  24261. * Gets the scene from the mesh
  24262. * @returns the indices array or null
  24263. */
  24264. getScene?(): Scene;
  24265. /**
  24266. * Gets the absolute position from the mesh
  24267. * @returns the absolute position
  24268. */
  24269. getAbsolutePosition(): Vector3;
  24270. /**
  24271. * Gets the absolute pivot point from the mesh
  24272. * @returns the absolute pivot point
  24273. */
  24274. getAbsolutePivotPoint(): Vector3;
  24275. /**
  24276. * Rotates the mesh
  24277. * @param axis The axis of rotation
  24278. * @param amount The amount of rotation
  24279. * @param space The space of the rotation
  24280. * @returns The rotation transform node
  24281. */
  24282. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24283. /**
  24284. * Translates the mesh
  24285. * @param axis The axis of translation
  24286. * @param distance The distance of translation
  24287. * @param space The space of the translation
  24288. * @returns The transform node
  24289. */
  24290. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24291. /**
  24292. * Sets the absolute position of the mesh
  24293. * @param absolutePosition The absolute position of the mesh
  24294. * @returns The transform node
  24295. */
  24296. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24297. /**
  24298. * Gets the class name of the mesh
  24299. * @returns The class name
  24300. */
  24301. getClassName(): string;
  24302. }
  24303. /**
  24304. * Represents a physics imposter
  24305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24306. */
  24307. export class PhysicsImpostor {
  24308. /**
  24309. * The physics-enabled object used as the physics imposter
  24310. */
  24311. object: IPhysicsEnabledObject;
  24312. /**
  24313. * The type of the physics imposter
  24314. */
  24315. type: number;
  24316. private _options;
  24317. private _scene?;
  24318. /**
  24319. * The default object size of the imposter
  24320. */
  24321. static DEFAULT_OBJECT_SIZE: Vector3;
  24322. /**
  24323. * The identity quaternion of the imposter
  24324. */
  24325. static IDENTITY_QUATERNION: Quaternion;
  24326. /** @hidden */
  24327. _pluginData: any;
  24328. private _physicsEngine;
  24329. private _physicsBody;
  24330. private _bodyUpdateRequired;
  24331. private _onBeforePhysicsStepCallbacks;
  24332. private _onAfterPhysicsStepCallbacks;
  24333. /** @hidden */
  24334. _onPhysicsCollideCallbacks: Array<{
  24335. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24336. otherImpostors: Array<PhysicsImpostor>;
  24337. }>;
  24338. private _deltaPosition;
  24339. private _deltaRotation;
  24340. private _deltaRotationConjugated;
  24341. /** @hidden */
  24342. _isFromLine: boolean;
  24343. private _parent;
  24344. private _isDisposed;
  24345. private static _tmpVecs;
  24346. private static _tmpQuat;
  24347. /**
  24348. * Specifies if the physics imposter is disposed
  24349. */
  24350. get isDisposed(): boolean;
  24351. /**
  24352. * Gets the mass of the physics imposter
  24353. */
  24354. get mass(): number;
  24355. set mass(value: number);
  24356. /**
  24357. * Gets the coefficient of friction
  24358. */
  24359. get friction(): number;
  24360. /**
  24361. * Sets the coefficient of friction
  24362. */
  24363. set friction(value: number);
  24364. /**
  24365. * Gets the coefficient of restitution
  24366. */
  24367. get restitution(): number;
  24368. /**
  24369. * Sets the coefficient of restitution
  24370. */
  24371. set restitution(value: number);
  24372. /**
  24373. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24374. */
  24375. get pressure(): number;
  24376. /**
  24377. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24378. */
  24379. set pressure(value: number);
  24380. /**
  24381. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24382. */
  24383. get stiffness(): number;
  24384. /**
  24385. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24386. */
  24387. set stiffness(value: number);
  24388. /**
  24389. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24390. */
  24391. get velocityIterations(): number;
  24392. /**
  24393. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24394. */
  24395. set velocityIterations(value: number);
  24396. /**
  24397. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24398. */
  24399. get positionIterations(): number;
  24400. /**
  24401. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24402. */
  24403. set positionIterations(value: number);
  24404. /**
  24405. * The unique id of the physics imposter
  24406. * set by the physics engine when adding this impostor to the array
  24407. */
  24408. uniqueId: number;
  24409. /**
  24410. * @hidden
  24411. */
  24412. soft: boolean;
  24413. /**
  24414. * @hidden
  24415. */
  24416. segments: number;
  24417. private _joints;
  24418. /**
  24419. * Initializes the physics imposter
  24420. * @param object The physics-enabled object used as the physics imposter
  24421. * @param type The type of the physics imposter
  24422. * @param _options The options for the physics imposter
  24423. * @param _scene The Babylon scene
  24424. */
  24425. constructor(
  24426. /**
  24427. * The physics-enabled object used as the physics imposter
  24428. */
  24429. object: IPhysicsEnabledObject,
  24430. /**
  24431. * The type of the physics imposter
  24432. */
  24433. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24434. /**
  24435. * This function will completly initialize this impostor.
  24436. * It will create a new body - but only if this mesh has no parent.
  24437. * If it has, this impostor will not be used other than to define the impostor
  24438. * of the child mesh.
  24439. * @hidden
  24440. */
  24441. _init(): void;
  24442. private _getPhysicsParent;
  24443. /**
  24444. * Should a new body be generated.
  24445. * @returns boolean specifying if body initialization is required
  24446. */
  24447. isBodyInitRequired(): boolean;
  24448. /**
  24449. * Sets the updated scaling
  24450. * @param updated Specifies if the scaling is updated
  24451. */
  24452. setScalingUpdated(): void;
  24453. /**
  24454. * Force a regeneration of this or the parent's impostor's body.
  24455. * Use under cautious - This will remove all joints already implemented.
  24456. */
  24457. forceUpdate(): void;
  24458. /**
  24459. * Gets the body that holds this impostor. Either its own, or its parent.
  24460. */
  24461. get physicsBody(): any;
  24462. /**
  24463. * Get the parent of the physics imposter
  24464. * @returns Physics imposter or null
  24465. */
  24466. get parent(): Nullable<PhysicsImpostor>;
  24467. /**
  24468. * Sets the parent of the physics imposter
  24469. */
  24470. set parent(value: Nullable<PhysicsImpostor>);
  24471. /**
  24472. * Set the physics body. Used mainly by the physics engine/plugin
  24473. */
  24474. set physicsBody(physicsBody: any);
  24475. /**
  24476. * Resets the update flags
  24477. */
  24478. resetUpdateFlags(): void;
  24479. /**
  24480. * Gets the object extend size
  24481. * @returns the object extend size
  24482. */
  24483. getObjectExtendSize(): Vector3;
  24484. /**
  24485. * Gets the object center
  24486. * @returns The object center
  24487. */
  24488. getObjectCenter(): Vector3;
  24489. /**
  24490. * Get a specific parameter from the options parameters
  24491. * @param paramName The object parameter name
  24492. * @returns The object parameter
  24493. */
  24494. getParam(paramName: string): any;
  24495. /**
  24496. * Sets a specific parameter in the options given to the physics plugin
  24497. * @param paramName The parameter name
  24498. * @param value The value of the parameter
  24499. */
  24500. setParam(paramName: string, value: number): void;
  24501. /**
  24502. * Specifically change the body's mass option. Won't recreate the physics body object
  24503. * @param mass The mass of the physics imposter
  24504. */
  24505. setMass(mass: number): void;
  24506. /**
  24507. * Gets the linear velocity
  24508. * @returns linear velocity or null
  24509. */
  24510. getLinearVelocity(): Nullable<Vector3>;
  24511. /**
  24512. * Sets the linear velocity
  24513. * @param velocity linear velocity or null
  24514. */
  24515. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24516. /**
  24517. * Gets the angular velocity
  24518. * @returns angular velocity or null
  24519. */
  24520. getAngularVelocity(): Nullable<Vector3>;
  24521. /**
  24522. * Sets the angular velocity
  24523. * @param velocity The velocity or null
  24524. */
  24525. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24526. /**
  24527. * Execute a function with the physics plugin native code
  24528. * Provide a function the will have two variables - the world object and the physics body object
  24529. * @param func The function to execute with the physics plugin native code
  24530. */
  24531. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24532. /**
  24533. * Register a function that will be executed before the physics world is stepping forward
  24534. * @param func The function to execute before the physics world is stepped forward
  24535. */
  24536. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24537. /**
  24538. * Unregister a function that will be executed before the physics world is stepping forward
  24539. * @param func The function to execute before the physics world is stepped forward
  24540. */
  24541. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24542. /**
  24543. * Register a function that will be executed after the physics step
  24544. * @param func The function to execute after physics step
  24545. */
  24546. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24547. /**
  24548. * Unregisters a function that will be executed after the physics step
  24549. * @param func The function to execute after physics step
  24550. */
  24551. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24552. /**
  24553. * register a function that will be executed when this impostor collides against a different body
  24554. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24555. * @param func Callback that is executed on collision
  24556. */
  24557. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24558. /**
  24559. * Unregisters the physics imposter on contact
  24560. * @param collideAgainst The physics object to collide against
  24561. * @param func Callback to execute on collision
  24562. */
  24563. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24564. private _tmpQuat;
  24565. private _tmpQuat2;
  24566. /**
  24567. * Get the parent rotation
  24568. * @returns The parent rotation
  24569. */
  24570. getParentsRotation(): Quaternion;
  24571. /**
  24572. * this function is executed by the physics engine.
  24573. */
  24574. beforeStep: () => void;
  24575. /**
  24576. * this function is executed by the physics engine
  24577. */
  24578. afterStep: () => void;
  24579. /**
  24580. * Legacy collision detection event support
  24581. */
  24582. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24583. /**
  24584. * event and body object due to cannon's event-based architecture.
  24585. */
  24586. onCollide: (e: {
  24587. body: any;
  24588. }) => void;
  24589. /**
  24590. * Apply a force
  24591. * @param force The force to apply
  24592. * @param contactPoint The contact point for the force
  24593. * @returns The physics imposter
  24594. */
  24595. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24596. /**
  24597. * Apply an impulse
  24598. * @param force The impulse force
  24599. * @param contactPoint The contact point for the impulse force
  24600. * @returns The physics imposter
  24601. */
  24602. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24603. /**
  24604. * A help function to create a joint
  24605. * @param otherImpostor A physics imposter used to create a joint
  24606. * @param jointType The type of joint
  24607. * @param jointData The data for the joint
  24608. * @returns The physics imposter
  24609. */
  24610. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24611. /**
  24612. * Add a joint to this impostor with a different impostor
  24613. * @param otherImpostor A physics imposter used to add a joint
  24614. * @param joint The joint to add
  24615. * @returns The physics imposter
  24616. */
  24617. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24618. /**
  24619. * Add an anchor to a cloth impostor
  24620. * @param otherImpostor rigid impostor to anchor to
  24621. * @param width ratio across width from 0 to 1
  24622. * @param height ratio up height from 0 to 1
  24623. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24624. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24625. * @returns impostor the soft imposter
  24626. */
  24627. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24628. /**
  24629. * Add a hook to a rope impostor
  24630. * @param otherImpostor rigid impostor to anchor to
  24631. * @param length ratio across rope from 0 to 1
  24632. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24633. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24634. * @returns impostor the rope imposter
  24635. */
  24636. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24637. /**
  24638. * Will keep this body still, in a sleep mode.
  24639. * @returns the physics imposter
  24640. */
  24641. sleep(): PhysicsImpostor;
  24642. /**
  24643. * Wake the body up.
  24644. * @returns The physics imposter
  24645. */
  24646. wakeUp(): PhysicsImpostor;
  24647. /**
  24648. * Clones the physics imposter
  24649. * @param newObject The physics imposter clones to this physics-enabled object
  24650. * @returns A nullable physics imposter
  24651. */
  24652. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24653. /**
  24654. * Disposes the physics imposter
  24655. */
  24656. dispose(): void;
  24657. /**
  24658. * Sets the delta position
  24659. * @param position The delta position amount
  24660. */
  24661. setDeltaPosition(position: Vector3): void;
  24662. /**
  24663. * Sets the delta rotation
  24664. * @param rotation The delta rotation amount
  24665. */
  24666. setDeltaRotation(rotation: Quaternion): void;
  24667. /**
  24668. * Gets the box size of the physics imposter and stores the result in the input parameter
  24669. * @param result Stores the box size
  24670. * @returns The physics imposter
  24671. */
  24672. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24673. /**
  24674. * Gets the radius of the physics imposter
  24675. * @returns Radius of the physics imposter
  24676. */
  24677. getRadius(): number;
  24678. /**
  24679. * Sync a bone with this impostor
  24680. * @param bone The bone to sync to the impostor.
  24681. * @param boneMesh The mesh that the bone is influencing.
  24682. * @param jointPivot The pivot of the joint / bone in local space.
  24683. * @param distToJoint Optional distance from the impostor to the joint.
  24684. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24685. */
  24686. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24687. /**
  24688. * Sync impostor to a bone
  24689. * @param bone The bone that the impostor will be synced to.
  24690. * @param boneMesh The mesh that the bone is influencing.
  24691. * @param jointPivot The pivot of the joint / bone in local space.
  24692. * @param distToJoint Optional distance from the impostor to the joint.
  24693. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24694. * @param boneAxis Optional vector3 axis the bone is aligned with
  24695. */
  24696. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24697. /**
  24698. * No-Imposter type
  24699. */
  24700. static NoImpostor: number;
  24701. /**
  24702. * Sphere-Imposter type
  24703. */
  24704. static SphereImpostor: number;
  24705. /**
  24706. * Box-Imposter type
  24707. */
  24708. static BoxImpostor: number;
  24709. /**
  24710. * Plane-Imposter type
  24711. */
  24712. static PlaneImpostor: number;
  24713. /**
  24714. * Mesh-imposter type
  24715. */
  24716. static MeshImpostor: number;
  24717. /**
  24718. * Capsule-Impostor type (Ammo.js plugin only)
  24719. */
  24720. static CapsuleImpostor: number;
  24721. /**
  24722. * Cylinder-Imposter type
  24723. */
  24724. static CylinderImpostor: number;
  24725. /**
  24726. * Particle-Imposter type
  24727. */
  24728. static ParticleImpostor: number;
  24729. /**
  24730. * Heightmap-Imposter type
  24731. */
  24732. static HeightmapImpostor: number;
  24733. /**
  24734. * ConvexHull-Impostor type (Ammo.js plugin only)
  24735. */
  24736. static ConvexHullImpostor: number;
  24737. /**
  24738. * Custom-Imposter type (Ammo.js plugin only)
  24739. */
  24740. static CustomImpostor: number;
  24741. /**
  24742. * Rope-Imposter type
  24743. */
  24744. static RopeImpostor: number;
  24745. /**
  24746. * Cloth-Imposter type
  24747. */
  24748. static ClothImpostor: number;
  24749. /**
  24750. * Softbody-Imposter type
  24751. */
  24752. static SoftbodyImpostor: number;
  24753. }
  24754. }
  24755. declare module "babylonjs/Meshes/mesh" {
  24756. import { Observable } from "babylonjs/Misc/observable";
  24757. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24758. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24759. import { Camera } from "babylonjs/Cameras/camera";
  24760. import { Scene } from "babylonjs/scene";
  24761. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24762. import { Color4 } from "babylonjs/Maths/math.color";
  24763. import { Engine } from "babylonjs/Engines/engine";
  24764. import { Node } from "babylonjs/node";
  24765. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24766. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24767. import { Buffer } from "babylonjs/Meshes/buffer";
  24768. import { Geometry } from "babylonjs/Meshes/geometry";
  24769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24770. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24771. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24772. import { Effect } from "babylonjs/Materials/effect";
  24773. import { Material } from "babylonjs/Materials/material";
  24774. import { Skeleton } from "babylonjs/Bones/skeleton";
  24775. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24776. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24777. import { Path3D } from "babylonjs/Maths/math.path";
  24778. import { Plane } from "babylonjs/Maths/math.plane";
  24779. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24780. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24781. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24782. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24783. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24784. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24785. /**
  24786. * @hidden
  24787. **/
  24788. export class _CreationDataStorage {
  24789. closePath?: boolean;
  24790. closeArray?: boolean;
  24791. idx: number[];
  24792. dashSize: number;
  24793. gapSize: number;
  24794. path3D: Path3D;
  24795. pathArray: Vector3[][];
  24796. arc: number;
  24797. radius: number;
  24798. cap: number;
  24799. tessellation: number;
  24800. }
  24801. /**
  24802. * @hidden
  24803. **/
  24804. class _InstanceDataStorage {
  24805. visibleInstances: any;
  24806. batchCache: _InstancesBatch;
  24807. instancesBufferSize: number;
  24808. instancesBuffer: Nullable<Buffer>;
  24809. instancesData: Float32Array;
  24810. overridenInstanceCount: number;
  24811. isFrozen: boolean;
  24812. previousBatch: Nullable<_InstancesBatch>;
  24813. hardwareInstancedRendering: boolean;
  24814. sideOrientation: number;
  24815. manualUpdate: boolean;
  24816. }
  24817. /**
  24818. * @hidden
  24819. **/
  24820. export class _InstancesBatch {
  24821. mustReturn: boolean;
  24822. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24823. renderSelf: boolean[];
  24824. hardwareInstancedRendering: boolean[];
  24825. }
  24826. /**
  24827. * Class used to represent renderable models
  24828. */
  24829. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24830. /**
  24831. * Mesh side orientation : usually the external or front surface
  24832. */
  24833. static readonly FRONTSIDE: number;
  24834. /**
  24835. * Mesh side orientation : usually the internal or back surface
  24836. */
  24837. static readonly BACKSIDE: number;
  24838. /**
  24839. * Mesh side orientation : both internal and external or front and back surfaces
  24840. */
  24841. static readonly DOUBLESIDE: number;
  24842. /**
  24843. * Mesh side orientation : by default, `FRONTSIDE`
  24844. */
  24845. static readonly DEFAULTSIDE: number;
  24846. /**
  24847. * Mesh cap setting : no cap
  24848. */
  24849. static readonly NO_CAP: number;
  24850. /**
  24851. * Mesh cap setting : one cap at the beginning of the mesh
  24852. */
  24853. static readonly CAP_START: number;
  24854. /**
  24855. * Mesh cap setting : one cap at the end of the mesh
  24856. */
  24857. static readonly CAP_END: number;
  24858. /**
  24859. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24860. */
  24861. static readonly CAP_ALL: number;
  24862. /**
  24863. * Mesh pattern setting : no flip or rotate
  24864. */
  24865. static readonly NO_FLIP: number;
  24866. /**
  24867. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24868. */
  24869. static readonly FLIP_TILE: number;
  24870. /**
  24871. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24872. */
  24873. static readonly ROTATE_TILE: number;
  24874. /**
  24875. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24876. */
  24877. static readonly FLIP_ROW: number;
  24878. /**
  24879. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24880. */
  24881. static readonly ROTATE_ROW: number;
  24882. /**
  24883. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24884. */
  24885. static readonly FLIP_N_ROTATE_TILE: number;
  24886. /**
  24887. * Mesh pattern setting : rotate pattern and rotate
  24888. */
  24889. static readonly FLIP_N_ROTATE_ROW: number;
  24890. /**
  24891. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24892. */
  24893. static readonly CENTER: number;
  24894. /**
  24895. * Mesh tile positioning : part tiles on left
  24896. */
  24897. static readonly LEFT: number;
  24898. /**
  24899. * Mesh tile positioning : part tiles on right
  24900. */
  24901. static readonly RIGHT: number;
  24902. /**
  24903. * Mesh tile positioning : part tiles on top
  24904. */
  24905. static readonly TOP: number;
  24906. /**
  24907. * Mesh tile positioning : part tiles on bottom
  24908. */
  24909. static readonly BOTTOM: number;
  24910. /**
  24911. * Gets the default side orientation.
  24912. * @param orientation the orientation to value to attempt to get
  24913. * @returns the default orientation
  24914. * @hidden
  24915. */
  24916. static _GetDefaultSideOrientation(orientation?: number): number;
  24917. private _internalMeshDataInfo;
  24918. /**
  24919. * An event triggered before rendering the mesh
  24920. */
  24921. get onBeforeRenderObservable(): Observable<Mesh>;
  24922. /**
  24923. * An event triggered before binding the mesh
  24924. */
  24925. get onBeforeBindObservable(): Observable<Mesh>;
  24926. /**
  24927. * An event triggered after rendering the mesh
  24928. */
  24929. get onAfterRenderObservable(): Observable<Mesh>;
  24930. /**
  24931. * An event triggered before drawing the mesh
  24932. */
  24933. get onBeforeDrawObservable(): Observable<Mesh>;
  24934. private _onBeforeDrawObserver;
  24935. /**
  24936. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24937. */
  24938. set onBeforeDraw(callback: () => void);
  24939. get hasInstances(): boolean;
  24940. /**
  24941. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24942. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24943. */
  24944. delayLoadState: number;
  24945. /**
  24946. * Gets the list of instances created from this mesh
  24947. * it is not supposed to be modified manually.
  24948. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24949. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24950. */
  24951. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24952. /**
  24953. * Gets the file containing delay loading data for this mesh
  24954. */
  24955. delayLoadingFile: string;
  24956. /** @hidden */
  24957. _binaryInfo: any;
  24958. /**
  24959. * User defined function used to change how LOD level selection is done
  24960. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24961. */
  24962. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24963. /**
  24964. * Gets or sets the morph target manager
  24965. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24966. */
  24967. get morphTargetManager(): Nullable<MorphTargetManager>;
  24968. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24969. /** @hidden */
  24970. _creationDataStorage: Nullable<_CreationDataStorage>;
  24971. /** @hidden */
  24972. _geometry: Nullable<Geometry>;
  24973. /** @hidden */
  24974. _delayInfo: Array<string>;
  24975. /** @hidden */
  24976. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24977. /** @hidden */
  24978. _instanceDataStorage: _InstanceDataStorage;
  24979. private _effectiveMaterial;
  24980. /** @hidden */
  24981. _shouldGenerateFlatShading: boolean;
  24982. /** @hidden */
  24983. _originalBuilderSideOrientation: number;
  24984. /**
  24985. * Use this property to change the original side orientation defined at construction time
  24986. */
  24987. overrideMaterialSideOrientation: Nullable<number>;
  24988. /**
  24989. * Gets the source mesh (the one used to clone this one from)
  24990. */
  24991. get source(): Nullable<Mesh>;
  24992. /**
  24993. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24994. */
  24995. get isUnIndexed(): boolean;
  24996. set isUnIndexed(value: boolean);
  24997. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24998. get worldMatrixInstancedBuffer(): Float32Array;
  24999. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25000. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25001. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25002. /**
  25003. * @constructor
  25004. * @param name The value used by scene.getMeshByName() to do a lookup.
  25005. * @param scene The scene to add this mesh to.
  25006. * @param parent The parent of this mesh, if it has one
  25007. * @param source An optional Mesh from which geometry is shared, cloned.
  25008. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25009. * When false, achieved by calling a clone(), also passing False.
  25010. * This will make creation of children, recursive.
  25011. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25012. */
  25013. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25014. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25015. doNotInstantiate: boolean;
  25016. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25017. /**
  25018. * Gets the class name
  25019. * @returns the string "Mesh".
  25020. */
  25021. getClassName(): string;
  25022. /** @hidden */
  25023. get _isMesh(): boolean;
  25024. /**
  25025. * Returns a description of this mesh
  25026. * @param fullDetails define if full details about this mesh must be used
  25027. * @returns a descriptive string representing this mesh
  25028. */
  25029. toString(fullDetails?: boolean): string;
  25030. /** @hidden */
  25031. _unBindEffect(): void;
  25032. /**
  25033. * Gets a boolean indicating if this mesh has LOD
  25034. */
  25035. get hasLODLevels(): boolean;
  25036. /**
  25037. * Gets the list of MeshLODLevel associated with the current mesh
  25038. * @returns an array of MeshLODLevel
  25039. */
  25040. getLODLevels(): MeshLODLevel[];
  25041. private _sortLODLevels;
  25042. /**
  25043. * Add a mesh as LOD level triggered at the given distance.
  25044. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25045. * @param distance The distance from the center of the object to show this level
  25046. * @param mesh The mesh to be added as LOD level (can be null)
  25047. * @return This mesh (for chaining)
  25048. */
  25049. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25050. /**
  25051. * Returns the LOD level mesh at the passed distance or null if not found.
  25052. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25053. * @param distance The distance from the center of the object to show this level
  25054. * @returns a Mesh or `null`
  25055. */
  25056. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25057. /**
  25058. * Remove a mesh from the LOD array
  25059. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25060. * @param mesh defines the mesh to be removed
  25061. * @return This mesh (for chaining)
  25062. */
  25063. removeLODLevel(mesh: Mesh): Mesh;
  25064. /**
  25065. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25066. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25067. * @param camera defines the camera to use to compute distance
  25068. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25069. * @return This mesh (for chaining)
  25070. */
  25071. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25072. /**
  25073. * Gets the mesh internal Geometry object
  25074. */
  25075. get geometry(): Nullable<Geometry>;
  25076. /**
  25077. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25078. * @returns the total number of vertices
  25079. */
  25080. getTotalVertices(): number;
  25081. /**
  25082. * Returns the content of an associated vertex buffer
  25083. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25084. * - VertexBuffer.PositionKind
  25085. * - VertexBuffer.UVKind
  25086. * - VertexBuffer.UV2Kind
  25087. * - VertexBuffer.UV3Kind
  25088. * - VertexBuffer.UV4Kind
  25089. * - VertexBuffer.UV5Kind
  25090. * - VertexBuffer.UV6Kind
  25091. * - VertexBuffer.ColorKind
  25092. * - VertexBuffer.MatricesIndicesKind
  25093. * - VertexBuffer.MatricesIndicesExtraKind
  25094. * - VertexBuffer.MatricesWeightsKind
  25095. * - VertexBuffer.MatricesWeightsExtraKind
  25096. * @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
  25097. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25098. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25099. */
  25100. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25101. /**
  25102. * Returns the mesh VertexBuffer object from the requested `kind`
  25103. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25104. * - VertexBuffer.PositionKind
  25105. * - VertexBuffer.NormalKind
  25106. * - VertexBuffer.UVKind
  25107. * - VertexBuffer.UV2Kind
  25108. * - VertexBuffer.UV3Kind
  25109. * - VertexBuffer.UV4Kind
  25110. * - VertexBuffer.UV5Kind
  25111. * - VertexBuffer.UV6Kind
  25112. * - VertexBuffer.ColorKind
  25113. * - VertexBuffer.MatricesIndicesKind
  25114. * - VertexBuffer.MatricesIndicesExtraKind
  25115. * - VertexBuffer.MatricesWeightsKind
  25116. * - VertexBuffer.MatricesWeightsExtraKind
  25117. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25118. */
  25119. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25120. /**
  25121. * Tests if a specific vertex buffer is associated with this mesh
  25122. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25123. * - VertexBuffer.PositionKind
  25124. * - VertexBuffer.NormalKind
  25125. * - VertexBuffer.UVKind
  25126. * - VertexBuffer.UV2Kind
  25127. * - VertexBuffer.UV3Kind
  25128. * - VertexBuffer.UV4Kind
  25129. * - VertexBuffer.UV5Kind
  25130. * - VertexBuffer.UV6Kind
  25131. * - VertexBuffer.ColorKind
  25132. * - VertexBuffer.MatricesIndicesKind
  25133. * - VertexBuffer.MatricesIndicesExtraKind
  25134. * - VertexBuffer.MatricesWeightsKind
  25135. * - VertexBuffer.MatricesWeightsExtraKind
  25136. * @returns a boolean
  25137. */
  25138. isVerticesDataPresent(kind: string): boolean;
  25139. /**
  25140. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25141. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25142. * - VertexBuffer.PositionKind
  25143. * - VertexBuffer.UVKind
  25144. * - VertexBuffer.UV2Kind
  25145. * - VertexBuffer.UV3Kind
  25146. * - VertexBuffer.UV4Kind
  25147. * - VertexBuffer.UV5Kind
  25148. * - VertexBuffer.UV6Kind
  25149. * - VertexBuffer.ColorKind
  25150. * - VertexBuffer.MatricesIndicesKind
  25151. * - VertexBuffer.MatricesIndicesExtraKind
  25152. * - VertexBuffer.MatricesWeightsKind
  25153. * - VertexBuffer.MatricesWeightsExtraKind
  25154. * @returns a boolean
  25155. */
  25156. isVertexBufferUpdatable(kind: string): boolean;
  25157. /**
  25158. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25159. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25160. * - VertexBuffer.PositionKind
  25161. * - VertexBuffer.NormalKind
  25162. * - VertexBuffer.UVKind
  25163. * - VertexBuffer.UV2Kind
  25164. * - VertexBuffer.UV3Kind
  25165. * - VertexBuffer.UV4Kind
  25166. * - VertexBuffer.UV5Kind
  25167. * - VertexBuffer.UV6Kind
  25168. * - VertexBuffer.ColorKind
  25169. * - VertexBuffer.MatricesIndicesKind
  25170. * - VertexBuffer.MatricesIndicesExtraKind
  25171. * - VertexBuffer.MatricesWeightsKind
  25172. * - VertexBuffer.MatricesWeightsExtraKind
  25173. * @returns an array of strings
  25174. */
  25175. getVerticesDataKinds(): string[];
  25176. /**
  25177. * Returns a positive integer : the total number of indices in this mesh geometry.
  25178. * @returns the numner of indices or zero if the mesh has no geometry.
  25179. */
  25180. getTotalIndices(): number;
  25181. /**
  25182. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25183. * @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.
  25184. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25185. * @returns the indices array or an empty array if the mesh has no geometry
  25186. */
  25187. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25188. get isBlocked(): boolean;
  25189. /**
  25190. * Determine if the current mesh is ready to be rendered
  25191. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25192. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25193. * @returns true if all associated assets are ready (material, textures, shaders)
  25194. */
  25195. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25196. /**
  25197. * 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.
  25198. */
  25199. get areNormalsFrozen(): boolean;
  25200. /**
  25201. * 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.
  25202. * @returns the current mesh
  25203. */
  25204. freezeNormals(): Mesh;
  25205. /**
  25206. * 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
  25207. * @returns the current mesh
  25208. */
  25209. unfreezeNormals(): Mesh;
  25210. /**
  25211. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25212. */
  25213. set overridenInstanceCount(count: number);
  25214. /** @hidden */
  25215. _preActivate(): Mesh;
  25216. /** @hidden */
  25217. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25218. /** @hidden */
  25219. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25220. /**
  25221. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25222. * This means the mesh underlying bounding box and sphere are recomputed.
  25223. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25224. * @returns the current mesh
  25225. */
  25226. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25227. /** @hidden */
  25228. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25229. /**
  25230. * This function will subdivide the mesh into multiple submeshes
  25231. * @param count defines the expected number of submeshes
  25232. */
  25233. subdivide(count: number): void;
  25234. /**
  25235. * Copy a FloatArray into a specific associated vertex buffer
  25236. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25237. * - VertexBuffer.PositionKind
  25238. * - VertexBuffer.UVKind
  25239. * - VertexBuffer.UV2Kind
  25240. * - VertexBuffer.UV3Kind
  25241. * - VertexBuffer.UV4Kind
  25242. * - VertexBuffer.UV5Kind
  25243. * - VertexBuffer.UV6Kind
  25244. * - VertexBuffer.ColorKind
  25245. * - VertexBuffer.MatricesIndicesKind
  25246. * - VertexBuffer.MatricesIndicesExtraKind
  25247. * - VertexBuffer.MatricesWeightsKind
  25248. * - VertexBuffer.MatricesWeightsExtraKind
  25249. * @param data defines the data source
  25250. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25251. * @param stride defines the data stride size (can be null)
  25252. * @returns the current mesh
  25253. */
  25254. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25255. /**
  25256. * Delete a vertex buffer associated with this mesh
  25257. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25258. * - VertexBuffer.PositionKind
  25259. * - VertexBuffer.UVKind
  25260. * - VertexBuffer.UV2Kind
  25261. * - VertexBuffer.UV3Kind
  25262. * - VertexBuffer.UV4Kind
  25263. * - VertexBuffer.UV5Kind
  25264. * - VertexBuffer.UV6Kind
  25265. * - VertexBuffer.ColorKind
  25266. * - VertexBuffer.MatricesIndicesKind
  25267. * - VertexBuffer.MatricesIndicesExtraKind
  25268. * - VertexBuffer.MatricesWeightsKind
  25269. * - VertexBuffer.MatricesWeightsExtraKind
  25270. */
  25271. removeVerticesData(kind: string): void;
  25272. /**
  25273. * Flags an associated vertex buffer as updatable
  25274. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25275. * - VertexBuffer.PositionKind
  25276. * - VertexBuffer.UVKind
  25277. * - VertexBuffer.UV2Kind
  25278. * - VertexBuffer.UV3Kind
  25279. * - VertexBuffer.UV4Kind
  25280. * - VertexBuffer.UV5Kind
  25281. * - VertexBuffer.UV6Kind
  25282. * - VertexBuffer.ColorKind
  25283. * - VertexBuffer.MatricesIndicesKind
  25284. * - VertexBuffer.MatricesIndicesExtraKind
  25285. * - VertexBuffer.MatricesWeightsKind
  25286. * - VertexBuffer.MatricesWeightsExtraKind
  25287. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25288. */
  25289. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25290. /**
  25291. * Sets the mesh global Vertex Buffer
  25292. * @param buffer defines the buffer to use
  25293. * @returns the current mesh
  25294. */
  25295. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25296. /**
  25297. * Update a specific associated vertex buffer
  25298. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25299. * - VertexBuffer.PositionKind
  25300. * - VertexBuffer.UVKind
  25301. * - VertexBuffer.UV2Kind
  25302. * - VertexBuffer.UV3Kind
  25303. * - VertexBuffer.UV4Kind
  25304. * - VertexBuffer.UV5Kind
  25305. * - VertexBuffer.UV6Kind
  25306. * - VertexBuffer.ColorKind
  25307. * - VertexBuffer.MatricesIndicesKind
  25308. * - VertexBuffer.MatricesIndicesExtraKind
  25309. * - VertexBuffer.MatricesWeightsKind
  25310. * - VertexBuffer.MatricesWeightsExtraKind
  25311. * @param data defines the data source
  25312. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25313. * @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)
  25314. * @returns the current mesh
  25315. */
  25316. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25317. /**
  25318. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25319. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25320. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25321. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25322. * @returns the current mesh
  25323. */
  25324. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25325. /**
  25326. * Creates a un-shared specific occurence of the geometry for the mesh.
  25327. * @returns the current mesh
  25328. */
  25329. makeGeometryUnique(): Mesh;
  25330. /**
  25331. * Set the index buffer of this mesh
  25332. * @param indices defines the source data
  25333. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25334. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25335. * @returns the current mesh
  25336. */
  25337. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25338. /**
  25339. * Update the current index buffer
  25340. * @param indices defines the source data
  25341. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25342. * @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)
  25343. * @returns the current mesh
  25344. */
  25345. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25346. /**
  25347. * Invert the geometry to move from a right handed system to a left handed one.
  25348. * @returns the current mesh
  25349. */
  25350. toLeftHanded(): Mesh;
  25351. /** @hidden */
  25352. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25353. /** @hidden */
  25354. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25355. /**
  25356. * Registers for this mesh a javascript function called just before the rendering process
  25357. * @param func defines the function to call before rendering this mesh
  25358. * @returns the current mesh
  25359. */
  25360. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25361. /**
  25362. * Disposes a previously registered javascript function called before the rendering
  25363. * @param func defines the function to remove
  25364. * @returns the current mesh
  25365. */
  25366. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25367. /**
  25368. * Registers for this mesh a javascript function called just after the rendering is complete
  25369. * @param func defines the function to call after rendering this mesh
  25370. * @returns the current mesh
  25371. */
  25372. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25373. /**
  25374. * Disposes a previously registered javascript function called after the rendering.
  25375. * @param func defines the function to remove
  25376. * @returns the current mesh
  25377. */
  25378. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25379. /** @hidden */
  25380. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25381. /** @hidden */
  25382. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25383. /** @hidden */
  25384. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25385. /** @hidden */
  25386. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25387. /** @hidden */
  25388. _rebuild(): void;
  25389. /** @hidden */
  25390. _freeze(): void;
  25391. /** @hidden */
  25392. _unFreeze(): void;
  25393. /**
  25394. * 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
  25395. * @param subMesh defines the subMesh to render
  25396. * @param enableAlphaMode defines if alpha mode can be changed
  25397. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25398. * @returns the current mesh
  25399. */
  25400. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25401. private _onBeforeDraw;
  25402. /**
  25403. * Renormalize the mesh and patch it up if there are no weights
  25404. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25405. * However in the case of zero weights then we set just a single influence to 1.
  25406. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25407. */
  25408. cleanMatrixWeights(): void;
  25409. private normalizeSkinFourWeights;
  25410. private normalizeSkinWeightsAndExtra;
  25411. /**
  25412. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25413. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25414. * the user know there was an issue with importing the mesh
  25415. * @returns a validation object with skinned, valid and report string
  25416. */
  25417. validateSkinning(): {
  25418. skinned: boolean;
  25419. valid: boolean;
  25420. report: string;
  25421. };
  25422. /** @hidden */
  25423. _checkDelayState(): Mesh;
  25424. private _queueLoad;
  25425. /**
  25426. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25427. * A mesh is in the frustum if its bounding box intersects the frustum
  25428. * @param frustumPlanes defines the frustum to test
  25429. * @returns true if the mesh is in the frustum planes
  25430. */
  25431. isInFrustum(frustumPlanes: Plane[]): boolean;
  25432. /**
  25433. * Sets the mesh material by the material or multiMaterial `id` property
  25434. * @param id is a string identifying the material or the multiMaterial
  25435. * @returns the current mesh
  25436. */
  25437. setMaterialByID(id: string): Mesh;
  25438. /**
  25439. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25440. * @returns an array of IAnimatable
  25441. */
  25442. getAnimatables(): IAnimatable[];
  25443. /**
  25444. * Modifies the mesh geometry according to the passed transformation matrix.
  25445. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25446. * The mesh normals are modified using the same transformation.
  25447. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25448. * @param transform defines the transform matrix to use
  25449. * @see http://doc.babylonjs.com/resources/baking_transformations
  25450. * @returns the current mesh
  25451. */
  25452. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25453. /**
  25454. * Modifies the mesh geometry according to its own current World Matrix.
  25455. * The mesh World Matrix is then reset.
  25456. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25457. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25458. * @see http://doc.babylonjs.com/resources/baking_transformations
  25459. * @returns the current mesh
  25460. */
  25461. bakeCurrentTransformIntoVertices(): Mesh;
  25462. /** @hidden */
  25463. get _positions(): Nullable<Vector3[]>;
  25464. /** @hidden */
  25465. _resetPointsArrayCache(): Mesh;
  25466. /** @hidden */
  25467. _generatePointsArray(): boolean;
  25468. /**
  25469. * Returns a new Mesh object generated from the current mesh properties.
  25470. * This method must not get confused with createInstance()
  25471. * @param name is a string, the name given to the new mesh
  25472. * @param newParent can be any Node object (default `null`)
  25473. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25474. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25475. * @returns a new mesh
  25476. */
  25477. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25478. /**
  25479. * Releases resources associated with this mesh.
  25480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25482. */
  25483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25484. /** @hidden */
  25485. _disposeInstanceSpecificData(): void;
  25486. /**
  25487. * Modifies the mesh geometry according to a displacement map.
  25488. * 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.
  25489. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25490. * @param url is a string, the URL from the image file is to be downloaded.
  25491. * @param minHeight is the lower limit of the displacement.
  25492. * @param maxHeight is the upper limit of the displacement.
  25493. * @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.
  25494. * @param uvOffset is an optional vector2 used to offset UV.
  25495. * @param uvScale is an optional vector2 used to scale UV.
  25496. * @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.
  25497. * @returns the Mesh.
  25498. */
  25499. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25500. /**
  25501. * Modifies the mesh geometry according to a displacementMap buffer.
  25502. * 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.
  25503. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25504. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25505. * @param heightMapWidth is the width of the buffer image.
  25506. * @param heightMapHeight is the height of the buffer image.
  25507. * @param minHeight is the lower limit of the displacement.
  25508. * @param maxHeight is the upper limit of the displacement.
  25509. * @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.
  25510. * @param uvOffset is an optional vector2 used to offset UV.
  25511. * @param uvScale is an optional vector2 used to scale UV.
  25512. * @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.
  25513. * @returns the Mesh.
  25514. */
  25515. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25516. /**
  25517. * Modify the mesh to get a flat shading rendering.
  25518. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25519. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25520. * @returns current mesh
  25521. */
  25522. convertToFlatShadedMesh(): Mesh;
  25523. /**
  25524. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25525. * In other words, more vertices, no more indices and a single bigger VBO.
  25526. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25527. * @returns current mesh
  25528. */
  25529. convertToUnIndexedMesh(): Mesh;
  25530. /**
  25531. * Inverses facet orientations.
  25532. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25533. * @param flipNormals will also inverts the normals
  25534. * @returns current mesh
  25535. */
  25536. flipFaces(flipNormals?: boolean): Mesh;
  25537. /**
  25538. * Increase the number of facets and hence vertices in a mesh
  25539. * Vertex normals are interpolated from existing vertex normals
  25540. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25541. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25542. */
  25543. increaseVertices(numberPerEdge: number): void;
  25544. /**
  25545. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25546. * This will undo any application of covertToFlatShadedMesh
  25547. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25548. */
  25549. forceSharedVertices(): void;
  25550. /** @hidden */
  25551. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25552. /** @hidden */
  25553. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25554. /**
  25555. * Creates a new InstancedMesh object from the mesh model.
  25556. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25557. * @param name defines the name of the new instance
  25558. * @returns a new InstancedMesh
  25559. */
  25560. createInstance(name: string): InstancedMesh;
  25561. /**
  25562. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25563. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25564. * @returns the current mesh
  25565. */
  25566. synchronizeInstances(): Mesh;
  25567. /**
  25568. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25569. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25570. * This should be used together with the simplification to avoid disappearing triangles.
  25571. * @param successCallback an optional success callback to be called after the optimization finished.
  25572. * @returns the current mesh
  25573. */
  25574. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25575. /**
  25576. * Serialize current mesh
  25577. * @param serializationObject defines the object which will receive the serialization data
  25578. */
  25579. serialize(serializationObject: any): void;
  25580. /** @hidden */
  25581. _syncGeometryWithMorphTargetManager(): void;
  25582. /** @hidden */
  25583. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25584. /**
  25585. * Returns a new Mesh object parsed from the source provided.
  25586. * @param parsedMesh is the source
  25587. * @param scene defines the hosting scene
  25588. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25589. * @returns a new Mesh
  25590. */
  25591. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25592. /**
  25593. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25594. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25595. * @param name defines the name of the mesh to create
  25596. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25597. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25598. * @param closePath creates a seam between the first and the last points of each path of the path array
  25599. * @param offset is taken in account only if the `pathArray` is containing a single path
  25600. * @param scene defines the hosting scene
  25601. * @param updatable defines if the mesh must be flagged as updatable
  25602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25603. * @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)
  25604. * @returns a new Mesh
  25605. */
  25606. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25607. /**
  25608. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25609. * @param name defines the name of the mesh to create
  25610. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25611. * @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
  25612. * @param scene defines the hosting scene
  25613. * @param updatable defines if the mesh must be flagged as updatable
  25614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25615. * @returns a new Mesh
  25616. */
  25617. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25618. /**
  25619. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25620. * @param name defines the name of the mesh to create
  25621. * @param size sets the size (float) of each box side (default 1)
  25622. * @param scene defines the hosting scene
  25623. * @param updatable defines if the mesh must be flagged as updatable
  25624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25625. * @returns a new Mesh
  25626. */
  25627. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25628. /**
  25629. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25630. * @param name defines the name of the mesh to create
  25631. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25632. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25633. * @param scene defines the hosting scene
  25634. * @param updatable defines if the mesh must be flagged as updatable
  25635. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25636. * @returns a new Mesh
  25637. */
  25638. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25639. /**
  25640. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25641. * @param name defines the name of the mesh to create
  25642. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25643. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25644. * @param scene defines the hosting scene
  25645. * @returns a new Mesh
  25646. */
  25647. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25648. /**
  25649. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25650. * @param name defines the name of the mesh to create
  25651. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25652. * @param diameterTop set the top cap diameter (floats, default 1)
  25653. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25654. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25655. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25656. * @param scene defines the hosting scene
  25657. * @param updatable defines if the mesh must be flagged as updatable
  25658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25659. * @returns a new Mesh
  25660. */
  25661. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25662. /**
  25663. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25664. * @param name defines the name of the mesh to create
  25665. * @param diameter sets the diameter size (float) of the torus (default 1)
  25666. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25667. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25668. * @param scene defines the hosting scene
  25669. * @param updatable defines if the mesh must be flagged as updatable
  25670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25671. * @returns a new Mesh
  25672. */
  25673. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25674. /**
  25675. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25676. * @param name defines the name of the mesh to create
  25677. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25678. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25679. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25680. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25681. * @param p the number of windings on X axis (positive integers, default 2)
  25682. * @param q the number of windings on Y axis (positive integers, default 3)
  25683. * @param scene defines the hosting scene
  25684. * @param updatable defines if the mesh must be flagged as updatable
  25685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25686. * @returns a new Mesh
  25687. */
  25688. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25689. /**
  25690. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25691. * @param name defines the name of the mesh to create
  25692. * @param points is an array successive Vector3
  25693. * @param scene defines the hosting scene
  25694. * @param updatable defines if the mesh must be flagged as updatable
  25695. * @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).
  25696. * @returns a new Mesh
  25697. */
  25698. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25699. /**
  25700. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25701. * @param name defines the name of the mesh to create
  25702. * @param points is an array successive Vector3
  25703. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25704. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25705. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25706. * @param scene defines the hosting scene
  25707. * @param updatable defines if the mesh must be flagged as updatable
  25708. * @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)
  25709. * @returns a new Mesh
  25710. */
  25711. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25712. /**
  25713. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25714. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25715. * 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.
  25716. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25717. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25718. * Remember you can only change the shape positions, not their number when updating a polygon.
  25719. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25720. * @param name defines the name of the mesh to create
  25721. * @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
  25722. * @param scene defines the hosting scene
  25723. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25724. * @param updatable defines if the mesh must be flagged as updatable
  25725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25726. * @param earcutInjection can be used to inject your own earcut reference
  25727. * @returns a new Mesh
  25728. */
  25729. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25730. /**
  25731. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25732. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25733. * @param name defines the name of the mesh to create
  25734. * @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
  25735. * @param depth defines the height of extrusion
  25736. * @param scene defines the hosting scene
  25737. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25738. * @param updatable defines if the mesh must be flagged as updatable
  25739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25740. * @param earcutInjection can be used to inject your own earcut reference
  25741. * @returns a new Mesh
  25742. */
  25743. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25744. /**
  25745. * Creates an extruded shape mesh.
  25746. * 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
  25747. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25748. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25749. * @param name defines the name of the mesh to create
  25750. * @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
  25751. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25752. * @param scale is the value to scale the shape
  25753. * @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
  25754. * @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
  25755. * @param scene defines the hosting scene
  25756. * @param updatable defines if the mesh must be flagged as updatable
  25757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25758. * @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)
  25759. * @returns a new Mesh
  25760. */
  25761. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25762. /**
  25763. * Creates an custom extruded shape mesh.
  25764. * The custom extrusion is a parametric shape.
  25765. * It has no predefined shape. Its final shape will depend on the input parameters.
  25766. * Please consider using the same method from the MeshBuilder class instead
  25767. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25768. * @param name defines the name of the mesh to create
  25769. * @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
  25770. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25771. * @param scaleFunction is a custom Javascript function called on each path point
  25772. * @param rotationFunction is a custom Javascript function called on each path point
  25773. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25774. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25775. * @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
  25776. * @param scene defines the hosting scene
  25777. * @param updatable defines if the mesh must be flagged as updatable
  25778. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25779. * @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)
  25780. * @returns a new Mesh
  25781. */
  25782. 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;
  25783. /**
  25784. * Creates lathe mesh.
  25785. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25786. * Please consider using the same method from the MeshBuilder class instead
  25787. * @param name defines the name of the mesh to create
  25788. * @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
  25789. * @param radius is the radius value of the lathe
  25790. * @param tessellation is the side number of the lathe.
  25791. * @param scene defines the hosting scene
  25792. * @param updatable defines if the mesh must be flagged as updatable
  25793. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25794. * @returns a new Mesh
  25795. */
  25796. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25797. /**
  25798. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25799. * @param name defines the name of the mesh to create
  25800. * @param size sets the size (float) of both sides of the plane at once (default 1)
  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 CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25807. /**
  25808. * Creates a ground mesh.
  25809. * Please consider using the same method from the MeshBuilder class instead
  25810. * @param name defines the name of the mesh to create
  25811. * @param width set the width of the ground
  25812. * @param height set the height of the ground
  25813. * @param subdivisions sets the number of subdivisions per side
  25814. * @param scene defines the hosting scene
  25815. * @param updatable defines if the mesh must be flagged as updatable
  25816. * @returns a new Mesh
  25817. */
  25818. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25819. /**
  25820. * Creates a tiled ground mesh.
  25821. * Please consider using the same method from the MeshBuilder class instead
  25822. * @param name defines the name of the mesh to create
  25823. * @param xmin set the ground minimum X coordinate
  25824. * @param zmin set the ground minimum Y coordinate
  25825. * @param xmax set the ground maximum X coordinate
  25826. * @param zmax set the ground maximum Z coordinate
  25827. * @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
  25828. * @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
  25829. * @param scene defines the hosting scene
  25830. * @param updatable defines if the mesh must be flagged as updatable
  25831. * @returns a new Mesh
  25832. */
  25833. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25834. w: number;
  25835. h: number;
  25836. }, precision: {
  25837. w: number;
  25838. h: number;
  25839. }, scene: Scene, updatable?: boolean): Mesh;
  25840. /**
  25841. * Creates a ground mesh from a height map.
  25842. * Please consider using the same method from the MeshBuilder class instead
  25843. * @see http://doc.babylonjs.com/babylon101/height_map
  25844. * @param name defines the name of the mesh to create
  25845. * @param url sets the URL of the height map image resource
  25846. * @param width set the ground width size
  25847. * @param height set the ground height size
  25848. * @param subdivisions sets the number of subdivision per side
  25849. * @param minHeight is the minimum altitude on the ground
  25850. * @param maxHeight is the maximum altitude on the ground
  25851. * @param scene defines the hosting scene
  25852. * @param updatable defines if the mesh must be flagged as updatable
  25853. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25854. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25855. * @returns a new Mesh
  25856. */
  25857. 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;
  25858. /**
  25859. * Creates a tube mesh.
  25860. * The tube is a parametric shape.
  25861. * It has no predefined shape. Its final shape will depend on the input parameters.
  25862. * Please consider using the same method from the MeshBuilder class instead
  25863. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25864. * @param name defines the name of the mesh to create
  25865. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25866. * @param radius sets the tube radius size
  25867. * @param tessellation is the number of sides on the tubular surface
  25868. * @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
  25869. * @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
  25870. * @param scene defines the hosting scene
  25871. * @param updatable defines if the mesh must be flagged as updatable
  25872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25873. * @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)
  25874. * @returns a new Mesh
  25875. */
  25876. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25877. (i: number, distance: number): number;
  25878. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25879. /**
  25880. * Creates a polyhedron mesh.
  25881. * Please consider using the same method from the MeshBuilder class instead.
  25882. * * 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
  25883. * * The parameter `size` (positive float, default 1) sets the polygon size
  25884. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25885. * * 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`
  25886. * * 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
  25887. * * 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)`)
  25888. * * 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
  25889. * * 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
  25890. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25891. * * If you create a double-sided mesh, you can choose what parts of 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
  25892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25893. * @param name defines the name of the mesh to create
  25894. * @param options defines the options used to create the mesh
  25895. * @param scene defines the hosting scene
  25896. * @returns a new Mesh
  25897. */
  25898. static CreatePolyhedron(name: string, options: {
  25899. type?: number;
  25900. size?: number;
  25901. sizeX?: number;
  25902. sizeY?: number;
  25903. sizeZ?: number;
  25904. custom?: any;
  25905. faceUV?: Vector4[];
  25906. faceColors?: Color4[];
  25907. updatable?: boolean;
  25908. sideOrientation?: number;
  25909. }, scene: Scene): Mesh;
  25910. /**
  25911. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25912. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25913. * * 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`)
  25914. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25915. * * 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
  25916. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25917. * * If you create a double-sided mesh, you can choose what parts of 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
  25918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25919. * @param name defines the name of the mesh
  25920. * @param options defines the options used to create the mesh
  25921. * @param scene defines the hosting scene
  25922. * @returns a new Mesh
  25923. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25924. */
  25925. static CreateIcoSphere(name: string, options: {
  25926. radius?: number;
  25927. flat?: boolean;
  25928. subdivisions?: number;
  25929. sideOrientation?: number;
  25930. updatable?: boolean;
  25931. }, scene: Scene): Mesh;
  25932. /**
  25933. * Creates a decal mesh.
  25934. * Please consider using the same method from the MeshBuilder class instead.
  25935. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25936. * @param name defines the name of the mesh
  25937. * @param sourceMesh defines the mesh receiving the decal
  25938. * @param position sets the position of the decal in world coordinates
  25939. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25940. * @param size sets the decal scaling
  25941. * @param angle sets the angle to rotate the decal
  25942. * @returns a new Mesh
  25943. */
  25944. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25945. /**
  25946. * Prepare internal position array for software CPU skinning
  25947. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25948. */
  25949. setPositionsForCPUSkinning(): Float32Array;
  25950. /**
  25951. * Prepare internal normal array for software CPU skinning
  25952. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25953. */
  25954. setNormalsForCPUSkinning(): Float32Array;
  25955. /**
  25956. * Updates the vertex buffer by applying transformation from the bones
  25957. * @param skeleton defines the skeleton to apply to current mesh
  25958. * @returns the current mesh
  25959. */
  25960. applySkeleton(skeleton: Skeleton): Mesh;
  25961. /**
  25962. * 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
  25963. * @param meshes defines the list of meshes to scan
  25964. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25965. */
  25966. static MinMax(meshes: AbstractMesh[]): {
  25967. min: Vector3;
  25968. max: Vector3;
  25969. };
  25970. /**
  25971. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25972. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25973. * @returns a vector3
  25974. */
  25975. static Center(meshesOrMinMaxVector: {
  25976. min: Vector3;
  25977. max: Vector3;
  25978. } | AbstractMesh[]): Vector3;
  25979. /**
  25980. * Merge the array of meshes into a single mesh for performance reasons.
  25981. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25982. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25983. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25984. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25985. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25986. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25987. * @returns a new mesh
  25988. */
  25989. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25990. /** @hidden */
  25991. addInstance(instance: InstancedMesh): void;
  25992. /** @hidden */
  25993. removeInstance(instance: InstancedMesh): void;
  25994. }
  25995. }
  25996. declare module "babylonjs/Cameras/camera" {
  25997. import { SmartArray } from "babylonjs/Misc/smartArray";
  25998. import { Observable } from "babylonjs/Misc/observable";
  25999. import { Nullable } from "babylonjs/types";
  26000. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26001. import { Scene } from "babylonjs/scene";
  26002. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26003. import { Node } from "babylonjs/node";
  26004. import { Mesh } from "babylonjs/Meshes/mesh";
  26005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26006. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26007. import { Viewport } from "babylonjs/Maths/math.viewport";
  26008. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26009. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26010. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26011. import { Ray } from "babylonjs/Culling/ray";
  26012. /**
  26013. * This is the base class of all the camera used in the application.
  26014. * @see http://doc.babylonjs.com/features/cameras
  26015. */
  26016. export class Camera extends Node {
  26017. /** @hidden */
  26018. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26019. /**
  26020. * This is the default projection mode used by the cameras.
  26021. * It helps recreating a feeling of perspective and better appreciate depth.
  26022. * This is the best way to simulate real life cameras.
  26023. */
  26024. static readonly PERSPECTIVE_CAMERA: number;
  26025. /**
  26026. * This helps creating camera with an orthographic mode.
  26027. * 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.
  26028. */
  26029. static readonly ORTHOGRAPHIC_CAMERA: number;
  26030. /**
  26031. * This is the default FOV mode for perspective cameras.
  26032. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26033. */
  26034. static readonly FOVMODE_VERTICAL_FIXED: number;
  26035. /**
  26036. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26037. */
  26038. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26039. /**
  26040. * This specifies ther is no need for a camera rig.
  26041. * Basically only one eye is rendered corresponding to the camera.
  26042. */
  26043. static readonly RIG_MODE_NONE: number;
  26044. /**
  26045. * Simulates a camera Rig with one blue eye and one red eye.
  26046. * This can be use with 3d blue and red glasses.
  26047. */
  26048. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26049. /**
  26050. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26051. */
  26052. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26053. /**
  26054. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26055. */
  26056. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26057. /**
  26058. * Defines that both eyes of the camera will be rendered over under each other.
  26059. */
  26060. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26061. /**
  26062. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26063. */
  26064. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26065. /**
  26066. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26067. */
  26068. static readonly RIG_MODE_VR: number;
  26069. /**
  26070. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26071. */
  26072. static readonly RIG_MODE_WEBVR: number;
  26073. /**
  26074. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26075. */
  26076. static readonly RIG_MODE_CUSTOM: number;
  26077. /**
  26078. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26079. */
  26080. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26081. /**
  26082. * Define the input manager associated with the camera.
  26083. */
  26084. inputs: CameraInputsManager<Camera>;
  26085. /** @hidden */
  26086. _position: Vector3;
  26087. /**
  26088. * Define the current local position of the camera in the scene
  26089. */
  26090. get position(): Vector3;
  26091. set position(newPosition: Vector3);
  26092. /**
  26093. * The vector the camera should consider as up.
  26094. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26095. */
  26096. upVector: Vector3;
  26097. /**
  26098. * Define the current limit on the left side for an orthographic camera
  26099. * In scene unit
  26100. */
  26101. orthoLeft: Nullable<number>;
  26102. /**
  26103. * Define the current limit on the right side for an orthographic camera
  26104. * In scene unit
  26105. */
  26106. orthoRight: Nullable<number>;
  26107. /**
  26108. * Define the current limit on the bottom side for an orthographic camera
  26109. * In scene unit
  26110. */
  26111. orthoBottom: Nullable<number>;
  26112. /**
  26113. * Define the current limit on the top side for an orthographic camera
  26114. * In scene unit
  26115. */
  26116. orthoTop: Nullable<number>;
  26117. /**
  26118. * Field Of View is set in Radians. (default is 0.8)
  26119. */
  26120. fov: number;
  26121. /**
  26122. * Define the minimum distance the camera can see from.
  26123. * This is important to note that the depth buffer are not infinite and the closer it starts
  26124. * the more your scene might encounter depth fighting issue.
  26125. */
  26126. minZ: number;
  26127. /**
  26128. * Define the maximum distance the camera can see to.
  26129. * This is important to note that the depth buffer are not infinite and the further it end
  26130. * the more your scene might encounter depth fighting issue.
  26131. */
  26132. maxZ: number;
  26133. /**
  26134. * Define the default inertia of the camera.
  26135. * This helps giving a smooth feeling to the camera movement.
  26136. */
  26137. inertia: number;
  26138. /**
  26139. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26140. */
  26141. mode: number;
  26142. /**
  26143. * Define wether the camera is intermediate.
  26144. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26145. */
  26146. isIntermediate: boolean;
  26147. /**
  26148. * Define the viewport of the camera.
  26149. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26150. */
  26151. viewport: Viewport;
  26152. /**
  26153. * Restricts the camera to viewing objects with the same layerMask.
  26154. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26155. */
  26156. layerMask: number;
  26157. /**
  26158. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26159. */
  26160. fovMode: number;
  26161. /**
  26162. * Rig mode of the camera.
  26163. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26164. * This is normally controlled byt the camera themselves as internal use.
  26165. */
  26166. cameraRigMode: number;
  26167. /**
  26168. * Defines the distance between both "eyes" in case of a RIG
  26169. */
  26170. interaxialDistance: number;
  26171. /**
  26172. * Defines if stereoscopic rendering is done side by side or over under.
  26173. */
  26174. isStereoscopicSideBySide: boolean;
  26175. /**
  26176. * 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
  26177. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26178. * else in the scene. (Eg. security camera)
  26179. *
  26180. * 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)
  26181. */
  26182. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26183. /**
  26184. * When set, the camera will render to this render target instead of the default canvas
  26185. *
  26186. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26187. */
  26188. outputRenderTarget: Nullable<RenderTargetTexture>;
  26189. /**
  26190. * Observable triggered when the camera view matrix has changed.
  26191. */
  26192. onViewMatrixChangedObservable: Observable<Camera>;
  26193. /**
  26194. * Observable triggered when the camera Projection matrix has changed.
  26195. */
  26196. onProjectionMatrixChangedObservable: Observable<Camera>;
  26197. /**
  26198. * Observable triggered when the inputs have been processed.
  26199. */
  26200. onAfterCheckInputsObservable: Observable<Camera>;
  26201. /**
  26202. * Observable triggered when reset has been called and applied to the camera.
  26203. */
  26204. onRestoreStateObservable: Observable<Camera>;
  26205. /** @hidden */
  26206. _cameraRigParams: any;
  26207. /** @hidden */
  26208. _rigCameras: Camera[];
  26209. /** @hidden */
  26210. _rigPostProcess: Nullable<PostProcess>;
  26211. protected _webvrViewMatrix: Matrix;
  26212. /** @hidden */
  26213. _skipRendering: boolean;
  26214. /** @hidden */
  26215. _projectionMatrix: Matrix;
  26216. /** @hidden */
  26217. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26218. /** @hidden */
  26219. _activeMeshes: SmartArray<AbstractMesh>;
  26220. protected _globalPosition: Vector3;
  26221. /** @hidden */
  26222. _computedViewMatrix: Matrix;
  26223. private _doNotComputeProjectionMatrix;
  26224. private _transformMatrix;
  26225. private _frustumPlanes;
  26226. private _refreshFrustumPlanes;
  26227. private _storedFov;
  26228. private _stateStored;
  26229. /**
  26230. * Instantiates a new camera object.
  26231. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26232. * @see http://doc.babylonjs.com/features/cameras
  26233. * @param name Defines the name of the camera in the scene
  26234. * @param position Defines the position of the camera
  26235. * @param scene Defines the scene the camera belongs too
  26236. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26237. */
  26238. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26239. /**
  26240. * Store current camera state (fov, position, etc..)
  26241. * @returns the camera
  26242. */
  26243. storeState(): Camera;
  26244. /**
  26245. * Restores the camera state values if it has been stored. You must call storeState() first
  26246. */
  26247. protected _restoreStateValues(): boolean;
  26248. /**
  26249. * Restored camera state. You must call storeState() first.
  26250. * @returns true if restored and false otherwise
  26251. */
  26252. restoreState(): boolean;
  26253. /**
  26254. * Gets the class name of the camera.
  26255. * @returns the class name
  26256. */
  26257. getClassName(): string;
  26258. /** @hidden */
  26259. readonly _isCamera: boolean;
  26260. /**
  26261. * Gets a string representation of the camera useful for debug purpose.
  26262. * @param fullDetails Defines that a more verboe level of logging is required
  26263. * @returns the string representation
  26264. */
  26265. toString(fullDetails?: boolean): string;
  26266. /**
  26267. * Gets the current world space position of the camera.
  26268. */
  26269. get globalPosition(): Vector3;
  26270. /**
  26271. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26272. * @returns the active meshe list
  26273. */
  26274. getActiveMeshes(): SmartArray<AbstractMesh>;
  26275. /**
  26276. * Check wether a mesh is part of the current active mesh list of the camera
  26277. * @param mesh Defines the mesh to check
  26278. * @returns true if active, false otherwise
  26279. */
  26280. isActiveMesh(mesh: Mesh): boolean;
  26281. /**
  26282. * Is this camera ready to be used/rendered
  26283. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26284. * @return true if the camera is ready
  26285. */
  26286. isReady(completeCheck?: boolean): boolean;
  26287. /** @hidden */
  26288. _initCache(): void;
  26289. /** @hidden */
  26290. _updateCache(ignoreParentClass?: boolean): void;
  26291. /** @hidden */
  26292. _isSynchronized(): boolean;
  26293. /** @hidden */
  26294. _isSynchronizedViewMatrix(): boolean;
  26295. /** @hidden */
  26296. _isSynchronizedProjectionMatrix(): boolean;
  26297. /**
  26298. * Attach the input controls to a specific dom element to get the input from.
  26299. * @param element Defines the element the controls should be listened from
  26300. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26301. */
  26302. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26303. /**
  26304. * Detach the current controls from the specified dom element.
  26305. * @param element Defines the element to stop listening the inputs from
  26306. */
  26307. detachControl(element: HTMLElement): void;
  26308. /**
  26309. * Update the camera state according to the different inputs gathered during the frame.
  26310. */
  26311. update(): void;
  26312. /** @hidden */
  26313. _checkInputs(): void;
  26314. /** @hidden */
  26315. get rigCameras(): Camera[];
  26316. /**
  26317. * Gets the post process used by the rig cameras
  26318. */
  26319. get rigPostProcess(): Nullable<PostProcess>;
  26320. /**
  26321. * Internal, gets the first post proces.
  26322. * @returns the first post process to be run on this camera.
  26323. */
  26324. _getFirstPostProcess(): Nullable<PostProcess>;
  26325. private _cascadePostProcessesToRigCams;
  26326. /**
  26327. * Attach a post process to the camera.
  26328. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26329. * @param postProcess The post process to attach to the camera
  26330. * @param insertAt The position of the post process in case several of them are in use in the scene
  26331. * @returns the position the post process has been inserted at
  26332. */
  26333. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26334. /**
  26335. * Detach a post process to the camera.
  26336. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26337. * @param postProcess The post process to detach from the camera
  26338. */
  26339. detachPostProcess(postProcess: PostProcess): void;
  26340. /**
  26341. * Gets the current world matrix of the camera
  26342. */
  26343. getWorldMatrix(): Matrix;
  26344. /** @hidden */
  26345. _getViewMatrix(): Matrix;
  26346. /**
  26347. * Gets the current view matrix of the camera.
  26348. * @param force forces the camera to recompute the matrix without looking at the cached state
  26349. * @returns the view matrix
  26350. */
  26351. getViewMatrix(force?: boolean): Matrix;
  26352. /**
  26353. * Freeze the projection matrix.
  26354. * It will prevent the cache check of the camera projection compute and can speed up perf
  26355. * if no parameter of the camera are meant to change
  26356. * @param projection Defines manually a projection if necessary
  26357. */
  26358. freezeProjectionMatrix(projection?: Matrix): void;
  26359. /**
  26360. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26361. */
  26362. unfreezeProjectionMatrix(): void;
  26363. /**
  26364. * Gets the current projection matrix of the camera.
  26365. * @param force forces the camera to recompute the matrix without looking at the cached state
  26366. * @returns the projection matrix
  26367. */
  26368. getProjectionMatrix(force?: boolean): Matrix;
  26369. /**
  26370. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26371. * @returns a Matrix
  26372. */
  26373. getTransformationMatrix(): Matrix;
  26374. private _updateFrustumPlanes;
  26375. /**
  26376. * Checks if a cullable object (mesh...) is in the camera frustum
  26377. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26378. * @param target The object to check
  26379. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26380. * @returns true if the object is in frustum otherwise false
  26381. */
  26382. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26383. /**
  26384. * Checks if a cullable object (mesh...) is in the camera frustum
  26385. * Unlike isInFrustum this cheks the full bounding box
  26386. * @param target The object to check
  26387. * @returns true if the object is in frustum otherwise false
  26388. */
  26389. isCompletelyInFrustum(target: ICullable): boolean;
  26390. /**
  26391. * Gets a ray in the forward direction from the camera.
  26392. * @param length Defines the length of the ray to create
  26393. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26394. * @param origin Defines the start point of the ray which defaults to the camera position
  26395. * @returns the forward ray
  26396. */
  26397. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26398. /**
  26399. * Releases resources associated with this node.
  26400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26402. */
  26403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26404. /** @hidden */
  26405. _isLeftCamera: boolean;
  26406. /**
  26407. * Gets the left camera of a rig setup in case of Rigged Camera
  26408. */
  26409. get isLeftCamera(): boolean;
  26410. /** @hidden */
  26411. _isRightCamera: boolean;
  26412. /**
  26413. * Gets the right camera of a rig setup in case of Rigged Camera
  26414. */
  26415. get isRightCamera(): boolean;
  26416. /**
  26417. * Gets the left camera of a rig setup in case of Rigged Camera
  26418. */
  26419. get leftCamera(): Nullable<FreeCamera>;
  26420. /**
  26421. * Gets the right camera of a rig setup in case of Rigged Camera
  26422. */
  26423. get rightCamera(): Nullable<FreeCamera>;
  26424. /**
  26425. * Gets the left camera target of a rig setup in case of Rigged Camera
  26426. * @returns the target position
  26427. */
  26428. getLeftTarget(): Nullable<Vector3>;
  26429. /**
  26430. * Gets the right camera target of a rig setup in case of Rigged Camera
  26431. * @returns the target position
  26432. */
  26433. getRightTarget(): Nullable<Vector3>;
  26434. /**
  26435. * @hidden
  26436. */
  26437. setCameraRigMode(mode: number, rigParams: any): void;
  26438. /** @hidden */
  26439. static _setStereoscopicRigMode(camera: Camera): void;
  26440. /** @hidden */
  26441. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26442. /** @hidden */
  26443. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26444. /** @hidden */
  26445. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26446. /** @hidden */
  26447. _getVRProjectionMatrix(): Matrix;
  26448. protected _updateCameraRotationMatrix(): void;
  26449. protected _updateWebVRCameraRotationMatrix(): void;
  26450. /**
  26451. * This function MUST be overwritten by the different WebVR cameras available.
  26452. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26453. * @hidden
  26454. */
  26455. _getWebVRProjectionMatrix(): Matrix;
  26456. /**
  26457. * This function MUST be overwritten by the different WebVR cameras available.
  26458. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26459. * @hidden
  26460. */
  26461. _getWebVRViewMatrix(): Matrix;
  26462. /** @hidden */
  26463. setCameraRigParameter(name: string, value: any): void;
  26464. /**
  26465. * needs to be overridden by children so sub has required properties to be copied
  26466. * @hidden
  26467. */
  26468. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26469. /**
  26470. * May need to be overridden by children
  26471. * @hidden
  26472. */
  26473. _updateRigCameras(): void;
  26474. /** @hidden */
  26475. _setupInputs(): void;
  26476. /**
  26477. * Serialiaze the camera setup to a json represention
  26478. * @returns the JSON representation
  26479. */
  26480. serialize(): any;
  26481. /**
  26482. * Clones the current camera.
  26483. * @param name The cloned camera name
  26484. * @returns the cloned camera
  26485. */
  26486. clone(name: string): Camera;
  26487. /**
  26488. * Gets the direction of the camera relative to a given local axis.
  26489. * @param localAxis Defines the reference axis to provide a relative direction.
  26490. * @return the direction
  26491. */
  26492. getDirection(localAxis: Vector3): Vector3;
  26493. /**
  26494. * Returns the current camera absolute rotation
  26495. */
  26496. get absoluteRotation(): Quaternion;
  26497. /**
  26498. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26499. * @param localAxis Defines the reference axis to provide a relative direction.
  26500. * @param result Defines the vector to store the result in
  26501. */
  26502. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26503. /**
  26504. * Gets a camera constructor for a given camera type
  26505. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26506. * @param name The name of the camera the result will be able to instantiate
  26507. * @param scene The scene the result will construct the camera in
  26508. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26509. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26510. * @returns a factory method to construc the camera
  26511. */
  26512. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26513. /**
  26514. * Compute the world matrix of the camera.
  26515. * @returns the camera world matrix
  26516. */
  26517. computeWorldMatrix(): Matrix;
  26518. /**
  26519. * Parse a JSON and creates the camera from the parsed information
  26520. * @param parsedCamera The JSON to parse
  26521. * @param scene The scene to instantiate the camera in
  26522. * @returns the newly constructed camera
  26523. */
  26524. static Parse(parsedCamera: any, scene: Scene): Camera;
  26525. }
  26526. }
  26527. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26528. import { Nullable } from "babylonjs/types";
  26529. import { Scene } from "babylonjs/scene";
  26530. import { Vector4 } from "babylonjs/Maths/math.vector";
  26531. import { Mesh } from "babylonjs/Meshes/mesh";
  26532. /**
  26533. * Class containing static functions to help procedurally build meshes
  26534. */
  26535. export class DiscBuilder {
  26536. /**
  26537. * Creates a plane polygonal mesh. By default, this is a disc
  26538. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26539. * * 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
  26540. * * 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
  26541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26544. * @param name defines the name of the mesh
  26545. * @param options defines the options used to create the mesh
  26546. * @param scene defines the hosting scene
  26547. * @returns the plane polygonal mesh
  26548. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26549. */
  26550. static CreateDisc(name: string, options: {
  26551. radius?: number;
  26552. tessellation?: number;
  26553. arc?: number;
  26554. updatable?: boolean;
  26555. sideOrientation?: number;
  26556. frontUVs?: Vector4;
  26557. backUVs?: Vector4;
  26558. }, scene?: Nullable<Scene>): Mesh;
  26559. }
  26560. }
  26561. declare module "babylonjs/Materials/fresnelParameters" {
  26562. import { Color3 } from "babylonjs/Maths/math.color";
  26563. /**
  26564. * This represents all the required information to add a fresnel effect on a material:
  26565. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26566. */
  26567. export class FresnelParameters {
  26568. private _isEnabled;
  26569. /**
  26570. * Define if the fresnel effect is enable or not.
  26571. */
  26572. get isEnabled(): boolean;
  26573. set isEnabled(value: boolean);
  26574. /**
  26575. * Define the color used on edges (grazing angle)
  26576. */
  26577. leftColor: Color3;
  26578. /**
  26579. * Define the color used on center
  26580. */
  26581. rightColor: Color3;
  26582. /**
  26583. * Define bias applied to computed fresnel term
  26584. */
  26585. bias: number;
  26586. /**
  26587. * Defined the power exponent applied to fresnel term
  26588. */
  26589. power: number;
  26590. /**
  26591. * Clones the current fresnel and its valuues
  26592. * @returns a clone fresnel configuration
  26593. */
  26594. clone(): FresnelParameters;
  26595. /**
  26596. * Serializes the current fresnel parameters to a JSON representation.
  26597. * @return the JSON serialization
  26598. */
  26599. serialize(): any;
  26600. /**
  26601. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26602. * @param parsedFresnelParameters Define the JSON representation
  26603. * @returns the parsed parameters
  26604. */
  26605. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26606. }
  26607. }
  26608. declare module "babylonjs/Materials/pushMaterial" {
  26609. import { Nullable } from "babylonjs/types";
  26610. import { Scene } from "babylonjs/scene";
  26611. import { Matrix } from "babylonjs/Maths/math.vector";
  26612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26613. import { Mesh } from "babylonjs/Meshes/mesh";
  26614. import { Material } from "babylonjs/Materials/material";
  26615. import { Effect } from "babylonjs/Materials/effect";
  26616. /**
  26617. * Base class of materials working in push mode in babylon JS
  26618. * @hidden
  26619. */
  26620. export class PushMaterial extends Material {
  26621. protected _activeEffect: Effect;
  26622. protected _normalMatrix: Matrix;
  26623. /**
  26624. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26625. * This means that the material can keep using a previous shader while a new one is being compiled.
  26626. * This is mostly used when shader parallel compilation is supported (true by default)
  26627. */
  26628. allowShaderHotSwapping: boolean;
  26629. constructor(name: string, scene: Scene);
  26630. getEffect(): Effect;
  26631. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26632. /**
  26633. * Binds the given world matrix to the active effect
  26634. *
  26635. * @param world the matrix to bind
  26636. */
  26637. bindOnlyWorldMatrix(world: Matrix): void;
  26638. /**
  26639. * Binds the given normal matrix to the active effect
  26640. *
  26641. * @param normalMatrix the matrix to bind
  26642. */
  26643. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26644. bind(world: Matrix, mesh?: Mesh): void;
  26645. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26646. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26647. }
  26648. }
  26649. declare module "babylonjs/Materials/materialFlags" {
  26650. /**
  26651. * This groups all the flags used to control the materials channel.
  26652. */
  26653. export class MaterialFlags {
  26654. private static _DiffuseTextureEnabled;
  26655. /**
  26656. * Are diffuse textures enabled in the application.
  26657. */
  26658. static get DiffuseTextureEnabled(): boolean;
  26659. static set DiffuseTextureEnabled(value: boolean);
  26660. private static _AmbientTextureEnabled;
  26661. /**
  26662. * Are ambient textures enabled in the application.
  26663. */
  26664. static get AmbientTextureEnabled(): boolean;
  26665. static set AmbientTextureEnabled(value: boolean);
  26666. private static _OpacityTextureEnabled;
  26667. /**
  26668. * Are opacity textures enabled in the application.
  26669. */
  26670. static get OpacityTextureEnabled(): boolean;
  26671. static set OpacityTextureEnabled(value: boolean);
  26672. private static _ReflectionTextureEnabled;
  26673. /**
  26674. * Are reflection textures enabled in the application.
  26675. */
  26676. static get ReflectionTextureEnabled(): boolean;
  26677. static set ReflectionTextureEnabled(value: boolean);
  26678. private static _EmissiveTextureEnabled;
  26679. /**
  26680. * Are emissive textures enabled in the application.
  26681. */
  26682. static get EmissiveTextureEnabled(): boolean;
  26683. static set EmissiveTextureEnabled(value: boolean);
  26684. private static _SpecularTextureEnabled;
  26685. /**
  26686. * Are specular textures enabled in the application.
  26687. */
  26688. static get SpecularTextureEnabled(): boolean;
  26689. static set SpecularTextureEnabled(value: boolean);
  26690. private static _BumpTextureEnabled;
  26691. /**
  26692. * Are bump textures enabled in the application.
  26693. */
  26694. static get BumpTextureEnabled(): boolean;
  26695. static set BumpTextureEnabled(value: boolean);
  26696. private static _LightmapTextureEnabled;
  26697. /**
  26698. * Are lightmap textures enabled in the application.
  26699. */
  26700. static get LightmapTextureEnabled(): boolean;
  26701. static set LightmapTextureEnabled(value: boolean);
  26702. private static _RefractionTextureEnabled;
  26703. /**
  26704. * Are refraction textures enabled in the application.
  26705. */
  26706. static get RefractionTextureEnabled(): boolean;
  26707. static set RefractionTextureEnabled(value: boolean);
  26708. private static _ColorGradingTextureEnabled;
  26709. /**
  26710. * Are color grading textures enabled in the application.
  26711. */
  26712. static get ColorGradingTextureEnabled(): boolean;
  26713. static set ColorGradingTextureEnabled(value: boolean);
  26714. private static _FresnelEnabled;
  26715. /**
  26716. * Are fresnels enabled in the application.
  26717. */
  26718. static get FresnelEnabled(): boolean;
  26719. static set FresnelEnabled(value: boolean);
  26720. private static _ClearCoatTextureEnabled;
  26721. /**
  26722. * Are clear coat textures enabled in the application.
  26723. */
  26724. static get ClearCoatTextureEnabled(): boolean;
  26725. static set ClearCoatTextureEnabled(value: boolean);
  26726. private static _ClearCoatBumpTextureEnabled;
  26727. /**
  26728. * Are clear coat bump textures enabled in the application.
  26729. */
  26730. static get ClearCoatBumpTextureEnabled(): boolean;
  26731. static set ClearCoatBumpTextureEnabled(value: boolean);
  26732. private static _ClearCoatTintTextureEnabled;
  26733. /**
  26734. * Are clear coat tint textures enabled in the application.
  26735. */
  26736. static get ClearCoatTintTextureEnabled(): boolean;
  26737. static set ClearCoatTintTextureEnabled(value: boolean);
  26738. private static _SheenTextureEnabled;
  26739. /**
  26740. * Are sheen textures enabled in the application.
  26741. */
  26742. static get SheenTextureEnabled(): boolean;
  26743. static set SheenTextureEnabled(value: boolean);
  26744. private static _AnisotropicTextureEnabled;
  26745. /**
  26746. * Are anisotropic textures enabled in the application.
  26747. */
  26748. static get AnisotropicTextureEnabled(): boolean;
  26749. static set AnisotropicTextureEnabled(value: boolean);
  26750. private static _ThicknessTextureEnabled;
  26751. /**
  26752. * Are thickness textures enabled in the application.
  26753. */
  26754. static get ThicknessTextureEnabled(): boolean;
  26755. static set ThicknessTextureEnabled(value: boolean);
  26756. }
  26757. }
  26758. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26759. /** @hidden */
  26760. export var defaultFragmentDeclaration: {
  26761. name: string;
  26762. shader: string;
  26763. };
  26764. }
  26765. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26766. /** @hidden */
  26767. export var defaultUboDeclaration: {
  26768. name: string;
  26769. shader: string;
  26770. };
  26771. }
  26772. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26773. /** @hidden */
  26774. export var lightFragmentDeclaration: {
  26775. name: string;
  26776. shader: string;
  26777. };
  26778. }
  26779. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26780. /** @hidden */
  26781. export var lightUboDeclaration: {
  26782. name: string;
  26783. shader: string;
  26784. };
  26785. }
  26786. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26787. /** @hidden */
  26788. export var lightsFragmentFunctions: {
  26789. name: string;
  26790. shader: string;
  26791. };
  26792. }
  26793. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26794. /** @hidden */
  26795. export var shadowsFragmentFunctions: {
  26796. name: string;
  26797. shader: string;
  26798. };
  26799. }
  26800. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26801. /** @hidden */
  26802. export var fresnelFunction: {
  26803. name: string;
  26804. shader: string;
  26805. };
  26806. }
  26807. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26808. /** @hidden */
  26809. export var reflectionFunction: {
  26810. name: string;
  26811. shader: string;
  26812. };
  26813. }
  26814. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26815. /** @hidden */
  26816. export var bumpFragmentFunctions: {
  26817. name: string;
  26818. shader: string;
  26819. };
  26820. }
  26821. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26822. /** @hidden */
  26823. export var logDepthDeclaration: {
  26824. name: string;
  26825. shader: string;
  26826. };
  26827. }
  26828. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26829. /** @hidden */
  26830. export var bumpFragment: {
  26831. name: string;
  26832. shader: string;
  26833. };
  26834. }
  26835. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26836. /** @hidden */
  26837. export var depthPrePass: {
  26838. name: string;
  26839. shader: string;
  26840. };
  26841. }
  26842. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26843. /** @hidden */
  26844. export var lightFragment: {
  26845. name: string;
  26846. shader: string;
  26847. };
  26848. }
  26849. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26850. /** @hidden */
  26851. export var logDepthFragment: {
  26852. name: string;
  26853. shader: string;
  26854. };
  26855. }
  26856. declare module "babylonjs/Shaders/default.fragment" {
  26857. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26858. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26859. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26860. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26861. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26862. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26863. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26864. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26865. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26866. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26867. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26868. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26869. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26870. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26871. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26872. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26873. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26874. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26875. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26876. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26877. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26878. /** @hidden */
  26879. export var defaultPixelShader: {
  26880. name: string;
  26881. shader: string;
  26882. };
  26883. }
  26884. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26885. /** @hidden */
  26886. export var defaultVertexDeclaration: {
  26887. name: string;
  26888. shader: string;
  26889. };
  26890. }
  26891. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26892. /** @hidden */
  26893. export var bumpVertexDeclaration: {
  26894. name: string;
  26895. shader: string;
  26896. };
  26897. }
  26898. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26899. /** @hidden */
  26900. export var bumpVertex: {
  26901. name: string;
  26902. shader: string;
  26903. };
  26904. }
  26905. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26906. /** @hidden */
  26907. export var fogVertex: {
  26908. name: string;
  26909. shader: string;
  26910. };
  26911. }
  26912. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26913. /** @hidden */
  26914. export var shadowsVertex: {
  26915. name: string;
  26916. shader: string;
  26917. };
  26918. }
  26919. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26920. /** @hidden */
  26921. export var pointCloudVertex: {
  26922. name: string;
  26923. shader: string;
  26924. };
  26925. }
  26926. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26927. /** @hidden */
  26928. export var logDepthVertex: {
  26929. name: string;
  26930. shader: string;
  26931. };
  26932. }
  26933. declare module "babylonjs/Shaders/default.vertex" {
  26934. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26935. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26936. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26937. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26939. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26940. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26941. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26942. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26943. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26946. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26948. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26949. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26950. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26951. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26952. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26953. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26954. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26955. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26956. /** @hidden */
  26957. export var defaultVertexShader: {
  26958. name: string;
  26959. shader: string;
  26960. };
  26961. }
  26962. declare module "babylonjs/Materials/standardMaterial" {
  26963. import { SmartArray } from "babylonjs/Misc/smartArray";
  26964. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26965. import { Nullable } from "babylonjs/types";
  26966. import { Scene } from "babylonjs/scene";
  26967. import { Matrix } from "babylonjs/Maths/math.vector";
  26968. import { Color3 } from "babylonjs/Maths/math.color";
  26969. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26971. import { Mesh } from "babylonjs/Meshes/mesh";
  26972. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26973. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26974. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26975. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26976. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26978. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26979. import "babylonjs/Shaders/default.fragment";
  26980. import "babylonjs/Shaders/default.vertex";
  26981. /** @hidden */
  26982. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26983. MAINUV1: boolean;
  26984. MAINUV2: boolean;
  26985. DIFFUSE: boolean;
  26986. DIFFUSEDIRECTUV: number;
  26987. AMBIENT: boolean;
  26988. AMBIENTDIRECTUV: number;
  26989. OPACITY: boolean;
  26990. OPACITYDIRECTUV: number;
  26991. OPACITYRGB: boolean;
  26992. REFLECTION: boolean;
  26993. EMISSIVE: boolean;
  26994. EMISSIVEDIRECTUV: number;
  26995. SPECULAR: boolean;
  26996. SPECULARDIRECTUV: number;
  26997. BUMP: boolean;
  26998. BUMPDIRECTUV: number;
  26999. PARALLAX: boolean;
  27000. PARALLAXOCCLUSION: boolean;
  27001. SPECULAROVERALPHA: boolean;
  27002. CLIPPLANE: boolean;
  27003. CLIPPLANE2: boolean;
  27004. CLIPPLANE3: boolean;
  27005. CLIPPLANE4: boolean;
  27006. CLIPPLANE5: boolean;
  27007. CLIPPLANE6: boolean;
  27008. ALPHATEST: boolean;
  27009. DEPTHPREPASS: boolean;
  27010. ALPHAFROMDIFFUSE: boolean;
  27011. POINTSIZE: boolean;
  27012. FOG: boolean;
  27013. SPECULARTERM: boolean;
  27014. DIFFUSEFRESNEL: boolean;
  27015. OPACITYFRESNEL: boolean;
  27016. REFLECTIONFRESNEL: boolean;
  27017. REFRACTIONFRESNEL: boolean;
  27018. EMISSIVEFRESNEL: boolean;
  27019. FRESNEL: boolean;
  27020. NORMAL: boolean;
  27021. UV1: boolean;
  27022. UV2: boolean;
  27023. VERTEXCOLOR: boolean;
  27024. VERTEXALPHA: boolean;
  27025. NUM_BONE_INFLUENCERS: number;
  27026. BonesPerMesh: number;
  27027. BONETEXTURE: boolean;
  27028. INSTANCES: boolean;
  27029. GLOSSINESS: boolean;
  27030. ROUGHNESS: boolean;
  27031. EMISSIVEASILLUMINATION: boolean;
  27032. LINKEMISSIVEWITHDIFFUSE: boolean;
  27033. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27034. LIGHTMAP: boolean;
  27035. LIGHTMAPDIRECTUV: number;
  27036. OBJECTSPACE_NORMALMAP: boolean;
  27037. USELIGHTMAPASSHADOWMAP: boolean;
  27038. REFLECTIONMAP_3D: boolean;
  27039. REFLECTIONMAP_SPHERICAL: boolean;
  27040. REFLECTIONMAP_PLANAR: boolean;
  27041. REFLECTIONMAP_CUBIC: boolean;
  27042. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27043. REFLECTIONMAP_PROJECTION: boolean;
  27044. REFLECTIONMAP_SKYBOX: boolean;
  27045. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  27046. REFLECTIONMAP_EXPLICIT: boolean;
  27047. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27048. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27049. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27050. INVERTCUBICMAP: boolean;
  27051. LOGARITHMICDEPTH: boolean;
  27052. REFRACTION: boolean;
  27053. REFRACTIONMAP_3D: boolean;
  27054. REFLECTIONOVERALPHA: boolean;
  27055. TWOSIDEDLIGHTING: boolean;
  27056. SHADOWFLOAT: boolean;
  27057. MORPHTARGETS: boolean;
  27058. MORPHTARGETS_NORMAL: boolean;
  27059. MORPHTARGETS_TANGENT: boolean;
  27060. MORPHTARGETS_UV: boolean;
  27061. NUM_MORPH_INFLUENCERS: number;
  27062. NONUNIFORMSCALING: boolean;
  27063. PREMULTIPLYALPHA: boolean;
  27064. IMAGEPROCESSING: boolean;
  27065. VIGNETTE: boolean;
  27066. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27067. VIGNETTEBLENDMODEOPAQUE: boolean;
  27068. TONEMAPPING: boolean;
  27069. TONEMAPPING_ACES: boolean;
  27070. CONTRAST: boolean;
  27071. COLORCURVES: boolean;
  27072. COLORGRADING: boolean;
  27073. COLORGRADING3D: boolean;
  27074. SAMPLER3DGREENDEPTH: boolean;
  27075. SAMPLER3DBGRMAP: boolean;
  27076. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27077. MULTIVIEW: boolean;
  27078. /**
  27079. * If the reflection texture on this material is in linear color space
  27080. * @hidden
  27081. */
  27082. IS_REFLECTION_LINEAR: boolean;
  27083. /**
  27084. * If the refraction texture on this material is in linear color space
  27085. * @hidden
  27086. */
  27087. IS_REFRACTION_LINEAR: boolean;
  27088. EXPOSURE: boolean;
  27089. constructor();
  27090. setReflectionMode(modeToEnable: string): void;
  27091. }
  27092. /**
  27093. * This is the default material used in Babylon. It is the best trade off between quality
  27094. * and performances.
  27095. * @see http://doc.babylonjs.com/babylon101/materials
  27096. */
  27097. export class StandardMaterial extends PushMaterial {
  27098. private _diffuseTexture;
  27099. /**
  27100. * The basic texture of the material as viewed under a light.
  27101. */
  27102. diffuseTexture: Nullable<BaseTexture>;
  27103. private _ambientTexture;
  27104. /**
  27105. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27106. */
  27107. ambientTexture: Nullable<BaseTexture>;
  27108. private _opacityTexture;
  27109. /**
  27110. * Define the transparency of the material from a texture.
  27111. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27112. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27113. */
  27114. opacityTexture: Nullable<BaseTexture>;
  27115. private _reflectionTexture;
  27116. /**
  27117. * Define the texture used to display the reflection.
  27118. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27119. */
  27120. reflectionTexture: Nullable<BaseTexture>;
  27121. private _emissiveTexture;
  27122. /**
  27123. * Define texture of the material as if self lit.
  27124. * This will be mixed in the final result even in the absence of light.
  27125. */
  27126. emissiveTexture: Nullable<BaseTexture>;
  27127. private _specularTexture;
  27128. /**
  27129. * Define how the color and intensity of the highlight given by the light in the material.
  27130. */
  27131. specularTexture: Nullable<BaseTexture>;
  27132. private _bumpTexture;
  27133. /**
  27134. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27135. * 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.
  27136. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27137. */
  27138. bumpTexture: Nullable<BaseTexture>;
  27139. private _lightmapTexture;
  27140. /**
  27141. * Complex lighting can be computationally expensive to compute at runtime.
  27142. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27143. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27144. */
  27145. lightmapTexture: Nullable<BaseTexture>;
  27146. private _refractionTexture;
  27147. /**
  27148. * Define the texture used to display the refraction.
  27149. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27150. */
  27151. refractionTexture: Nullable<BaseTexture>;
  27152. /**
  27153. * The color of the material lit by the environmental background lighting.
  27154. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27155. */
  27156. ambientColor: Color3;
  27157. /**
  27158. * The basic color of the material as viewed under a light.
  27159. */
  27160. diffuseColor: Color3;
  27161. /**
  27162. * Define how the color and intensity of the highlight given by the light in the material.
  27163. */
  27164. specularColor: Color3;
  27165. /**
  27166. * Define the color of the material as if self lit.
  27167. * This will be mixed in the final result even in the absence of light.
  27168. */
  27169. emissiveColor: Color3;
  27170. /**
  27171. * Defines how sharp are the highlights in the material.
  27172. * The bigger the value the sharper giving a more glossy feeling to the result.
  27173. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27174. */
  27175. specularPower: number;
  27176. private _useAlphaFromDiffuseTexture;
  27177. /**
  27178. * Does the transparency come from the diffuse texture alpha channel.
  27179. */
  27180. useAlphaFromDiffuseTexture: boolean;
  27181. private _useEmissiveAsIllumination;
  27182. /**
  27183. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27184. */
  27185. useEmissiveAsIllumination: boolean;
  27186. private _linkEmissiveWithDiffuse;
  27187. /**
  27188. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27189. * the emissive level when the final color is close to one.
  27190. */
  27191. linkEmissiveWithDiffuse: boolean;
  27192. private _useSpecularOverAlpha;
  27193. /**
  27194. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27195. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27196. */
  27197. useSpecularOverAlpha: boolean;
  27198. private _useReflectionOverAlpha;
  27199. /**
  27200. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27201. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27202. */
  27203. useReflectionOverAlpha: boolean;
  27204. private _disableLighting;
  27205. /**
  27206. * Does lights from the scene impacts this material.
  27207. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27208. */
  27209. disableLighting: boolean;
  27210. private _useObjectSpaceNormalMap;
  27211. /**
  27212. * Allows using an object space normal map (instead of tangent space).
  27213. */
  27214. useObjectSpaceNormalMap: boolean;
  27215. private _useParallax;
  27216. /**
  27217. * Is parallax enabled or not.
  27218. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27219. */
  27220. useParallax: boolean;
  27221. private _useParallaxOcclusion;
  27222. /**
  27223. * Is parallax occlusion enabled or not.
  27224. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27225. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27226. */
  27227. useParallaxOcclusion: boolean;
  27228. /**
  27229. * 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.
  27230. */
  27231. parallaxScaleBias: number;
  27232. private _roughness;
  27233. /**
  27234. * Helps to define how blurry the reflections should appears in the material.
  27235. */
  27236. roughness: number;
  27237. /**
  27238. * In case of refraction, define the value of the index of refraction.
  27239. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27240. */
  27241. indexOfRefraction: number;
  27242. /**
  27243. * Invert the refraction texture alongside the y axis.
  27244. * It can be useful with procedural textures or probe for instance.
  27245. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27246. */
  27247. invertRefractionY: boolean;
  27248. /**
  27249. * Defines the alpha limits in alpha test mode.
  27250. */
  27251. alphaCutOff: number;
  27252. private _useLightmapAsShadowmap;
  27253. /**
  27254. * In case of light mapping, define whether the map contains light or shadow informations.
  27255. */
  27256. useLightmapAsShadowmap: boolean;
  27257. private _diffuseFresnelParameters;
  27258. /**
  27259. * Define the diffuse fresnel parameters of the material.
  27260. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27261. */
  27262. diffuseFresnelParameters: FresnelParameters;
  27263. private _opacityFresnelParameters;
  27264. /**
  27265. * Define the opacity fresnel parameters of the material.
  27266. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27267. */
  27268. opacityFresnelParameters: FresnelParameters;
  27269. private _reflectionFresnelParameters;
  27270. /**
  27271. * Define the reflection fresnel parameters of the material.
  27272. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27273. */
  27274. reflectionFresnelParameters: FresnelParameters;
  27275. private _refractionFresnelParameters;
  27276. /**
  27277. * Define the refraction fresnel parameters of the material.
  27278. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27279. */
  27280. refractionFresnelParameters: FresnelParameters;
  27281. private _emissiveFresnelParameters;
  27282. /**
  27283. * Define the emissive fresnel parameters of the material.
  27284. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27285. */
  27286. emissiveFresnelParameters: FresnelParameters;
  27287. private _useReflectionFresnelFromSpecular;
  27288. /**
  27289. * If true automatically deducts the fresnels values from the material specularity.
  27290. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27291. */
  27292. useReflectionFresnelFromSpecular: boolean;
  27293. private _useGlossinessFromSpecularMapAlpha;
  27294. /**
  27295. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27296. */
  27297. useGlossinessFromSpecularMapAlpha: boolean;
  27298. private _maxSimultaneousLights;
  27299. /**
  27300. * Defines the maximum number of lights that can be used in the material
  27301. */
  27302. maxSimultaneousLights: number;
  27303. private _invertNormalMapX;
  27304. /**
  27305. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27306. */
  27307. invertNormalMapX: boolean;
  27308. private _invertNormalMapY;
  27309. /**
  27310. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27311. */
  27312. invertNormalMapY: boolean;
  27313. private _twoSidedLighting;
  27314. /**
  27315. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27316. */
  27317. twoSidedLighting: boolean;
  27318. /**
  27319. * Default configuration related to image processing available in the standard Material.
  27320. */
  27321. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27322. /**
  27323. * Gets the image processing configuration used either in this material.
  27324. */
  27325. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27326. /**
  27327. * Sets the Default image processing configuration used either in the this material.
  27328. *
  27329. * If sets to null, the scene one is in use.
  27330. */
  27331. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27332. /**
  27333. * Keep track of the image processing observer to allow dispose and replace.
  27334. */
  27335. private _imageProcessingObserver;
  27336. /**
  27337. * Attaches a new image processing configuration to the Standard Material.
  27338. * @param configuration
  27339. */
  27340. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27341. /**
  27342. * Gets wether the color curves effect is enabled.
  27343. */
  27344. get cameraColorCurvesEnabled(): boolean;
  27345. /**
  27346. * Sets wether the color curves effect is enabled.
  27347. */
  27348. set cameraColorCurvesEnabled(value: boolean);
  27349. /**
  27350. * Gets wether the color grading effect is enabled.
  27351. */
  27352. get cameraColorGradingEnabled(): boolean;
  27353. /**
  27354. * Gets wether the color grading effect is enabled.
  27355. */
  27356. set cameraColorGradingEnabled(value: boolean);
  27357. /**
  27358. * Gets wether tonemapping is enabled or not.
  27359. */
  27360. get cameraToneMappingEnabled(): boolean;
  27361. /**
  27362. * Sets wether tonemapping is enabled or not
  27363. */
  27364. set cameraToneMappingEnabled(value: boolean);
  27365. /**
  27366. * The camera exposure used on this material.
  27367. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27368. * This corresponds to a photographic exposure.
  27369. */
  27370. get cameraExposure(): number;
  27371. /**
  27372. * The camera exposure used on this material.
  27373. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27374. * This corresponds to a photographic exposure.
  27375. */
  27376. set cameraExposure(value: number);
  27377. /**
  27378. * Gets The camera contrast used on this material.
  27379. */
  27380. get cameraContrast(): number;
  27381. /**
  27382. * Sets The camera contrast used on this material.
  27383. */
  27384. set cameraContrast(value: number);
  27385. /**
  27386. * Gets the Color Grading 2D Lookup Texture.
  27387. */
  27388. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27389. /**
  27390. * Sets the Color Grading 2D Lookup Texture.
  27391. */
  27392. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27393. /**
  27394. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27395. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27396. * 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;
  27397. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27398. */
  27399. get cameraColorCurves(): Nullable<ColorCurves>;
  27400. /**
  27401. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27402. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27403. * 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;
  27404. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27405. */
  27406. set cameraColorCurves(value: Nullable<ColorCurves>);
  27407. /**
  27408. * Custom callback helping to override the default shader used in the material.
  27409. */
  27410. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27411. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27412. protected _worldViewProjectionMatrix: Matrix;
  27413. protected _globalAmbientColor: Color3;
  27414. protected _useLogarithmicDepth: boolean;
  27415. protected _rebuildInParallel: boolean;
  27416. /**
  27417. * Instantiates a new standard material.
  27418. * This is the default material used in Babylon. It is the best trade off between quality
  27419. * and performances.
  27420. * @see http://doc.babylonjs.com/babylon101/materials
  27421. * @param name Define the name of the material in the scene
  27422. * @param scene Define the scene the material belong to
  27423. */
  27424. constructor(name: string, scene: Scene);
  27425. /**
  27426. * Gets a boolean indicating that current material needs to register RTT
  27427. */
  27428. get hasRenderTargetTextures(): boolean;
  27429. /**
  27430. * Gets the current class name of the material e.g. "StandardMaterial"
  27431. * Mainly use in serialization.
  27432. * @returns the class name
  27433. */
  27434. getClassName(): string;
  27435. /**
  27436. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27437. * You can try switching to logarithmic depth.
  27438. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27439. */
  27440. get useLogarithmicDepth(): boolean;
  27441. set useLogarithmicDepth(value: boolean);
  27442. /**
  27443. * Specifies if the material will require alpha blending
  27444. * @returns a boolean specifying if alpha blending is needed
  27445. */
  27446. needAlphaBlending(): boolean;
  27447. /**
  27448. * Specifies if this material should be rendered in alpha test mode
  27449. * @returns a boolean specifying if an alpha test is needed.
  27450. */
  27451. needAlphaTesting(): boolean;
  27452. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27453. /**
  27454. * Get the texture used for alpha test purpose.
  27455. * @returns the diffuse texture in case of the standard material.
  27456. */
  27457. getAlphaTestTexture(): Nullable<BaseTexture>;
  27458. /**
  27459. * Get if the submesh is ready to be used and all its information available.
  27460. * Child classes can use it to update shaders
  27461. * @param mesh defines the mesh to check
  27462. * @param subMesh defines which submesh to check
  27463. * @param useInstances specifies that instances should be used
  27464. * @returns a boolean indicating that the submesh is ready or not
  27465. */
  27466. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27467. /**
  27468. * Builds the material UBO layouts.
  27469. * Used internally during the effect preparation.
  27470. */
  27471. buildUniformLayout(): void;
  27472. /**
  27473. * Unbinds the material from the mesh
  27474. */
  27475. unbind(): void;
  27476. /**
  27477. * Binds the submesh to this material by preparing the effect and shader to draw
  27478. * @param world defines the world transformation matrix
  27479. * @param mesh defines the mesh containing the submesh
  27480. * @param subMesh defines the submesh to bind the material to
  27481. */
  27482. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27483. /**
  27484. * Get the list of animatables in the material.
  27485. * @returns the list of animatables object used in the material
  27486. */
  27487. getAnimatables(): IAnimatable[];
  27488. /**
  27489. * Gets the active textures from the material
  27490. * @returns an array of textures
  27491. */
  27492. getActiveTextures(): BaseTexture[];
  27493. /**
  27494. * Specifies if the material uses a texture
  27495. * @param texture defines the texture to check against the material
  27496. * @returns a boolean specifying if the material uses the texture
  27497. */
  27498. hasTexture(texture: BaseTexture): boolean;
  27499. /**
  27500. * Disposes the material
  27501. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27502. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27503. */
  27504. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27505. /**
  27506. * Makes a duplicate of the material, and gives it a new name
  27507. * @param name defines the new name for the duplicated material
  27508. * @returns the cloned material
  27509. */
  27510. clone(name: string): StandardMaterial;
  27511. /**
  27512. * Serializes this material in a JSON representation
  27513. * @returns the serialized material object
  27514. */
  27515. serialize(): any;
  27516. /**
  27517. * Creates a standard material from parsed material data
  27518. * @param source defines the JSON representation of the material
  27519. * @param scene defines the hosting scene
  27520. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27521. * @returns a new standard material
  27522. */
  27523. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27524. /**
  27525. * Are diffuse textures enabled in the application.
  27526. */
  27527. static get DiffuseTextureEnabled(): boolean;
  27528. static set DiffuseTextureEnabled(value: boolean);
  27529. /**
  27530. * Are ambient textures enabled in the application.
  27531. */
  27532. static get AmbientTextureEnabled(): boolean;
  27533. static set AmbientTextureEnabled(value: boolean);
  27534. /**
  27535. * Are opacity textures enabled in the application.
  27536. */
  27537. static get OpacityTextureEnabled(): boolean;
  27538. static set OpacityTextureEnabled(value: boolean);
  27539. /**
  27540. * Are reflection textures enabled in the application.
  27541. */
  27542. static get ReflectionTextureEnabled(): boolean;
  27543. static set ReflectionTextureEnabled(value: boolean);
  27544. /**
  27545. * Are emissive textures enabled in the application.
  27546. */
  27547. static get EmissiveTextureEnabled(): boolean;
  27548. static set EmissiveTextureEnabled(value: boolean);
  27549. /**
  27550. * Are specular textures enabled in the application.
  27551. */
  27552. static get SpecularTextureEnabled(): boolean;
  27553. static set SpecularTextureEnabled(value: boolean);
  27554. /**
  27555. * Are bump textures enabled in the application.
  27556. */
  27557. static get BumpTextureEnabled(): boolean;
  27558. static set BumpTextureEnabled(value: boolean);
  27559. /**
  27560. * Are lightmap textures enabled in the application.
  27561. */
  27562. static get LightmapTextureEnabled(): boolean;
  27563. static set LightmapTextureEnabled(value: boolean);
  27564. /**
  27565. * Are refraction textures enabled in the application.
  27566. */
  27567. static get RefractionTextureEnabled(): boolean;
  27568. static set RefractionTextureEnabled(value: boolean);
  27569. /**
  27570. * Are color grading textures enabled in the application.
  27571. */
  27572. static get ColorGradingTextureEnabled(): boolean;
  27573. static set ColorGradingTextureEnabled(value: boolean);
  27574. /**
  27575. * Are fresnels enabled in the application.
  27576. */
  27577. static get FresnelEnabled(): boolean;
  27578. static set FresnelEnabled(value: boolean);
  27579. }
  27580. }
  27581. declare module "babylonjs/Particles/solidParticleSystem" {
  27582. import { Nullable } from "babylonjs/types";
  27583. import { Vector3 } from "babylonjs/Maths/math.vector";
  27584. import { Mesh } from "babylonjs/Meshes/mesh";
  27585. import { Scene, IDisposable } from "babylonjs/scene";
  27586. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27587. import { Material } from "babylonjs/Materials/material";
  27588. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27589. /**
  27590. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27591. *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.
  27592. * The SPS is also a particle system. It provides some methods to manage the particles.
  27593. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27594. *
  27595. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27596. */
  27597. export class SolidParticleSystem implements IDisposable {
  27598. /**
  27599. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27600. * Example : var p = SPS.particles[i];
  27601. */
  27602. particles: SolidParticle[];
  27603. /**
  27604. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27605. */
  27606. nbParticles: number;
  27607. /**
  27608. * If the particles must ever face the camera (default false). Useful for planar particles.
  27609. */
  27610. billboard: boolean;
  27611. /**
  27612. * Recompute normals when adding a shape
  27613. */
  27614. recomputeNormals: boolean;
  27615. /**
  27616. * This a counter ofr your own usage. It's not set by any SPS functions.
  27617. */
  27618. counter: number;
  27619. /**
  27620. * The SPS name. This name is also given to the underlying mesh.
  27621. */
  27622. name: string;
  27623. /**
  27624. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27625. */
  27626. mesh: Mesh;
  27627. /**
  27628. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27629. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27630. */
  27631. vars: any;
  27632. /**
  27633. * This array is populated when the SPS is set as 'pickable'.
  27634. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27635. * Each element of this array is an object `{idx: int, faceId: int}`.
  27636. * `idx` is the picked particle index in the `SPS.particles` array
  27637. * `faceId` is the picked face index counted within this particle.
  27638. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27639. */
  27640. pickedParticles: {
  27641. idx: number;
  27642. faceId: number;
  27643. }[];
  27644. /**
  27645. * This array is populated when `enableDepthSort` is set to true.
  27646. * Each element of this array is an instance of the class DepthSortedParticle.
  27647. */
  27648. depthSortedParticles: DepthSortedParticle[];
  27649. /**
  27650. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27651. * @hidden
  27652. */
  27653. _bSphereOnly: boolean;
  27654. /**
  27655. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27656. * @hidden
  27657. */
  27658. _bSphereRadiusFactor: number;
  27659. private _scene;
  27660. private _positions;
  27661. private _indices;
  27662. private _normals;
  27663. private _colors;
  27664. private _uvs;
  27665. private _indices32;
  27666. private _positions32;
  27667. private _normals32;
  27668. private _fixedNormal32;
  27669. private _colors32;
  27670. private _uvs32;
  27671. private _index;
  27672. private _updatable;
  27673. private _pickable;
  27674. private _isVisibilityBoxLocked;
  27675. private _alwaysVisible;
  27676. private _depthSort;
  27677. private _expandable;
  27678. private _shapeCounter;
  27679. private _copy;
  27680. private _color;
  27681. private _computeParticleColor;
  27682. private _computeParticleTexture;
  27683. private _computeParticleRotation;
  27684. private _computeParticleVertex;
  27685. private _computeBoundingBox;
  27686. private _depthSortParticles;
  27687. private _camera;
  27688. private _mustUnrotateFixedNormals;
  27689. private _particlesIntersect;
  27690. private _needs32Bits;
  27691. private _isNotBuilt;
  27692. private _lastParticleId;
  27693. private _idxOfId;
  27694. private _multimaterialEnabled;
  27695. private _useModelMaterial;
  27696. private _indicesByMaterial;
  27697. private _materialIndexes;
  27698. private _depthSortFunction;
  27699. private _materialSortFunction;
  27700. private _materials;
  27701. private _multimaterial;
  27702. private _materialIndexesById;
  27703. private _defaultMaterial;
  27704. private _autoUpdateSubMeshes;
  27705. /**
  27706. * Creates a SPS (Solid Particle System) object.
  27707. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27708. * @param scene (Scene) is the scene in which the SPS is added.
  27709. * @param options defines the options of the sps e.g.
  27710. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27711. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27712. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27713. * * 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.
  27714. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27715. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27716. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27717. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27718. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27719. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27720. */
  27721. constructor(name: string, scene: Scene, options?: {
  27722. updatable?: boolean;
  27723. isPickable?: boolean;
  27724. enableDepthSort?: boolean;
  27725. particleIntersection?: boolean;
  27726. boundingSphereOnly?: boolean;
  27727. bSphereRadiusFactor?: number;
  27728. expandable?: boolean;
  27729. useModelMaterial?: boolean;
  27730. enableMultiMaterial?: boolean;
  27731. });
  27732. /**
  27733. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27734. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27735. * @returns the created mesh
  27736. */
  27737. buildMesh(): Mesh;
  27738. /**
  27739. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27740. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27741. * Thus the particles generated from `digest()` have their property `position` set yet.
  27742. * @param mesh ( Mesh ) is the mesh to be digested
  27743. * @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
  27744. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27745. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27746. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27747. * @returns the current SPS
  27748. */
  27749. digest(mesh: Mesh, options?: {
  27750. facetNb?: number;
  27751. number?: number;
  27752. delta?: number;
  27753. storage?: [];
  27754. }): SolidParticleSystem;
  27755. /**
  27756. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27757. * @hidden
  27758. */
  27759. private _unrotateFixedNormals;
  27760. /**
  27761. * Resets the temporary working copy particle
  27762. * @hidden
  27763. */
  27764. private _resetCopy;
  27765. /**
  27766. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27767. * @param p the current index in the positions array to be updated
  27768. * @param ind the current index in the indices array
  27769. * @param shape a Vector3 array, the shape geometry
  27770. * @param positions the positions array to be updated
  27771. * @param meshInd the shape indices array
  27772. * @param indices the indices array to be updated
  27773. * @param meshUV the shape uv array
  27774. * @param uvs the uv array to be updated
  27775. * @param meshCol the shape color array
  27776. * @param colors the color array to be updated
  27777. * @param meshNor the shape normals array
  27778. * @param normals the normals array to be updated
  27779. * @param idx the particle index
  27780. * @param idxInShape the particle index in its shape
  27781. * @param options the addShape() method passed options
  27782. * @model the particle model
  27783. * @hidden
  27784. */
  27785. private _meshBuilder;
  27786. /**
  27787. * Returns a shape Vector3 array from positions float array
  27788. * @param positions float array
  27789. * @returns a vector3 array
  27790. * @hidden
  27791. */
  27792. private _posToShape;
  27793. /**
  27794. * Returns a shapeUV array from a float uvs (array deep copy)
  27795. * @param uvs as a float array
  27796. * @returns a shapeUV array
  27797. * @hidden
  27798. */
  27799. private _uvsToShapeUV;
  27800. /**
  27801. * Adds a new particle object in the particles array
  27802. * @param idx particle index in particles array
  27803. * @param id particle id
  27804. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27805. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27806. * @param model particle ModelShape object
  27807. * @param shapeId model shape identifier
  27808. * @param idxInShape index of the particle in the current model
  27809. * @param bInfo model bounding info object
  27810. * @param storage target storage array, if any
  27811. * @hidden
  27812. */
  27813. private _addParticle;
  27814. /**
  27815. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27816. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27817. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27818. * @param nb (positive integer) the number of particles to be created from this model
  27819. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27820. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27821. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27822. * @returns the number of shapes in the system
  27823. */
  27824. addShape(mesh: Mesh, nb: number, options?: {
  27825. positionFunction?: any;
  27826. vertexFunction?: any;
  27827. storage?: [];
  27828. }): number;
  27829. /**
  27830. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27831. * @hidden
  27832. */
  27833. private _rebuildParticle;
  27834. /**
  27835. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27836. * @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.
  27837. * @returns the SPS.
  27838. */
  27839. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27840. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27841. * Returns an array with the removed particles.
  27842. * 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.
  27843. * The SPS can't be empty so at least one particle needs to remain in place.
  27844. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27845. * @param start index of the first particle to remove
  27846. * @param end index of the last particle to remove (included)
  27847. * @returns an array populated with the removed particles
  27848. */
  27849. removeParticles(start: number, end: number): SolidParticle[];
  27850. /**
  27851. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27852. * @param solidParticleArray an array populated with Solid Particles objects
  27853. * @returns the SPS
  27854. */
  27855. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27856. /**
  27857. * Creates a new particle and modifies the SPS mesh geometry :
  27858. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27859. * - calls _addParticle() to populate the particle array
  27860. * factorized code from addShape() and insertParticlesFromArray()
  27861. * @param idx particle index in the particles array
  27862. * @param i particle index in its shape
  27863. * @param modelShape particle ModelShape object
  27864. * @param shape shape vertex array
  27865. * @param meshInd shape indices array
  27866. * @param meshUV shape uv array
  27867. * @param meshCol shape color array
  27868. * @param meshNor shape normals array
  27869. * @param bbInfo shape bounding info
  27870. * @param storage target particle storage
  27871. * @options addShape() passed options
  27872. * @hidden
  27873. */
  27874. private _insertNewParticle;
  27875. /**
  27876. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27877. * This method calls `updateParticle()` for each particle of the SPS.
  27878. * For an animated SPS, it is usually called within the render loop.
  27879. * 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.
  27880. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27881. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27882. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27883. * @returns the SPS.
  27884. */
  27885. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27886. /**
  27887. * Disposes the SPS.
  27888. */
  27889. dispose(): void;
  27890. /**
  27891. * Returns a SolidParticle object from its identifier : particle.id
  27892. * @param id (integer) the particle Id
  27893. * @returns the searched particle or null if not found in the SPS.
  27894. */
  27895. getParticleById(id: number): Nullable<SolidParticle>;
  27896. /**
  27897. * Returns a new array populated with the particles having the passed shapeId.
  27898. * @param shapeId (integer) the shape identifier
  27899. * @returns a new solid particle array
  27900. */
  27901. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27902. /**
  27903. * Populates the passed array "ref" with the particles having the passed shapeId.
  27904. * @param shapeId the shape identifier
  27905. * @returns the SPS
  27906. * @param ref
  27907. */
  27908. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27909. /**
  27910. * Computes the required SubMeshes according the materials assigned to the particles.
  27911. * @returns the solid particle system.
  27912. * Does nothing if called before the SPS mesh is built.
  27913. */
  27914. computeSubMeshes(): SolidParticleSystem;
  27915. /**
  27916. * Sorts the solid particles by material when MultiMaterial is enabled.
  27917. * Updates the indices32 array.
  27918. * Updates the indicesByMaterial array.
  27919. * Updates the mesh indices array.
  27920. * @returns the SPS
  27921. * @hidden
  27922. */
  27923. private _sortParticlesByMaterial;
  27924. /**
  27925. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27926. * @hidden
  27927. */
  27928. private _setMaterialIndexesById;
  27929. /**
  27930. * Returns an array with unique values of Materials from the passed array
  27931. * @param array the material array to be checked and filtered
  27932. * @hidden
  27933. */
  27934. private _filterUniqueMaterialId;
  27935. /**
  27936. * Sets a new Standard Material as _defaultMaterial if not already set.
  27937. * @hidden
  27938. */
  27939. private _setDefaultMaterial;
  27940. /**
  27941. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27942. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27943. * @returns the SPS.
  27944. */
  27945. refreshVisibleSize(): SolidParticleSystem;
  27946. /**
  27947. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27948. * @param size the size (float) of the visibility box
  27949. * note : this doesn't lock the SPS mesh bounding box.
  27950. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27951. */
  27952. setVisibilityBox(size: number): void;
  27953. /**
  27954. * Gets whether the SPS as always visible or not
  27955. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27956. */
  27957. get isAlwaysVisible(): boolean;
  27958. /**
  27959. * Sets the SPS as always visible or not
  27960. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27961. */
  27962. set isAlwaysVisible(val: boolean);
  27963. /**
  27964. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27965. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27966. */
  27967. set isVisibilityBoxLocked(val: boolean);
  27968. /**
  27969. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27970. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27971. */
  27972. get isVisibilityBoxLocked(): boolean;
  27973. /**
  27974. * Tells to `setParticles()` to compute the particle rotations or not.
  27975. * Default value : true. The SPS is faster when it's set to false.
  27976. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27977. */
  27978. set computeParticleRotation(val: boolean);
  27979. /**
  27980. * Tells to `setParticles()` to compute the particle colors or not.
  27981. * Default value : true. The SPS is faster when it's set to false.
  27982. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27983. */
  27984. set computeParticleColor(val: boolean);
  27985. set computeParticleTexture(val: boolean);
  27986. /**
  27987. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27988. * Default value : false. The SPS is faster when it's set to false.
  27989. * Note : the particle custom vertex positions aren't stored values.
  27990. */
  27991. set computeParticleVertex(val: boolean);
  27992. /**
  27993. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27994. */
  27995. set computeBoundingBox(val: boolean);
  27996. /**
  27997. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27998. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27999. * Default : `true`
  28000. */
  28001. set depthSortParticles(val: boolean);
  28002. /**
  28003. * Gets if `setParticles()` computes the particle rotations or not.
  28004. * Default value : true. The SPS is faster when it's set to false.
  28005. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28006. */
  28007. get computeParticleRotation(): boolean;
  28008. /**
  28009. * Gets if `setParticles()` computes the particle colors or not.
  28010. * Default value : true. The SPS is faster when it's set to false.
  28011. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28012. */
  28013. get computeParticleColor(): boolean;
  28014. /**
  28015. * Gets if `setParticles()` computes the particle textures or not.
  28016. * Default value : true. The SPS is faster when it's set to false.
  28017. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28018. */
  28019. get computeParticleTexture(): boolean;
  28020. /**
  28021. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28022. * Default value : false. The SPS is faster when it's set to false.
  28023. * Note : the particle custom vertex positions aren't stored values.
  28024. */
  28025. get computeParticleVertex(): boolean;
  28026. /**
  28027. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28028. */
  28029. get computeBoundingBox(): boolean;
  28030. /**
  28031. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28032. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28033. * Default : `true`
  28034. */
  28035. get depthSortParticles(): boolean;
  28036. /**
  28037. * Gets if the SPS is created as expandable at construction time.
  28038. * Default : `false`
  28039. */
  28040. get expandable(): boolean;
  28041. /**
  28042. * Gets if the SPS supports the Multi Materials
  28043. */
  28044. get multimaterialEnabled(): boolean;
  28045. /**
  28046. * Gets if the SPS uses the model materials for its own multimaterial.
  28047. */
  28048. get useModelMaterial(): boolean;
  28049. /**
  28050. * The SPS used material array.
  28051. */
  28052. get materials(): Material[];
  28053. /**
  28054. * Sets the SPS MultiMaterial from the passed materials.
  28055. * Note : the passed array is internally copied and not used then by reference.
  28056. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28057. */
  28058. setMultiMaterial(materials: Material[]): void;
  28059. /**
  28060. * The SPS computed multimaterial object
  28061. */
  28062. get multimaterial(): MultiMaterial;
  28063. set multimaterial(mm: MultiMaterial);
  28064. /**
  28065. * If the subMeshes must be updated on the next call to setParticles()
  28066. */
  28067. get autoUpdateSubMeshes(): boolean;
  28068. set autoUpdateSubMeshes(val: boolean);
  28069. /**
  28070. * This function does nothing. It may be overwritten to set all the particle first values.
  28071. * The SPS doesn't call this function, you may have to call it by your own.
  28072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28073. */
  28074. initParticles(): void;
  28075. /**
  28076. * This function does nothing. It may be overwritten to recycle a particle.
  28077. * The SPS doesn't call this function, you may have to call it by your own.
  28078. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28079. * @param particle The particle to recycle
  28080. * @returns the recycled particle
  28081. */
  28082. recycleParticle(particle: SolidParticle): SolidParticle;
  28083. /**
  28084. * Updates a particle : this function should be overwritten by the user.
  28085. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28086. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28087. * @example : just set a particle position or velocity and recycle conditions
  28088. * @param particle The particle to update
  28089. * @returns the updated particle
  28090. */
  28091. updateParticle(particle: SolidParticle): SolidParticle;
  28092. /**
  28093. * Updates a vertex of a particle : it can be overwritten by the user.
  28094. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28095. * @param particle the current particle
  28096. * @param vertex the current index of the current particle
  28097. * @param pt the index of the current vertex in the particle shape
  28098. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28099. * @example : just set a vertex particle position
  28100. * @returns the updated vertex
  28101. */
  28102. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28103. /**
  28104. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28105. * This does nothing and may be overwritten by the user.
  28106. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28107. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28108. * @param update the boolean update value actually passed to setParticles()
  28109. */
  28110. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28111. /**
  28112. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28113. * This will be passed three parameters.
  28114. * This does nothing and may be overwritten by the user.
  28115. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28116. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28117. * @param update the boolean update value actually passed to setParticles()
  28118. */
  28119. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28120. }
  28121. }
  28122. declare module "babylonjs/Particles/solidParticle" {
  28123. import { Nullable } from "babylonjs/types";
  28124. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28125. import { Color4 } from "babylonjs/Maths/math.color";
  28126. import { Mesh } from "babylonjs/Meshes/mesh";
  28127. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28128. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28129. import { Plane } from "babylonjs/Maths/math.plane";
  28130. import { Material } from "babylonjs/Materials/material";
  28131. /**
  28132. * Represents one particle of a solid particle system.
  28133. */
  28134. export class SolidParticle {
  28135. /**
  28136. * particle global index
  28137. */
  28138. idx: number;
  28139. /**
  28140. * particle identifier
  28141. */
  28142. id: number;
  28143. /**
  28144. * The color of the particle
  28145. */
  28146. color: Nullable<Color4>;
  28147. /**
  28148. * The world space position of the particle.
  28149. */
  28150. position: Vector3;
  28151. /**
  28152. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28153. */
  28154. rotation: Vector3;
  28155. /**
  28156. * The world space rotation quaternion of the particle.
  28157. */
  28158. rotationQuaternion: Nullable<Quaternion>;
  28159. /**
  28160. * The scaling of the particle.
  28161. */
  28162. scaling: Vector3;
  28163. /**
  28164. * The uvs of the particle.
  28165. */
  28166. uvs: Vector4;
  28167. /**
  28168. * The current speed of the particle.
  28169. */
  28170. velocity: Vector3;
  28171. /**
  28172. * The pivot point in the particle local space.
  28173. */
  28174. pivot: Vector3;
  28175. /**
  28176. * Must the particle be translated from its pivot point in its local space ?
  28177. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28178. * Default : false
  28179. */
  28180. translateFromPivot: boolean;
  28181. /**
  28182. * Is the particle active or not ?
  28183. */
  28184. alive: boolean;
  28185. /**
  28186. * Is the particle visible or not ?
  28187. */
  28188. isVisible: boolean;
  28189. /**
  28190. * Index of this particle in the global "positions" array (Internal use)
  28191. * @hidden
  28192. */
  28193. _pos: number;
  28194. /**
  28195. * @hidden Index of this particle in the global "indices" array (Internal use)
  28196. */
  28197. _ind: number;
  28198. /**
  28199. * @hidden ModelShape of this particle (Internal use)
  28200. */
  28201. _model: ModelShape;
  28202. /**
  28203. * ModelShape id of this particle
  28204. */
  28205. shapeId: number;
  28206. /**
  28207. * Index of the particle in its shape id
  28208. */
  28209. idxInShape: number;
  28210. /**
  28211. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28212. */
  28213. _modelBoundingInfo: BoundingInfo;
  28214. /**
  28215. * @hidden Particle BoundingInfo object (Internal use)
  28216. */
  28217. _boundingInfo: BoundingInfo;
  28218. /**
  28219. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28220. */
  28221. _sps: SolidParticleSystem;
  28222. /**
  28223. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28224. */
  28225. _stillInvisible: boolean;
  28226. /**
  28227. * @hidden Last computed particle rotation matrix
  28228. */
  28229. _rotationMatrix: number[];
  28230. /**
  28231. * Parent particle Id, if any.
  28232. * Default null.
  28233. */
  28234. parentId: Nullable<number>;
  28235. /**
  28236. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28237. */
  28238. materialIndex: Nullable<number>;
  28239. /**
  28240. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28241. * The possible values are :
  28242. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28243. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28244. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28245. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28246. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28247. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28248. * */
  28249. cullingStrategy: number;
  28250. /**
  28251. * @hidden Internal global position in the SPS.
  28252. */
  28253. _globalPosition: Vector3;
  28254. /**
  28255. * Creates a Solid Particle object.
  28256. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28257. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28258. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28259. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28260. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28261. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28262. * @param shapeId (integer) is the model shape identifier in the SPS.
  28263. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28264. * @param sps defines the sps it is associated to
  28265. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28266. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28267. */
  28268. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28269. /**
  28270. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28271. * @param target the particle target
  28272. * @returns the current particle
  28273. */
  28274. copyToRef(target: SolidParticle): SolidParticle;
  28275. /**
  28276. * Legacy support, changed scale to scaling
  28277. */
  28278. get scale(): Vector3;
  28279. /**
  28280. * Legacy support, changed scale to scaling
  28281. */
  28282. set scale(scale: Vector3);
  28283. /**
  28284. * Legacy support, changed quaternion to rotationQuaternion
  28285. */
  28286. get quaternion(): Nullable<Quaternion>;
  28287. /**
  28288. * Legacy support, changed quaternion to rotationQuaternion
  28289. */
  28290. set quaternion(q: Nullable<Quaternion>);
  28291. /**
  28292. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28293. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28294. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28295. * @returns true if it intersects
  28296. */
  28297. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28298. /**
  28299. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28300. * A particle is in the frustum if its bounding box intersects the frustum
  28301. * @param frustumPlanes defines the frustum to test
  28302. * @returns true if the particle is in the frustum planes
  28303. */
  28304. isInFrustum(frustumPlanes: Plane[]): boolean;
  28305. /**
  28306. * get the rotation matrix of the particle
  28307. * @hidden
  28308. */
  28309. getRotationMatrix(m: Matrix): void;
  28310. }
  28311. /**
  28312. * Represents the shape of the model used by one particle of a solid particle system.
  28313. * SPS internal tool, don't use it manually.
  28314. */
  28315. export class ModelShape {
  28316. /**
  28317. * The shape id
  28318. * @hidden
  28319. */
  28320. shapeID: number;
  28321. /**
  28322. * flat array of model positions (internal use)
  28323. * @hidden
  28324. */
  28325. _shape: Vector3[];
  28326. /**
  28327. * flat array of model UVs (internal use)
  28328. * @hidden
  28329. */
  28330. _shapeUV: number[];
  28331. /**
  28332. * color array of the model
  28333. * @hidden
  28334. */
  28335. _shapeColors: number[];
  28336. /**
  28337. * indices array of the model
  28338. * @hidden
  28339. */
  28340. _indices: number[];
  28341. /**
  28342. * normals array of the model
  28343. * @hidden
  28344. */
  28345. _normals: number[];
  28346. /**
  28347. * length of the shape in the model indices array (internal use)
  28348. * @hidden
  28349. */
  28350. _indicesLength: number;
  28351. /**
  28352. * Custom position function (internal use)
  28353. * @hidden
  28354. */
  28355. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28356. /**
  28357. * Custom vertex function (internal use)
  28358. * @hidden
  28359. */
  28360. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28361. /**
  28362. * Model material (internal use)
  28363. * @hidden
  28364. */
  28365. _material: Nullable<Material>;
  28366. /**
  28367. * 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.
  28368. * SPS internal tool, don't use it manually.
  28369. * @hidden
  28370. */
  28371. 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>);
  28372. }
  28373. /**
  28374. * Represents a Depth Sorted Particle in the solid particle system.
  28375. * @hidden
  28376. */
  28377. export class DepthSortedParticle {
  28378. /**
  28379. * Index of the particle in the "indices" array
  28380. */
  28381. ind: number;
  28382. /**
  28383. * Length of the particle shape in the "indices" array
  28384. */
  28385. indicesLength: number;
  28386. /**
  28387. * Squared distance from the particle to the camera
  28388. */
  28389. sqDistance: number;
  28390. /**
  28391. * Material index when used with MultiMaterials
  28392. */
  28393. materialIndex: number;
  28394. /**
  28395. * Creates a new sorted particle
  28396. * @param materialIndex
  28397. */
  28398. constructor(ind: number, indLength: number, materialIndex: number);
  28399. }
  28400. }
  28401. declare module "babylonjs/Collisions/meshCollisionData" {
  28402. import { Collider } from "babylonjs/Collisions/collider";
  28403. import { Vector3 } from "babylonjs/Maths/math.vector";
  28404. import { Nullable } from "babylonjs/types";
  28405. import { Observer } from "babylonjs/Misc/observable";
  28406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28407. /**
  28408. * @hidden
  28409. */
  28410. export class _MeshCollisionData {
  28411. _checkCollisions: boolean;
  28412. _collisionMask: number;
  28413. _collisionGroup: number;
  28414. _collider: Nullable<Collider>;
  28415. _oldPositionForCollisions: Vector3;
  28416. _diffPositionForCollisions: Vector3;
  28417. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28418. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28419. }
  28420. }
  28421. declare module "babylonjs/Meshes/abstractMesh" {
  28422. import { Observable } from "babylonjs/Misc/observable";
  28423. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28424. import { Camera } from "babylonjs/Cameras/camera";
  28425. import { Scene, IDisposable } from "babylonjs/scene";
  28426. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28427. import { Node } from "babylonjs/node";
  28428. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28429. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28430. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28431. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28432. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28433. import { Material } from "babylonjs/Materials/material";
  28434. import { Light } from "babylonjs/Lights/light";
  28435. import { Skeleton } from "babylonjs/Bones/skeleton";
  28436. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28437. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28438. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28439. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28440. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28441. import { Plane } from "babylonjs/Maths/math.plane";
  28442. import { Ray } from "babylonjs/Culling/ray";
  28443. import { Collider } from "babylonjs/Collisions/collider";
  28444. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28445. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28446. /** @hidden */
  28447. class _FacetDataStorage {
  28448. facetPositions: Vector3[];
  28449. facetNormals: Vector3[];
  28450. facetPartitioning: number[][];
  28451. facetNb: number;
  28452. partitioningSubdivisions: number;
  28453. partitioningBBoxRatio: number;
  28454. facetDataEnabled: boolean;
  28455. facetParameters: any;
  28456. bbSize: Vector3;
  28457. subDiv: {
  28458. max: number;
  28459. X: number;
  28460. Y: number;
  28461. Z: number;
  28462. };
  28463. facetDepthSort: boolean;
  28464. facetDepthSortEnabled: boolean;
  28465. depthSortedIndices: IndicesArray;
  28466. depthSortedFacets: {
  28467. ind: number;
  28468. sqDistance: number;
  28469. }[];
  28470. facetDepthSortFunction: (f1: {
  28471. ind: number;
  28472. sqDistance: number;
  28473. }, f2: {
  28474. ind: number;
  28475. sqDistance: number;
  28476. }) => number;
  28477. facetDepthSortFrom: Vector3;
  28478. facetDepthSortOrigin: Vector3;
  28479. invertedMatrix: Matrix;
  28480. }
  28481. /**
  28482. * @hidden
  28483. **/
  28484. class _InternalAbstractMeshDataInfo {
  28485. _hasVertexAlpha: boolean;
  28486. _useVertexColors: boolean;
  28487. _numBoneInfluencers: number;
  28488. _applyFog: boolean;
  28489. _receiveShadows: boolean;
  28490. _facetData: _FacetDataStorage;
  28491. _visibility: number;
  28492. _skeleton: Nullable<Skeleton>;
  28493. _layerMask: number;
  28494. _computeBonesUsingShaders: boolean;
  28495. _isActive: boolean;
  28496. _onlyForInstances: boolean;
  28497. _isActiveIntermediate: boolean;
  28498. _onlyForInstancesIntermediate: boolean;
  28499. _actAsRegularMesh: boolean;
  28500. }
  28501. /**
  28502. * Class used to store all common mesh properties
  28503. */
  28504. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28505. /** No occlusion */
  28506. static OCCLUSION_TYPE_NONE: number;
  28507. /** Occlusion set to optimisitic */
  28508. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28509. /** Occlusion set to strict */
  28510. static OCCLUSION_TYPE_STRICT: number;
  28511. /** Use an accurante occlusion algorithm */
  28512. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28513. /** Use a conservative occlusion algorithm */
  28514. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28515. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28516. * Test order :
  28517. * Is the bounding sphere outside the frustum ?
  28518. * If not, are the bounding box vertices outside the frustum ?
  28519. * It not, then the cullable object is in the frustum.
  28520. */
  28521. static readonly CULLINGSTRATEGY_STANDARD: number;
  28522. /** Culling strategy : Bounding Sphere Only.
  28523. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28524. * It's also less accurate than the standard because some not visible objects can still be selected.
  28525. * Test : is the bounding sphere outside the frustum ?
  28526. * If not, then the cullable object is in the frustum.
  28527. */
  28528. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28529. /** Culling strategy : Optimistic Inclusion.
  28530. * This in an inclusion test first, then the standard exclusion test.
  28531. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28532. * 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.
  28533. * Anyway, it's as accurate as the standard strategy.
  28534. * Test :
  28535. * Is the cullable object bounding sphere center in the frustum ?
  28536. * If not, apply the default culling strategy.
  28537. */
  28538. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28539. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28540. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28541. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28542. * 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.
  28543. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28544. * Test :
  28545. * Is the cullable object bounding sphere center in the frustum ?
  28546. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28547. */
  28548. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28549. /**
  28550. * No billboard
  28551. */
  28552. static get BILLBOARDMODE_NONE(): number;
  28553. /** Billboard on X axis */
  28554. static get BILLBOARDMODE_X(): number;
  28555. /** Billboard on Y axis */
  28556. static get BILLBOARDMODE_Y(): number;
  28557. /** Billboard on Z axis */
  28558. static get BILLBOARDMODE_Z(): number;
  28559. /** Billboard on all axes */
  28560. static get BILLBOARDMODE_ALL(): number;
  28561. /** Billboard on using position instead of orientation */
  28562. static get BILLBOARDMODE_USE_POSITION(): number;
  28563. /** @hidden */
  28564. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28565. /**
  28566. * The culling strategy to use to check whether the mesh must be rendered or not.
  28567. * This value can be changed at any time and will be used on the next render mesh selection.
  28568. * The possible values are :
  28569. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28570. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28571. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28572. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28573. * Please read each static variable documentation to get details about the culling process.
  28574. * */
  28575. cullingStrategy: number;
  28576. /**
  28577. * Gets the number of facets in the mesh
  28578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28579. */
  28580. get facetNb(): number;
  28581. /**
  28582. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28583. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28584. */
  28585. get partitioningSubdivisions(): number;
  28586. set partitioningSubdivisions(nb: number);
  28587. /**
  28588. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28589. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28591. */
  28592. get partitioningBBoxRatio(): number;
  28593. set partitioningBBoxRatio(ratio: number);
  28594. /**
  28595. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28596. * Works only for updatable meshes.
  28597. * Doesn't work with multi-materials
  28598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28599. */
  28600. get mustDepthSortFacets(): boolean;
  28601. set mustDepthSortFacets(sort: boolean);
  28602. /**
  28603. * The location (Vector3) where the facet depth sort must be computed from.
  28604. * By default, the active camera position.
  28605. * Used only when facet depth sort is enabled
  28606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28607. */
  28608. get facetDepthSortFrom(): Vector3;
  28609. set facetDepthSortFrom(location: Vector3);
  28610. /**
  28611. * gets a boolean indicating if facetData is enabled
  28612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28613. */
  28614. get isFacetDataEnabled(): boolean;
  28615. /** @hidden */
  28616. _updateNonUniformScalingState(value: boolean): boolean;
  28617. /**
  28618. * An event triggered when this mesh collides with another one
  28619. */
  28620. onCollideObservable: Observable<AbstractMesh>;
  28621. /** Set a function to call when this mesh collides with another one */
  28622. set onCollide(callback: () => void);
  28623. /**
  28624. * An event triggered when the collision's position changes
  28625. */
  28626. onCollisionPositionChangeObservable: Observable<Vector3>;
  28627. /** Set a function to call when the collision's position changes */
  28628. set onCollisionPositionChange(callback: () => void);
  28629. /**
  28630. * An event triggered when material is changed
  28631. */
  28632. onMaterialChangedObservable: Observable<AbstractMesh>;
  28633. /**
  28634. * Gets or sets the orientation for POV movement & rotation
  28635. */
  28636. definedFacingForward: boolean;
  28637. /** @hidden */
  28638. _occlusionQuery: Nullable<WebGLQuery>;
  28639. /** @hidden */
  28640. _renderingGroup: Nullable<RenderingGroup>;
  28641. /**
  28642. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28643. */
  28644. get visibility(): number;
  28645. /**
  28646. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28647. */
  28648. set visibility(value: number);
  28649. /** Gets or sets the alpha index used to sort transparent meshes
  28650. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28651. */
  28652. alphaIndex: number;
  28653. /**
  28654. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28655. */
  28656. isVisible: boolean;
  28657. /**
  28658. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28659. */
  28660. isPickable: boolean;
  28661. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28662. showSubMeshesBoundingBox: boolean;
  28663. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28664. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28665. */
  28666. isBlocker: boolean;
  28667. /**
  28668. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28669. */
  28670. enablePointerMoveEvents: boolean;
  28671. /**
  28672. * Specifies the rendering group id for this mesh (0 by default)
  28673. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28674. */
  28675. renderingGroupId: number;
  28676. private _material;
  28677. /** Gets or sets current material */
  28678. get material(): Nullable<Material>;
  28679. set material(value: Nullable<Material>);
  28680. /**
  28681. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28682. * @see http://doc.babylonjs.com/babylon101/shadows
  28683. */
  28684. get receiveShadows(): boolean;
  28685. set receiveShadows(value: boolean);
  28686. /** Defines color to use when rendering outline */
  28687. outlineColor: Color3;
  28688. /** Define width to use when rendering outline */
  28689. outlineWidth: number;
  28690. /** Defines color to use when rendering overlay */
  28691. overlayColor: Color3;
  28692. /** Defines alpha to use when rendering overlay */
  28693. overlayAlpha: number;
  28694. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28695. get hasVertexAlpha(): boolean;
  28696. set hasVertexAlpha(value: boolean);
  28697. /** 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) */
  28698. get useVertexColors(): boolean;
  28699. set useVertexColors(value: boolean);
  28700. /**
  28701. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28702. */
  28703. get computeBonesUsingShaders(): boolean;
  28704. set computeBonesUsingShaders(value: boolean);
  28705. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28706. get numBoneInfluencers(): number;
  28707. set numBoneInfluencers(value: number);
  28708. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28709. get applyFog(): boolean;
  28710. set applyFog(value: boolean);
  28711. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28712. useOctreeForRenderingSelection: boolean;
  28713. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28714. useOctreeForPicking: boolean;
  28715. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28716. useOctreeForCollisions: boolean;
  28717. /**
  28718. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28719. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28720. */
  28721. get layerMask(): number;
  28722. set layerMask(value: number);
  28723. /**
  28724. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28725. */
  28726. alwaysSelectAsActiveMesh: boolean;
  28727. /**
  28728. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28729. */
  28730. doNotSyncBoundingInfo: boolean;
  28731. /**
  28732. * Gets or sets the current action manager
  28733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28734. */
  28735. actionManager: Nullable<AbstractActionManager>;
  28736. private _meshCollisionData;
  28737. /**
  28738. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28739. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28740. */
  28741. ellipsoid: Vector3;
  28742. /**
  28743. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28745. */
  28746. ellipsoidOffset: Vector3;
  28747. /**
  28748. * Gets or sets a collision mask used to mask collisions (default is -1).
  28749. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28750. */
  28751. get collisionMask(): number;
  28752. set collisionMask(mask: number);
  28753. /**
  28754. * Gets or sets the current collision group mask (-1 by default).
  28755. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28756. */
  28757. get collisionGroup(): number;
  28758. set collisionGroup(mask: number);
  28759. /**
  28760. * Defines edge width used when edgesRenderer is enabled
  28761. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28762. */
  28763. edgesWidth: number;
  28764. /**
  28765. * Defines edge color used when edgesRenderer is enabled
  28766. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28767. */
  28768. edgesColor: Color4;
  28769. /** @hidden */
  28770. _edgesRenderer: Nullable<IEdgesRenderer>;
  28771. /** @hidden */
  28772. _masterMesh: Nullable<AbstractMesh>;
  28773. /** @hidden */
  28774. _boundingInfo: Nullable<BoundingInfo>;
  28775. /** @hidden */
  28776. _renderId: number;
  28777. /**
  28778. * Gets or sets the list of subMeshes
  28779. * @see http://doc.babylonjs.com/how_to/multi_materials
  28780. */
  28781. subMeshes: SubMesh[];
  28782. /** @hidden */
  28783. _intersectionsInProgress: AbstractMesh[];
  28784. /** @hidden */
  28785. _unIndexed: boolean;
  28786. /** @hidden */
  28787. _lightSources: Light[];
  28788. /** Gets the list of lights affecting that mesh */
  28789. get lightSources(): Light[];
  28790. /** @hidden */
  28791. get _positions(): Nullable<Vector3[]>;
  28792. /** @hidden */
  28793. _waitingData: {
  28794. lods: Nullable<any>;
  28795. actions: Nullable<any>;
  28796. freezeWorldMatrix: Nullable<boolean>;
  28797. };
  28798. /** @hidden */
  28799. _bonesTransformMatrices: Nullable<Float32Array>;
  28800. /** @hidden */
  28801. _transformMatrixTexture: Nullable<RawTexture>;
  28802. /**
  28803. * Gets or sets a skeleton to apply skining transformations
  28804. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28805. */
  28806. set skeleton(value: Nullable<Skeleton>);
  28807. get skeleton(): Nullable<Skeleton>;
  28808. /**
  28809. * An event triggered when the mesh is rebuilt.
  28810. */
  28811. onRebuildObservable: Observable<AbstractMesh>;
  28812. /**
  28813. * Creates a new AbstractMesh
  28814. * @param name defines the name of the mesh
  28815. * @param scene defines the hosting scene
  28816. */
  28817. constructor(name: string, scene?: Nullable<Scene>);
  28818. /**
  28819. * Returns the string "AbstractMesh"
  28820. * @returns "AbstractMesh"
  28821. */
  28822. getClassName(): string;
  28823. /**
  28824. * Gets a string representation of the current mesh
  28825. * @param fullDetails defines a boolean indicating if full details must be included
  28826. * @returns a string representation of the current mesh
  28827. */
  28828. toString(fullDetails?: boolean): string;
  28829. /**
  28830. * @hidden
  28831. */
  28832. protected _getEffectiveParent(): Nullable<Node>;
  28833. /** @hidden */
  28834. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28835. /** @hidden */
  28836. _rebuild(): void;
  28837. /** @hidden */
  28838. _resyncLightSources(): void;
  28839. /** @hidden */
  28840. _resyncLightSource(light: Light): void;
  28841. /** @hidden */
  28842. _unBindEffect(): void;
  28843. /** @hidden */
  28844. _removeLightSource(light: Light, dispose: boolean): void;
  28845. private _markSubMeshesAsDirty;
  28846. /** @hidden */
  28847. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28848. /** @hidden */
  28849. _markSubMeshesAsAttributesDirty(): void;
  28850. /** @hidden */
  28851. _markSubMeshesAsMiscDirty(): void;
  28852. /**
  28853. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28854. */
  28855. get scaling(): Vector3;
  28856. set scaling(newScaling: Vector3);
  28857. /**
  28858. * Returns true if the mesh is blocked. Implemented by child classes
  28859. */
  28860. get isBlocked(): boolean;
  28861. /**
  28862. * Returns the mesh itself by default. Implemented by child classes
  28863. * @param camera defines the camera to use to pick the right LOD level
  28864. * @returns the currentAbstractMesh
  28865. */
  28866. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28867. /**
  28868. * Returns 0 by default. Implemented by child classes
  28869. * @returns an integer
  28870. */
  28871. getTotalVertices(): number;
  28872. /**
  28873. * Returns a positive integer : the total number of indices in this mesh geometry.
  28874. * @returns the numner of indices or zero if the mesh has no geometry.
  28875. */
  28876. getTotalIndices(): number;
  28877. /**
  28878. * Returns null by default. Implemented by child classes
  28879. * @returns null
  28880. */
  28881. getIndices(): Nullable<IndicesArray>;
  28882. /**
  28883. * Returns the array of the requested vertex data kind. Implemented by child classes
  28884. * @param kind defines the vertex data kind to use
  28885. * @returns null
  28886. */
  28887. getVerticesData(kind: string): Nullable<FloatArray>;
  28888. /**
  28889. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28890. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28891. * Note that a new underlying VertexBuffer object is created each call.
  28892. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28893. * @param kind defines vertex data kind:
  28894. * * VertexBuffer.PositionKind
  28895. * * VertexBuffer.UVKind
  28896. * * VertexBuffer.UV2Kind
  28897. * * VertexBuffer.UV3Kind
  28898. * * VertexBuffer.UV4Kind
  28899. * * VertexBuffer.UV5Kind
  28900. * * VertexBuffer.UV6Kind
  28901. * * VertexBuffer.ColorKind
  28902. * * VertexBuffer.MatricesIndicesKind
  28903. * * VertexBuffer.MatricesIndicesExtraKind
  28904. * * VertexBuffer.MatricesWeightsKind
  28905. * * VertexBuffer.MatricesWeightsExtraKind
  28906. * @param data defines the data source
  28907. * @param updatable defines if the data must be flagged as updatable (or static)
  28908. * @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
  28909. * @returns the current mesh
  28910. */
  28911. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28912. /**
  28913. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28914. * If the mesh has no geometry, it is simply returned as it is.
  28915. * @param kind defines vertex data kind:
  28916. * * VertexBuffer.PositionKind
  28917. * * VertexBuffer.UVKind
  28918. * * VertexBuffer.UV2Kind
  28919. * * VertexBuffer.UV3Kind
  28920. * * VertexBuffer.UV4Kind
  28921. * * VertexBuffer.UV5Kind
  28922. * * VertexBuffer.UV6Kind
  28923. * * VertexBuffer.ColorKind
  28924. * * VertexBuffer.MatricesIndicesKind
  28925. * * VertexBuffer.MatricesIndicesExtraKind
  28926. * * VertexBuffer.MatricesWeightsKind
  28927. * * VertexBuffer.MatricesWeightsExtraKind
  28928. * @param data defines the data source
  28929. * @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
  28930. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28931. * @returns the current mesh
  28932. */
  28933. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28934. /**
  28935. * Sets the mesh indices,
  28936. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28937. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28938. * @param totalVertices Defines the total number of vertices
  28939. * @returns the current mesh
  28940. */
  28941. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28942. /**
  28943. * Gets a boolean indicating if specific vertex data is present
  28944. * @param kind defines the vertex data kind to use
  28945. * @returns true is data kind is present
  28946. */
  28947. isVerticesDataPresent(kind: string): boolean;
  28948. /**
  28949. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28950. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28951. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28952. * @returns a BoundingInfo
  28953. */
  28954. getBoundingInfo(): BoundingInfo;
  28955. /**
  28956. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28957. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28958. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28959. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28960. * @returns the current mesh
  28961. */
  28962. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28963. /**
  28964. * Overwrite the current bounding info
  28965. * @param boundingInfo defines the new bounding info
  28966. * @returns the current mesh
  28967. */
  28968. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28969. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28970. get useBones(): boolean;
  28971. /** @hidden */
  28972. _preActivate(): void;
  28973. /** @hidden */
  28974. _preActivateForIntermediateRendering(renderId: number): void;
  28975. /** @hidden */
  28976. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28977. /** @hidden */
  28978. _postActivate(): void;
  28979. /** @hidden */
  28980. _freeze(): void;
  28981. /** @hidden */
  28982. _unFreeze(): void;
  28983. /**
  28984. * Gets the current world matrix
  28985. * @returns a Matrix
  28986. */
  28987. getWorldMatrix(): Matrix;
  28988. /** @hidden */
  28989. _getWorldMatrixDeterminant(): number;
  28990. /**
  28991. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28992. */
  28993. get isAnInstance(): boolean;
  28994. /**
  28995. * Gets a boolean indicating if this mesh has instances
  28996. */
  28997. get hasInstances(): boolean;
  28998. /**
  28999. * Perform relative position change from the point of view of behind the front of the mesh.
  29000. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29001. * Supports definition of mesh facing forward or backward
  29002. * @param amountRight defines the distance on the right axis
  29003. * @param amountUp defines the distance on the up axis
  29004. * @param amountForward defines the distance on the forward axis
  29005. * @returns the current mesh
  29006. */
  29007. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29008. /**
  29009. * Calculate relative position change from the point of view of behind the front of the mesh.
  29010. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29011. * Supports definition of mesh facing forward or backward
  29012. * @param amountRight defines the distance on the right axis
  29013. * @param amountUp defines the distance on the up axis
  29014. * @param amountForward defines the distance on the forward axis
  29015. * @returns the new displacement vector
  29016. */
  29017. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29018. /**
  29019. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29020. * Supports definition of mesh facing forward or backward
  29021. * @param flipBack defines the flip
  29022. * @param twirlClockwise defines the twirl
  29023. * @param tiltRight defines the tilt
  29024. * @returns the current mesh
  29025. */
  29026. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29027. /**
  29028. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29029. * Supports definition of mesh facing forward or backward.
  29030. * @param flipBack defines the flip
  29031. * @param twirlClockwise defines the twirl
  29032. * @param tiltRight defines the tilt
  29033. * @returns the new rotation vector
  29034. */
  29035. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29036. /**
  29037. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29038. * This means the mesh underlying bounding box and sphere are recomputed.
  29039. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29040. * @returns the current mesh
  29041. */
  29042. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29043. /** @hidden */
  29044. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29045. /** @hidden */
  29046. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29047. /** @hidden */
  29048. _updateBoundingInfo(): AbstractMesh;
  29049. /** @hidden */
  29050. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29051. /** @hidden */
  29052. protected _afterComputeWorldMatrix(): void;
  29053. /** @hidden */
  29054. get _effectiveMesh(): AbstractMesh;
  29055. /**
  29056. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29057. * A mesh is in the frustum if its bounding box intersects the frustum
  29058. * @param frustumPlanes defines the frustum to test
  29059. * @returns true if the mesh is in the frustum planes
  29060. */
  29061. isInFrustum(frustumPlanes: Plane[]): boolean;
  29062. /**
  29063. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29064. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29065. * @param frustumPlanes defines the frustum to test
  29066. * @returns true if the mesh is completely in the frustum planes
  29067. */
  29068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29069. /**
  29070. * True if the mesh intersects another mesh or a SolidParticle object
  29071. * @param mesh defines a target mesh or SolidParticle to test
  29072. * @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)
  29073. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29074. * @returns true if there is an intersection
  29075. */
  29076. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29077. /**
  29078. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29079. * @param point defines the point to test
  29080. * @returns true if there is an intersection
  29081. */
  29082. intersectsPoint(point: Vector3): boolean;
  29083. /**
  29084. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29086. */
  29087. get checkCollisions(): boolean;
  29088. set checkCollisions(collisionEnabled: boolean);
  29089. /**
  29090. * Gets Collider object used to compute collisions (not physics)
  29091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29092. */
  29093. get collider(): Nullable<Collider>;
  29094. /**
  29095. * Move the mesh using collision engine
  29096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29097. * @param displacement defines the requested displacement vector
  29098. * @returns the current mesh
  29099. */
  29100. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29101. private _onCollisionPositionChange;
  29102. /** @hidden */
  29103. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29104. /** @hidden */
  29105. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29106. /** @hidden */
  29107. _checkCollision(collider: Collider): AbstractMesh;
  29108. /** @hidden */
  29109. _generatePointsArray(): boolean;
  29110. /**
  29111. * Checks if the passed Ray intersects with the mesh
  29112. * @param ray defines the ray to use
  29113. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29114. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29115. * @returns the picking info
  29116. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29117. */
  29118. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29119. /**
  29120. * Clones the current mesh
  29121. * @param name defines the mesh name
  29122. * @param newParent defines the new mesh parent
  29123. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29124. * @returns the new mesh
  29125. */
  29126. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29127. /**
  29128. * Disposes all the submeshes of the current meshnp
  29129. * @returns the current mesh
  29130. */
  29131. releaseSubMeshes(): AbstractMesh;
  29132. /**
  29133. * Releases resources associated with this abstract mesh.
  29134. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29135. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29136. */
  29137. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29138. /**
  29139. * Adds the passed mesh as a child to the current mesh
  29140. * @param mesh defines the child mesh
  29141. * @returns the current mesh
  29142. */
  29143. addChild(mesh: AbstractMesh): AbstractMesh;
  29144. /**
  29145. * Removes the passed mesh from the current mesh children list
  29146. * @param mesh defines the child mesh
  29147. * @returns the current mesh
  29148. */
  29149. removeChild(mesh: AbstractMesh): AbstractMesh;
  29150. /** @hidden */
  29151. private _initFacetData;
  29152. /**
  29153. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29154. * This method can be called within the render loop.
  29155. * 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
  29156. * @returns the current mesh
  29157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29158. */
  29159. updateFacetData(): AbstractMesh;
  29160. /**
  29161. * Returns the facetLocalNormals array.
  29162. * The normals are expressed in the mesh local spac
  29163. * @returns an array of Vector3
  29164. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29165. */
  29166. getFacetLocalNormals(): Vector3[];
  29167. /**
  29168. * Returns the facetLocalPositions array.
  29169. * The facet positions are expressed in the mesh local space
  29170. * @returns an array of Vector3
  29171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29172. */
  29173. getFacetLocalPositions(): Vector3[];
  29174. /**
  29175. * Returns the facetLocalPartioning array
  29176. * @returns an array of array of numbers
  29177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29178. */
  29179. getFacetLocalPartitioning(): number[][];
  29180. /**
  29181. * Returns the i-th facet position in the world system.
  29182. * This method allocates a new Vector3 per call
  29183. * @param i defines the facet index
  29184. * @returns a new Vector3
  29185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29186. */
  29187. getFacetPosition(i: number): Vector3;
  29188. /**
  29189. * Sets the reference Vector3 with the i-th facet position in the world system
  29190. * @param i defines the facet index
  29191. * @param ref defines the target vector
  29192. * @returns the current mesh
  29193. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29194. */
  29195. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29196. /**
  29197. * Returns the i-th facet normal in the world system.
  29198. * This method allocates a new Vector3 per call
  29199. * @param i defines the facet index
  29200. * @returns a new Vector3
  29201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29202. */
  29203. getFacetNormal(i: number): Vector3;
  29204. /**
  29205. * Sets the reference Vector3 with the i-th facet normal in the world system
  29206. * @param i defines the facet index
  29207. * @param ref defines the target vector
  29208. * @returns the current mesh
  29209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29210. */
  29211. getFacetNormalToRef(i: number, ref: Vector3): this;
  29212. /**
  29213. * 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)
  29214. * @param x defines x coordinate
  29215. * @param y defines y coordinate
  29216. * @param z defines z coordinate
  29217. * @returns the array of facet indexes
  29218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29219. */
  29220. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29221. /**
  29222. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29223. * @param projected sets as the (x,y,z) world projection on the facet
  29224. * @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
  29225. * @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
  29226. * @param x defines x coordinate
  29227. * @param y defines y coordinate
  29228. * @param z defines z coordinate
  29229. * @returns the face index if found (or null instead)
  29230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29231. */
  29232. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29233. /**
  29234. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29235. * @param projected sets as the (x,y,z) local projection on the facet
  29236. * @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
  29237. * @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
  29238. * @param x defines x coordinate
  29239. * @param y defines y coordinate
  29240. * @param z defines z coordinate
  29241. * @returns the face index if found (or null instead)
  29242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29243. */
  29244. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29245. /**
  29246. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29247. * @returns the parameters
  29248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29249. */
  29250. getFacetDataParameters(): any;
  29251. /**
  29252. * Disables the feature FacetData and frees the related memory
  29253. * @returns the current mesh
  29254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29255. */
  29256. disableFacetData(): AbstractMesh;
  29257. /**
  29258. * Updates the AbstractMesh indices array
  29259. * @param indices defines the data source
  29260. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29261. * @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)
  29262. * @returns the current mesh
  29263. */
  29264. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29265. /**
  29266. * Creates new normals data for the mesh
  29267. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29268. * @returns the current mesh
  29269. */
  29270. createNormals(updatable: boolean): AbstractMesh;
  29271. /**
  29272. * Align the mesh with a normal
  29273. * @param normal defines the normal to use
  29274. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29275. * @returns the current mesh
  29276. */
  29277. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29278. /** @hidden */
  29279. _checkOcclusionQuery(): boolean;
  29280. /**
  29281. * Disables the mesh edge rendering mode
  29282. * @returns the currentAbstractMesh
  29283. */
  29284. disableEdgesRendering(): AbstractMesh;
  29285. /**
  29286. * Enables the edge rendering mode on the mesh.
  29287. * This mode makes the mesh edges visible
  29288. * @param epsilon defines the maximal distance between two angles to detect a face
  29289. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29290. * @returns the currentAbstractMesh
  29291. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29292. */
  29293. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29294. }
  29295. }
  29296. declare module "babylonjs/Actions/actionEvent" {
  29297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29298. import { Nullable } from "babylonjs/types";
  29299. import { Sprite } from "babylonjs/Sprites/sprite";
  29300. import { Scene } from "babylonjs/scene";
  29301. import { Vector2 } from "babylonjs/Maths/math.vector";
  29302. /**
  29303. * Interface used to define ActionEvent
  29304. */
  29305. export interface IActionEvent {
  29306. /** The mesh or sprite that triggered the action */
  29307. source: any;
  29308. /** The X mouse cursor position at the time of the event */
  29309. pointerX: number;
  29310. /** The Y mouse cursor position at the time of the event */
  29311. pointerY: number;
  29312. /** The mesh that is currently pointed at (can be null) */
  29313. meshUnderPointer: Nullable<AbstractMesh>;
  29314. /** the original (browser) event that triggered the ActionEvent */
  29315. sourceEvent?: any;
  29316. /** additional data for the event */
  29317. additionalData?: any;
  29318. }
  29319. /**
  29320. * ActionEvent is the event being sent when an action is triggered.
  29321. */
  29322. export class ActionEvent implements IActionEvent {
  29323. /** The mesh or sprite that triggered the action */
  29324. source: any;
  29325. /** The X mouse cursor position at the time of the event */
  29326. pointerX: number;
  29327. /** The Y mouse cursor position at the time of the event */
  29328. pointerY: number;
  29329. /** The mesh that is currently pointed at (can be null) */
  29330. meshUnderPointer: Nullable<AbstractMesh>;
  29331. /** the original (browser) event that triggered the ActionEvent */
  29332. sourceEvent?: any;
  29333. /** additional data for the event */
  29334. additionalData?: any;
  29335. /**
  29336. * Creates a new ActionEvent
  29337. * @param source The mesh or sprite that triggered the action
  29338. * @param pointerX The X mouse cursor position at the time of the event
  29339. * @param pointerY The Y mouse cursor position at the time of the event
  29340. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29341. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29342. * @param additionalData additional data for the event
  29343. */
  29344. constructor(
  29345. /** The mesh or sprite that triggered the action */
  29346. source: any,
  29347. /** The X mouse cursor position at the time of the event */
  29348. pointerX: number,
  29349. /** The Y mouse cursor position at the time of the event */
  29350. pointerY: number,
  29351. /** The mesh that is currently pointed at (can be null) */
  29352. meshUnderPointer: Nullable<AbstractMesh>,
  29353. /** the original (browser) event that triggered the ActionEvent */
  29354. sourceEvent?: any,
  29355. /** additional data for the event */
  29356. additionalData?: any);
  29357. /**
  29358. * Helper function to auto-create an ActionEvent from a source mesh.
  29359. * @param source The source mesh that triggered the event
  29360. * @param evt The original (browser) event
  29361. * @param additionalData additional data for the event
  29362. * @returns the new ActionEvent
  29363. */
  29364. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29365. /**
  29366. * Helper function to auto-create an ActionEvent from a source sprite
  29367. * @param source The source sprite that triggered the event
  29368. * @param scene Scene associated with the sprite
  29369. * @param evt The original (browser) event
  29370. * @param additionalData additional data for the event
  29371. * @returns the new ActionEvent
  29372. */
  29373. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29374. /**
  29375. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29376. * @param scene the scene where the event occurred
  29377. * @param evt The original (browser) event
  29378. * @returns the new ActionEvent
  29379. */
  29380. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29381. /**
  29382. * Helper function to auto-create an ActionEvent from a primitive
  29383. * @param prim defines the target primitive
  29384. * @param pointerPos defines the pointer position
  29385. * @param evt The original (browser) event
  29386. * @param additionalData additional data for the event
  29387. * @returns the new ActionEvent
  29388. */
  29389. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29390. }
  29391. }
  29392. declare module "babylonjs/Actions/abstractActionManager" {
  29393. import { IDisposable } from "babylonjs/scene";
  29394. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29395. import { IAction } from "babylonjs/Actions/action";
  29396. import { Nullable } from "babylonjs/types";
  29397. /**
  29398. * Abstract class used to decouple action Manager from scene and meshes.
  29399. * Do not instantiate.
  29400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29401. */
  29402. export abstract class AbstractActionManager implements IDisposable {
  29403. /** Gets the list of active triggers */
  29404. static Triggers: {
  29405. [key: string]: number;
  29406. };
  29407. /** Gets the cursor to use when hovering items */
  29408. hoverCursor: string;
  29409. /** Gets the list of actions */
  29410. actions: IAction[];
  29411. /**
  29412. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29413. */
  29414. isRecursive: boolean;
  29415. /**
  29416. * Releases all associated resources
  29417. */
  29418. abstract dispose(): void;
  29419. /**
  29420. * Does this action manager has pointer triggers
  29421. */
  29422. abstract get hasPointerTriggers(): boolean;
  29423. /**
  29424. * Does this action manager has pick triggers
  29425. */
  29426. abstract get hasPickTriggers(): boolean;
  29427. /**
  29428. * Process a specific trigger
  29429. * @param trigger defines the trigger to process
  29430. * @param evt defines the event details to be processed
  29431. */
  29432. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29433. /**
  29434. * Does this action manager handles actions of any of the given triggers
  29435. * @param triggers defines the triggers to be tested
  29436. * @return a boolean indicating whether one (or more) of the triggers is handled
  29437. */
  29438. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29439. /**
  29440. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29441. * speed.
  29442. * @param triggerA defines the trigger to be tested
  29443. * @param triggerB defines the trigger to be tested
  29444. * @return a boolean indicating whether one (or more) of the triggers is handled
  29445. */
  29446. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29447. /**
  29448. * Does this action manager handles actions of a given trigger
  29449. * @param trigger defines the trigger to be tested
  29450. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29451. * @return whether the trigger is handled
  29452. */
  29453. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29454. /**
  29455. * Serialize this manager to a JSON object
  29456. * @param name defines the property name to store this manager
  29457. * @returns a JSON representation of this manager
  29458. */
  29459. abstract serialize(name: string): any;
  29460. /**
  29461. * Registers an action to this action manager
  29462. * @param action defines the action to be registered
  29463. * @return the action amended (prepared) after registration
  29464. */
  29465. abstract registerAction(action: IAction): Nullable<IAction>;
  29466. /**
  29467. * Unregisters an action to this action manager
  29468. * @param action defines the action to be unregistered
  29469. * @return a boolean indicating whether the action has been unregistered
  29470. */
  29471. abstract unregisterAction(action: IAction): Boolean;
  29472. /**
  29473. * Does exist one action manager with at least one trigger
  29474. **/
  29475. static get HasTriggers(): boolean;
  29476. /**
  29477. * Does exist one action manager with at least one pick trigger
  29478. **/
  29479. static get HasPickTriggers(): boolean;
  29480. /**
  29481. * Does exist one action manager that handles actions of a given trigger
  29482. * @param trigger defines the trigger to be tested
  29483. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29484. **/
  29485. static HasSpecificTrigger(trigger: number): boolean;
  29486. }
  29487. }
  29488. declare module "babylonjs/node" {
  29489. import { Scene } from "babylonjs/scene";
  29490. import { Nullable } from "babylonjs/types";
  29491. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29492. import { Engine } from "babylonjs/Engines/engine";
  29493. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29494. import { Observable } from "babylonjs/Misc/observable";
  29495. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29496. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29497. import { Animatable } from "babylonjs/Animations/animatable";
  29498. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29499. import { Animation } from "babylonjs/Animations/animation";
  29500. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29502. /**
  29503. * Defines how a node can be built from a string name.
  29504. */
  29505. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29506. /**
  29507. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29508. */
  29509. export class Node implements IBehaviorAware<Node> {
  29510. /** @hidden */
  29511. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29512. private static _NodeConstructors;
  29513. /**
  29514. * Add a new node constructor
  29515. * @param type defines the type name of the node to construct
  29516. * @param constructorFunc defines the constructor function
  29517. */
  29518. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29519. /**
  29520. * Returns a node constructor based on type name
  29521. * @param type defines the type name
  29522. * @param name defines the new node name
  29523. * @param scene defines the hosting scene
  29524. * @param options defines optional options to transmit to constructors
  29525. * @returns the new constructor or null
  29526. */
  29527. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29528. /**
  29529. * Gets or sets the name of the node
  29530. */
  29531. name: string;
  29532. /**
  29533. * Gets or sets the id of the node
  29534. */
  29535. id: string;
  29536. /**
  29537. * Gets or sets the unique id of the node
  29538. */
  29539. uniqueId: number;
  29540. /**
  29541. * Gets or sets a string used to store user defined state for the node
  29542. */
  29543. state: string;
  29544. /**
  29545. * Gets or sets an object used to store user defined information for the node
  29546. */
  29547. metadata: any;
  29548. /**
  29549. * For internal use only. Please do not use.
  29550. */
  29551. reservedDataStore: any;
  29552. /**
  29553. * List of inspectable custom properties (used by the Inspector)
  29554. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29555. */
  29556. inspectableCustomProperties: IInspectable[];
  29557. private _doNotSerialize;
  29558. /**
  29559. * Gets or sets a boolean used to define if the node must be serialized
  29560. */
  29561. get doNotSerialize(): boolean;
  29562. set doNotSerialize(value: boolean);
  29563. /** @hidden */
  29564. _isDisposed: boolean;
  29565. /**
  29566. * Gets a list of Animations associated with the node
  29567. */
  29568. animations: import("babylonjs/Animations/animation").Animation[];
  29569. protected _ranges: {
  29570. [name: string]: Nullable<AnimationRange>;
  29571. };
  29572. /**
  29573. * Callback raised when the node is ready to be used
  29574. */
  29575. onReady: Nullable<(node: Node) => void>;
  29576. private _isEnabled;
  29577. private _isParentEnabled;
  29578. private _isReady;
  29579. /** @hidden */
  29580. _currentRenderId: number;
  29581. private _parentUpdateId;
  29582. /** @hidden */
  29583. _childUpdateId: number;
  29584. /** @hidden */
  29585. _waitingParentId: Nullable<string>;
  29586. /** @hidden */
  29587. _scene: Scene;
  29588. /** @hidden */
  29589. _cache: any;
  29590. private _parentNode;
  29591. private _children;
  29592. /** @hidden */
  29593. _worldMatrix: Matrix;
  29594. /** @hidden */
  29595. _worldMatrixDeterminant: number;
  29596. /** @hidden */
  29597. _worldMatrixDeterminantIsDirty: boolean;
  29598. /** @hidden */
  29599. private _sceneRootNodesIndex;
  29600. /**
  29601. * Gets a boolean indicating if the node has been disposed
  29602. * @returns true if the node was disposed
  29603. */
  29604. isDisposed(): boolean;
  29605. /**
  29606. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29607. * @see https://doc.babylonjs.com/how_to/parenting
  29608. */
  29609. set parent(parent: Nullable<Node>);
  29610. get parent(): Nullable<Node>;
  29611. /** @hidden */
  29612. _addToSceneRootNodes(): void;
  29613. /** @hidden */
  29614. _removeFromSceneRootNodes(): void;
  29615. private _animationPropertiesOverride;
  29616. /**
  29617. * Gets or sets the animation properties override
  29618. */
  29619. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29620. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29621. /**
  29622. * Gets a string idenfifying the name of the class
  29623. * @returns "Node" string
  29624. */
  29625. getClassName(): string;
  29626. /** @hidden */
  29627. readonly _isNode: boolean;
  29628. /**
  29629. * An event triggered when the mesh is disposed
  29630. */
  29631. onDisposeObservable: Observable<Node>;
  29632. private _onDisposeObserver;
  29633. /**
  29634. * Sets a callback that will be raised when the node will be disposed
  29635. */
  29636. set onDispose(callback: () => void);
  29637. /**
  29638. * Creates a new Node
  29639. * @param name the name and id to be given to this node
  29640. * @param scene the scene this node will be added to
  29641. */
  29642. constructor(name: string, scene?: Nullable<Scene>);
  29643. /**
  29644. * Gets the scene of the node
  29645. * @returns a scene
  29646. */
  29647. getScene(): Scene;
  29648. /**
  29649. * Gets the engine of the node
  29650. * @returns a Engine
  29651. */
  29652. getEngine(): Engine;
  29653. private _behaviors;
  29654. /**
  29655. * Attach a behavior to the node
  29656. * @see http://doc.babylonjs.com/features/behaviour
  29657. * @param behavior defines the behavior to attach
  29658. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29659. * @returns the current Node
  29660. */
  29661. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29662. /**
  29663. * Remove an attached behavior
  29664. * @see http://doc.babylonjs.com/features/behaviour
  29665. * @param behavior defines the behavior to attach
  29666. * @returns the current Node
  29667. */
  29668. removeBehavior(behavior: Behavior<Node>): Node;
  29669. /**
  29670. * Gets the list of attached behaviors
  29671. * @see http://doc.babylonjs.com/features/behaviour
  29672. */
  29673. get behaviors(): Behavior<Node>[];
  29674. /**
  29675. * Gets an attached behavior by name
  29676. * @param name defines the name of the behavior to look for
  29677. * @see http://doc.babylonjs.com/features/behaviour
  29678. * @returns null if behavior was not found else the requested behavior
  29679. */
  29680. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29681. /**
  29682. * Returns the latest update of the World matrix
  29683. * @returns a Matrix
  29684. */
  29685. getWorldMatrix(): Matrix;
  29686. /** @hidden */
  29687. _getWorldMatrixDeterminant(): number;
  29688. /**
  29689. * Returns directly the latest state of the mesh World matrix.
  29690. * A Matrix is returned.
  29691. */
  29692. get worldMatrixFromCache(): Matrix;
  29693. /** @hidden */
  29694. _initCache(): void;
  29695. /** @hidden */
  29696. updateCache(force?: boolean): void;
  29697. /** @hidden */
  29698. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29699. /** @hidden */
  29700. _updateCache(ignoreParentClass?: boolean): void;
  29701. /** @hidden */
  29702. _isSynchronized(): boolean;
  29703. /** @hidden */
  29704. _markSyncedWithParent(): void;
  29705. /** @hidden */
  29706. isSynchronizedWithParent(): boolean;
  29707. /** @hidden */
  29708. isSynchronized(): boolean;
  29709. /**
  29710. * Is this node ready to be used/rendered
  29711. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29712. * @return true if the node is ready
  29713. */
  29714. isReady(completeCheck?: boolean): boolean;
  29715. /**
  29716. * Is this node enabled?
  29717. * 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
  29718. * @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
  29719. * @return whether this node (and its parent) is enabled
  29720. */
  29721. isEnabled(checkAncestors?: boolean): boolean;
  29722. /** @hidden */
  29723. protected _syncParentEnabledState(): void;
  29724. /**
  29725. * Set the enabled state of this node
  29726. * @param value defines the new enabled state
  29727. */
  29728. setEnabled(value: boolean): void;
  29729. /**
  29730. * Is this node a descendant of the given node?
  29731. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29732. * @param ancestor defines the parent node to inspect
  29733. * @returns a boolean indicating if this node is a descendant of the given node
  29734. */
  29735. isDescendantOf(ancestor: Node): boolean;
  29736. /** @hidden */
  29737. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29738. /**
  29739. * Will return all nodes that have this node as ascendant
  29740. * @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
  29741. * @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
  29742. * @return all children nodes of all types
  29743. */
  29744. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29745. /**
  29746. * Get all child-meshes of this node
  29747. * @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)
  29748. * @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
  29749. * @returns an array of AbstractMesh
  29750. */
  29751. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29752. /**
  29753. * Get all direct children of this node
  29754. * @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
  29755. * @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)
  29756. * @returns an array of Node
  29757. */
  29758. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29759. /** @hidden */
  29760. _setReady(state: boolean): void;
  29761. /**
  29762. * Get an animation by name
  29763. * @param name defines the name of the animation to look for
  29764. * @returns null if not found else the requested animation
  29765. */
  29766. getAnimationByName(name: string): Nullable<Animation>;
  29767. /**
  29768. * Creates an animation range for this node
  29769. * @param name defines the name of the range
  29770. * @param from defines the starting key
  29771. * @param to defines the end key
  29772. */
  29773. createAnimationRange(name: string, from: number, to: number): void;
  29774. /**
  29775. * Delete a specific animation range
  29776. * @param name defines the name of the range to delete
  29777. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29778. */
  29779. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29780. /**
  29781. * Get an animation range by name
  29782. * @param name defines the name of the animation range to look for
  29783. * @returns null if not found else the requested animation range
  29784. */
  29785. getAnimationRange(name: string): Nullable<AnimationRange>;
  29786. /**
  29787. * Gets the list of all animation ranges defined on this node
  29788. * @returns an array
  29789. */
  29790. getAnimationRanges(): Nullable<AnimationRange>[];
  29791. /**
  29792. * Will start the animation sequence
  29793. * @param name defines the range frames for animation sequence
  29794. * @param loop defines if the animation should loop (false by default)
  29795. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29796. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29797. * @returns the object created for this animation. If range does not exist, it will return null
  29798. */
  29799. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29800. /**
  29801. * Serialize animation ranges into a JSON compatible object
  29802. * @returns serialization object
  29803. */
  29804. serializeAnimationRanges(): any;
  29805. /**
  29806. * Computes the world matrix of the node
  29807. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29808. * @returns the world matrix
  29809. */
  29810. computeWorldMatrix(force?: boolean): Matrix;
  29811. /**
  29812. * Releases resources associated with this node.
  29813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29815. */
  29816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29817. /**
  29818. * Parse animation range data from a serialization object and store them into a given node
  29819. * @param node defines where to store the animation ranges
  29820. * @param parsedNode defines the serialization object to read data from
  29821. * @param scene defines the hosting scene
  29822. */
  29823. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29824. /**
  29825. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29826. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29827. * @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
  29828. * @returns the new bounding vectors
  29829. */
  29830. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29831. min: Vector3;
  29832. max: Vector3;
  29833. };
  29834. }
  29835. }
  29836. declare module "babylonjs/Animations/animation" {
  29837. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29838. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29839. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29840. import { Nullable } from "babylonjs/types";
  29841. import { Scene } from "babylonjs/scene";
  29842. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29843. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29844. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29845. import { Node } from "babylonjs/node";
  29846. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29847. import { Size } from "babylonjs/Maths/math.size";
  29848. import { Animatable } from "babylonjs/Animations/animatable";
  29849. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29850. /**
  29851. * @hidden
  29852. */
  29853. export class _IAnimationState {
  29854. key: number;
  29855. repeatCount: number;
  29856. workValue?: any;
  29857. loopMode?: number;
  29858. offsetValue?: any;
  29859. highLimitValue?: any;
  29860. }
  29861. /**
  29862. * Class used to store any kind of animation
  29863. */
  29864. export class Animation {
  29865. /**Name of the animation */
  29866. name: string;
  29867. /**Property to animate */
  29868. targetProperty: string;
  29869. /**The frames per second of the animation */
  29870. framePerSecond: number;
  29871. /**The data type of the animation */
  29872. dataType: number;
  29873. /**The loop mode of the animation */
  29874. loopMode?: number | undefined;
  29875. /**Specifies if blending should be enabled */
  29876. enableBlending?: boolean | undefined;
  29877. /**
  29878. * Use matrix interpolation instead of using direct key value when animating matrices
  29879. */
  29880. static AllowMatricesInterpolation: boolean;
  29881. /**
  29882. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29883. */
  29884. static AllowMatrixDecomposeForInterpolation: boolean;
  29885. /**
  29886. * Stores the key frames of the animation
  29887. */
  29888. private _keys;
  29889. /**
  29890. * Stores the easing function of the animation
  29891. */
  29892. private _easingFunction;
  29893. /**
  29894. * @hidden Internal use only
  29895. */
  29896. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29897. /**
  29898. * The set of event that will be linked to this animation
  29899. */
  29900. private _events;
  29901. /**
  29902. * Stores an array of target property paths
  29903. */
  29904. targetPropertyPath: string[];
  29905. /**
  29906. * Stores the blending speed of the animation
  29907. */
  29908. blendingSpeed: number;
  29909. /**
  29910. * Stores the animation ranges for the animation
  29911. */
  29912. private _ranges;
  29913. /**
  29914. * @hidden Internal use
  29915. */
  29916. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29917. /**
  29918. * Sets up an animation
  29919. * @param property The property to animate
  29920. * @param animationType The animation type to apply
  29921. * @param framePerSecond The frames per second of the animation
  29922. * @param easingFunction The easing function used in the animation
  29923. * @returns The created animation
  29924. */
  29925. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29926. /**
  29927. * Create and start an animation on a node
  29928. * @param name defines the name of the global animation that will be run on all nodes
  29929. * @param node defines the root node where the animation will take place
  29930. * @param targetProperty defines property to animate
  29931. * @param framePerSecond defines the number of frame per second yo use
  29932. * @param totalFrame defines the number of frames in total
  29933. * @param from defines the initial value
  29934. * @param to defines the final value
  29935. * @param loopMode defines which loop mode you want to use (off by default)
  29936. * @param easingFunction defines the easing function to use (linear by default)
  29937. * @param onAnimationEnd defines the callback to call when animation end
  29938. * @returns the animatable created for this animation
  29939. */
  29940. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29941. /**
  29942. * Create and start an animation on a node and its descendants
  29943. * @param name defines the name of the global animation that will be run on all nodes
  29944. * @param node defines the root node where the animation will take place
  29945. * @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
  29946. * @param targetProperty defines property to animate
  29947. * @param framePerSecond defines the number of frame per second to use
  29948. * @param totalFrame defines the number of frames in total
  29949. * @param from defines the initial value
  29950. * @param to defines the final value
  29951. * @param loopMode defines which loop mode you want to use (off by default)
  29952. * @param easingFunction defines the easing function to use (linear by default)
  29953. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29954. * @returns the list of animatables created for all nodes
  29955. * @example https://www.babylonjs-playground.com/#MH0VLI
  29956. */
  29957. 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[]>;
  29958. /**
  29959. * Creates a new animation, merges it with the existing animations and starts it
  29960. * @param name Name of the animation
  29961. * @param node Node which contains the scene that begins the animations
  29962. * @param targetProperty Specifies which property to animate
  29963. * @param framePerSecond The frames per second of the animation
  29964. * @param totalFrame The total number of frames
  29965. * @param from The frame at the beginning of the animation
  29966. * @param to The frame at the end of the animation
  29967. * @param loopMode Specifies the loop mode of the animation
  29968. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29969. * @param onAnimationEnd Callback to run once the animation is complete
  29970. * @returns Nullable animation
  29971. */
  29972. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29973. /**
  29974. * Transition property of an host to the target Value
  29975. * @param property The property to transition
  29976. * @param targetValue The target Value of the property
  29977. * @param host The object where the property to animate belongs
  29978. * @param scene Scene used to run the animation
  29979. * @param frameRate Framerate (in frame/s) to use
  29980. * @param transition The transition type we want to use
  29981. * @param duration The duration of the animation, in milliseconds
  29982. * @param onAnimationEnd Callback trigger at the end of the animation
  29983. * @returns Nullable animation
  29984. */
  29985. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29986. /**
  29987. * Return the array of runtime animations currently using this animation
  29988. */
  29989. get runtimeAnimations(): RuntimeAnimation[];
  29990. /**
  29991. * Specifies if any of the runtime animations are currently running
  29992. */
  29993. get hasRunningRuntimeAnimations(): boolean;
  29994. /**
  29995. * Initializes the animation
  29996. * @param name Name of the animation
  29997. * @param targetProperty Property to animate
  29998. * @param framePerSecond The frames per second of the animation
  29999. * @param dataType The data type of the animation
  30000. * @param loopMode The loop mode of the animation
  30001. * @param enableBlending Specifies if blending should be enabled
  30002. */
  30003. constructor(
  30004. /**Name of the animation */
  30005. name: string,
  30006. /**Property to animate */
  30007. targetProperty: string,
  30008. /**The frames per second of the animation */
  30009. framePerSecond: number,
  30010. /**The data type of the animation */
  30011. dataType: number,
  30012. /**The loop mode of the animation */
  30013. loopMode?: number | undefined,
  30014. /**Specifies if blending should be enabled */
  30015. enableBlending?: boolean | undefined);
  30016. /**
  30017. * Converts the animation to a string
  30018. * @param fullDetails support for multiple levels of logging within scene loading
  30019. * @returns String form of the animation
  30020. */
  30021. toString(fullDetails?: boolean): string;
  30022. /**
  30023. * Add an event to this animation
  30024. * @param event Event to add
  30025. */
  30026. addEvent(event: AnimationEvent): void;
  30027. /**
  30028. * Remove all events found at the given frame
  30029. * @param frame The frame to remove events from
  30030. */
  30031. removeEvents(frame: number): void;
  30032. /**
  30033. * Retrieves all the events from the animation
  30034. * @returns Events from the animation
  30035. */
  30036. getEvents(): AnimationEvent[];
  30037. /**
  30038. * Creates an animation range
  30039. * @param name Name of the animation range
  30040. * @param from Starting frame of the animation range
  30041. * @param to Ending frame of the animation
  30042. */
  30043. createRange(name: string, from: number, to: number): void;
  30044. /**
  30045. * Deletes an animation range by name
  30046. * @param name Name of the animation range to delete
  30047. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30048. */
  30049. deleteRange(name: string, deleteFrames?: boolean): void;
  30050. /**
  30051. * Gets the animation range by name, or null if not defined
  30052. * @param name Name of the animation range
  30053. * @returns Nullable animation range
  30054. */
  30055. getRange(name: string): Nullable<AnimationRange>;
  30056. /**
  30057. * Gets the key frames from the animation
  30058. * @returns The key frames of the animation
  30059. */
  30060. getKeys(): Array<IAnimationKey>;
  30061. /**
  30062. * Gets the highest frame rate of the animation
  30063. * @returns Highest frame rate of the animation
  30064. */
  30065. getHighestFrame(): number;
  30066. /**
  30067. * Gets the easing function of the animation
  30068. * @returns Easing function of the animation
  30069. */
  30070. getEasingFunction(): IEasingFunction;
  30071. /**
  30072. * Sets the easing function of the animation
  30073. * @param easingFunction A custom mathematical formula for animation
  30074. */
  30075. setEasingFunction(easingFunction: EasingFunction): void;
  30076. /**
  30077. * Interpolates a scalar linearly
  30078. * @param startValue Start value of the animation curve
  30079. * @param endValue End value of the animation curve
  30080. * @param gradient Scalar amount to interpolate
  30081. * @returns Interpolated scalar value
  30082. */
  30083. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30084. /**
  30085. * Interpolates a scalar cubically
  30086. * @param startValue Start value of the animation curve
  30087. * @param outTangent End tangent of the animation
  30088. * @param endValue End value of the animation curve
  30089. * @param inTangent Start tangent of the animation curve
  30090. * @param gradient Scalar amount to interpolate
  30091. * @returns Interpolated scalar value
  30092. */
  30093. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30094. /**
  30095. * Interpolates a quaternion using a spherical linear interpolation
  30096. * @param startValue Start value of the animation curve
  30097. * @param endValue End value of the animation curve
  30098. * @param gradient Scalar amount to interpolate
  30099. * @returns Interpolated quaternion value
  30100. */
  30101. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30102. /**
  30103. * Interpolates a quaternion cubically
  30104. * @param startValue Start value of the animation curve
  30105. * @param outTangent End tangent of the animation curve
  30106. * @param endValue End value of the animation curve
  30107. * @param inTangent Start tangent of the animation curve
  30108. * @param gradient Scalar amount to interpolate
  30109. * @returns Interpolated quaternion value
  30110. */
  30111. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30112. /**
  30113. * Interpolates a Vector3 linearl
  30114. * @param startValue Start value of the animation curve
  30115. * @param endValue End value of the animation curve
  30116. * @param gradient Scalar amount to interpolate
  30117. * @returns Interpolated scalar value
  30118. */
  30119. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30120. /**
  30121. * Interpolates a Vector3 cubically
  30122. * @param startValue Start value of the animation curve
  30123. * @param outTangent End tangent of the animation
  30124. * @param endValue End value of the animation curve
  30125. * @param inTangent Start tangent of the animation curve
  30126. * @param gradient Scalar amount to interpolate
  30127. * @returns InterpolatedVector3 value
  30128. */
  30129. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30130. /**
  30131. * Interpolates a Vector2 linearly
  30132. * @param startValue Start value of the animation curve
  30133. * @param endValue End value of the animation curve
  30134. * @param gradient Scalar amount to interpolate
  30135. * @returns Interpolated Vector2 value
  30136. */
  30137. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30138. /**
  30139. * Interpolates a Vector2 cubically
  30140. * @param startValue Start value of the animation curve
  30141. * @param outTangent End tangent of the animation
  30142. * @param endValue End value of the animation curve
  30143. * @param inTangent Start tangent of the animation curve
  30144. * @param gradient Scalar amount to interpolate
  30145. * @returns Interpolated Vector2 value
  30146. */
  30147. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30148. /**
  30149. * Interpolates a size linearly
  30150. * @param startValue Start value of the animation curve
  30151. * @param endValue End value of the animation curve
  30152. * @param gradient Scalar amount to interpolate
  30153. * @returns Interpolated Size value
  30154. */
  30155. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30156. /**
  30157. * Interpolates a Color3 linearly
  30158. * @param startValue Start value of the animation curve
  30159. * @param endValue End value of the animation curve
  30160. * @param gradient Scalar amount to interpolate
  30161. * @returns Interpolated Color3 value
  30162. */
  30163. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30164. /**
  30165. * Interpolates a Color4 linearly
  30166. * @param startValue Start value of the animation curve
  30167. * @param endValue End value of the animation curve
  30168. * @param gradient Scalar amount to interpolate
  30169. * @returns Interpolated Color3 value
  30170. */
  30171. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30172. /**
  30173. * @hidden Internal use only
  30174. */
  30175. _getKeyValue(value: any): any;
  30176. /**
  30177. * @hidden Internal use only
  30178. */
  30179. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30180. /**
  30181. * Defines the function to use to interpolate matrices
  30182. * @param startValue defines the start matrix
  30183. * @param endValue defines the end matrix
  30184. * @param gradient defines the gradient between both matrices
  30185. * @param result defines an optional target matrix where to store the interpolation
  30186. * @returns the interpolated matrix
  30187. */
  30188. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30189. /**
  30190. * Makes a copy of the animation
  30191. * @returns Cloned animation
  30192. */
  30193. clone(): Animation;
  30194. /**
  30195. * Sets the key frames of the animation
  30196. * @param values The animation key frames to set
  30197. */
  30198. setKeys(values: Array<IAnimationKey>): void;
  30199. /**
  30200. * Serializes the animation to an object
  30201. * @returns Serialized object
  30202. */
  30203. serialize(): any;
  30204. /**
  30205. * Float animation type
  30206. */
  30207. static readonly ANIMATIONTYPE_FLOAT: number;
  30208. /**
  30209. * Vector3 animation type
  30210. */
  30211. static readonly ANIMATIONTYPE_VECTOR3: number;
  30212. /**
  30213. * Quaternion animation type
  30214. */
  30215. static readonly ANIMATIONTYPE_QUATERNION: number;
  30216. /**
  30217. * Matrix animation type
  30218. */
  30219. static readonly ANIMATIONTYPE_MATRIX: number;
  30220. /**
  30221. * Color3 animation type
  30222. */
  30223. static readonly ANIMATIONTYPE_COLOR3: number;
  30224. /**
  30225. * Color3 animation type
  30226. */
  30227. static readonly ANIMATIONTYPE_COLOR4: number;
  30228. /**
  30229. * Vector2 animation type
  30230. */
  30231. static readonly ANIMATIONTYPE_VECTOR2: number;
  30232. /**
  30233. * Size animation type
  30234. */
  30235. static readonly ANIMATIONTYPE_SIZE: number;
  30236. /**
  30237. * Relative Loop Mode
  30238. */
  30239. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30240. /**
  30241. * Cycle Loop Mode
  30242. */
  30243. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30244. /**
  30245. * Constant Loop Mode
  30246. */
  30247. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30248. /** @hidden */
  30249. static _UniversalLerp(left: any, right: any, amount: number): any;
  30250. /**
  30251. * Parses an animation object and creates an animation
  30252. * @param parsedAnimation Parsed animation object
  30253. * @returns Animation object
  30254. */
  30255. static Parse(parsedAnimation: any): Animation;
  30256. /**
  30257. * Appends the serialized animations from the source animations
  30258. * @param source Source containing the animations
  30259. * @param destination Target to store the animations
  30260. */
  30261. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30262. }
  30263. }
  30264. declare module "babylonjs/Animations/animatable.interface" {
  30265. import { Nullable } from "babylonjs/types";
  30266. import { Animation } from "babylonjs/Animations/animation";
  30267. /**
  30268. * Interface containing an array of animations
  30269. */
  30270. export interface IAnimatable {
  30271. /**
  30272. * Array of animations
  30273. */
  30274. animations: Nullable<Array<Animation>>;
  30275. }
  30276. }
  30277. declare module "babylonjs/Misc/decorators" {
  30278. import { Nullable } from "babylonjs/types";
  30279. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30280. import { Scene } from "babylonjs/scene";
  30281. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30282. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30283. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30284. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30285. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30286. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30287. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30288. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30289. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30290. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30291. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30292. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30293. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30294. /**
  30295. * Decorator used to define property that can be serialized as reference to a camera
  30296. * @param sourceName defines the name of the property to decorate
  30297. */
  30298. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30299. /**
  30300. * Class used to help serialization objects
  30301. */
  30302. export class SerializationHelper {
  30303. /** @hidden */
  30304. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30305. /** @hidden */
  30306. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30307. /** @hidden */
  30308. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30309. /** @hidden */
  30310. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30311. /**
  30312. * Appends the serialized animations from the source animations
  30313. * @param source Source containing the animations
  30314. * @param destination Target to store the animations
  30315. */
  30316. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30317. /**
  30318. * Static function used to serialized a specific entity
  30319. * @param entity defines the entity to serialize
  30320. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30321. * @returns a JSON compatible object representing the serialization of the entity
  30322. */
  30323. static Serialize<T>(entity: T, serializationObject?: any): any;
  30324. /**
  30325. * Creates a new entity from a serialization data object
  30326. * @param creationFunction defines a function used to instanciated the new entity
  30327. * @param source defines the source serialization data
  30328. * @param scene defines the hosting scene
  30329. * @param rootUrl defines the root url for resources
  30330. * @returns a new entity
  30331. */
  30332. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30333. /**
  30334. * Clones an object
  30335. * @param creationFunction defines the function used to instanciate the new object
  30336. * @param source defines the source object
  30337. * @returns the cloned object
  30338. */
  30339. static Clone<T>(creationFunction: () => T, source: T): T;
  30340. /**
  30341. * Instanciates a new object based on a source one (some data will be shared between both object)
  30342. * @param creationFunction defines the function used to instanciate the new object
  30343. * @param source defines the source object
  30344. * @returns the new object
  30345. */
  30346. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30347. }
  30348. }
  30349. declare module "babylonjs/Misc/guid" {
  30350. /**
  30351. * Class used to manipulate GUIDs
  30352. */
  30353. export class GUID {
  30354. /**
  30355. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30356. * Be aware Math.random() could cause collisions, but:
  30357. * "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"
  30358. * @returns a pseudo random id
  30359. */
  30360. static RandomId(): string;
  30361. }
  30362. }
  30363. declare module "babylonjs/Materials/Textures/baseTexture" {
  30364. import { Observable } from "babylonjs/Misc/observable";
  30365. import { Nullable } from "babylonjs/types";
  30366. import { Scene } from "babylonjs/scene";
  30367. import { Matrix } from "babylonjs/Maths/math.vector";
  30368. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30369. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30370. import { ISize } from "babylonjs/Maths/math.size";
  30371. import "babylonjs/Misc/fileTools";
  30372. /**
  30373. * Base class of all the textures in babylon.
  30374. * It groups all the common properties the materials, post process, lights... might need
  30375. * in order to make a correct use of the texture.
  30376. */
  30377. export class BaseTexture implements IAnimatable {
  30378. /**
  30379. * Default anisotropic filtering level for the application.
  30380. * It is set to 4 as a good tradeoff between perf and quality.
  30381. */
  30382. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30383. /**
  30384. * Gets or sets the unique id of the texture
  30385. */
  30386. uniqueId: number;
  30387. /**
  30388. * Define the name of the texture.
  30389. */
  30390. name: string;
  30391. /**
  30392. * Gets or sets an object used to store user defined information.
  30393. */
  30394. metadata: any;
  30395. /**
  30396. * For internal use only. Please do not use.
  30397. */
  30398. reservedDataStore: any;
  30399. private _hasAlpha;
  30400. /**
  30401. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30402. */
  30403. set hasAlpha(value: boolean);
  30404. get hasAlpha(): boolean;
  30405. /**
  30406. * Defines if the alpha value should be determined via the rgb values.
  30407. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30408. */
  30409. getAlphaFromRGB: boolean;
  30410. /**
  30411. * Intensity or strength of the texture.
  30412. * It is commonly used by materials to fine tune the intensity of the texture
  30413. */
  30414. level: number;
  30415. /**
  30416. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30417. * This is part of the texture as textures usually maps to one uv set.
  30418. */
  30419. coordinatesIndex: number;
  30420. private _coordinatesMode;
  30421. /**
  30422. * How a texture is mapped.
  30423. *
  30424. * | Value | Type | Description |
  30425. * | ----- | ----------------------------------- | ----------- |
  30426. * | 0 | EXPLICIT_MODE | |
  30427. * | 1 | SPHERICAL_MODE | |
  30428. * | 2 | PLANAR_MODE | |
  30429. * | 3 | CUBIC_MODE | |
  30430. * | 4 | PROJECTION_MODE | |
  30431. * | 5 | SKYBOX_MODE | |
  30432. * | 6 | INVCUBIC_MODE | |
  30433. * | 7 | EQUIRECTANGULAR_MODE | |
  30434. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30435. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30436. */
  30437. set coordinatesMode(value: number);
  30438. get coordinatesMode(): number;
  30439. /**
  30440. * | Value | Type | Description |
  30441. * | ----- | ------------------ | ----------- |
  30442. * | 0 | CLAMP_ADDRESSMODE | |
  30443. * | 1 | WRAP_ADDRESSMODE | |
  30444. * | 2 | MIRROR_ADDRESSMODE | |
  30445. */
  30446. wrapU: number;
  30447. /**
  30448. * | Value | Type | Description |
  30449. * | ----- | ------------------ | ----------- |
  30450. * | 0 | CLAMP_ADDRESSMODE | |
  30451. * | 1 | WRAP_ADDRESSMODE | |
  30452. * | 2 | MIRROR_ADDRESSMODE | |
  30453. */
  30454. wrapV: number;
  30455. /**
  30456. * | Value | Type | Description |
  30457. * | ----- | ------------------ | ----------- |
  30458. * | 0 | CLAMP_ADDRESSMODE | |
  30459. * | 1 | WRAP_ADDRESSMODE | |
  30460. * | 2 | MIRROR_ADDRESSMODE | |
  30461. */
  30462. wrapR: number;
  30463. /**
  30464. * With compliant hardware and browser (supporting anisotropic filtering)
  30465. * this defines the level of anisotropic filtering in the texture.
  30466. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30467. */
  30468. anisotropicFilteringLevel: number;
  30469. /**
  30470. * Define if the texture is a cube texture or if false a 2d texture.
  30471. */
  30472. get isCube(): boolean;
  30473. set isCube(value: boolean);
  30474. /**
  30475. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30476. */
  30477. get is3D(): boolean;
  30478. set is3D(value: boolean);
  30479. /**
  30480. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30481. */
  30482. get is2DArray(): boolean;
  30483. set is2DArray(value: boolean);
  30484. /**
  30485. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30486. * HDR texture are usually stored in linear space.
  30487. * This only impacts the PBR and Background materials
  30488. */
  30489. gammaSpace: boolean;
  30490. /**
  30491. * Gets or sets whether or not the texture contains RGBD data.
  30492. */
  30493. get isRGBD(): boolean;
  30494. set isRGBD(value: boolean);
  30495. /**
  30496. * Is Z inverted in the texture (useful in a cube texture).
  30497. */
  30498. invertZ: boolean;
  30499. /**
  30500. * Are mip maps generated for this texture or not.
  30501. */
  30502. get noMipmap(): boolean;
  30503. /**
  30504. * @hidden
  30505. */
  30506. lodLevelInAlpha: boolean;
  30507. /**
  30508. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30509. */
  30510. get lodGenerationOffset(): number;
  30511. set lodGenerationOffset(value: number);
  30512. /**
  30513. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30514. */
  30515. get lodGenerationScale(): number;
  30516. set lodGenerationScale(value: number);
  30517. /**
  30518. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30519. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30520. * average roughness values.
  30521. */
  30522. get linearSpecularLOD(): boolean;
  30523. set linearSpecularLOD(value: boolean);
  30524. /**
  30525. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30526. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30527. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30528. */
  30529. get irradianceTexture(): Nullable<BaseTexture>;
  30530. set irradianceTexture(value: Nullable<BaseTexture>);
  30531. /**
  30532. * Define if the texture is a render target.
  30533. */
  30534. isRenderTarget: boolean;
  30535. /**
  30536. * Define the unique id of the texture in the scene.
  30537. */
  30538. get uid(): string;
  30539. /**
  30540. * Return a string representation of the texture.
  30541. * @returns the texture as a string
  30542. */
  30543. toString(): string;
  30544. /**
  30545. * Get the class name of the texture.
  30546. * @returns "BaseTexture"
  30547. */
  30548. getClassName(): string;
  30549. /**
  30550. * Define the list of animation attached to the texture.
  30551. */
  30552. animations: import("babylonjs/Animations/animation").Animation[];
  30553. /**
  30554. * An event triggered when the texture is disposed.
  30555. */
  30556. onDisposeObservable: Observable<BaseTexture>;
  30557. private _onDisposeObserver;
  30558. /**
  30559. * Callback triggered when the texture has been disposed.
  30560. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30561. */
  30562. set onDispose(callback: () => void);
  30563. /**
  30564. * Define the current state of the loading sequence when in delayed load mode.
  30565. */
  30566. delayLoadState: number;
  30567. private _scene;
  30568. /** @hidden */
  30569. _texture: Nullable<InternalTexture>;
  30570. private _uid;
  30571. /**
  30572. * Define if the texture is preventinga material to render or not.
  30573. * If not and the texture is not ready, the engine will use a default black texture instead.
  30574. */
  30575. get isBlocking(): boolean;
  30576. /**
  30577. * Instantiates a new BaseTexture.
  30578. * Base class of all the textures in babylon.
  30579. * It groups all the common properties the materials, post process, lights... might need
  30580. * in order to make a correct use of the texture.
  30581. * @param scene Define the scene the texture blongs to
  30582. */
  30583. constructor(scene: Nullable<Scene>);
  30584. /**
  30585. * Get the scene the texture belongs to.
  30586. * @returns the scene or null if undefined
  30587. */
  30588. getScene(): Nullable<Scene>;
  30589. /**
  30590. * Get the texture transform matrix used to offset tile the texture for istance.
  30591. * @returns the transformation matrix
  30592. */
  30593. getTextureMatrix(): Matrix;
  30594. /**
  30595. * Get the texture reflection matrix used to rotate/transform the reflection.
  30596. * @returns the reflection matrix
  30597. */
  30598. getReflectionTextureMatrix(): Matrix;
  30599. /**
  30600. * Get the underlying lower level texture from Babylon.
  30601. * @returns the insternal texture
  30602. */
  30603. getInternalTexture(): Nullable<InternalTexture>;
  30604. /**
  30605. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30606. * @returns true if ready or not blocking
  30607. */
  30608. isReadyOrNotBlocking(): boolean;
  30609. /**
  30610. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30611. * @returns true if fully ready
  30612. */
  30613. isReady(): boolean;
  30614. private _cachedSize;
  30615. /**
  30616. * Get the size of the texture.
  30617. * @returns the texture size.
  30618. */
  30619. getSize(): ISize;
  30620. /**
  30621. * Get the base size of the texture.
  30622. * It can be different from the size if the texture has been resized for POT for instance
  30623. * @returns the base size
  30624. */
  30625. getBaseSize(): ISize;
  30626. /**
  30627. * Update the sampling mode of the texture.
  30628. * Default is Trilinear mode.
  30629. *
  30630. * | Value | Type | Description |
  30631. * | ----- | ------------------ | ----------- |
  30632. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30633. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30634. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30635. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30636. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30637. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30638. * | 7 | NEAREST_LINEAR | |
  30639. * | 8 | NEAREST_NEAREST | |
  30640. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30641. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30642. * | 11 | LINEAR_LINEAR | |
  30643. * | 12 | LINEAR_NEAREST | |
  30644. *
  30645. * > _mag_: magnification filter (close to the viewer)
  30646. * > _min_: minification filter (far from the viewer)
  30647. * > _mip_: filter used between mip map levels
  30648. *@param samplingMode Define the new sampling mode of the texture
  30649. */
  30650. updateSamplingMode(samplingMode: number): void;
  30651. /**
  30652. * Scales the texture if is `canRescale()`
  30653. * @param ratio the resize factor we want to use to rescale
  30654. */
  30655. scale(ratio: number): void;
  30656. /**
  30657. * Get if the texture can rescale.
  30658. */
  30659. get canRescale(): boolean;
  30660. /** @hidden */
  30661. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30662. /** @hidden */
  30663. _rebuild(): void;
  30664. /**
  30665. * Triggers the load sequence in delayed load mode.
  30666. */
  30667. delayLoad(): void;
  30668. /**
  30669. * Clones the texture.
  30670. * @returns the cloned texture
  30671. */
  30672. clone(): Nullable<BaseTexture>;
  30673. /**
  30674. * Get the texture underlying type (INT, FLOAT...)
  30675. */
  30676. get textureType(): number;
  30677. /**
  30678. * Get the texture underlying format (RGB, RGBA...)
  30679. */
  30680. get textureFormat(): number;
  30681. /**
  30682. * Indicates that textures need to be re-calculated for all materials
  30683. */
  30684. protected _markAllSubMeshesAsTexturesDirty(): void;
  30685. /**
  30686. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30687. * This will returns an RGBA array buffer containing either in values (0-255) or
  30688. * float values (0-1) depending of the underlying buffer type.
  30689. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30690. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30691. * @param buffer defines a user defined buffer to fill with data (can be null)
  30692. * @returns The Array buffer containing the pixels data.
  30693. */
  30694. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30695. /**
  30696. * Release and destroy the underlying lower level texture aka internalTexture.
  30697. */
  30698. releaseInternalTexture(): void;
  30699. /** @hidden */
  30700. get _lodTextureHigh(): Nullable<BaseTexture>;
  30701. /** @hidden */
  30702. get _lodTextureMid(): Nullable<BaseTexture>;
  30703. /** @hidden */
  30704. get _lodTextureLow(): Nullable<BaseTexture>;
  30705. /**
  30706. * Dispose the texture and release its associated resources.
  30707. */
  30708. dispose(): void;
  30709. /**
  30710. * Serialize the texture into a JSON representation that can be parsed later on.
  30711. * @returns the JSON representation of the texture
  30712. */
  30713. serialize(): any;
  30714. /**
  30715. * Helper function to be called back once a list of texture contains only ready textures.
  30716. * @param textures Define the list of textures to wait for
  30717. * @param callback Define the callback triggered once the entire list will be ready
  30718. */
  30719. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30720. }
  30721. }
  30722. declare module "babylonjs/Materials/effect" {
  30723. import { Observable } from "babylonjs/Misc/observable";
  30724. import { Nullable } from "babylonjs/types";
  30725. import { IDisposable } from "babylonjs/scene";
  30726. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30727. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30728. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30729. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30730. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30731. import { Engine } from "babylonjs/Engines/engine";
  30732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30734. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30735. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30736. /**
  30737. * Options to be used when creating an effect.
  30738. */
  30739. export interface IEffectCreationOptions {
  30740. /**
  30741. * Atrributes that will be used in the shader.
  30742. */
  30743. attributes: string[];
  30744. /**
  30745. * Uniform varible names that will be set in the shader.
  30746. */
  30747. uniformsNames: string[];
  30748. /**
  30749. * Uniform buffer variable names that will be set in the shader.
  30750. */
  30751. uniformBuffersNames: string[];
  30752. /**
  30753. * Sampler texture variable names that will be set in the shader.
  30754. */
  30755. samplers: string[];
  30756. /**
  30757. * Define statements that will be set in the shader.
  30758. */
  30759. defines: any;
  30760. /**
  30761. * Possible fallbacks for this effect to improve performance when needed.
  30762. */
  30763. fallbacks: Nullable<IEffectFallbacks>;
  30764. /**
  30765. * Callback that will be called when the shader is compiled.
  30766. */
  30767. onCompiled: Nullable<(effect: Effect) => void>;
  30768. /**
  30769. * Callback that will be called if an error occurs during shader compilation.
  30770. */
  30771. onError: Nullable<(effect: Effect, errors: string) => void>;
  30772. /**
  30773. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30774. */
  30775. indexParameters?: any;
  30776. /**
  30777. * Max number of lights that can be used in the shader.
  30778. */
  30779. maxSimultaneousLights?: number;
  30780. /**
  30781. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30782. */
  30783. transformFeedbackVaryings?: Nullable<string[]>;
  30784. }
  30785. /**
  30786. * Effect containing vertex and fragment shader that can be executed on an object.
  30787. */
  30788. export class Effect implements IDisposable {
  30789. /**
  30790. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30791. */
  30792. static ShadersRepository: string;
  30793. /**
  30794. * Name of the effect.
  30795. */
  30796. name: any;
  30797. /**
  30798. * String container all the define statements that should be set on the shader.
  30799. */
  30800. defines: string;
  30801. /**
  30802. * Callback that will be called when the shader is compiled.
  30803. */
  30804. onCompiled: Nullable<(effect: Effect) => void>;
  30805. /**
  30806. * Callback that will be called if an error occurs during shader compilation.
  30807. */
  30808. onError: Nullable<(effect: Effect, errors: string) => void>;
  30809. /**
  30810. * Callback that will be called when effect is bound.
  30811. */
  30812. onBind: Nullable<(effect: Effect) => void>;
  30813. /**
  30814. * Unique ID of the effect.
  30815. */
  30816. uniqueId: number;
  30817. /**
  30818. * Observable that will be called when the shader is compiled.
  30819. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30820. */
  30821. onCompileObservable: Observable<Effect>;
  30822. /**
  30823. * Observable that will be called if an error occurs during shader compilation.
  30824. */
  30825. onErrorObservable: Observable<Effect>;
  30826. /** @hidden */
  30827. _onBindObservable: Nullable<Observable<Effect>>;
  30828. /**
  30829. * @hidden
  30830. * Specifies if the effect was previously ready
  30831. */
  30832. _wasPreviouslyReady: boolean;
  30833. /**
  30834. * Observable that will be called when effect is bound.
  30835. */
  30836. get onBindObservable(): Observable<Effect>;
  30837. /** @hidden */
  30838. _bonesComputationForcedToCPU: boolean;
  30839. private static _uniqueIdSeed;
  30840. private _engine;
  30841. private _uniformBuffersNames;
  30842. private _uniformsNames;
  30843. private _samplerList;
  30844. private _samplers;
  30845. private _isReady;
  30846. private _compilationError;
  30847. private _allFallbacksProcessed;
  30848. private _attributesNames;
  30849. private _attributes;
  30850. private _attributeLocationByName;
  30851. private _uniforms;
  30852. /**
  30853. * Key for the effect.
  30854. * @hidden
  30855. */
  30856. _key: string;
  30857. private _indexParameters;
  30858. private _fallbacks;
  30859. private _vertexSourceCode;
  30860. private _fragmentSourceCode;
  30861. private _vertexSourceCodeOverride;
  30862. private _fragmentSourceCodeOverride;
  30863. private _transformFeedbackVaryings;
  30864. /**
  30865. * Compiled shader to webGL program.
  30866. * @hidden
  30867. */
  30868. _pipelineContext: Nullable<IPipelineContext>;
  30869. private _valueCache;
  30870. private static _baseCache;
  30871. /**
  30872. * Instantiates an effect.
  30873. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30874. * @param baseName Name of the effect.
  30875. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30876. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30877. * @param samplers List of sampler variables that will be passed to the shader.
  30878. * @param engine Engine to be used to render the effect
  30879. * @param defines Define statements to be added to the shader.
  30880. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30881. * @param onCompiled Callback that will be called when the shader is compiled.
  30882. * @param onError Callback that will be called if an error occurs during shader compilation.
  30883. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30884. */
  30885. 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);
  30886. private _useFinalCode;
  30887. /**
  30888. * Unique key for this effect
  30889. */
  30890. get key(): string;
  30891. /**
  30892. * If the effect has been compiled and prepared.
  30893. * @returns if the effect is compiled and prepared.
  30894. */
  30895. isReady(): boolean;
  30896. private _isReadyInternal;
  30897. /**
  30898. * The engine the effect was initialized with.
  30899. * @returns the engine.
  30900. */
  30901. getEngine(): Engine;
  30902. /**
  30903. * The pipeline context for this effect
  30904. * @returns the associated pipeline context
  30905. */
  30906. getPipelineContext(): Nullable<IPipelineContext>;
  30907. /**
  30908. * The set of names of attribute variables for the shader.
  30909. * @returns An array of attribute names.
  30910. */
  30911. getAttributesNames(): string[];
  30912. /**
  30913. * Returns the attribute at the given index.
  30914. * @param index The index of the attribute.
  30915. * @returns The location of the attribute.
  30916. */
  30917. getAttributeLocation(index: number): number;
  30918. /**
  30919. * Returns the attribute based on the name of the variable.
  30920. * @param name of the attribute to look up.
  30921. * @returns the attribute location.
  30922. */
  30923. getAttributeLocationByName(name: string): number;
  30924. /**
  30925. * The number of attributes.
  30926. * @returns the numnber of attributes.
  30927. */
  30928. getAttributesCount(): number;
  30929. /**
  30930. * Gets the index of a uniform variable.
  30931. * @param uniformName of the uniform to look up.
  30932. * @returns the index.
  30933. */
  30934. getUniformIndex(uniformName: string): number;
  30935. /**
  30936. * Returns the attribute based on the name of the variable.
  30937. * @param uniformName of the uniform to look up.
  30938. * @returns the location of the uniform.
  30939. */
  30940. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30941. /**
  30942. * Returns an array of sampler variable names
  30943. * @returns The array of sampler variable neames.
  30944. */
  30945. getSamplers(): string[];
  30946. /**
  30947. * The error from the last compilation.
  30948. * @returns the error string.
  30949. */
  30950. getCompilationError(): string;
  30951. /**
  30952. * Gets a boolean indicating that all fallbacks were used during compilation
  30953. * @returns true if all fallbacks were used
  30954. */
  30955. allFallbacksProcessed(): boolean;
  30956. /**
  30957. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30958. * @param func The callback to be used.
  30959. */
  30960. executeWhenCompiled(func: (effect: Effect) => void): void;
  30961. private _checkIsReady;
  30962. private _loadShader;
  30963. /**
  30964. * Recompiles the webGL program
  30965. * @param vertexSourceCode The source code for the vertex shader.
  30966. * @param fragmentSourceCode The source code for the fragment shader.
  30967. * @param onCompiled Callback called when completed.
  30968. * @param onError Callback called on error.
  30969. * @hidden
  30970. */
  30971. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30972. /**
  30973. * Prepares the effect
  30974. * @hidden
  30975. */
  30976. _prepareEffect(): void;
  30977. private _processCompilationErrors;
  30978. /**
  30979. * Checks if the effect is supported. (Must be called after compilation)
  30980. */
  30981. get isSupported(): boolean;
  30982. /**
  30983. * Binds a texture to the engine to be used as output of the shader.
  30984. * @param channel Name of the output variable.
  30985. * @param texture Texture to bind.
  30986. * @hidden
  30987. */
  30988. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30989. /**
  30990. * Sets a texture on the engine to be used in the shader.
  30991. * @param channel Name of the sampler variable.
  30992. * @param texture Texture to set.
  30993. */
  30994. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30995. /**
  30996. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30997. * @param channel Name of the sampler variable.
  30998. * @param texture Texture to set.
  30999. */
  31000. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31001. /**
  31002. * Sets an array of textures on the engine to be used in the shader.
  31003. * @param channel Name of the variable.
  31004. * @param textures Textures to set.
  31005. */
  31006. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31007. /**
  31008. * 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)
  31009. * @param channel Name of the sampler variable.
  31010. * @param postProcess Post process to get the input texture from.
  31011. */
  31012. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31013. /**
  31014. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31015. * 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)
  31016. * @param channel Name of the sampler variable.
  31017. * @param postProcess Post process to get the output texture from.
  31018. */
  31019. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31020. /** @hidden */
  31021. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31022. /** @hidden */
  31023. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31024. /** @hidden */
  31025. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31026. /** @hidden */
  31027. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31028. /**
  31029. * Binds a buffer to a uniform.
  31030. * @param buffer Buffer to bind.
  31031. * @param name Name of the uniform variable to bind to.
  31032. */
  31033. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31034. /**
  31035. * Binds block to a uniform.
  31036. * @param blockName Name of the block to bind.
  31037. * @param index Index to bind.
  31038. */
  31039. bindUniformBlock(blockName: string, index: number): void;
  31040. /**
  31041. * Sets an interger value on a uniform variable.
  31042. * @param uniformName Name of the variable.
  31043. * @param value Value to be set.
  31044. * @returns this effect.
  31045. */
  31046. setInt(uniformName: string, value: number): Effect;
  31047. /**
  31048. * Sets an int array on a uniform variable.
  31049. * @param uniformName Name of the variable.
  31050. * @param array array to be set.
  31051. * @returns this effect.
  31052. */
  31053. setIntArray(uniformName: string, array: Int32Array): Effect;
  31054. /**
  31055. * 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)
  31056. * @param uniformName Name of the variable.
  31057. * @param array array to be set.
  31058. * @returns this effect.
  31059. */
  31060. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31061. /**
  31062. * 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)
  31063. * @param uniformName Name of the variable.
  31064. * @param array array to be set.
  31065. * @returns this effect.
  31066. */
  31067. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31068. /**
  31069. * 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)
  31070. * @param uniformName Name of the variable.
  31071. * @param array array to be set.
  31072. * @returns this effect.
  31073. */
  31074. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31075. /**
  31076. * Sets an float array on a uniform variable.
  31077. * @param uniformName Name of the variable.
  31078. * @param array array to be set.
  31079. * @returns this effect.
  31080. */
  31081. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31082. /**
  31083. * 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)
  31084. * @param uniformName Name of the variable.
  31085. * @param array array to be set.
  31086. * @returns this effect.
  31087. */
  31088. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31089. /**
  31090. * 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)
  31091. * @param uniformName Name of the variable.
  31092. * @param array array to be set.
  31093. * @returns this effect.
  31094. */
  31095. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31096. /**
  31097. * 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)
  31098. * @param uniformName Name of the variable.
  31099. * @param array array to be set.
  31100. * @returns this effect.
  31101. */
  31102. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31103. /**
  31104. * Sets an array on a uniform variable.
  31105. * @param uniformName Name of the variable.
  31106. * @param array array to be set.
  31107. * @returns this effect.
  31108. */
  31109. setArray(uniformName: string, array: number[]): Effect;
  31110. /**
  31111. * 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)
  31112. * @param uniformName Name of the variable.
  31113. * @param array array to be set.
  31114. * @returns this effect.
  31115. */
  31116. setArray2(uniformName: string, array: number[]): Effect;
  31117. /**
  31118. * 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)
  31119. * @param uniformName Name of the variable.
  31120. * @param array array to be set.
  31121. * @returns this effect.
  31122. */
  31123. setArray3(uniformName: string, array: number[]): Effect;
  31124. /**
  31125. * 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)
  31126. * @param uniformName Name of the variable.
  31127. * @param array array to be set.
  31128. * @returns this effect.
  31129. */
  31130. setArray4(uniformName: string, array: number[]): Effect;
  31131. /**
  31132. * Sets matrices on a uniform variable.
  31133. * @param uniformName Name of the variable.
  31134. * @param matrices matrices to be set.
  31135. * @returns this effect.
  31136. */
  31137. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31138. /**
  31139. * Sets matrix on a uniform variable.
  31140. * @param uniformName Name of the variable.
  31141. * @param matrix matrix to be set.
  31142. * @returns this effect.
  31143. */
  31144. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31145. /**
  31146. * 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)
  31147. * @param uniformName Name of the variable.
  31148. * @param matrix matrix to be set.
  31149. * @returns this effect.
  31150. */
  31151. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31152. /**
  31153. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31154. * @param uniformName Name of the variable.
  31155. * @param matrix matrix to be set.
  31156. * @returns this effect.
  31157. */
  31158. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31159. /**
  31160. * Sets a float on a uniform variable.
  31161. * @param uniformName Name of the variable.
  31162. * @param value value to be set.
  31163. * @returns this effect.
  31164. */
  31165. setFloat(uniformName: string, value: number): Effect;
  31166. /**
  31167. * Sets a boolean on a uniform variable.
  31168. * @param uniformName Name of the variable.
  31169. * @param bool value to be set.
  31170. * @returns this effect.
  31171. */
  31172. setBool(uniformName: string, bool: boolean): Effect;
  31173. /**
  31174. * Sets a Vector2 on a uniform variable.
  31175. * @param uniformName Name of the variable.
  31176. * @param vector2 vector2 to be set.
  31177. * @returns this effect.
  31178. */
  31179. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31180. /**
  31181. * Sets a float2 on a uniform variable.
  31182. * @param uniformName Name of the variable.
  31183. * @param x First float in float2.
  31184. * @param y Second float in float2.
  31185. * @returns this effect.
  31186. */
  31187. setFloat2(uniformName: string, x: number, y: number): Effect;
  31188. /**
  31189. * Sets a Vector3 on a uniform variable.
  31190. * @param uniformName Name of the variable.
  31191. * @param vector3 Value to be set.
  31192. * @returns this effect.
  31193. */
  31194. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31195. /**
  31196. * Sets a float3 on a uniform variable.
  31197. * @param uniformName Name of the variable.
  31198. * @param x First float in float3.
  31199. * @param y Second float in float3.
  31200. * @param z Third float in float3.
  31201. * @returns this effect.
  31202. */
  31203. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31204. /**
  31205. * Sets a Vector4 on a uniform variable.
  31206. * @param uniformName Name of the variable.
  31207. * @param vector4 Value to be set.
  31208. * @returns this effect.
  31209. */
  31210. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31211. /**
  31212. * Sets a float4 on a uniform variable.
  31213. * @param uniformName Name of the variable.
  31214. * @param x First float in float4.
  31215. * @param y Second float in float4.
  31216. * @param z Third float in float4.
  31217. * @param w Fourth float in float4.
  31218. * @returns this effect.
  31219. */
  31220. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31221. /**
  31222. * Sets a Color3 on a uniform variable.
  31223. * @param uniformName Name of the variable.
  31224. * @param color3 Value to be set.
  31225. * @returns this effect.
  31226. */
  31227. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31228. /**
  31229. * Sets a Color4 on a uniform variable.
  31230. * @param uniformName Name of the variable.
  31231. * @param color3 Value to be set.
  31232. * @param alpha Alpha value to be set.
  31233. * @returns this effect.
  31234. */
  31235. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31236. /**
  31237. * Sets a Color4 on a uniform variable
  31238. * @param uniformName defines the name of the variable
  31239. * @param color4 defines the value to be set
  31240. * @returns this effect.
  31241. */
  31242. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31243. /** Release all associated resources */
  31244. dispose(): void;
  31245. /**
  31246. * This function will add a new shader to the shader store
  31247. * @param name the name of the shader
  31248. * @param pixelShader optional pixel shader content
  31249. * @param vertexShader optional vertex shader content
  31250. */
  31251. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31252. /**
  31253. * Store of each shader (The can be looked up using effect.key)
  31254. */
  31255. static ShadersStore: {
  31256. [key: string]: string;
  31257. };
  31258. /**
  31259. * Store of each included file for a shader (The can be looked up using effect.key)
  31260. */
  31261. static IncludesShadersStore: {
  31262. [key: string]: string;
  31263. };
  31264. /**
  31265. * Resets the cache of effects.
  31266. */
  31267. static ResetCache(): void;
  31268. }
  31269. }
  31270. declare module "babylonjs/Engines/engineCapabilities" {
  31271. /**
  31272. * Interface used to describe the capabilities of the engine relatively to the current browser
  31273. */
  31274. export interface EngineCapabilities {
  31275. /** Maximum textures units per fragment shader */
  31276. maxTexturesImageUnits: number;
  31277. /** Maximum texture units per vertex shader */
  31278. maxVertexTextureImageUnits: number;
  31279. /** Maximum textures units in the entire pipeline */
  31280. maxCombinedTexturesImageUnits: number;
  31281. /** Maximum texture size */
  31282. maxTextureSize: number;
  31283. /** Maximum texture samples */
  31284. maxSamples?: number;
  31285. /** Maximum cube texture size */
  31286. maxCubemapTextureSize: number;
  31287. /** Maximum render texture size */
  31288. maxRenderTextureSize: number;
  31289. /** Maximum number of vertex attributes */
  31290. maxVertexAttribs: number;
  31291. /** Maximum number of varyings */
  31292. maxVaryingVectors: number;
  31293. /** Maximum number of uniforms per vertex shader */
  31294. maxVertexUniformVectors: number;
  31295. /** Maximum number of uniforms per fragment shader */
  31296. maxFragmentUniformVectors: number;
  31297. /** Defines if standard derivates (dx/dy) are supported */
  31298. standardDerivatives: boolean;
  31299. /** Defines if s3tc texture compression is supported */
  31300. s3tc?: WEBGL_compressed_texture_s3tc;
  31301. /** Defines if pvrtc texture compression is supported */
  31302. pvrtc: any;
  31303. /** Defines if etc1 texture compression is supported */
  31304. etc1: any;
  31305. /** Defines if etc2 texture compression is supported */
  31306. etc2: any;
  31307. /** Defines if astc texture compression is supported */
  31308. astc: any;
  31309. /** Defines if float textures are supported */
  31310. textureFloat: boolean;
  31311. /** Defines if vertex array objects are supported */
  31312. vertexArrayObject: boolean;
  31313. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31314. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31315. /** Gets the maximum level of anisotropy supported */
  31316. maxAnisotropy: number;
  31317. /** Defines if instancing is supported */
  31318. instancedArrays: boolean;
  31319. /** Defines if 32 bits indices are supported */
  31320. uintIndices: boolean;
  31321. /** Defines if high precision shaders are supported */
  31322. highPrecisionShaderSupported: boolean;
  31323. /** Defines if depth reading in the fragment shader is supported */
  31324. fragmentDepthSupported: boolean;
  31325. /** Defines if float texture linear filtering is supported*/
  31326. textureFloatLinearFiltering: boolean;
  31327. /** Defines if rendering to float textures is supported */
  31328. textureFloatRender: boolean;
  31329. /** Defines if half float textures are supported*/
  31330. textureHalfFloat: boolean;
  31331. /** Defines if half float texture linear filtering is supported*/
  31332. textureHalfFloatLinearFiltering: boolean;
  31333. /** Defines if rendering to half float textures is supported */
  31334. textureHalfFloatRender: boolean;
  31335. /** Defines if textureLOD shader command is supported */
  31336. textureLOD: boolean;
  31337. /** Defines if draw buffers extension is supported */
  31338. drawBuffersExtension: boolean;
  31339. /** Defines if depth textures are supported */
  31340. depthTextureExtension: boolean;
  31341. /** Defines if float color buffer are supported */
  31342. colorBufferFloat: boolean;
  31343. /** Gets disjoint timer query extension (null if not supported) */
  31344. timerQuery?: EXT_disjoint_timer_query;
  31345. /** Defines if timestamp can be used with timer query */
  31346. canUseTimestampForTimerQuery: boolean;
  31347. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31348. multiview?: any;
  31349. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31350. oculusMultiview?: any;
  31351. /** Function used to let the system compiles shaders in background */
  31352. parallelShaderCompile?: {
  31353. COMPLETION_STATUS_KHR: number;
  31354. };
  31355. /** Max number of texture samples for MSAA */
  31356. maxMSAASamples: number;
  31357. /** Defines if the blend min max extension is supported */
  31358. blendMinMax: boolean;
  31359. }
  31360. }
  31361. declare module "babylonjs/States/depthCullingState" {
  31362. import { Nullable } from "babylonjs/types";
  31363. /**
  31364. * @hidden
  31365. **/
  31366. export class DepthCullingState {
  31367. private _isDepthTestDirty;
  31368. private _isDepthMaskDirty;
  31369. private _isDepthFuncDirty;
  31370. private _isCullFaceDirty;
  31371. private _isCullDirty;
  31372. private _isZOffsetDirty;
  31373. private _isFrontFaceDirty;
  31374. private _depthTest;
  31375. private _depthMask;
  31376. private _depthFunc;
  31377. private _cull;
  31378. private _cullFace;
  31379. private _zOffset;
  31380. private _frontFace;
  31381. /**
  31382. * Initializes the state.
  31383. */
  31384. constructor();
  31385. get isDirty(): boolean;
  31386. get zOffset(): number;
  31387. set zOffset(value: number);
  31388. get cullFace(): Nullable<number>;
  31389. set cullFace(value: Nullable<number>);
  31390. get cull(): Nullable<boolean>;
  31391. set cull(value: Nullable<boolean>);
  31392. get depthFunc(): Nullable<number>;
  31393. set depthFunc(value: Nullable<number>);
  31394. get depthMask(): boolean;
  31395. set depthMask(value: boolean);
  31396. get depthTest(): boolean;
  31397. set depthTest(value: boolean);
  31398. get frontFace(): Nullable<number>;
  31399. set frontFace(value: Nullable<number>);
  31400. reset(): void;
  31401. apply(gl: WebGLRenderingContext): void;
  31402. }
  31403. }
  31404. declare module "babylonjs/States/stencilState" {
  31405. /**
  31406. * @hidden
  31407. **/
  31408. export class StencilState {
  31409. /** 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 */
  31410. static readonly ALWAYS: number;
  31411. /** Passed to stencilOperation to specify that stencil value must be kept */
  31412. static readonly KEEP: number;
  31413. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31414. static readonly REPLACE: number;
  31415. private _isStencilTestDirty;
  31416. private _isStencilMaskDirty;
  31417. private _isStencilFuncDirty;
  31418. private _isStencilOpDirty;
  31419. private _stencilTest;
  31420. private _stencilMask;
  31421. private _stencilFunc;
  31422. private _stencilFuncRef;
  31423. private _stencilFuncMask;
  31424. private _stencilOpStencilFail;
  31425. private _stencilOpDepthFail;
  31426. private _stencilOpStencilDepthPass;
  31427. get isDirty(): boolean;
  31428. get stencilFunc(): number;
  31429. set stencilFunc(value: number);
  31430. get stencilFuncRef(): number;
  31431. set stencilFuncRef(value: number);
  31432. get stencilFuncMask(): number;
  31433. set stencilFuncMask(value: number);
  31434. get stencilOpStencilFail(): number;
  31435. set stencilOpStencilFail(value: number);
  31436. get stencilOpDepthFail(): number;
  31437. set stencilOpDepthFail(value: number);
  31438. get stencilOpStencilDepthPass(): number;
  31439. set stencilOpStencilDepthPass(value: number);
  31440. get stencilMask(): number;
  31441. set stencilMask(value: number);
  31442. get stencilTest(): boolean;
  31443. set stencilTest(value: boolean);
  31444. constructor();
  31445. reset(): void;
  31446. apply(gl: WebGLRenderingContext): void;
  31447. }
  31448. }
  31449. declare module "babylonjs/States/alphaCullingState" {
  31450. /**
  31451. * @hidden
  31452. **/
  31453. export class AlphaState {
  31454. private _isAlphaBlendDirty;
  31455. private _isBlendFunctionParametersDirty;
  31456. private _isBlendEquationParametersDirty;
  31457. private _isBlendConstantsDirty;
  31458. private _alphaBlend;
  31459. private _blendFunctionParameters;
  31460. private _blendEquationParameters;
  31461. private _blendConstants;
  31462. /**
  31463. * Initializes the state.
  31464. */
  31465. constructor();
  31466. get isDirty(): boolean;
  31467. get alphaBlend(): boolean;
  31468. set alphaBlend(value: boolean);
  31469. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31470. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31471. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31472. reset(): void;
  31473. apply(gl: WebGLRenderingContext): void;
  31474. }
  31475. }
  31476. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31477. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31478. /** @hidden */
  31479. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31480. attributeProcessor(attribute: string): string;
  31481. varyingProcessor(varying: string, isFragment: boolean): string;
  31482. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31483. }
  31484. }
  31485. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31486. /**
  31487. * Interface for attribute information associated with buffer instanciation
  31488. */
  31489. export interface InstancingAttributeInfo {
  31490. /**
  31491. * Name of the GLSL attribute
  31492. * if attribute index is not specified, this is used to retrieve the index from the effect
  31493. */
  31494. attributeName: string;
  31495. /**
  31496. * Index/offset of the attribute in the vertex shader
  31497. * if not specified, this will be computes from the name.
  31498. */
  31499. index?: number;
  31500. /**
  31501. * size of the attribute, 1, 2, 3 or 4
  31502. */
  31503. attributeSize: number;
  31504. /**
  31505. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31506. */
  31507. offset: number;
  31508. /**
  31509. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31510. * default to 1
  31511. */
  31512. divisor?: number;
  31513. /**
  31514. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31515. * default is FLOAT
  31516. */
  31517. attributeType?: number;
  31518. /**
  31519. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31520. */
  31521. normalized?: boolean;
  31522. }
  31523. }
  31524. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31525. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31526. import { Nullable } from "babylonjs/types";
  31527. module "babylonjs/Engines/thinEngine" {
  31528. interface ThinEngine {
  31529. /**
  31530. * Update a video texture
  31531. * @param texture defines the texture to update
  31532. * @param video defines the video element to use
  31533. * @param invertY defines if data must be stored with Y axis inverted
  31534. */
  31535. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31536. }
  31537. }
  31538. }
  31539. declare module "babylonjs/Materials/Textures/videoTexture" {
  31540. import { Observable } from "babylonjs/Misc/observable";
  31541. import { Nullable } from "babylonjs/types";
  31542. import { Scene } from "babylonjs/scene";
  31543. import { Texture } from "babylonjs/Materials/Textures/texture";
  31544. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31545. /**
  31546. * Settings for finer control over video usage
  31547. */
  31548. export interface VideoTextureSettings {
  31549. /**
  31550. * Applies `autoplay` to video, if specified
  31551. */
  31552. autoPlay?: boolean;
  31553. /**
  31554. * Applies `loop` to video, if specified
  31555. */
  31556. loop?: boolean;
  31557. /**
  31558. * Automatically updates internal texture from video at every frame in the render loop
  31559. */
  31560. autoUpdateTexture: boolean;
  31561. /**
  31562. * Image src displayed during the video loading or until the user interacts with the video.
  31563. */
  31564. poster?: string;
  31565. }
  31566. /**
  31567. * If you want to display a video in your scene, this is the special texture for that.
  31568. * This special texture works similar to other textures, with the exception of a few parameters.
  31569. * @see https://doc.babylonjs.com/how_to/video_texture
  31570. */
  31571. export class VideoTexture extends Texture {
  31572. /**
  31573. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31574. */
  31575. readonly autoUpdateTexture: boolean;
  31576. /**
  31577. * The video instance used by the texture internally
  31578. */
  31579. readonly video: HTMLVideoElement;
  31580. private _onUserActionRequestedObservable;
  31581. /**
  31582. * Event triggerd when a dom action is required by the user to play the video.
  31583. * This happens due to recent changes in browser policies preventing video to auto start.
  31584. */
  31585. get onUserActionRequestedObservable(): Observable<Texture>;
  31586. private _generateMipMaps;
  31587. private _engine;
  31588. private _stillImageCaptured;
  31589. private _displayingPosterTexture;
  31590. private _settings;
  31591. private _createInternalTextureOnEvent;
  31592. private _frameId;
  31593. private _currentSrc;
  31594. /**
  31595. * Creates a video texture.
  31596. * If you want to display a video in your scene, this is the special texture for that.
  31597. * This special texture works similar to other textures, with the exception of a few parameters.
  31598. * @see https://doc.babylonjs.com/how_to/video_texture
  31599. * @param name optional name, will detect from video source, if not defined
  31600. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31601. * @param scene is obviously the current scene.
  31602. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31603. * @param invertY is false by default but can be used to invert video on Y axis
  31604. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31605. * @param settings allows finer control over video usage
  31606. */
  31607. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31608. private _getName;
  31609. private _getVideo;
  31610. private _createInternalTexture;
  31611. private reset;
  31612. /**
  31613. * @hidden Internal method to initiate `update`.
  31614. */
  31615. _rebuild(): void;
  31616. /**
  31617. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31618. */
  31619. update(): void;
  31620. /**
  31621. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31622. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31623. */
  31624. updateTexture(isVisible: boolean): void;
  31625. protected _updateInternalTexture: () => void;
  31626. /**
  31627. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31628. * @param url New url.
  31629. */
  31630. updateURL(url: string): void;
  31631. /**
  31632. * Clones the texture.
  31633. * @returns the cloned texture
  31634. */
  31635. clone(): VideoTexture;
  31636. /**
  31637. * Dispose the texture and release its associated resources.
  31638. */
  31639. dispose(): void;
  31640. /**
  31641. * Creates a video texture straight from a stream.
  31642. * @param scene Define the scene the texture should be created in
  31643. * @param stream Define the stream the texture should be created from
  31644. * @returns The created video texture as a promise
  31645. */
  31646. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31647. /**
  31648. * Creates a video texture straight from your WebCam video feed.
  31649. * @param scene Define the scene the texture should be created in
  31650. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31651. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31652. * @returns The created video texture as a promise
  31653. */
  31654. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31655. minWidth: number;
  31656. maxWidth: number;
  31657. minHeight: number;
  31658. maxHeight: number;
  31659. deviceId: string;
  31660. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31661. /**
  31662. * Creates a video texture straight from your WebCam video feed.
  31663. * @param scene Define the scene the texture should be created in
  31664. * @param onReady Define a callback to triggered once the texture will be ready
  31665. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31666. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31667. */
  31668. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31669. minWidth: number;
  31670. maxWidth: number;
  31671. minHeight: number;
  31672. maxHeight: number;
  31673. deviceId: string;
  31674. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31675. }
  31676. }
  31677. declare module "babylonjs/Engines/thinEngine" {
  31678. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31679. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31680. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31681. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31682. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31683. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31684. import { Observable } from "babylonjs/Misc/observable";
  31685. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31686. import { StencilState } from "babylonjs/States/stencilState";
  31687. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31688. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31689. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31690. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31691. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31692. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31693. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31694. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31695. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31696. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31697. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31698. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31699. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31700. import { WebRequest } from "babylonjs/Misc/webRequest";
  31701. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31702. /**
  31703. * Defines the interface used by objects working like Scene
  31704. * @hidden
  31705. */
  31706. interface ISceneLike {
  31707. _addPendingData(data: any): void;
  31708. _removePendingData(data: any): void;
  31709. offlineProvider: IOfflineProvider;
  31710. }
  31711. /** Interface defining initialization parameters for Engine class */
  31712. export interface EngineOptions extends WebGLContextAttributes {
  31713. /**
  31714. * Defines if the engine should no exceed a specified device ratio
  31715. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31716. */
  31717. limitDeviceRatio?: number;
  31718. /**
  31719. * Defines if webvr should be enabled automatically
  31720. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31721. */
  31722. autoEnableWebVR?: boolean;
  31723. /**
  31724. * Defines if webgl2 should be turned off even if supported
  31725. * @see http://doc.babylonjs.com/features/webgl2
  31726. */
  31727. disableWebGL2Support?: boolean;
  31728. /**
  31729. * Defines if webaudio should be initialized as well
  31730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31731. */
  31732. audioEngine?: boolean;
  31733. /**
  31734. * Defines if animations should run using a deterministic lock step
  31735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31736. */
  31737. deterministicLockstep?: boolean;
  31738. /** Defines the maximum steps to use with deterministic lock step mode */
  31739. lockstepMaxSteps?: number;
  31740. /** Defines the seconds between each deterministic lock step */
  31741. timeStep?: number;
  31742. /**
  31743. * Defines that engine should ignore context lost events
  31744. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31745. */
  31746. doNotHandleContextLost?: boolean;
  31747. /**
  31748. * Defines that engine should ignore modifying touch action attribute and style
  31749. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31750. */
  31751. doNotHandleTouchAction?: boolean;
  31752. /**
  31753. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31754. */
  31755. useHighPrecisionFloats?: boolean;
  31756. }
  31757. /**
  31758. * The base engine class (root of all engines)
  31759. */
  31760. export class ThinEngine {
  31761. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31762. static ExceptionList: ({
  31763. key: string;
  31764. capture: string;
  31765. captureConstraint: number;
  31766. targets: string[];
  31767. } | {
  31768. key: string;
  31769. capture: null;
  31770. captureConstraint: null;
  31771. targets: string[];
  31772. })[];
  31773. /** @hidden */
  31774. static _TextureLoaders: IInternalTextureLoader[];
  31775. /**
  31776. * Returns the current npm package of the sdk
  31777. */
  31778. static get NpmPackage(): string;
  31779. /**
  31780. * Returns the current version of the framework
  31781. */
  31782. static get Version(): string;
  31783. /**
  31784. * Returns a string describing the current engine
  31785. */
  31786. get description(): string;
  31787. /**
  31788. * Gets or sets the epsilon value used by collision engine
  31789. */
  31790. static CollisionsEpsilon: number;
  31791. /**
  31792. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31793. */
  31794. static get ShadersRepository(): string;
  31795. static set ShadersRepository(value: string);
  31796. /**
  31797. * Gets or sets the textures that the engine should not attempt to load as compressed
  31798. */
  31799. protected _excludedCompressedTextures: string[];
  31800. /**
  31801. * Filters the compressed texture formats to only include
  31802. * files that are not included in the skippable list
  31803. *
  31804. * @param url the current extension
  31805. * @param textureFormatInUse the current compressed texture format
  31806. * @returns "format" string
  31807. */
  31808. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31809. /** @hidden */
  31810. _shaderProcessor: IShaderProcessor;
  31811. /**
  31812. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31813. */
  31814. forcePOTTextures: boolean;
  31815. /**
  31816. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31817. */
  31818. isFullscreen: boolean;
  31819. /**
  31820. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31821. */
  31822. cullBackFaces: boolean;
  31823. /**
  31824. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31825. */
  31826. renderEvenInBackground: boolean;
  31827. /**
  31828. * Gets or sets a boolean indicating that cache can be kept between frames
  31829. */
  31830. preventCacheWipeBetweenFrames: boolean;
  31831. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31832. validateShaderPrograms: boolean;
  31833. /**
  31834. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31835. * This can provide greater z depth for distant objects.
  31836. */
  31837. useReverseDepthBuffer: boolean;
  31838. /**
  31839. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31840. */
  31841. disableUniformBuffers: boolean;
  31842. /** @hidden */
  31843. _uniformBuffers: UniformBuffer[];
  31844. /**
  31845. * Gets a boolean indicating that the engine supports uniform buffers
  31846. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31847. */
  31848. get supportsUniformBuffers(): boolean;
  31849. /** @hidden */
  31850. _gl: WebGLRenderingContext;
  31851. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31852. protected _windowIsBackground: boolean;
  31853. protected _webGLVersion: number;
  31854. protected _creationOptions: EngineOptions;
  31855. protected _highPrecisionShadersAllowed: boolean;
  31856. /** @hidden */
  31857. get _shouldUseHighPrecisionShader(): boolean;
  31858. /**
  31859. * Gets a boolean indicating that only power of 2 textures are supported
  31860. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31861. */
  31862. get needPOTTextures(): boolean;
  31863. /** @hidden */
  31864. _badOS: boolean;
  31865. /** @hidden */
  31866. _badDesktopOS: boolean;
  31867. private _hardwareScalingLevel;
  31868. /** @hidden */
  31869. _caps: EngineCapabilities;
  31870. private _isStencilEnable;
  31871. private _glVersion;
  31872. private _glRenderer;
  31873. private _glVendor;
  31874. /** @hidden */
  31875. _videoTextureSupported: boolean;
  31876. protected _renderingQueueLaunched: boolean;
  31877. protected _activeRenderLoops: (() => void)[];
  31878. /**
  31879. * Observable signaled when a context lost event is raised
  31880. */
  31881. onContextLostObservable: Observable<ThinEngine>;
  31882. /**
  31883. * Observable signaled when a context restored event is raised
  31884. */
  31885. onContextRestoredObservable: Observable<ThinEngine>;
  31886. private _onContextLost;
  31887. private _onContextRestored;
  31888. protected _contextWasLost: boolean;
  31889. /** @hidden */
  31890. _doNotHandleContextLost: boolean;
  31891. /**
  31892. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31894. */
  31895. get doNotHandleContextLost(): boolean;
  31896. set doNotHandleContextLost(value: boolean);
  31897. /**
  31898. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31899. */
  31900. disableVertexArrayObjects: boolean;
  31901. /** @hidden */
  31902. protected _colorWrite: boolean;
  31903. /** @hidden */
  31904. protected _colorWriteChanged: boolean;
  31905. /** @hidden */
  31906. protected _depthCullingState: DepthCullingState;
  31907. /** @hidden */
  31908. protected _stencilState: StencilState;
  31909. /** @hidden */
  31910. _alphaState: AlphaState;
  31911. /** @hidden */
  31912. _alphaMode: number;
  31913. /** @hidden */
  31914. _alphaEquation: number;
  31915. /** @hidden */
  31916. _internalTexturesCache: InternalTexture[];
  31917. /** @hidden */
  31918. protected _activeChannel: number;
  31919. private _currentTextureChannel;
  31920. /** @hidden */
  31921. protected _boundTexturesCache: {
  31922. [key: string]: Nullable<InternalTexture>;
  31923. };
  31924. /** @hidden */
  31925. protected _currentEffect: Nullable<Effect>;
  31926. /** @hidden */
  31927. protected _currentProgram: Nullable<WebGLProgram>;
  31928. private _compiledEffects;
  31929. private _vertexAttribArraysEnabled;
  31930. /** @hidden */
  31931. protected _cachedViewport: Nullable<IViewportLike>;
  31932. private _cachedVertexArrayObject;
  31933. /** @hidden */
  31934. protected _cachedVertexBuffers: any;
  31935. /** @hidden */
  31936. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31937. /** @hidden */
  31938. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31939. /** @hidden */
  31940. _currentRenderTarget: Nullable<InternalTexture>;
  31941. private _uintIndicesCurrentlySet;
  31942. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31943. /** @hidden */
  31944. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31945. private _currentBufferPointers;
  31946. private _currentInstanceLocations;
  31947. private _currentInstanceBuffers;
  31948. private _textureUnits;
  31949. /** @hidden */
  31950. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31951. /** @hidden */
  31952. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31953. /** @hidden */
  31954. _boundRenderFunction: any;
  31955. private _vaoRecordInProgress;
  31956. private _mustWipeVertexAttributes;
  31957. private _emptyTexture;
  31958. private _emptyCubeTexture;
  31959. private _emptyTexture3D;
  31960. private _emptyTexture2DArray;
  31961. /** @hidden */
  31962. _frameHandler: number;
  31963. private _nextFreeTextureSlots;
  31964. private _maxSimultaneousTextures;
  31965. private _activeRequests;
  31966. protected _texturesSupported: string[];
  31967. /** @hidden */
  31968. _textureFormatInUse: Nullable<string>;
  31969. protected get _supportsHardwareTextureRescaling(): boolean;
  31970. /**
  31971. * Gets the list of texture formats supported
  31972. */
  31973. get texturesSupported(): Array<string>;
  31974. /**
  31975. * Gets the list of texture formats in use
  31976. */
  31977. get textureFormatInUse(): Nullable<string>;
  31978. /**
  31979. * Gets the current viewport
  31980. */
  31981. get currentViewport(): Nullable<IViewportLike>;
  31982. /**
  31983. * Gets the default empty texture
  31984. */
  31985. get emptyTexture(): InternalTexture;
  31986. /**
  31987. * Gets the default empty 3D texture
  31988. */
  31989. get emptyTexture3D(): InternalTexture;
  31990. /**
  31991. * Gets the default empty 2D array texture
  31992. */
  31993. get emptyTexture2DArray(): InternalTexture;
  31994. /**
  31995. * Gets the default empty cube texture
  31996. */
  31997. get emptyCubeTexture(): InternalTexture;
  31998. /**
  31999. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32000. */
  32001. readonly premultipliedAlpha: boolean;
  32002. /**
  32003. * Observable event triggered before each texture is initialized
  32004. */
  32005. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32006. /**
  32007. * Creates a new engine
  32008. * @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
  32009. * @param antialias defines enable antialiasing (default: false)
  32010. * @param options defines further options to be sent to the getContext() function
  32011. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32012. */
  32013. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32014. private _rebuildInternalTextures;
  32015. private _rebuildEffects;
  32016. /**
  32017. * Gets a boolean indicating if all created effects are ready
  32018. * @returns true if all effects are ready
  32019. */
  32020. areAllEffectsReady(): boolean;
  32021. protected _rebuildBuffers(): void;
  32022. private _initGLContext;
  32023. /**
  32024. * Gets version of the current webGL context
  32025. */
  32026. get webGLVersion(): number;
  32027. /**
  32028. * Gets a string idenfifying the name of the class
  32029. * @returns "Engine" string
  32030. */
  32031. getClassName(): string;
  32032. /**
  32033. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32034. */
  32035. get isStencilEnable(): boolean;
  32036. /** @hidden */
  32037. _prepareWorkingCanvas(): void;
  32038. /**
  32039. * Reset the texture cache to empty state
  32040. */
  32041. resetTextureCache(): void;
  32042. /**
  32043. * Gets an object containing information about the current webGL context
  32044. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32045. */
  32046. getGlInfo(): {
  32047. vendor: string;
  32048. renderer: string;
  32049. version: string;
  32050. };
  32051. /**
  32052. * Defines the hardware scaling level.
  32053. * By default the hardware scaling level is computed from the window device ratio.
  32054. * 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.
  32055. * @param level defines the level to use
  32056. */
  32057. setHardwareScalingLevel(level: number): void;
  32058. /**
  32059. * Gets the current hardware scaling level.
  32060. * By default the hardware scaling level is computed from the window device ratio.
  32061. * 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.
  32062. * @returns a number indicating the current hardware scaling level
  32063. */
  32064. getHardwareScalingLevel(): number;
  32065. /**
  32066. * Gets the list of loaded textures
  32067. * @returns an array containing all loaded textures
  32068. */
  32069. getLoadedTexturesCache(): InternalTexture[];
  32070. /**
  32071. * Gets the object containing all engine capabilities
  32072. * @returns the EngineCapabilities object
  32073. */
  32074. getCaps(): EngineCapabilities;
  32075. /**
  32076. * stop executing a render loop function and remove it from the execution array
  32077. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32078. */
  32079. stopRenderLoop(renderFunction?: () => void): void;
  32080. /** @hidden */
  32081. _renderLoop(): void;
  32082. /**
  32083. * Gets the HTML canvas attached with the current webGL context
  32084. * @returns a HTML canvas
  32085. */
  32086. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32087. /**
  32088. * Gets host window
  32089. * @returns the host window object
  32090. */
  32091. getHostWindow(): Nullable<Window>;
  32092. /**
  32093. * Gets the current render width
  32094. * @param useScreen defines if screen size must be used (or the current render target if any)
  32095. * @returns a number defining the current render width
  32096. */
  32097. getRenderWidth(useScreen?: boolean): number;
  32098. /**
  32099. * Gets the current render height
  32100. * @param useScreen defines if screen size must be used (or the current render target if any)
  32101. * @returns a number defining the current render height
  32102. */
  32103. getRenderHeight(useScreen?: boolean): number;
  32104. /**
  32105. * Can be used to override the current requestAnimationFrame requester.
  32106. * @hidden
  32107. */
  32108. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32109. /**
  32110. * Register and execute a render loop. The engine can have more than one render function
  32111. * @param renderFunction defines the function to continuously execute
  32112. */
  32113. runRenderLoop(renderFunction: () => void): void;
  32114. /**
  32115. * Clear the current render buffer or the current render target (if any is set up)
  32116. * @param color defines the color to use
  32117. * @param backBuffer defines if the back buffer must be cleared
  32118. * @param depth defines if the depth buffer must be cleared
  32119. * @param stencil defines if the stencil buffer must be cleared
  32120. */
  32121. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32122. private _viewportCached;
  32123. /** @hidden */
  32124. _viewport(x: number, y: number, width: number, height: number): void;
  32125. /**
  32126. * Set the WebGL's viewport
  32127. * @param viewport defines the viewport element to be used
  32128. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32129. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32130. */
  32131. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32132. /**
  32133. * Begin a new frame
  32134. */
  32135. beginFrame(): void;
  32136. /**
  32137. * Enf the current frame
  32138. */
  32139. endFrame(): void;
  32140. /**
  32141. * Resize the view according to the canvas' size
  32142. */
  32143. resize(): void;
  32144. /**
  32145. * Force a specific size of the canvas
  32146. * @param width defines the new canvas' width
  32147. * @param height defines the new canvas' height
  32148. */
  32149. setSize(width: number, height: number): void;
  32150. /**
  32151. * Binds the frame buffer to the specified texture.
  32152. * @param texture The texture to render to or null for the default canvas
  32153. * @param faceIndex The face of the texture to render to in case of cube texture
  32154. * @param requiredWidth The width of the target to render to
  32155. * @param requiredHeight The height of the target to render to
  32156. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32157. * @param lodLevel defines the lod level to bind to the frame buffer
  32158. * @param layer defines the 2d array index to bind to frame buffer to
  32159. */
  32160. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32161. /** @hidden */
  32162. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32163. /**
  32164. * Unbind the current render target texture from the webGL context
  32165. * @param texture defines the render target texture to unbind
  32166. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32167. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32168. */
  32169. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32170. /**
  32171. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32172. */
  32173. flushFramebuffer(): void;
  32174. /**
  32175. * Unbind the current render target and bind the default framebuffer
  32176. */
  32177. restoreDefaultFramebuffer(): void;
  32178. /** @hidden */
  32179. protected _resetVertexBufferBinding(): void;
  32180. /**
  32181. * Creates a vertex buffer
  32182. * @param data the data for the vertex buffer
  32183. * @returns the new WebGL static buffer
  32184. */
  32185. createVertexBuffer(data: DataArray): DataBuffer;
  32186. private _createVertexBuffer;
  32187. /**
  32188. * Creates a dynamic vertex buffer
  32189. * @param data the data for the dynamic vertex buffer
  32190. * @returns the new WebGL dynamic buffer
  32191. */
  32192. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32193. protected _resetIndexBufferBinding(): void;
  32194. /**
  32195. * Creates a new index buffer
  32196. * @param indices defines the content of the index buffer
  32197. * @param updatable defines if the index buffer must be updatable
  32198. * @returns a new webGL buffer
  32199. */
  32200. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32201. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32202. /**
  32203. * Bind a webGL buffer to the webGL context
  32204. * @param buffer defines the buffer to bind
  32205. */
  32206. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32207. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32208. private bindBuffer;
  32209. /**
  32210. * update the bound buffer with the given data
  32211. * @param data defines the data to update
  32212. */
  32213. updateArrayBuffer(data: Float32Array): void;
  32214. private _vertexAttribPointer;
  32215. /** @hidden */
  32216. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32217. private _bindVertexBuffersAttributes;
  32218. /**
  32219. * Records a vertex array object
  32220. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32221. * @param vertexBuffers defines the list of vertex buffers to store
  32222. * @param indexBuffer defines the index buffer to store
  32223. * @param effect defines the effect to store
  32224. * @returns the new vertex array object
  32225. */
  32226. recordVertexArrayObject(vertexBuffers: {
  32227. [key: string]: VertexBuffer;
  32228. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32229. /**
  32230. * Bind a specific vertex array object
  32231. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32232. * @param vertexArrayObject defines the vertex array object to bind
  32233. * @param indexBuffer defines the index buffer to bind
  32234. */
  32235. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32236. /**
  32237. * Bind webGl buffers directly to the webGL context
  32238. * @param vertexBuffer defines the vertex buffer to bind
  32239. * @param indexBuffer defines the index buffer to bind
  32240. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32241. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32242. * @param effect defines the effect associated with the vertex buffer
  32243. */
  32244. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32245. private _unbindVertexArrayObject;
  32246. /**
  32247. * Bind a list of vertex buffers to the webGL context
  32248. * @param vertexBuffers defines the list of vertex buffers to bind
  32249. * @param indexBuffer defines the index buffer to bind
  32250. * @param effect defines the effect associated with the vertex buffers
  32251. */
  32252. bindBuffers(vertexBuffers: {
  32253. [key: string]: Nullable<VertexBuffer>;
  32254. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32255. /**
  32256. * Unbind all instance attributes
  32257. */
  32258. unbindInstanceAttributes(): void;
  32259. /**
  32260. * Release and free the memory of a vertex array object
  32261. * @param vao defines the vertex array object to delete
  32262. */
  32263. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32264. /** @hidden */
  32265. _releaseBuffer(buffer: DataBuffer): boolean;
  32266. protected _deleteBuffer(buffer: DataBuffer): void;
  32267. /**
  32268. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32269. * @param instancesBuffer defines the webGL buffer to update and bind
  32270. * @param data defines the data to store in the buffer
  32271. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32272. */
  32273. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32274. /**
  32275. * Bind the content of a webGL buffer used with instanciation
  32276. * @param instancesBuffer defines the webGL buffer to bind
  32277. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32278. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32279. */
  32280. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32281. /**
  32282. * Disable the instance attribute corresponding to the name in parameter
  32283. * @param name defines the name of the attribute to disable
  32284. */
  32285. disableInstanceAttributeByName(name: string): void;
  32286. /**
  32287. * Disable the instance attribute corresponding to the location in parameter
  32288. * @param attributeLocation defines the attribute location of the attribute to disable
  32289. */
  32290. disableInstanceAttribute(attributeLocation: number): void;
  32291. /**
  32292. * Disable the attribute corresponding to the location in parameter
  32293. * @param attributeLocation defines the attribute location of the attribute to disable
  32294. */
  32295. disableAttributeByIndex(attributeLocation: number): void;
  32296. /**
  32297. * Send a draw order
  32298. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32299. * @param indexStart defines the starting index
  32300. * @param indexCount defines the number of index to draw
  32301. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32302. */
  32303. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32304. /**
  32305. * Draw a list of points
  32306. * @param verticesStart defines the index of first vertex to draw
  32307. * @param verticesCount defines the count of vertices to draw
  32308. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32309. */
  32310. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32311. /**
  32312. * Draw a list of unindexed primitives
  32313. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32314. * @param verticesStart defines the index of first vertex to draw
  32315. * @param verticesCount defines the count of vertices to draw
  32316. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32317. */
  32318. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32319. /**
  32320. * Draw a list of indexed primitives
  32321. * @param fillMode defines the primitive to use
  32322. * @param indexStart defines the starting index
  32323. * @param indexCount defines the number of index to draw
  32324. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32325. */
  32326. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32327. /**
  32328. * Draw a list of unindexed primitives
  32329. * @param fillMode defines the primitive to use
  32330. * @param verticesStart defines the index of first vertex to draw
  32331. * @param verticesCount defines the count of vertices to draw
  32332. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32333. */
  32334. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32335. private _drawMode;
  32336. /** @hidden */
  32337. protected _reportDrawCall(): void;
  32338. /** @hidden */
  32339. _releaseEffect(effect: Effect): void;
  32340. /** @hidden */
  32341. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32342. /**
  32343. * Create a new effect (used to store vertex/fragment shaders)
  32344. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32345. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32346. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32347. * @param samplers defines an array of string used to represent textures
  32348. * @param defines defines the string containing the defines to use to compile the shaders
  32349. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32350. * @param onCompiled defines a function to call when the effect creation is successful
  32351. * @param onError defines a function to call when the effect creation has failed
  32352. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32353. * @returns the new Effect
  32354. */
  32355. 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;
  32356. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32357. private _compileShader;
  32358. private _compileRawShader;
  32359. /**
  32360. * Directly creates a webGL program
  32361. * @param pipelineContext defines the pipeline context to attach to
  32362. * @param vertexCode defines the vertex shader code to use
  32363. * @param fragmentCode defines the fragment shader code to use
  32364. * @param context defines the webGL context to use (if not set, the current one will be used)
  32365. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32366. * @returns the new webGL program
  32367. */
  32368. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32369. /**
  32370. * Creates a webGL program
  32371. * @param pipelineContext defines the pipeline context to attach to
  32372. * @param vertexCode defines the vertex shader code to use
  32373. * @param fragmentCode defines the fragment shader code to use
  32374. * @param defines defines the string containing the defines to use to compile the shaders
  32375. * @param context defines the webGL context to use (if not set, the current one will be used)
  32376. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32377. * @returns the new webGL program
  32378. */
  32379. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32380. /**
  32381. * Creates a new pipeline context
  32382. * @returns the new pipeline
  32383. */
  32384. createPipelineContext(): IPipelineContext;
  32385. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32386. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32387. /** @hidden */
  32388. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32389. /** @hidden */
  32390. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32391. /** @hidden */
  32392. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32393. /**
  32394. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32395. * @param pipelineContext defines the pipeline context to use
  32396. * @param uniformsNames defines the list of uniform names
  32397. * @returns an array of webGL uniform locations
  32398. */
  32399. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32400. /**
  32401. * Gets the lsit of active attributes for a given webGL program
  32402. * @param pipelineContext defines the pipeline context to use
  32403. * @param attributesNames defines the list of attribute names to get
  32404. * @returns an array of indices indicating the offset of each attribute
  32405. */
  32406. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32407. /**
  32408. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32409. * @param effect defines the effect to activate
  32410. */
  32411. enableEffect(effect: Nullable<Effect>): void;
  32412. /**
  32413. * Set the value of an uniform to a number (int)
  32414. * @param uniform defines the webGL uniform location where to store the value
  32415. * @param value defines the int number to store
  32416. */
  32417. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32418. /**
  32419. * Set the value of an uniform to an array of int32
  32420. * @param uniform defines the webGL uniform location where to store the value
  32421. * @param array defines the array of int32 to store
  32422. */
  32423. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32424. /**
  32425. * Set the value of an uniform to an array of int32 (stored as vec2)
  32426. * @param uniform defines the webGL uniform location where to store the value
  32427. * @param array defines the array of int32 to store
  32428. */
  32429. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32430. /**
  32431. * Set the value of an uniform to an array of int32 (stored as vec3)
  32432. * @param uniform defines the webGL uniform location where to store the value
  32433. * @param array defines the array of int32 to store
  32434. */
  32435. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32436. /**
  32437. * Set the value of an uniform to an array of int32 (stored as vec4)
  32438. * @param uniform defines the webGL uniform location where to store the value
  32439. * @param array defines the array of int32 to store
  32440. */
  32441. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32442. /**
  32443. * Set the value of an uniform to an array of number
  32444. * @param uniform defines the webGL uniform location where to store the value
  32445. * @param array defines the array of number to store
  32446. */
  32447. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32448. /**
  32449. * Set the value of an uniform to an array of number (stored as vec2)
  32450. * @param uniform defines the webGL uniform location where to store the value
  32451. * @param array defines the array of number to store
  32452. */
  32453. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32454. /**
  32455. * Set the value of an uniform to an array of number (stored as vec3)
  32456. * @param uniform defines the webGL uniform location where to store the value
  32457. * @param array defines the array of number to store
  32458. */
  32459. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32460. /**
  32461. * Set the value of an uniform to an array of number (stored as vec4)
  32462. * @param uniform defines the webGL uniform location where to store the value
  32463. * @param array defines the array of number to store
  32464. */
  32465. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32466. /**
  32467. * Set the value of an uniform to an array of float32 (stored as matrices)
  32468. * @param uniform defines the webGL uniform location where to store the value
  32469. * @param matrices defines the array of float32 to store
  32470. */
  32471. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32472. /**
  32473. * Set the value of an uniform to a matrix (3x3)
  32474. * @param uniform defines the webGL uniform location where to store the value
  32475. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32476. */
  32477. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32478. /**
  32479. * Set the value of an uniform to a matrix (2x2)
  32480. * @param uniform defines the webGL uniform location where to store the value
  32481. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32482. */
  32483. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32484. /**
  32485. * Set the value of an uniform to a number (float)
  32486. * @param uniform defines the webGL uniform location where to store the value
  32487. * @param value defines the float number to store
  32488. */
  32489. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32490. /**
  32491. * Set the value of an uniform to a vec2
  32492. * @param uniform defines the webGL uniform location where to store the value
  32493. * @param x defines the 1st component of the value
  32494. * @param y defines the 2nd component of the value
  32495. */
  32496. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32497. /**
  32498. * Set the value of an uniform to a vec3
  32499. * @param uniform defines the webGL uniform location where to store the value
  32500. * @param x defines the 1st component of the value
  32501. * @param y defines the 2nd component of the value
  32502. * @param z defines the 3rd component of the value
  32503. */
  32504. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32505. /**
  32506. * Set the value of an uniform to a vec4
  32507. * @param uniform defines the webGL uniform location where to store the value
  32508. * @param x defines the 1st component of the value
  32509. * @param y defines the 2nd component of the value
  32510. * @param z defines the 3rd component of the value
  32511. * @param w defines the 4th component of the value
  32512. */
  32513. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32514. /**
  32515. * Apply all cached states (depth, culling, stencil and alpha)
  32516. */
  32517. applyStates(): void;
  32518. /**
  32519. * Enable or disable color writing
  32520. * @param enable defines the state to set
  32521. */
  32522. setColorWrite(enable: boolean): void;
  32523. /**
  32524. * Gets a boolean indicating if color writing is enabled
  32525. * @returns the current color writing state
  32526. */
  32527. getColorWrite(): boolean;
  32528. /**
  32529. * Gets the depth culling state manager
  32530. */
  32531. get depthCullingState(): DepthCullingState;
  32532. /**
  32533. * Gets the alpha state manager
  32534. */
  32535. get alphaState(): AlphaState;
  32536. /**
  32537. * Gets the stencil state manager
  32538. */
  32539. get stencilState(): StencilState;
  32540. /**
  32541. * Clears the list of texture accessible through engine.
  32542. * This can help preventing texture load conflict due to name collision.
  32543. */
  32544. clearInternalTexturesCache(): void;
  32545. /**
  32546. * Force the entire cache to be cleared
  32547. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32548. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32549. */
  32550. wipeCaches(bruteForce?: boolean): void;
  32551. /** @hidden */
  32552. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32553. min: number;
  32554. mag: number;
  32555. };
  32556. /** @hidden */
  32557. _createTexture(): WebGLTexture;
  32558. /**
  32559. * Usually called from Texture.ts.
  32560. * Passed information to create a WebGLTexture
  32561. * @param urlArg defines a value which contains one of the following:
  32562. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32563. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32564. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32565. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32566. * @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)
  32567. * @param scene needed for loading to the correct scene
  32568. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32569. * @param onLoad optional callback to be called upon successful completion
  32570. * @param onError optional callback to be called upon failure
  32571. * @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
  32572. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32573. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32574. * @param forcedExtension defines the extension to use to pick the right loader
  32575. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32576. * @param mimeType defines an optional mime type
  32577. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32578. */
  32579. 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;
  32580. /**
  32581. * Loads an image as an HTMLImageElement.
  32582. * @param input url string, ArrayBuffer, or Blob to load
  32583. * @param onLoad callback called when the image successfully loads
  32584. * @param onError callback called when the image fails to load
  32585. * @param offlineProvider offline provider for caching
  32586. * @param mimeType optional mime type
  32587. * @returns the HTMLImageElement of the loaded image
  32588. * @hidden
  32589. */
  32590. 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>;
  32591. /**
  32592. * @hidden
  32593. */
  32594. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32595. /**
  32596. * Creates a raw texture
  32597. * @param data defines the data to store in the texture
  32598. * @param width defines the width of the texture
  32599. * @param height defines the height of the texture
  32600. * @param format defines the format of the data
  32601. * @param generateMipMaps defines if the engine should generate the mip levels
  32602. * @param invertY defines if data must be stored with Y axis inverted
  32603. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32604. * @param compression defines the compression used (null by default)
  32605. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32606. * @returns the raw texture inside an InternalTexture
  32607. */
  32608. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32609. /**
  32610. * Creates a new raw cube texture
  32611. * @param data defines the array of data to use to create each face
  32612. * @param size defines the size of the textures
  32613. * @param format defines the format of the data
  32614. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32615. * @param generateMipMaps defines if the engine should generate the mip levels
  32616. * @param invertY defines if data must be stored with Y axis inverted
  32617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32618. * @param compression defines the compression used (null by default)
  32619. * @returns the cube texture as an InternalTexture
  32620. */
  32621. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32622. /**
  32623. * Creates a new raw 3D texture
  32624. * @param data defines the data used to create the texture
  32625. * @param width defines the width of the texture
  32626. * @param height defines the height of the texture
  32627. * @param depth defines the depth of the texture
  32628. * @param format defines the format of the texture
  32629. * @param generateMipMaps defines if the engine must generate mip levels
  32630. * @param invertY defines if data must be stored with Y axis inverted
  32631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32632. * @param compression defines the compressed used (can be null)
  32633. * @param textureType defines the compressed used (can be null)
  32634. * @returns a new raw 3D texture (stored in an InternalTexture)
  32635. */
  32636. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32637. /**
  32638. * Creates a new raw 2D array texture
  32639. * @param data defines the data used to create the texture
  32640. * @param width defines the width of the texture
  32641. * @param height defines the height of the texture
  32642. * @param depth defines the number of layers of the texture
  32643. * @param format defines the format of the texture
  32644. * @param generateMipMaps defines if the engine must generate mip levels
  32645. * @param invertY defines if data must be stored with Y axis inverted
  32646. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32647. * @param compression defines the compressed used (can be null)
  32648. * @param textureType defines the compressed used (can be null)
  32649. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32650. */
  32651. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32652. private _unpackFlipYCached;
  32653. /**
  32654. * In case you are sharing the context with other applications, it might
  32655. * be interested to not cache the unpack flip y state to ensure a consistent
  32656. * value would be set.
  32657. */
  32658. enableUnpackFlipYCached: boolean;
  32659. /** @hidden */
  32660. _unpackFlipY(value: boolean): void;
  32661. /** @hidden */
  32662. _getUnpackAlignement(): number;
  32663. private _getTextureTarget;
  32664. /**
  32665. * Update the sampling mode of a given texture
  32666. * @param samplingMode defines the required sampling mode
  32667. * @param texture defines the texture to update
  32668. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32669. */
  32670. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32671. /**
  32672. * Update the sampling mode of a given texture
  32673. * @param texture defines the texture to update
  32674. * @param wrapU defines the texture wrap mode of the u coordinates
  32675. * @param wrapV defines the texture wrap mode of the v coordinates
  32676. * @param wrapR defines the texture wrap mode of the r coordinates
  32677. */
  32678. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32679. /** @hidden */
  32680. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32681. width: number;
  32682. height: number;
  32683. layers?: number;
  32684. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32685. /** @hidden */
  32686. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32687. /** @hidden */
  32688. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32689. /**
  32690. * Update a portion of an internal texture
  32691. * @param texture defines the texture to update
  32692. * @param imageData defines the data to store into the texture
  32693. * @param xOffset defines the x coordinates of the update rectangle
  32694. * @param yOffset defines the y coordinates of the update rectangle
  32695. * @param width defines the width of the update rectangle
  32696. * @param height defines the height of the update rectangle
  32697. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32698. * @param lod defines the lod level to update (0 by default)
  32699. */
  32700. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32701. /** @hidden */
  32702. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32703. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32704. private _prepareWebGLTexture;
  32705. /** @hidden */
  32706. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32707. private _getDepthStencilBuffer;
  32708. /** @hidden */
  32709. _releaseFramebufferObjects(texture: InternalTexture): void;
  32710. /** @hidden */
  32711. _releaseTexture(texture: InternalTexture): void;
  32712. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32713. protected _setProgram(program: WebGLProgram): void;
  32714. protected _boundUniforms: {
  32715. [key: number]: WebGLUniformLocation;
  32716. };
  32717. /**
  32718. * Binds an effect to the webGL context
  32719. * @param effect defines the effect to bind
  32720. */
  32721. bindSamplers(effect: Effect): void;
  32722. private _activateCurrentTexture;
  32723. /** @hidden */
  32724. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32725. /** @hidden */
  32726. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32727. /**
  32728. * Unbind all textures from the webGL context
  32729. */
  32730. unbindAllTextures(): void;
  32731. /**
  32732. * Sets a texture to the according uniform.
  32733. * @param channel The texture channel
  32734. * @param uniform The uniform to set
  32735. * @param texture The texture to apply
  32736. */
  32737. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32738. private _bindSamplerUniformToChannel;
  32739. private _getTextureWrapMode;
  32740. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32741. /**
  32742. * Sets an array of texture to the webGL context
  32743. * @param channel defines the channel where the texture array must be set
  32744. * @param uniform defines the associated uniform location
  32745. * @param textures defines the array of textures to bind
  32746. */
  32747. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32748. /** @hidden */
  32749. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32750. private _setTextureParameterFloat;
  32751. private _setTextureParameterInteger;
  32752. /**
  32753. * Unbind all vertex attributes from the webGL context
  32754. */
  32755. unbindAllAttributes(): void;
  32756. /**
  32757. * 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
  32758. */
  32759. releaseEffects(): void;
  32760. /**
  32761. * Dispose and release all associated resources
  32762. */
  32763. dispose(): void;
  32764. /**
  32765. * Attach a new callback raised when context lost event is fired
  32766. * @param callback defines the callback to call
  32767. */
  32768. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32769. /**
  32770. * Attach a new callback raised when context restored event is fired
  32771. * @param callback defines the callback to call
  32772. */
  32773. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32774. /**
  32775. * Get the current error code of the webGL context
  32776. * @returns the error code
  32777. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32778. */
  32779. getError(): number;
  32780. private _canRenderToFloatFramebuffer;
  32781. private _canRenderToHalfFloatFramebuffer;
  32782. private _canRenderToFramebuffer;
  32783. /** @hidden */
  32784. _getWebGLTextureType(type: number): number;
  32785. /** @hidden */
  32786. _getInternalFormat(format: number): number;
  32787. /** @hidden */
  32788. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32789. /** @hidden */
  32790. _getRGBAMultiSampleBufferFormat(type: number): number;
  32791. /** @hidden */
  32792. _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;
  32793. /**
  32794. * Loads a file from a url
  32795. * @param url url to load
  32796. * @param onSuccess callback called when the file successfully loads
  32797. * @param onProgress callback called while file is loading (if the server supports this mode)
  32798. * @param offlineProvider defines the offline provider for caching
  32799. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32800. * @param onError callback called when the file fails to load
  32801. * @returns a file request object
  32802. * @hidden
  32803. */
  32804. 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;
  32805. /**
  32806. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32807. * @param x defines the x coordinate of the rectangle where pixels must be read
  32808. * @param y defines the y coordinate of the rectangle where pixels must be read
  32809. * @param width defines the width of the rectangle where pixels must be read
  32810. * @param height defines the height of the rectangle where pixels must be read
  32811. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32812. * @returns a Uint8Array containing RGBA colors
  32813. */
  32814. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32815. private static _isSupported;
  32816. /**
  32817. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32818. * @returns true if the engine can be created
  32819. * @ignorenaming
  32820. */
  32821. static isSupported(): boolean;
  32822. /**
  32823. * Find the next highest power of two.
  32824. * @param x Number to start search from.
  32825. * @return Next highest power of two.
  32826. */
  32827. static CeilingPOT(x: number): number;
  32828. /**
  32829. * Find the next lowest power of two.
  32830. * @param x Number to start search from.
  32831. * @return Next lowest power of two.
  32832. */
  32833. static FloorPOT(x: number): number;
  32834. /**
  32835. * Find the nearest power of two.
  32836. * @param x Number to start search from.
  32837. * @return Next nearest power of two.
  32838. */
  32839. static NearestPOT(x: number): number;
  32840. /**
  32841. * Get the closest exponent of two
  32842. * @param value defines the value to approximate
  32843. * @param max defines the maximum value to return
  32844. * @param mode defines how to define the closest value
  32845. * @returns closest exponent of two of the given value
  32846. */
  32847. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32848. /**
  32849. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32850. * @param func - the function to be called
  32851. * @param requester - the object that will request the next frame. Falls back to window.
  32852. * @returns frame number
  32853. */
  32854. static QueueNewFrame(func: () => void, requester?: any): number;
  32855. /**
  32856. * Gets host document
  32857. * @returns the host document object
  32858. */
  32859. getHostDocument(): Nullable<Document>;
  32860. }
  32861. }
  32862. declare module "babylonjs/Maths/sphericalPolynomial" {
  32863. import { Vector3 } from "babylonjs/Maths/math.vector";
  32864. import { Color3 } from "babylonjs/Maths/math.color";
  32865. /**
  32866. * Class representing spherical harmonics coefficients to the 3rd degree
  32867. */
  32868. export class SphericalHarmonics {
  32869. /**
  32870. * Defines whether or not the harmonics have been prescaled for rendering.
  32871. */
  32872. preScaled: boolean;
  32873. /**
  32874. * The l0,0 coefficients of the spherical harmonics
  32875. */
  32876. l00: Vector3;
  32877. /**
  32878. * The l1,-1 coefficients of the spherical harmonics
  32879. */
  32880. l1_1: Vector3;
  32881. /**
  32882. * The l1,0 coefficients of the spherical harmonics
  32883. */
  32884. l10: Vector3;
  32885. /**
  32886. * The l1,1 coefficients of the spherical harmonics
  32887. */
  32888. l11: Vector3;
  32889. /**
  32890. * The l2,-2 coefficients of the spherical harmonics
  32891. */
  32892. l2_2: Vector3;
  32893. /**
  32894. * The l2,-1 coefficients of the spherical harmonics
  32895. */
  32896. l2_1: Vector3;
  32897. /**
  32898. * The l2,0 coefficients of the spherical harmonics
  32899. */
  32900. l20: Vector3;
  32901. /**
  32902. * The l2,1 coefficients of the spherical harmonics
  32903. */
  32904. l21: Vector3;
  32905. /**
  32906. * The l2,2 coefficients of the spherical harmonics
  32907. */
  32908. l22: Vector3;
  32909. /**
  32910. * Adds a light to the spherical harmonics
  32911. * @param direction the direction of the light
  32912. * @param color the color of the light
  32913. * @param deltaSolidAngle the delta solid angle of the light
  32914. */
  32915. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32916. /**
  32917. * Scales the spherical harmonics by the given amount
  32918. * @param scale the amount to scale
  32919. */
  32920. scaleInPlace(scale: number): void;
  32921. /**
  32922. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32923. *
  32924. * ```
  32925. * E_lm = A_l * L_lm
  32926. * ```
  32927. *
  32928. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32929. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32930. * the scaling factors are given in equation 9.
  32931. */
  32932. convertIncidentRadianceToIrradiance(): void;
  32933. /**
  32934. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32935. *
  32936. * ```
  32937. * L = (1/pi) * E * rho
  32938. * ```
  32939. *
  32940. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32941. */
  32942. convertIrradianceToLambertianRadiance(): void;
  32943. /**
  32944. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32945. * required operations at run time.
  32946. *
  32947. * This is simply done by scaling back the SH with Ylm constants parameter.
  32948. * The trigonometric part being applied by the shader at run time.
  32949. */
  32950. preScaleForRendering(): void;
  32951. /**
  32952. * Constructs a spherical harmonics from an array.
  32953. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32954. * @returns the spherical harmonics
  32955. */
  32956. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32957. /**
  32958. * Gets the spherical harmonics from polynomial
  32959. * @param polynomial the spherical polynomial
  32960. * @returns the spherical harmonics
  32961. */
  32962. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32963. }
  32964. /**
  32965. * Class representing spherical polynomial coefficients to the 3rd degree
  32966. */
  32967. export class SphericalPolynomial {
  32968. private _harmonics;
  32969. /**
  32970. * The spherical harmonics used to create the polynomials.
  32971. */
  32972. get preScaledHarmonics(): SphericalHarmonics;
  32973. /**
  32974. * The x coefficients of the spherical polynomial
  32975. */
  32976. x: Vector3;
  32977. /**
  32978. * The y coefficients of the spherical polynomial
  32979. */
  32980. y: Vector3;
  32981. /**
  32982. * The z coefficients of the spherical polynomial
  32983. */
  32984. z: Vector3;
  32985. /**
  32986. * The xx coefficients of the spherical polynomial
  32987. */
  32988. xx: Vector3;
  32989. /**
  32990. * The yy coefficients of the spherical polynomial
  32991. */
  32992. yy: Vector3;
  32993. /**
  32994. * The zz coefficients of the spherical polynomial
  32995. */
  32996. zz: Vector3;
  32997. /**
  32998. * The xy coefficients of the spherical polynomial
  32999. */
  33000. xy: Vector3;
  33001. /**
  33002. * The yz coefficients of the spherical polynomial
  33003. */
  33004. yz: Vector3;
  33005. /**
  33006. * The zx coefficients of the spherical polynomial
  33007. */
  33008. zx: Vector3;
  33009. /**
  33010. * Adds an ambient color to the spherical polynomial
  33011. * @param color the color to add
  33012. */
  33013. addAmbient(color: Color3): void;
  33014. /**
  33015. * Scales the spherical polynomial by the given amount
  33016. * @param scale the amount to scale
  33017. */
  33018. scaleInPlace(scale: number): void;
  33019. /**
  33020. * Gets the spherical polynomial from harmonics
  33021. * @param harmonics the spherical harmonics
  33022. * @returns the spherical polynomial
  33023. */
  33024. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33025. /**
  33026. * Constructs a spherical polynomial from an array.
  33027. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33028. * @returns the spherical polynomial
  33029. */
  33030. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33031. }
  33032. }
  33033. declare module "babylonjs/Materials/Textures/internalTexture" {
  33034. import { Observable } from "babylonjs/Misc/observable";
  33035. import { Nullable, int } from "babylonjs/types";
  33036. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33038. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33039. /**
  33040. * Defines the source of the internal texture
  33041. */
  33042. export enum InternalTextureSource {
  33043. /**
  33044. * The source of the texture data is unknown
  33045. */
  33046. Unknown = 0,
  33047. /**
  33048. * Texture data comes from an URL
  33049. */
  33050. Url = 1,
  33051. /**
  33052. * Texture data is only used for temporary storage
  33053. */
  33054. Temp = 2,
  33055. /**
  33056. * Texture data comes from raw data (ArrayBuffer)
  33057. */
  33058. Raw = 3,
  33059. /**
  33060. * Texture content is dynamic (video or dynamic texture)
  33061. */
  33062. Dynamic = 4,
  33063. /**
  33064. * Texture content is generated by rendering to it
  33065. */
  33066. RenderTarget = 5,
  33067. /**
  33068. * Texture content is part of a multi render target process
  33069. */
  33070. MultiRenderTarget = 6,
  33071. /**
  33072. * Texture data comes from a cube data file
  33073. */
  33074. Cube = 7,
  33075. /**
  33076. * Texture data comes from a raw cube data
  33077. */
  33078. CubeRaw = 8,
  33079. /**
  33080. * Texture data come from a prefiltered cube data file
  33081. */
  33082. CubePrefiltered = 9,
  33083. /**
  33084. * Texture content is raw 3D data
  33085. */
  33086. Raw3D = 10,
  33087. /**
  33088. * Texture content is raw 2D array data
  33089. */
  33090. Raw2DArray = 11,
  33091. /**
  33092. * Texture content is a depth texture
  33093. */
  33094. Depth = 12,
  33095. /**
  33096. * Texture data comes from a raw cube data encoded with RGBD
  33097. */
  33098. CubeRawRGBD = 13
  33099. }
  33100. /**
  33101. * Class used to store data associated with WebGL texture data for the engine
  33102. * This class should not be used directly
  33103. */
  33104. export class InternalTexture {
  33105. /** @hidden */
  33106. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33107. /**
  33108. * Defines if the texture is ready
  33109. */
  33110. isReady: boolean;
  33111. /**
  33112. * Defines if the texture is a cube texture
  33113. */
  33114. isCube: boolean;
  33115. /**
  33116. * Defines if the texture contains 3D data
  33117. */
  33118. is3D: boolean;
  33119. /**
  33120. * Defines if the texture contains 2D array data
  33121. */
  33122. is2DArray: boolean;
  33123. /**
  33124. * Defines if the texture contains multiview data
  33125. */
  33126. isMultiview: boolean;
  33127. /**
  33128. * Gets the URL used to load this texture
  33129. */
  33130. url: string;
  33131. /**
  33132. * Gets the sampling mode of the texture
  33133. */
  33134. samplingMode: number;
  33135. /**
  33136. * Gets a boolean indicating if the texture needs mipmaps generation
  33137. */
  33138. generateMipMaps: boolean;
  33139. /**
  33140. * Gets the number of samples used by the texture (WebGL2+ only)
  33141. */
  33142. samples: number;
  33143. /**
  33144. * Gets the type of the texture (int, float...)
  33145. */
  33146. type: number;
  33147. /**
  33148. * Gets the format of the texture (RGB, RGBA...)
  33149. */
  33150. format: number;
  33151. /**
  33152. * Observable called when the texture is loaded
  33153. */
  33154. onLoadedObservable: Observable<InternalTexture>;
  33155. /**
  33156. * Gets the width of the texture
  33157. */
  33158. width: number;
  33159. /**
  33160. * Gets the height of the texture
  33161. */
  33162. height: number;
  33163. /**
  33164. * Gets the depth of the texture
  33165. */
  33166. depth: number;
  33167. /**
  33168. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33169. */
  33170. baseWidth: number;
  33171. /**
  33172. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33173. */
  33174. baseHeight: number;
  33175. /**
  33176. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33177. */
  33178. baseDepth: number;
  33179. /**
  33180. * Gets a boolean indicating if the texture is inverted on Y axis
  33181. */
  33182. invertY: boolean;
  33183. /** @hidden */
  33184. _invertVScale: boolean;
  33185. /** @hidden */
  33186. _associatedChannel: number;
  33187. /** @hidden */
  33188. _source: InternalTextureSource;
  33189. /** @hidden */
  33190. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33191. /** @hidden */
  33192. _bufferView: Nullable<ArrayBufferView>;
  33193. /** @hidden */
  33194. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33195. /** @hidden */
  33196. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33197. /** @hidden */
  33198. _size: number;
  33199. /** @hidden */
  33200. _extension: string;
  33201. /** @hidden */
  33202. _files: Nullable<string[]>;
  33203. /** @hidden */
  33204. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33205. /** @hidden */
  33206. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33207. /** @hidden */
  33208. _framebuffer: Nullable<WebGLFramebuffer>;
  33209. /** @hidden */
  33210. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33211. /** @hidden */
  33212. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33213. /** @hidden */
  33214. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33215. /** @hidden */
  33216. _attachments: Nullable<number[]>;
  33217. /** @hidden */
  33218. _cachedCoordinatesMode: Nullable<number>;
  33219. /** @hidden */
  33220. _cachedWrapU: Nullable<number>;
  33221. /** @hidden */
  33222. _cachedWrapV: Nullable<number>;
  33223. /** @hidden */
  33224. _cachedWrapR: Nullable<number>;
  33225. /** @hidden */
  33226. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33227. /** @hidden */
  33228. _isDisabled: boolean;
  33229. /** @hidden */
  33230. _compression: Nullable<string>;
  33231. /** @hidden */
  33232. _generateStencilBuffer: boolean;
  33233. /** @hidden */
  33234. _generateDepthBuffer: boolean;
  33235. /** @hidden */
  33236. _comparisonFunction: number;
  33237. /** @hidden */
  33238. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33239. /** @hidden */
  33240. _lodGenerationScale: number;
  33241. /** @hidden */
  33242. _lodGenerationOffset: number;
  33243. /** @hidden */
  33244. _depthStencilTexture: Nullable<InternalTexture>;
  33245. /** @hidden */
  33246. _colorTextureArray: Nullable<WebGLTexture>;
  33247. /** @hidden */
  33248. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33249. /** @hidden */
  33250. _lodTextureHigh: Nullable<BaseTexture>;
  33251. /** @hidden */
  33252. _lodTextureMid: Nullable<BaseTexture>;
  33253. /** @hidden */
  33254. _lodTextureLow: Nullable<BaseTexture>;
  33255. /** @hidden */
  33256. _isRGBD: boolean;
  33257. /** @hidden */
  33258. _linearSpecularLOD: boolean;
  33259. /** @hidden */
  33260. _irradianceTexture: Nullable<BaseTexture>;
  33261. /** @hidden */
  33262. _webGLTexture: Nullable<WebGLTexture>;
  33263. /** @hidden */
  33264. _references: number;
  33265. private _engine;
  33266. /**
  33267. * Gets the Engine the texture belongs to.
  33268. * @returns The babylon engine
  33269. */
  33270. getEngine(): ThinEngine;
  33271. /**
  33272. * Gets the data source type of the texture
  33273. */
  33274. get source(): InternalTextureSource;
  33275. /**
  33276. * Creates a new InternalTexture
  33277. * @param engine defines the engine to use
  33278. * @param source defines the type of data that will be used
  33279. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33280. */
  33281. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33282. /**
  33283. * Increments the number of references (ie. the number of Texture that point to it)
  33284. */
  33285. incrementReferences(): void;
  33286. /**
  33287. * Change the size of the texture (not the size of the content)
  33288. * @param width defines the new width
  33289. * @param height defines the new height
  33290. * @param depth defines the new depth (1 by default)
  33291. */
  33292. updateSize(width: int, height: int, depth?: int): void;
  33293. /** @hidden */
  33294. _rebuild(): void;
  33295. /** @hidden */
  33296. _swapAndDie(target: InternalTexture): void;
  33297. /**
  33298. * Dispose the current allocated resources
  33299. */
  33300. dispose(): void;
  33301. }
  33302. }
  33303. declare module "babylonjs/Audio/analyser" {
  33304. import { Scene } from "babylonjs/scene";
  33305. /**
  33306. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33308. */
  33309. export class Analyser {
  33310. /**
  33311. * Gets or sets the smoothing
  33312. * @ignorenaming
  33313. */
  33314. SMOOTHING: number;
  33315. /**
  33316. * Gets or sets the FFT table size
  33317. * @ignorenaming
  33318. */
  33319. FFT_SIZE: number;
  33320. /**
  33321. * Gets or sets the bar graph amplitude
  33322. * @ignorenaming
  33323. */
  33324. BARGRAPHAMPLITUDE: number;
  33325. /**
  33326. * Gets or sets the position of the debug canvas
  33327. * @ignorenaming
  33328. */
  33329. DEBUGCANVASPOS: {
  33330. x: number;
  33331. y: number;
  33332. };
  33333. /**
  33334. * Gets or sets the debug canvas size
  33335. * @ignorenaming
  33336. */
  33337. DEBUGCANVASSIZE: {
  33338. width: number;
  33339. height: number;
  33340. };
  33341. private _byteFreqs;
  33342. private _byteTime;
  33343. private _floatFreqs;
  33344. private _webAudioAnalyser;
  33345. private _debugCanvas;
  33346. private _debugCanvasContext;
  33347. private _scene;
  33348. private _registerFunc;
  33349. private _audioEngine;
  33350. /**
  33351. * Creates a new analyser
  33352. * @param scene defines hosting scene
  33353. */
  33354. constructor(scene: Scene);
  33355. /**
  33356. * Get the number of data values you will have to play with for the visualization
  33357. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33358. * @returns a number
  33359. */
  33360. getFrequencyBinCount(): number;
  33361. /**
  33362. * Gets the current frequency data as a byte array
  33363. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33364. * @returns a Uint8Array
  33365. */
  33366. getByteFrequencyData(): Uint8Array;
  33367. /**
  33368. * Gets the current waveform as a byte array
  33369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33370. * @returns a Uint8Array
  33371. */
  33372. getByteTimeDomainData(): Uint8Array;
  33373. /**
  33374. * Gets the current frequency data as a float array
  33375. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33376. * @returns a Float32Array
  33377. */
  33378. getFloatFrequencyData(): Float32Array;
  33379. /**
  33380. * Renders the debug canvas
  33381. */
  33382. drawDebugCanvas(): void;
  33383. /**
  33384. * Stops rendering the debug canvas and removes it
  33385. */
  33386. stopDebugCanvas(): void;
  33387. /**
  33388. * Connects two audio nodes
  33389. * @param inputAudioNode defines first node to connect
  33390. * @param outputAudioNode defines second node to connect
  33391. */
  33392. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33393. /**
  33394. * Releases all associated resources
  33395. */
  33396. dispose(): void;
  33397. }
  33398. }
  33399. declare module "babylonjs/Audio/audioEngine" {
  33400. import { IDisposable } from "babylonjs/scene";
  33401. import { Analyser } from "babylonjs/Audio/analyser";
  33402. import { Nullable } from "babylonjs/types";
  33403. import { Observable } from "babylonjs/Misc/observable";
  33404. /**
  33405. * This represents an audio engine and it is responsible
  33406. * to play, synchronize and analyse sounds throughout the application.
  33407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33408. */
  33409. export interface IAudioEngine extends IDisposable {
  33410. /**
  33411. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33412. */
  33413. readonly canUseWebAudio: boolean;
  33414. /**
  33415. * Gets the current AudioContext if available.
  33416. */
  33417. readonly audioContext: Nullable<AudioContext>;
  33418. /**
  33419. * The master gain node defines the global audio volume of your audio engine.
  33420. */
  33421. readonly masterGain: GainNode;
  33422. /**
  33423. * Gets whether or not mp3 are supported by your browser.
  33424. */
  33425. readonly isMP3supported: boolean;
  33426. /**
  33427. * Gets whether or not ogg are supported by your browser.
  33428. */
  33429. readonly isOGGsupported: boolean;
  33430. /**
  33431. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33432. * @ignoreNaming
  33433. */
  33434. WarnedWebAudioUnsupported: boolean;
  33435. /**
  33436. * Defines if the audio engine relies on a custom unlocked button.
  33437. * In this case, the embedded button will not be displayed.
  33438. */
  33439. useCustomUnlockedButton: boolean;
  33440. /**
  33441. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33442. */
  33443. readonly unlocked: boolean;
  33444. /**
  33445. * Event raised when audio has been unlocked on the browser.
  33446. */
  33447. onAudioUnlockedObservable: Observable<AudioEngine>;
  33448. /**
  33449. * Event raised when audio has been locked on the browser.
  33450. */
  33451. onAudioLockedObservable: Observable<AudioEngine>;
  33452. /**
  33453. * Flags the audio engine in Locked state.
  33454. * This happens due to new browser policies preventing audio to autoplay.
  33455. */
  33456. lock(): void;
  33457. /**
  33458. * Unlocks the audio engine once a user action has been done on the dom.
  33459. * This is helpful to resume play once browser policies have been satisfied.
  33460. */
  33461. unlock(): void;
  33462. }
  33463. /**
  33464. * This represents the default audio engine used in babylon.
  33465. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33467. */
  33468. export class AudioEngine implements IAudioEngine {
  33469. private _audioContext;
  33470. private _audioContextInitialized;
  33471. private _muteButton;
  33472. private _hostElement;
  33473. /**
  33474. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33475. */
  33476. canUseWebAudio: boolean;
  33477. /**
  33478. * The master gain node defines the global audio volume of your audio engine.
  33479. */
  33480. masterGain: GainNode;
  33481. /**
  33482. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33483. * @ignoreNaming
  33484. */
  33485. WarnedWebAudioUnsupported: boolean;
  33486. /**
  33487. * Gets whether or not mp3 are supported by your browser.
  33488. */
  33489. isMP3supported: boolean;
  33490. /**
  33491. * Gets whether or not ogg are supported by your browser.
  33492. */
  33493. isOGGsupported: boolean;
  33494. /**
  33495. * Gets whether audio has been unlocked on the device.
  33496. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33497. * a user interaction has happened.
  33498. */
  33499. unlocked: boolean;
  33500. /**
  33501. * Defines if the audio engine relies on a custom unlocked button.
  33502. * In this case, the embedded button will not be displayed.
  33503. */
  33504. useCustomUnlockedButton: boolean;
  33505. /**
  33506. * Event raised when audio has been unlocked on the browser.
  33507. */
  33508. onAudioUnlockedObservable: Observable<AudioEngine>;
  33509. /**
  33510. * Event raised when audio has been locked on the browser.
  33511. */
  33512. onAudioLockedObservable: Observable<AudioEngine>;
  33513. /**
  33514. * Gets the current AudioContext if available.
  33515. */
  33516. get audioContext(): Nullable<AudioContext>;
  33517. private _connectedAnalyser;
  33518. /**
  33519. * Instantiates a new audio engine.
  33520. *
  33521. * There should be only one per page as some browsers restrict the number
  33522. * of audio contexts you can create.
  33523. * @param hostElement defines the host element where to display the mute icon if necessary
  33524. */
  33525. constructor(hostElement?: Nullable<HTMLElement>);
  33526. /**
  33527. * Flags the audio engine in Locked state.
  33528. * This happens due to new browser policies preventing audio to autoplay.
  33529. */
  33530. lock(): void;
  33531. /**
  33532. * Unlocks the audio engine once a user action has been done on the dom.
  33533. * This is helpful to resume play once browser policies have been satisfied.
  33534. */
  33535. unlock(): void;
  33536. private _resumeAudioContext;
  33537. private _initializeAudioContext;
  33538. private _tryToRun;
  33539. private _triggerRunningState;
  33540. private _triggerSuspendedState;
  33541. private _displayMuteButton;
  33542. private _moveButtonToTopLeft;
  33543. private _onResize;
  33544. private _hideMuteButton;
  33545. /**
  33546. * Destroy and release the resources associated with the audio ccontext.
  33547. */
  33548. dispose(): void;
  33549. /**
  33550. * Gets the global volume sets on the master gain.
  33551. * @returns the global volume if set or -1 otherwise
  33552. */
  33553. getGlobalVolume(): number;
  33554. /**
  33555. * Sets the global volume of your experience (sets on the master gain).
  33556. * @param newVolume Defines the new global volume of the application
  33557. */
  33558. setGlobalVolume(newVolume: number): void;
  33559. /**
  33560. * Connect the audio engine to an audio analyser allowing some amazing
  33561. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33563. * @param analyser The analyser to connect to the engine
  33564. */
  33565. connectToAnalyser(analyser: Analyser): void;
  33566. }
  33567. }
  33568. declare module "babylonjs/Loading/loadingScreen" {
  33569. /**
  33570. * Interface used to present a loading screen while loading a scene
  33571. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33572. */
  33573. export interface ILoadingScreen {
  33574. /**
  33575. * Function called to display the loading screen
  33576. */
  33577. displayLoadingUI: () => void;
  33578. /**
  33579. * Function called to hide the loading screen
  33580. */
  33581. hideLoadingUI: () => void;
  33582. /**
  33583. * Gets or sets the color to use for the background
  33584. */
  33585. loadingUIBackgroundColor: string;
  33586. /**
  33587. * Gets or sets the text to display while loading
  33588. */
  33589. loadingUIText: string;
  33590. }
  33591. /**
  33592. * Class used for the default loading screen
  33593. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33594. */
  33595. export class DefaultLoadingScreen implements ILoadingScreen {
  33596. private _renderingCanvas;
  33597. private _loadingText;
  33598. private _loadingDivBackgroundColor;
  33599. private _loadingDiv;
  33600. private _loadingTextDiv;
  33601. /** Gets or sets the logo url to use for the default loading screen */
  33602. static DefaultLogoUrl: string;
  33603. /** Gets or sets the spinner url to use for the default loading screen */
  33604. static DefaultSpinnerUrl: string;
  33605. /**
  33606. * Creates a new default loading screen
  33607. * @param _renderingCanvas defines the canvas used to render the scene
  33608. * @param _loadingText defines the default text to display
  33609. * @param _loadingDivBackgroundColor defines the default background color
  33610. */
  33611. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33612. /**
  33613. * Function called to display the loading screen
  33614. */
  33615. displayLoadingUI(): void;
  33616. /**
  33617. * Function called to hide the loading screen
  33618. */
  33619. hideLoadingUI(): void;
  33620. /**
  33621. * Gets or sets the text to display while loading
  33622. */
  33623. set loadingUIText(text: string);
  33624. get loadingUIText(): string;
  33625. /**
  33626. * Gets or sets the color to use for the background
  33627. */
  33628. get loadingUIBackgroundColor(): string;
  33629. set loadingUIBackgroundColor(color: string);
  33630. private _resizeLoadingUI;
  33631. }
  33632. }
  33633. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33634. /**
  33635. * Interface for any object that can request an animation frame
  33636. */
  33637. export interface ICustomAnimationFrameRequester {
  33638. /**
  33639. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33640. */
  33641. renderFunction?: Function;
  33642. /**
  33643. * Called to request the next frame to render to
  33644. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33645. */
  33646. requestAnimationFrame: Function;
  33647. /**
  33648. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33649. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33650. */
  33651. requestID?: number;
  33652. }
  33653. }
  33654. declare module "babylonjs/Misc/performanceMonitor" {
  33655. /**
  33656. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33657. */
  33658. export class PerformanceMonitor {
  33659. private _enabled;
  33660. private _rollingFrameTime;
  33661. private _lastFrameTimeMs;
  33662. /**
  33663. * constructor
  33664. * @param frameSampleSize The number of samples required to saturate the sliding window
  33665. */
  33666. constructor(frameSampleSize?: number);
  33667. /**
  33668. * Samples current frame
  33669. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33670. */
  33671. sampleFrame(timeMs?: number): void;
  33672. /**
  33673. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33674. */
  33675. get averageFrameTime(): number;
  33676. /**
  33677. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33678. */
  33679. get averageFrameTimeVariance(): number;
  33680. /**
  33681. * Returns the frame time of the most recent frame
  33682. */
  33683. get instantaneousFrameTime(): number;
  33684. /**
  33685. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33686. */
  33687. get averageFPS(): number;
  33688. /**
  33689. * Returns the average framerate in frames per second using the most recent frame time
  33690. */
  33691. get instantaneousFPS(): number;
  33692. /**
  33693. * Returns true if enough samples have been taken to completely fill the sliding window
  33694. */
  33695. get isSaturated(): boolean;
  33696. /**
  33697. * Enables contributions to the sliding window sample set
  33698. */
  33699. enable(): void;
  33700. /**
  33701. * Disables contributions to the sliding window sample set
  33702. * Samples will not be interpolated over the disabled period
  33703. */
  33704. disable(): void;
  33705. /**
  33706. * Returns true if sampling is enabled
  33707. */
  33708. get isEnabled(): boolean;
  33709. /**
  33710. * Resets performance monitor
  33711. */
  33712. reset(): void;
  33713. }
  33714. /**
  33715. * RollingAverage
  33716. *
  33717. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33718. */
  33719. export class RollingAverage {
  33720. /**
  33721. * Current average
  33722. */
  33723. average: number;
  33724. /**
  33725. * Current variance
  33726. */
  33727. variance: number;
  33728. protected _samples: Array<number>;
  33729. protected _sampleCount: number;
  33730. protected _pos: number;
  33731. protected _m2: number;
  33732. /**
  33733. * constructor
  33734. * @param length The number of samples required to saturate the sliding window
  33735. */
  33736. constructor(length: number);
  33737. /**
  33738. * Adds a sample to the sample set
  33739. * @param v The sample value
  33740. */
  33741. add(v: number): void;
  33742. /**
  33743. * Returns previously added values or null if outside of history or outside the sliding window domain
  33744. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33745. * @return Value previously recorded with add() or null if outside of range
  33746. */
  33747. history(i: number): number;
  33748. /**
  33749. * Returns true if enough samples have been taken to completely fill the sliding window
  33750. * @return true if sample-set saturated
  33751. */
  33752. isSaturated(): boolean;
  33753. /**
  33754. * Resets the rolling average (equivalent to 0 samples taken so far)
  33755. */
  33756. reset(): void;
  33757. /**
  33758. * Wraps a value around the sample range boundaries
  33759. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33760. * @return Wrapped position in sample range
  33761. */
  33762. protected _wrapPosition(i: number): number;
  33763. }
  33764. }
  33765. declare module "babylonjs/Misc/perfCounter" {
  33766. /**
  33767. * This class is used to track a performance counter which is number based.
  33768. * The user has access to many properties which give statistics of different nature.
  33769. *
  33770. * The implementer can track two kinds of Performance Counter: time and count.
  33771. * 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.
  33772. * 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.
  33773. */
  33774. export class PerfCounter {
  33775. /**
  33776. * Gets or sets a global boolean to turn on and off all the counters
  33777. */
  33778. static Enabled: boolean;
  33779. /**
  33780. * Returns the smallest value ever
  33781. */
  33782. get min(): number;
  33783. /**
  33784. * Returns the biggest value ever
  33785. */
  33786. get max(): number;
  33787. /**
  33788. * Returns the average value since the performance counter is running
  33789. */
  33790. get average(): number;
  33791. /**
  33792. * Returns the average value of the last second the counter was monitored
  33793. */
  33794. get lastSecAverage(): number;
  33795. /**
  33796. * Returns the current value
  33797. */
  33798. get current(): number;
  33799. /**
  33800. * Gets the accumulated total
  33801. */
  33802. get total(): number;
  33803. /**
  33804. * Gets the total value count
  33805. */
  33806. get count(): number;
  33807. /**
  33808. * Creates a new counter
  33809. */
  33810. constructor();
  33811. /**
  33812. * Call this method to start monitoring a new frame.
  33813. * 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.
  33814. */
  33815. fetchNewFrame(): void;
  33816. /**
  33817. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33818. * @param newCount the count value to add to the monitored count
  33819. * @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.
  33820. */
  33821. addCount(newCount: number, fetchResult: boolean): void;
  33822. /**
  33823. * Start monitoring this performance counter
  33824. */
  33825. beginMonitoring(): void;
  33826. /**
  33827. * Compute the time lapsed since the previous beginMonitoring() call.
  33828. * @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
  33829. */
  33830. endMonitoring(newFrame?: boolean): void;
  33831. private _fetchResult;
  33832. private _startMonitoringTime;
  33833. private _min;
  33834. private _max;
  33835. private _average;
  33836. private _current;
  33837. private _totalValueCount;
  33838. private _totalAccumulated;
  33839. private _lastSecAverage;
  33840. private _lastSecAccumulated;
  33841. private _lastSecTime;
  33842. private _lastSecValueCount;
  33843. }
  33844. }
  33845. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33846. module "babylonjs/Engines/thinEngine" {
  33847. interface ThinEngine {
  33848. /**
  33849. * Sets alpha constants used by some alpha blending modes
  33850. * @param r defines the red component
  33851. * @param g defines the green component
  33852. * @param b defines the blue component
  33853. * @param a defines the alpha component
  33854. */
  33855. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33856. /**
  33857. * Sets the current alpha mode
  33858. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33859. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33860. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33861. */
  33862. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33863. /**
  33864. * Gets the current alpha mode
  33865. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33866. * @returns the current alpha mode
  33867. */
  33868. getAlphaMode(): number;
  33869. /**
  33870. * Sets the current alpha equation
  33871. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33872. */
  33873. setAlphaEquation(equation: number): void;
  33874. /**
  33875. * Gets the current alpha equation.
  33876. * @returns the current alpha equation
  33877. */
  33878. getAlphaEquation(): number;
  33879. }
  33880. }
  33881. }
  33882. declare module "babylonjs/Engines/engine" {
  33883. import { Observable } from "babylonjs/Misc/observable";
  33884. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33885. import { Scene } from "babylonjs/scene";
  33886. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33887. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33888. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33889. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33890. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33891. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33892. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33893. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33894. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33896. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33897. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33898. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33899. import "babylonjs/Engines/Extensions/engine.alpha";
  33900. import { Material } from "babylonjs/Materials/material";
  33901. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33902. /**
  33903. * Defines the interface used by display changed events
  33904. */
  33905. export interface IDisplayChangedEventArgs {
  33906. /** Gets the vrDisplay object (if any) */
  33907. vrDisplay: Nullable<any>;
  33908. /** Gets a boolean indicating if webVR is supported */
  33909. vrSupported: boolean;
  33910. }
  33911. /**
  33912. * Defines the interface used by objects containing a viewport (like a camera)
  33913. */
  33914. interface IViewportOwnerLike {
  33915. /**
  33916. * Gets or sets the viewport
  33917. */
  33918. viewport: IViewportLike;
  33919. }
  33920. /**
  33921. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33922. */
  33923. export class Engine extends ThinEngine {
  33924. /** Defines that alpha blending is disabled */
  33925. static readonly ALPHA_DISABLE: number;
  33926. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33927. static readonly ALPHA_ADD: number;
  33928. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33929. static readonly ALPHA_COMBINE: number;
  33930. /** Defines that alpha blending to DEST - SRC * DEST */
  33931. static readonly ALPHA_SUBTRACT: number;
  33932. /** Defines that alpha blending to SRC * DEST */
  33933. static readonly ALPHA_MULTIPLY: number;
  33934. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33935. static readonly ALPHA_MAXIMIZED: number;
  33936. /** Defines that alpha blending to SRC + DEST */
  33937. static readonly ALPHA_ONEONE: number;
  33938. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33939. static readonly ALPHA_PREMULTIPLIED: number;
  33940. /**
  33941. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33942. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33943. */
  33944. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33945. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33946. static readonly ALPHA_INTERPOLATE: number;
  33947. /**
  33948. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33949. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33950. */
  33951. static readonly ALPHA_SCREENMODE: number;
  33952. /** Defines that the ressource is not delayed*/
  33953. static readonly DELAYLOADSTATE_NONE: number;
  33954. /** Defines that the ressource was successfully delay loaded */
  33955. static readonly DELAYLOADSTATE_LOADED: number;
  33956. /** Defines that the ressource is currently delay loading */
  33957. static readonly DELAYLOADSTATE_LOADING: number;
  33958. /** Defines that the ressource is delayed and has not started loading */
  33959. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33960. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33961. static readonly NEVER: number;
  33962. /** 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 */
  33963. static readonly ALWAYS: number;
  33964. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33965. static readonly LESS: number;
  33966. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33967. static readonly EQUAL: number;
  33968. /** 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 */
  33969. static readonly LEQUAL: number;
  33970. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33971. static readonly GREATER: number;
  33972. /** 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 */
  33973. static readonly GEQUAL: number;
  33974. /** 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 */
  33975. static readonly NOTEQUAL: number;
  33976. /** Passed to stencilOperation to specify that stencil value must be kept */
  33977. static readonly KEEP: number;
  33978. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33979. static readonly REPLACE: number;
  33980. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33981. static readonly INCR: number;
  33982. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33983. static readonly DECR: number;
  33984. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33985. static readonly INVERT: number;
  33986. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33987. static readonly INCR_WRAP: number;
  33988. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33989. static readonly DECR_WRAP: number;
  33990. /** Texture is not repeating outside of 0..1 UVs */
  33991. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33992. /** Texture is repeating outside of 0..1 UVs */
  33993. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33994. /** Texture is repeating and mirrored */
  33995. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33996. /** ALPHA */
  33997. static readonly TEXTUREFORMAT_ALPHA: number;
  33998. /** LUMINANCE */
  33999. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34000. /** LUMINANCE_ALPHA */
  34001. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34002. /** RGB */
  34003. static readonly TEXTUREFORMAT_RGB: number;
  34004. /** RGBA */
  34005. static readonly TEXTUREFORMAT_RGBA: number;
  34006. /** RED */
  34007. static readonly TEXTUREFORMAT_RED: number;
  34008. /** RED (2nd reference) */
  34009. static readonly TEXTUREFORMAT_R: number;
  34010. /** RG */
  34011. static readonly TEXTUREFORMAT_RG: number;
  34012. /** RED_INTEGER */
  34013. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34014. /** RED_INTEGER (2nd reference) */
  34015. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34016. /** RG_INTEGER */
  34017. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34018. /** RGB_INTEGER */
  34019. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34020. /** RGBA_INTEGER */
  34021. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34022. /** UNSIGNED_BYTE */
  34023. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34024. /** UNSIGNED_BYTE (2nd reference) */
  34025. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34026. /** FLOAT */
  34027. static readonly TEXTURETYPE_FLOAT: number;
  34028. /** HALF_FLOAT */
  34029. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34030. /** BYTE */
  34031. static readonly TEXTURETYPE_BYTE: number;
  34032. /** SHORT */
  34033. static readonly TEXTURETYPE_SHORT: number;
  34034. /** UNSIGNED_SHORT */
  34035. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34036. /** INT */
  34037. static readonly TEXTURETYPE_INT: number;
  34038. /** UNSIGNED_INT */
  34039. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34040. /** UNSIGNED_SHORT_4_4_4_4 */
  34041. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34042. /** UNSIGNED_SHORT_5_5_5_1 */
  34043. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34044. /** UNSIGNED_SHORT_5_6_5 */
  34045. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34046. /** UNSIGNED_INT_2_10_10_10_REV */
  34047. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34048. /** UNSIGNED_INT_24_8 */
  34049. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34050. /** UNSIGNED_INT_10F_11F_11F_REV */
  34051. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34052. /** UNSIGNED_INT_5_9_9_9_REV */
  34053. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34054. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34055. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34056. /** nearest is mag = nearest and min = nearest and mip = linear */
  34057. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34058. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34059. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34060. /** Trilinear is mag = linear and min = linear and mip = linear */
  34061. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34062. /** nearest is mag = nearest and min = nearest and mip = linear */
  34063. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34064. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34065. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34066. /** Trilinear is mag = linear and min = linear and mip = linear */
  34067. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34068. /** mag = nearest and min = nearest and mip = nearest */
  34069. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34070. /** mag = nearest and min = linear and mip = nearest */
  34071. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34072. /** mag = nearest and min = linear and mip = linear */
  34073. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34074. /** mag = nearest and min = linear and mip = none */
  34075. static readonly TEXTURE_NEAREST_LINEAR: number;
  34076. /** mag = nearest and min = nearest and mip = none */
  34077. static readonly TEXTURE_NEAREST_NEAREST: number;
  34078. /** mag = linear and min = nearest and mip = nearest */
  34079. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34080. /** mag = linear and min = nearest and mip = linear */
  34081. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34082. /** mag = linear and min = linear and mip = none */
  34083. static readonly TEXTURE_LINEAR_LINEAR: number;
  34084. /** mag = linear and min = nearest and mip = none */
  34085. static readonly TEXTURE_LINEAR_NEAREST: number;
  34086. /** Explicit coordinates mode */
  34087. static readonly TEXTURE_EXPLICIT_MODE: number;
  34088. /** Spherical coordinates mode */
  34089. static readonly TEXTURE_SPHERICAL_MODE: number;
  34090. /** Planar coordinates mode */
  34091. static readonly TEXTURE_PLANAR_MODE: number;
  34092. /** Cubic coordinates mode */
  34093. static readonly TEXTURE_CUBIC_MODE: number;
  34094. /** Projection coordinates mode */
  34095. static readonly TEXTURE_PROJECTION_MODE: number;
  34096. /** Skybox coordinates mode */
  34097. static readonly TEXTURE_SKYBOX_MODE: number;
  34098. /** Inverse Cubic coordinates mode */
  34099. static readonly TEXTURE_INVCUBIC_MODE: number;
  34100. /** Equirectangular coordinates mode */
  34101. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34102. /** Equirectangular Fixed coordinates mode */
  34103. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34104. /** Equirectangular Fixed Mirrored coordinates mode */
  34105. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34106. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34107. static readonly SCALEMODE_FLOOR: number;
  34108. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34109. static readonly SCALEMODE_NEAREST: number;
  34110. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34111. static readonly SCALEMODE_CEILING: number;
  34112. /**
  34113. * Returns the current npm package of the sdk
  34114. */
  34115. static get NpmPackage(): string;
  34116. /**
  34117. * Returns the current version of the framework
  34118. */
  34119. static get Version(): string;
  34120. /** Gets the list of created engines */
  34121. static get Instances(): Engine[];
  34122. /**
  34123. * Gets the latest created engine
  34124. */
  34125. static get LastCreatedEngine(): Nullable<Engine>;
  34126. /**
  34127. * Gets the latest created scene
  34128. */
  34129. static get LastCreatedScene(): Nullable<Scene>;
  34130. /**
  34131. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34132. * @param flag defines which part of the materials must be marked as dirty
  34133. * @param predicate defines a predicate used to filter which materials should be affected
  34134. */
  34135. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34136. /**
  34137. * Method called to create the default loading screen.
  34138. * This can be overriden in your own app.
  34139. * @param canvas The rendering canvas element
  34140. * @returns The loading screen
  34141. */
  34142. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34143. /**
  34144. * Method called to create the default rescale post process on each engine.
  34145. */
  34146. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34147. /**
  34148. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34149. **/
  34150. enableOfflineSupport: boolean;
  34151. /**
  34152. * 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)
  34153. **/
  34154. disableManifestCheck: boolean;
  34155. /**
  34156. * Gets the list of created scenes
  34157. */
  34158. scenes: Scene[];
  34159. /**
  34160. * Event raised when a new scene is created
  34161. */
  34162. onNewSceneAddedObservable: Observable<Scene>;
  34163. /**
  34164. * Gets the list of created postprocesses
  34165. */
  34166. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34167. /**
  34168. * Gets a boolean indicating if the pointer is currently locked
  34169. */
  34170. isPointerLock: boolean;
  34171. /**
  34172. * Observable event triggered each time the rendering canvas is resized
  34173. */
  34174. onResizeObservable: Observable<Engine>;
  34175. /**
  34176. * Observable event triggered each time the canvas loses focus
  34177. */
  34178. onCanvasBlurObservable: Observable<Engine>;
  34179. /**
  34180. * Observable event triggered each time the canvas gains focus
  34181. */
  34182. onCanvasFocusObservable: Observable<Engine>;
  34183. /**
  34184. * Observable event triggered each time the canvas receives pointerout event
  34185. */
  34186. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34187. /**
  34188. * Observable raised when the engine begins a new frame
  34189. */
  34190. onBeginFrameObservable: Observable<Engine>;
  34191. /**
  34192. * If set, will be used to request the next animation frame for the render loop
  34193. */
  34194. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34195. /**
  34196. * Observable raised when the engine ends the current frame
  34197. */
  34198. onEndFrameObservable: Observable<Engine>;
  34199. /**
  34200. * Observable raised when the engine is about to compile a shader
  34201. */
  34202. onBeforeShaderCompilationObservable: Observable<Engine>;
  34203. /**
  34204. * Observable raised when the engine has jsut compiled a shader
  34205. */
  34206. onAfterShaderCompilationObservable: Observable<Engine>;
  34207. /**
  34208. * Gets the audio engine
  34209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34210. * @ignorenaming
  34211. */
  34212. static audioEngine: IAudioEngine;
  34213. /**
  34214. * Default AudioEngine factory responsible of creating the Audio Engine.
  34215. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34216. */
  34217. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34218. /**
  34219. * Default offline support factory responsible of creating a tool used to store data locally.
  34220. * By default, this will create a Database object if the workload has been embedded.
  34221. */
  34222. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34223. private _loadingScreen;
  34224. private _pointerLockRequested;
  34225. private _dummyFramebuffer;
  34226. private _rescalePostProcess;
  34227. private _deterministicLockstep;
  34228. private _lockstepMaxSteps;
  34229. private _timeStep;
  34230. protected get _supportsHardwareTextureRescaling(): boolean;
  34231. private _fps;
  34232. private _deltaTime;
  34233. /** @hidden */
  34234. _drawCalls: PerfCounter;
  34235. /** 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 */
  34236. canvasTabIndex: number;
  34237. /**
  34238. * Turn this value on if you want to pause FPS computation when in background
  34239. */
  34240. disablePerformanceMonitorInBackground: boolean;
  34241. private _performanceMonitor;
  34242. /**
  34243. * Gets the performance monitor attached to this engine
  34244. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34245. */
  34246. get performanceMonitor(): PerformanceMonitor;
  34247. private _onFocus;
  34248. private _onBlur;
  34249. private _onCanvasPointerOut;
  34250. private _onCanvasBlur;
  34251. private _onCanvasFocus;
  34252. private _onFullscreenChange;
  34253. private _onPointerLockChange;
  34254. /**
  34255. * Gets the HTML element used to attach event listeners
  34256. * @returns a HTML element
  34257. */
  34258. getInputElement(): Nullable<HTMLElement>;
  34259. /**
  34260. * Creates a new engine
  34261. * @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
  34262. * @param antialias defines enable antialiasing (default: false)
  34263. * @param options defines further options to be sent to the getContext() function
  34264. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34265. */
  34266. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34267. /**
  34268. * Gets current aspect ratio
  34269. * @param viewportOwner defines the camera to use to get the aspect ratio
  34270. * @param useScreen defines if screen size must be used (or the current render target if any)
  34271. * @returns a number defining the aspect ratio
  34272. */
  34273. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34274. /**
  34275. * Gets current screen aspect ratio
  34276. * @returns a number defining the aspect ratio
  34277. */
  34278. getScreenAspectRatio(): number;
  34279. /**
  34280. * Gets the client rect of the HTML canvas attached with the current webGL context
  34281. * @returns a client rectanglee
  34282. */
  34283. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34284. /**
  34285. * Gets the client rect of the HTML element used for events
  34286. * @returns a client rectanglee
  34287. */
  34288. getInputElementClientRect(): Nullable<ClientRect>;
  34289. /**
  34290. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34291. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34292. * @returns true if engine is in deterministic lock step mode
  34293. */
  34294. isDeterministicLockStep(): boolean;
  34295. /**
  34296. * Gets the max steps when engine is running in deterministic lock step
  34297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34298. * @returns the max steps
  34299. */
  34300. getLockstepMaxSteps(): number;
  34301. /**
  34302. * Returns the time in ms between steps when using deterministic lock step.
  34303. * @returns time step in (ms)
  34304. */
  34305. getTimeStep(): number;
  34306. /**
  34307. * Force the mipmap generation for the given render target texture
  34308. * @param texture defines the render target texture to use
  34309. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34310. */
  34311. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34312. /** States */
  34313. /**
  34314. * Set various states to the webGL context
  34315. * @param culling defines backface culling state
  34316. * @param zOffset defines the value to apply to zOffset (0 by default)
  34317. * @param force defines if states must be applied even if cache is up to date
  34318. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34319. */
  34320. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34321. /**
  34322. * Set the z offset to apply to current rendering
  34323. * @param value defines the offset to apply
  34324. */
  34325. setZOffset(value: number): void;
  34326. /**
  34327. * Gets the current value of the zOffset
  34328. * @returns the current zOffset state
  34329. */
  34330. getZOffset(): number;
  34331. /**
  34332. * Enable or disable depth buffering
  34333. * @param enable defines the state to set
  34334. */
  34335. setDepthBuffer(enable: boolean): void;
  34336. /**
  34337. * Gets a boolean indicating if depth writing is enabled
  34338. * @returns the current depth writing state
  34339. */
  34340. getDepthWrite(): boolean;
  34341. /**
  34342. * Enable or disable depth writing
  34343. * @param enable defines the state to set
  34344. */
  34345. setDepthWrite(enable: boolean): void;
  34346. /**
  34347. * Gets a boolean indicating if stencil buffer is enabled
  34348. * @returns the current stencil buffer state
  34349. */
  34350. getStencilBuffer(): boolean;
  34351. /**
  34352. * Enable or disable the stencil buffer
  34353. * @param enable defines if the stencil buffer must be enabled or disabled
  34354. */
  34355. setStencilBuffer(enable: boolean): void;
  34356. /**
  34357. * Gets the current stencil mask
  34358. * @returns a number defining the new stencil mask to use
  34359. */
  34360. getStencilMask(): number;
  34361. /**
  34362. * Sets the current stencil mask
  34363. * @param mask defines the new stencil mask to use
  34364. */
  34365. setStencilMask(mask: number): void;
  34366. /**
  34367. * Gets the current stencil function
  34368. * @returns a number defining the stencil function to use
  34369. */
  34370. getStencilFunction(): number;
  34371. /**
  34372. * Gets the current stencil reference value
  34373. * @returns a number defining the stencil reference value to use
  34374. */
  34375. getStencilFunctionReference(): number;
  34376. /**
  34377. * Gets the current stencil mask
  34378. * @returns a number defining the stencil mask to use
  34379. */
  34380. getStencilFunctionMask(): number;
  34381. /**
  34382. * Sets the current stencil function
  34383. * @param stencilFunc defines the new stencil function to use
  34384. */
  34385. setStencilFunction(stencilFunc: number): void;
  34386. /**
  34387. * Sets the current stencil reference
  34388. * @param reference defines the new stencil reference to use
  34389. */
  34390. setStencilFunctionReference(reference: number): void;
  34391. /**
  34392. * Sets the current stencil mask
  34393. * @param mask defines the new stencil mask to use
  34394. */
  34395. setStencilFunctionMask(mask: number): void;
  34396. /**
  34397. * Gets the current stencil operation when stencil fails
  34398. * @returns a number defining stencil operation to use when stencil fails
  34399. */
  34400. getStencilOperationFail(): number;
  34401. /**
  34402. * Gets the current stencil operation when depth fails
  34403. * @returns a number defining stencil operation to use when depth fails
  34404. */
  34405. getStencilOperationDepthFail(): number;
  34406. /**
  34407. * Gets the current stencil operation when stencil passes
  34408. * @returns a number defining stencil operation to use when stencil passes
  34409. */
  34410. getStencilOperationPass(): number;
  34411. /**
  34412. * Sets the stencil operation to use when stencil fails
  34413. * @param operation defines the stencil operation to use when stencil fails
  34414. */
  34415. setStencilOperationFail(operation: number): void;
  34416. /**
  34417. * Sets the stencil operation to use when depth fails
  34418. * @param operation defines the stencil operation to use when depth fails
  34419. */
  34420. setStencilOperationDepthFail(operation: number): void;
  34421. /**
  34422. * Sets the stencil operation to use when stencil passes
  34423. * @param operation defines the stencil operation to use when stencil passes
  34424. */
  34425. setStencilOperationPass(operation: number): void;
  34426. /**
  34427. * Sets a boolean indicating if the dithering state is enabled or disabled
  34428. * @param value defines the dithering state
  34429. */
  34430. setDitheringState(value: boolean): void;
  34431. /**
  34432. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34433. * @param value defines the rasterizer state
  34434. */
  34435. setRasterizerState(value: boolean): void;
  34436. /**
  34437. * Gets the current depth function
  34438. * @returns a number defining the depth function
  34439. */
  34440. getDepthFunction(): Nullable<number>;
  34441. /**
  34442. * Sets the current depth function
  34443. * @param depthFunc defines the function to use
  34444. */
  34445. setDepthFunction(depthFunc: number): void;
  34446. /**
  34447. * Sets the current depth function to GREATER
  34448. */
  34449. setDepthFunctionToGreater(): void;
  34450. /**
  34451. * Sets the current depth function to GEQUAL
  34452. */
  34453. setDepthFunctionToGreaterOrEqual(): void;
  34454. /**
  34455. * Sets the current depth function to LESS
  34456. */
  34457. setDepthFunctionToLess(): void;
  34458. /**
  34459. * Sets the current depth function to LEQUAL
  34460. */
  34461. setDepthFunctionToLessOrEqual(): void;
  34462. private _cachedStencilBuffer;
  34463. private _cachedStencilFunction;
  34464. private _cachedStencilMask;
  34465. private _cachedStencilOperationPass;
  34466. private _cachedStencilOperationFail;
  34467. private _cachedStencilOperationDepthFail;
  34468. private _cachedStencilReference;
  34469. /**
  34470. * Caches the the state of the stencil buffer
  34471. */
  34472. cacheStencilState(): void;
  34473. /**
  34474. * Restores the state of the stencil buffer
  34475. */
  34476. restoreStencilState(): void;
  34477. /**
  34478. * Directly set the WebGL Viewport
  34479. * @param x defines the x coordinate of the viewport (in screen space)
  34480. * @param y defines the y coordinate of the viewport (in screen space)
  34481. * @param width defines the width of the viewport (in screen space)
  34482. * @param height defines the height of the viewport (in screen space)
  34483. * @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
  34484. */
  34485. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34486. /**
  34487. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34488. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34489. * @param y defines the y-coordinate of the corner of the clear rectangle
  34490. * @param width defines the width of the clear rectangle
  34491. * @param height defines the height of the clear rectangle
  34492. * @param clearColor defines the clear color
  34493. */
  34494. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34495. /**
  34496. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34497. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34498. * @param y defines the y-coordinate of the corner of the clear rectangle
  34499. * @param width defines the width of the clear rectangle
  34500. * @param height defines the height of the clear rectangle
  34501. */
  34502. enableScissor(x: number, y: number, width: number, height: number): void;
  34503. /**
  34504. * Disable previously set scissor test rectangle
  34505. */
  34506. disableScissor(): void;
  34507. protected _reportDrawCall(): void;
  34508. /**
  34509. * Initializes a webVR display and starts listening to display change events
  34510. * The onVRDisplayChangedObservable will be notified upon these changes
  34511. * @returns The onVRDisplayChangedObservable
  34512. */
  34513. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34514. /** @hidden */
  34515. _prepareVRComponent(): void;
  34516. /** @hidden */
  34517. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34518. /** @hidden */
  34519. _submitVRFrame(): void;
  34520. /**
  34521. * Call this function to leave webVR mode
  34522. * Will do nothing if webVR is not supported or if there is no webVR device
  34523. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34524. */
  34525. disableVR(): void;
  34526. /**
  34527. * Gets a boolean indicating that the system is in VR mode and is presenting
  34528. * @returns true if VR mode is engaged
  34529. */
  34530. isVRPresenting(): boolean;
  34531. /** @hidden */
  34532. _requestVRFrame(): void;
  34533. /** @hidden */
  34534. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34535. /**
  34536. * Gets the source code of the vertex shader associated with a specific webGL program
  34537. * @param program defines the program to use
  34538. * @returns a string containing the source code of the vertex shader associated with the program
  34539. */
  34540. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34541. /**
  34542. * Gets the source code of the fragment shader associated with a specific webGL program
  34543. * @param program defines the program to use
  34544. * @returns a string containing the source code of the fragment shader associated with the program
  34545. */
  34546. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34547. /**
  34548. * Sets a depth stencil texture from a render target to the according uniform.
  34549. * @param channel The texture channel
  34550. * @param uniform The uniform to set
  34551. * @param texture The render target texture containing the depth stencil texture to apply
  34552. */
  34553. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34554. /**
  34555. * Sets a texture to the webGL context from a postprocess
  34556. * @param channel defines the channel to use
  34557. * @param postProcess defines the source postprocess
  34558. */
  34559. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34560. /**
  34561. * Binds the output of the passed in post process to the texture channel specified
  34562. * @param channel The channel the texture should be bound to
  34563. * @param postProcess The post process which's output should be bound
  34564. */
  34565. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34566. /** @hidden */
  34567. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34568. protected _rebuildBuffers(): void;
  34569. /** @hidden */
  34570. _renderFrame(): void;
  34571. _renderLoop(): void;
  34572. /** @hidden */
  34573. _renderViews(): boolean;
  34574. /**
  34575. * Toggle full screen mode
  34576. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34577. */
  34578. switchFullscreen(requestPointerLock: boolean): void;
  34579. /**
  34580. * Enters full screen mode
  34581. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34582. */
  34583. enterFullscreen(requestPointerLock: boolean): void;
  34584. /**
  34585. * Exits full screen mode
  34586. */
  34587. exitFullscreen(): void;
  34588. /**
  34589. * Enters Pointerlock mode
  34590. */
  34591. enterPointerlock(): void;
  34592. /**
  34593. * Exits Pointerlock mode
  34594. */
  34595. exitPointerlock(): void;
  34596. /**
  34597. * Begin a new frame
  34598. */
  34599. beginFrame(): void;
  34600. /**
  34601. * Enf the current frame
  34602. */
  34603. endFrame(): void;
  34604. resize(): void;
  34605. /**
  34606. * Set the compressed texture format to use, based on the formats you have, and the formats
  34607. * supported by the hardware / browser.
  34608. *
  34609. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34610. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34611. * to API arguments needed to compressed textures. This puts the burden on the container
  34612. * generator to house the arcane code for determining these for current & future formats.
  34613. *
  34614. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34615. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34616. *
  34617. * Note: The result of this call is not taken into account when a texture is base64.
  34618. *
  34619. * @param formatsAvailable defines the list of those format families you have created
  34620. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34621. *
  34622. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34623. * @returns The extension selected.
  34624. */
  34625. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34626. /**
  34627. * Set the compressed texture extensions or file names to skip.
  34628. *
  34629. * @param skippedFiles defines the list of those texture files you want to skip
  34630. * Example: [".dds", ".env", "myfile.png"]
  34631. */
  34632. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34633. /**
  34634. * Force a specific size of the canvas
  34635. * @param width defines the new canvas' width
  34636. * @param height defines the new canvas' height
  34637. */
  34638. setSize(width: number, height: number): void;
  34639. /**
  34640. * Updates a dynamic vertex buffer.
  34641. * @param vertexBuffer the vertex buffer to update
  34642. * @param data the data used to update the vertex buffer
  34643. * @param byteOffset the byte offset of the data
  34644. * @param byteLength the byte length of the data
  34645. */
  34646. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34647. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34648. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34649. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34650. _releaseTexture(texture: InternalTexture): void;
  34651. /**
  34652. * @hidden
  34653. * Rescales a texture
  34654. * @param source input texutre
  34655. * @param destination destination texture
  34656. * @param scene scene to use to render the resize
  34657. * @param internalFormat format to use when resizing
  34658. * @param onComplete callback to be called when resize has completed
  34659. */
  34660. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34661. /**
  34662. * Gets the current framerate
  34663. * @returns a number representing the framerate
  34664. */
  34665. getFps(): number;
  34666. /**
  34667. * Gets the time spent between current and previous frame
  34668. * @returns a number representing the delta time in ms
  34669. */
  34670. getDeltaTime(): number;
  34671. private _measureFps;
  34672. /** @hidden */
  34673. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34674. /**
  34675. * Update a dynamic index buffer
  34676. * @param indexBuffer defines the target index buffer
  34677. * @param indices defines the data to update
  34678. * @param offset defines the offset in the target index buffer where update should start
  34679. */
  34680. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34681. /**
  34682. * Updates the sample count of a render target texture
  34683. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34684. * @param texture defines the texture to update
  34685. * @param samples defines the sample count to set
  34686. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34687. */
  34688. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34689. /**
  34690. * Updates a depth texture Comparison Mode and Function.
  34691. * If the comparison Function is equal to 0, the mode will be set to none.
  34692. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34693. * @param texture The texture to set the comparison function for
  34694. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34695. */
  34696. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34697. /**
  34698. * Creates a webGL buffer to use with instanciation
  34699. * @param capacity defines the size of the buffer
  34700. * @returns the webGL buffer
  34701. */
  34702. createInstancesBuffer(capacity: number): DataBuffer;
  34703. /**
  34704. * Delete a webGL buffer used with instanciation
  34705. * @param buffer defines the webGL buffer to delete
  34706. */
  34707. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34708. /** @hidden */
  34709. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34710. dispose(): void;
  34711. private _disableTouchAction;
  34712. /**
  34713. * Display the loading screen
  34714. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34715. */
  34716. displayLoadingUI(): void;
  34717. /**
  34718. * Hide the loading screen
  34719. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34720. */
  34721. hideLoadingUI(): void;
  34722. /**
  34723. * Gets the current loading screen object
  34724. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34725. */
  34726. get loadingScreen(): ILoadingScreen;
  34727. /**
  34728. * Sets the current loading screen object
  34729. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34730. */
  34731. set loadingScreen(loadingScreen: ILoadingScreen);
  34732. /**
  34733. * Sets the current loading screen text
  34734. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34735. */
  34736. set loadingUIText(text: string);
  34737. /**
  34738. * Sets the current loading screen background color
  34739. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34740. */
  34741. set loadingUIBackgroundColor(color: string);
  34742. /** Pointerlock and fullscreen */
  34743. /**
  34744. * Ask the browser to promote the current element to pointerlock mode
  34745. * @param element defines the DOM element to promote
  34746. */
  34747. static _RequestPointerlock(element: HTMLElement): void;
  34748. /**
  34749. * Asks the browser to exit pointerlock mode
  34750. */
  34751. static _ExitPointerlock(): void;
  34752. /**
  34753. * Ask the browser to promote the current element to fullscreen rendering mode
  34754. * @param element defines the DOM element to promote
  34755. */
  34756. static _RequestFullscreen(element: HTMLElement): void;
  34757. /**
  34758. * Asks the browser to exit fullscreen mode
  34759. */
  34760. static _ExitFullscreen(): void;
  34761. }
  34762. }
  34763. declare module "babylonjs/Engines/engineStore" {
  34764. import { Nullable } from "babylonjs/types";
  34765. import { Engine } from "babylonjs/Engines/engine";
  34766. import { Scene } from "babylonjs/scene";
  34767. /**
  34768. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34769. * during the life time of the application.
  34770. */
  34771. export class EngineStore {
  34772. /** Gets the list of created engines */
  34773. static Instances: import("babylonjs/Engines/engine").Engine[];
  34774. /** @hidden */
  34775. static _LastCreatedScene: Nullable<Scene>;
  34776. /**
  34777. * Gets the latest created engine
  34778. */
  34779. static get LastCreatedEngine(): Nullable<Engine>;
  34780. /**
  34781. * Gets the latest created scene
  34782. */
  34783. static get LastCreatedScene(): Nullable<Scene>;
  34784. /**
  34785. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34786. * @ignorenaming
  34787. */
  34788. static UseFallbackTexture: boolean;
  34789. /**
  34790. * Texture content used if a texture cannot loaded
  34791. * @ignorenaming
  34792. */
  34793. static FallbackTexture: string;
  34794. }
  34795. }
  34796. declare module "babylonjs/Misc/promise" {
  34797. /**
  34798. * Helper class that provides a small promise polyfill
  34799. */
  34800. export class PromisePolyfill {
  34801. /**
  34802. * Static function used to check if the polyfill is required
  34803. * If this is the case then the function will inject the polyfill to window.Promise
  34804. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34805. */
  34806. static Apply(force?: boolean): void;
  34807. }
  34808. }
  34809. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34810. /**
  34811. * Interface for screenshot methods with describe argument called `size` as object with options
  34812. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34813. */
  34814. export interface IScreenshotSize {
  34815. /**
  34816. * number in pixels for canvas height
  34817. */
  34818. height?: number;
  34819. /**
  34820. * multiplier allowing render at a higher or lower resolution
  34821. * If value is defined then height and width will be ignored and taken from camera
  34822. */
  34823. precision?: number;
  34824. /**
  34825. * number in pixels for canvas width
  34826. */
  34827. width?: number;
  34828. }
  34829. }
  34830. declare module "babylonjs/Misc/tools" {
  34831. import { Nullable, float } from "babylonjs/types";
  34832. import { DomManagement } from "babylonjs/Misc/domManagement";
  34833. import { WebRequest } from "babylonjs/Misc/webRequest";
  34834. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34835. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34836. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34837. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34838. import { Camera } from "babylonjs/Cameras/camera";
  34839. import { Engine } from "babylonjs/Engines/engine";
  34840. interface IColor4Like {
  34841. r: float;
  34842. g: float;
  34843. b: float;
  34844. a: float;
  34845. }
  34846. /**
  34847. * Class containing a set of static utilities functions
  34848. */
  34849. export class Tools {
  34850. /**
  34851. * Gets or sets the base URL to use to load assets
  34852. */
  34853. static get BaseUrl(): string;
  34854. static set BaseUrl(value: string);
  34855. /**
  34856. * Enable/Disable Custom HTTP Request Headers globally.
  34857. * default = false
  34858. * @see CustomRequestHeaders
  34859. */
  34860. static UseCustomRequestHeaders: boolean;
  34861. /**
  34862. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34863. * i.e. when loading files, where the server/service expects an Authorization header
  34864. */
  34865. static CustomRequestHeaders: {
  34866. [key: string]: string;
  34867. };
  34868. /**
  34869. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34870. */
  34871. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34872. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34873. /**
  34874. * Default behaviour for cors in the application.
  34875. * It can be a string if the expected behavior is identical in the entire app.
  34876. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34877. */
  34878. static CorsBehavior: string | ((url: string | string[]) => string);
  34879. /**
  34880. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34881. * @ignorenaming
  34882. */
  34883. static get UseFallbackTexture(): boolean;
  34884. static set UseFallbackTexture(value: boolean);
  34885. /**
  34886. * Use this object to register external classes like custom textures or material
  34887. * to allow the laoders to instantiate them
  34888. */
  34889. static get RegisteredExternalClasses(): {
  34890. [key: string]: Object;
  34891. };
  34892. static set RegisteredExternalClasses(classes: {
  34893. [key: string]: Object;
  34894. });
  34895. /**
  34896. * Texture content used if a texture cannot loaded
  34897. * @ignorenaming
  34898. */
  34899. static get fallbackTexture(): string;
  34900. static set fallbackTexture(value: string);
  34901. /**
  34902. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34903. * @param u defines the coordinate on X axis
  34904. * @param v defines the coordinate on Y axis
  34905. * @param width defines the width of the source data
  34906. * @param height defines the height of the source data
  34907. * @param pixels defines the source byte array
  34908. * @param color defines the output color
  34909. */
  34910. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34911. /**
  34912. * Interpolates between a and b via alpha
  34913. * @param a The lower value (returned when alpha = 0)
  34914. * @param b The upper value (returned when alpha = 1)
  34915. * @param alpha The interpolation-factor
  34916. * @return The mixed value
  34917. */
  34918. static Mix(a: number, b: number, alpha: number): number;
  34919. /**
  34920. * Tries to instantiate a new object from a given class name
  34921. * @param className defines the class name to instantiate
  34922. * @returns the new object or null if the system was not able to do the instantiation
  34923. */
  34924. static Instantiate(className: string): any;
  34925. /**
  34926. * Provides a slice function that will work even on IE
  34927. * @param data defines the array to slice
  34928. * @param start defines the start of the data (optional)
  34929. * @param end defines the end of the data (optional)
  34930. * @returns the new sliced array
  34931. */
  34932. static Slice<T>(data: T, start?: number, end?: number): T;
  34933. /**
  34934. * Polyfill for setImmediate
  34935. * @param action defines the action to execute after the current execution block
  34936. */
  34937. static SetImmediate(action: () => void): void;
  34938. /**
  34939. * Function indicating if a number is an exponent of 2
  34940. * @param value defines the value to test
  34941. * @returns true if the value is an exponent of 2
  34942. */
  34943. static IsExponentOfTwo(value: number): boolean;
  34944. private static _tmpFloatArray;
  34945. /**
  34946. * Returns the nearest 32-bit single precision float representation of a Number
  34947. * @param value A Number. If the parameter is of a different type, it will get converted
  34948. * to a number or to NaN if it cannot be converted
  34949. * @returns number
  34950. */
  34951. static FloatRound(value: number): number;
  34952. /**
  34953. * Extracts the filename from a path
  34954. * @param path defines the path to use
  34955. * @returns the filename
  34956. */
  34957. static GetFilename(path: string): string;
  34958. /**
  34959. * Extracts the "folder" part of a path (everything before the filename).
  34960. * @param uri The URI to extract the info from
  34961. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34962. * @returns The "folder" part of the path
  34963. */
  34964. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34965. /**
  34966. * Extracts text content from a DOM element hierarchy
  34967. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34968. */
  34969. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34970. /**
  34971. * Convert an angle in radians to degrees
  34972. * @param angle defines the angle to convert
  34973. * @returns the angle in degrees
  34974. */
  34975. static ToDegrees(angle: number): number;
  34976. /**
  34977. * Convert an angle in degrees to radians
  34978. * @param angle defines the angle to convert
  34979. * @returns the angle in radians
  34980. */
  34981. static ToRadians(angle: number): number;
  34982. /**
  34983. * Returns an array if obj is not an array
  34984. * @param obj defines the object to evaluate as an array
  34985. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34986. * @returns either obj directly if obj is an array or a new array containing obj
  34987. */
  34988. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34989. /**
  34990. * Gets the pointer prefix to use
  34991. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34992. */
  34993. static GetPointerPrefix(): string;
  34994. /**
  34995. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34996. * @param url define the url we are trying
  34997. * @param element define the dom element where to configure the cors policy
  34998. */
  34999. static SetCorsBehavior(url: string | string[], element: {
  35000. crossOrigin: string | null;
  35001. }): void;
  35002. /**
  35003. * Removes unwanted characters from an url
  35004. * @param url defines the url to clean
  35005. * @returns the cleaned url
  35006. */
  35007. static CleanUrl(url: string): string;
  35008. /**
  35009. * Gets or sets a function used to pre-process url before using them to load assets
  35010. */
  35011. static get PreprocessUrl(): (url: string) => string;
  35012. static set PreprocessUrl(processor: (url: string) => string);
  35013. /**
  35014. * Loads an image as an HTMLImageElement.
  35015. * @param input url string, ArrayBuffer, or Blob to load
  35016. * @param onLoad callback called when the image successfully loads
  35017. * @param onError callback called when the image fails to load
  35018. * @param offlineProvider offline provider for caching
  35019. * @param mimeType optional mime type
  35020. * @returns the HTMLImageElement of the loaded image
  35021. */
  35022. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35023. /**
  35024. * Loads a file from a url
  35025. * @param url url string, ArrayBuffer, or Blob to load
  35026. * @param onSuccess callback called when the file successfully loads
  35027. * @param onProgress callback called while file is loading (if the server supports this mode)
  35028. * @param offlineProvider defines the offline provider for caching
  35029. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35030. * @param onError callback called when the file fails to load
  35031. * @returns a file request object
  35032. */
  35033. 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;
  35034. /**
  35035. * Loads a file from a url
  35036. * @param url the file url to load
  35037. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  35038. */
  35039. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  35040. /**
  35041. * Load a script (identified by an url). When the url returns, the
  35042. * content of this file is added into a new script element, attached to the DOM (body element)
  35043. * @param scriptUrl defines the url of the script to laod
  35044. * @param onSuccess defines the callback called when the script is loaded
  35045. * @param onError defines the callback to call if an error occurs
  35046. * @param scriptId defines the id of the script element
  35047. */
  35048. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35049. /**
  35050. * Load an asynchronous script (identified by an url). When the url returns, the
  35051. * content of this file is added into a new script element, attached to the DOM (body element)
  35052. * @param scriptUrl defines the url of the script to laod
  35053. * @param scriptId defines the id of the script element
  35054. * @returns a promise request object
  35055. */
  35056. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35057. /**
  35058. * Loads a file from a blob
  35059. * @param fileToLoad defines the blob to use
  35060. * @param callback defines the callback to call when data is loaded
  35061. * @param progressCallback defines the callback to call during loading process
  35062. * @returns a file request object
  35063. */
  35064. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35065. /**
  35066. * Reads a file from a File object
  35067. * @param file defines the file to load
  35068. * @param onSuccess defines the callback to call when data is loaded
  35069. * @param onProgress defines the callback to call during loading process
  35070. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35071. * @param onError defines the callback to call when an error occurs
  35072. * @returns a file request object
  35073. */
  35074. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35075. /**
  35076. * Creates a data url from a given string content
  35077. * @param content defines the content to convert
  35078. * @returns the new data url link
  35079. */
  35080. static FileAsURL(content: string): string;
  35081. /**
  35082. * Format the given number to a specific decimal format
  35083. * @param value defines the number to format
  35084. * @param decimals defines the number of decimals to use
  35085. * @returns the formatted string
  35086. */
  35087. static Format(value: number, decimals?: number): string;
  35088. /**
  35089. * Tries to copy an object by duplicating every property
  35090. * @param source defines the source object
  35091. * @param destination defines the target object
  35092. * @param doNotCopyList defines a list of properties to avoid
  35093. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35094. */
  35095. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35096. /**
  35097. * Gets a boolean indicating if the given object has no own property
  35098. * @param obj defines the object to test
  35099. * @returns true if object has no own property
  35100. */
  35101. static IsEmpty(obj: any): boolean;
  35102. /**
  35103. * Function used to register events at window level
  35104. * @param windowElement defines the Window object to use
  35105. * @param events defines the events to register
  35106. */
  35107. static RegisterTopRootEvents(windowElement: Window, events: {
  35108. name: string;
  35109. handler: Nullable<(e: FocusEvent) => any>;
  35110. }[]): void;
  35111. /**
  35112. * Function used to unregister events from window level
  35113. * @param windowElement defines the Window object to use
  35114. * @param events defines the events to unregister
  35115. */
  35116. static UnregisterTopRootEvents(windowElement: Window, events: {
  35117. name: string;
  35118. handler: Nullable<(e: FocusEvent) => any>;
  35119. }[]): void;
  35120. /**
  35121. * @ignore
  35122. */
  35123. static _ScreenshotCanvas: HTMLCanvasElement;
  35124. /**
  35125. * Dumps the current bound framebuffer
  35126. * @param width defines the rendering width
  35127. * @param height defines the rendering height
  35128. * @param engine defines the hosting engine
  35129. * @param successCallback defines the callback triggered once the data are available
  35130. * @param mimeType defines the mime type of the result
  35131. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35132. */
  35133. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35134. /**
  35135. * Converts the canvas data to blob.
  35136. * This acts as a polyfill for browsers not supporting the to blob function.
  35137. * @param canvas Defines the canvas to extract the data from
  35138. * @param successCallback Defines the callback triggered once the data are available
  35139. * @param mimeType Defines the mime type of the result
  35140. */
  35141. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35142. /**
  35143. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35144. * @param successCallback defines the callback triggered once the data are available
  35145. * @param mimeType defines the mime type of the result
  35146. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35147. */
  35148. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35149. /**
  35150. * Downloads a blob in the browser
  35151. * @param blob defines the blob to download
  35152. * @param fileName defines the name of the downloaded file
  35153. */
  35154. static Download(blob: Blob, fileName: string): void;
  35155. /**
  35156. * Captures a screenshot of the current rendering
  35157. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35158. * @param engine defines the rendering engine
  35159. * @param camera defines the source camera
  35160. * @param size This parameter can be set to a single number or to an object with the
  35161. * following (optional) properties: precision, width, height. If a single number is passed,
  35162. * it will be used for both width and height. If an object is passed, the screenshot size
  35163. * will be derived from the parameters. The precision property is a multiplier allowing
  35164. * rendering at a higher or lower resolution
  35165. * @param successCallback defines the callback receives a single parameter which contains the
  35166. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35167. * src parameter of an <img> to display it
  35168. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35169. * Check your browser for supported MIME types
  35170. */
  35171. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35172. /**
  35173. * Captures a screenshot of the current rendering
  35174. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35175. * @param engine defines the rendering engine
  35176. * @param camera defines the source camera
  35177. * @param size This parameter can be set to a single number or to an object with the
  35178. * following (optional) properties: precision, width, height. If a single number is passed,
  35179. * it will be used for both width and height. If an object is passed, the screenshot size
  35180. * will be derived from the parameters. The precision property is a multiplier allowing
  35181. * rendering at a higher or lower resolution
  35182. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35183. * Check your browser for supported MIME types
  35184. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35185. * to the src parameter of an <img> to display it
  35186. */
  35187. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35188. /**
  35189. * Generates an image screenshot from the specified camera.
  35190. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35191. * @param engine The engine to use for rendering
  35192. * @param camera The camera to use for rendering
  35193. * @param size This parameter can be set to a single number or to an object with the
  35194. * following (optional) properties: precision, width, height. If a single number is passed,
  35195. * it will be used for both width and height. If an object is passed, the screenshot size
  35196. * will be derived from the parameters. The precision property is a multiplier allowing
  35197. * rendering at a higher or lower resolution
  35198. * @param successCallback The callback receives a single parameter which contains the
  35199. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35200. * src parameter of an <img> to display it
  35201. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35202. * Check your browser for supported MIME types
  35203. * @param samples Texture samples (default: 1)
  35204. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35205. * @param fileName A name for for the downloaded file.
  35206. */
  35207. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35208. /**
  35209. * Generates an image screenshot from the specified camera.
  35210. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35211. * @param engine The engine to use for rendering
  35212. * @param camera The camera to use for rendering
  35213. * @param size This parameter can be set to a single number or to an object with the
  35214. * following (optional) properties: precision, width, height. If a single number is passed,
  35215. * it will be used for both width and height. If an object is passed, the screenshot size
  35216. * will be derived from the parameters. The precision property is a multiplier allowing
  35217. * rendering at a higher or lower resolution
  35218. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35219. * Check your browser for supported MIME types
  35220. * @param samples Texture samples (default: 1)
  35221. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35222. * @param fileName A name for for the downloaded file.
  35223. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35224. * to the src parameter of an <img> to display it
  35225. */
  35226. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35227. /**
  35228. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35229. * Be aware Math.random() could cause collisions, but:
  35230. * "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"
  35231. * @returns a pseudo random id
  35232. */
  35233. static RandomId(): string;
  35234. /**
  35235. * Test if the given uri is a base64 string
  35236. * @param uri The uri to test
  35237. * @return True if the uri is a base64 string or false otherwise
  35238. */
  35239. static IsBase64(uri: string): boolean;
  35240. /**
  35241. * Decode the given base64 uri.
  35242. * @param uri The uri to decode
  35243. * @return The decoded base64 data.
  35244. */
  35245. static DecodeBase64(uri: string): ArrayBuffer;
  35246. /**
  35247. * Gets the absolute url.
  35248. * @param url the input url
  35249. * @return the absolute url
  35250. */
  35251. static GetAbsoluteUrl(url: string): string;
  35252. /**
  35253. * No log
  35254. */
  35255. static readonly NoneLogLevel: number;
  35256. /**
  35257. * Only message logs
  35258. */
  35259. static readonly MessageLogLevel: number;
  35260. /**
  35261. * Only warning logs
  35262. */
  35263. static readonly WarningLogLevel: number;
  35264. /**
  35265. * Only error logs
  35266. */
  35267. static readonly ErrorLogLevel: number;
  35268. /**
  35269. * All logs
  35270. */
  35271. static readonly AllLogLevel: number;
  35272. /**
  35273. * Gets a value indicating the number of loading errors
  35274. * @ignorenaming
  35275. */
  35276. static get errorsCount(): number;
  35277. /**
  35278. * Callback called when a new log is added
  35279. */
  35280. static OnNewCacheEntry: (entry: string) => void;
  35281. /**
  35282. * Log a message to the console
  35283. * @param message defines the message to log
  35284. */
  35285. static Log(message: string): void;
  35286. /**
  35287. * Write a warning message to the console
  35288. * @param message defines the message to log
  35289. */
  35290. static Warn(message: string): void;
  35291. /**
  35292. * Write an error message to the console
  35293. * @param message defines the message to log
  35294. */
  35295. static Error(message: string): void;
  35296. /**
  35297. * Gets current log cache (list of logs)
  35298. */
  35299. static get LogCache(): string;
  35300. /**
  35301. * Clears the log cache
  35302. */
  35303. static ClearLogCache(): void;
  35304. /**
  35305. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35306. */
  35307. static set LogLevels(level: number);
  35308. /**
  35309. * Checks if the window object exists
  35310. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35311. */
  35312. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35313. /**
  35314. * No performance log
  35315. */
  35316. static readonly PerformanceNoneLogLevel: number;
  35317. /**
  35318. * Use user marks to log performance
  35319. */
  35320. static readonly PerformanceUserMarkLogLevel: number;
  35321. /**
  35322. * Log performance to the console
  35323. */
  35324. static readonly PerformanceConsoleLogLevel: number;
  35325. private static _performance;
  35326. /**
  35327. * Sets the current performance log level
  35328. */
  35329. static set PerformanceLogLevel(level: number);
  35330. private static _StartPerformanceCounterDisabled;
  35331. private static _EndPerformanceCounterDisabled;
  35332. private static _StartUserMark;
  35333. private static _EndUserMark;
  35334. private static _StartPerformanceConsole;
  35335. private static _EndPerformanceConsole;
  35336. /**
  35337. * Starts a performance counter
  35338. */
  35339. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35340. /**
  35341. * Ends a specific performance coutner
  35342. */
  35343. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35344. /**
  35345. * Gets either window.performance.now() if supported or Date.now() else
  35346. */
  35347. static get Now(): number;
  35348. /**
  35349. * This method will return the name of the class used to create the instance of the given object.
  35350. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35351. * @param object the object to get the class name from
  35352. * @param isType defines if the object is actually a type
  35353. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35354. */
  35355. static GetClassName(object: any, isType?: boolean): string;
  35356. /**
  35357. * Gets the first element of an array satisfying a given predicate
  35358. * @param array defines the array to browse
  35359. * @param predicate defines the predicate to use
  35360. * @returns null if not found or the element
  35361. */
  35362. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35363. /**
  35364. * This method will return the name of the full name of the class, including its owning module (if any).
  35365. * 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).
  35366. * @param object the object to get the class name from
  35367. * @param isType defines if the object is actually a type
  35368. * @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.
  35369. * @ignorenaming
  35370. */
  35371. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35372. /**
  35373. * Returns a promise that resolves after the given amount of time.
  35374. * @param delay Number of milliseconds to delay
  35375. * @returns Promise that resolves after the given amount of time
  35376. */
  35377. static DelayAsync(delay: number): Promise<void>;
  35378. /**
  35379. * Utility function to detect if the current user agent is Safari
  35380. * @returns whether or not the current user agent is safari
  35381. */
  35382. static IsSafari(): boolean;
  35383. }
  35384. /**
  35385. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35386. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35387. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35388. * @param name The name of the class, case should be preserved
  35389. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35390. */
  35391. export function className(name: string, module?: string): (target: Object) => void;
  35392. /**
  35393. * An implementation of a loop for asynchronous functions.
  35394. */
  35395. export class AsyncLoop {
  35396. /**
  35397. * Defines the number of iterations for the loop
  35398. */
  35399. iterations: number;
  35400. /**
  35401. * Defines the current index of the loop.
  35402. */
  35403. index: number;
  35404. private _done;
  35405. private _fn;
  35406. private _successCallback;
  35407. /**
  35408. * Constructor.
  35409. * @param iterations the number of iterations.
  35410. * @param func the function to run each iteration
  35411. * @param successCallback the callback that will be called upon succesful execution
  35412. * @param offset starting offset.
  35413. */
  35414. constructor(
  35415. /**
  35416. * Defines the number of iterations for the loop
  35417. */
  35418. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35419. /**
  35420. * Execute the next iteration. Must be called after the last iteration was finished.
  35421. */
  35422. executeNext(): void;
  35423. /**
  35424. * Break the loop and run the success callback.
  35425. */
  35426. breakLoop(): void;
  35427. /**
  35428. * Create and run an async loop.
  35429. * @param iterations the number of iterations.
  35430. * @param fn the function to run each iteration
  35431. * @param successCallback the callback that will be called upon succesful execution
  35432. * @param offset starting offset.
  35433. * @returns the created async loop object
  35434. */
  35435. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35436. /**
  35437. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35438. * @param iterations total number of iterations
  35439. * @param syncedIterations number of synchronous iterations in each async iteration.
  35440. * @param fn the function to call each iteration.
  35441. * @param callback a success call back that will be called when iterating stops.
  35442. * @param breakFunction a break condition (optional)
  35443. * @param timeout timeout settings for the setTimeout function. default - 0.
  35444. * @returns the created async loop object
  35445. */
  35446. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35447. }
  35448. }
  35449. declare module "babylonjs/Misc/stringDictionary" {
  35450. import { Nullable } from "babylonjs/types";
  35451. /**
  35452. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35453. * The underlying implementation relies on an associative array to ensure the best performances.
  35454. * The value can be anything including 'null' but except 'undefined'
  35455. */
  35456. export class StringDictionary<T> {
  35457. /**
  35458. * This will clear this dictionary and copy the content from the 'source' one.
  35459. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35460. * @param source the dictionary to take the content from and copy to this dictionary
  35461. */
  35462. copyFrom(source: StringDictionary<T>): void;
  35463. /**
  35464. * Get a value based from its key
  35465. * @param key the given key to get the matching value from
  35466. * @return the value if found, otherwise undefined is returned
  35467. */
  35468. get(key: string): T | undefined;
  35469. /**
  35470. * Get a value from its key or add it if it doesn't exist.
  35471. * This method will ensure you that a given key/data will be present in the dictionary.
  35472. * @param key the given key to get the matching value from
  35473. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35474. * The factory will only be invoked if there's no data for the given key.
  35475. * @return the value corresponding to the key.
  35476. */
  35477. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35478. /**
  35479. * Get a value from its key if present in the dictionary otherwise add it
  35480. * @param key the key to get the value from
  35481. * @param val if there's no such key/value pair in the dictionary add it with this value
  35482. * @return the value corresponding to the key
  35483. */
  35484. getOrAdd(key: string, val: T): T;
  35485. /**
  35486. * Check if there's a given key in the dictionary
  35487. * @param key the key to check for
  35488. * @return true if the key is present, false otherwise
  35489. */
  35490. contains(key: string): boolean;
  35491. /**
  35492. * Add a new key and its corresponding value
  35493. * @param key the key to add
  35494. * @param value the value corresponding to the key
  35495. * @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
  35496. */
  35497. add(key: string, value: T): boolean;
  35498. /**
  35499. * Update a specific value associated to a key
  35500. * @param key defines the key to use
  35501. * @param value defines the value to store
  35502. * @returns true if the value was updated (or false if the key was not found)
  35503. */
  35504. set(key: string, value: T): boolean;
  35505. /**
  35506. * Get the element of the given key and remove it from the dictionary
  35507. * @param key defines the key to search
  35508. * @returns the value associated with the key or null if not found
  35509. */
  35510. getAndRemove(key: string): Nullable<T>;
  35511. /**
  35512. * Remove a key/value from the dictionary.
  35513. * @param key the key to remove
  35514. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35515. */
  35516. remove(key: string): boolean;
  35517. /**
  35518. * Clear the whole content of the dictionary
  35519. */
  35520. clear(): void;
  35521. /**
  35522. * Gets the current count
  35523. */
  35524. get count(): number;
  35525. /**
  35526. * Execute a callback on each key/val of the dictionary.
  35527. * Note that you can remove any element in this dictionary in the callback implementation
  35528. * @param callback the callback to execute on a given key/value pair
  35529. */
  35530. forEach(callback: (key: string, val: T) => void): void;
  35531. /**
  35532. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35533. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35534. * Note that you can remove any element in this dictionary in the callback implementation
  35535. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35536. * @returns the first item
  35537. */
  35538. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35539. private _count;
  35540. private _data;
  35541. }
  35542. }
  35543. declare module "babylonjs/Collisions/collisionCoordinator" {
  35544. import { Nullable } from "babylonjs/types";
  35545. import { Scene } from "babylonjs/scene";
  35546. import { Vector3 } from "babylonjs/Maths/math.vector";
  35547. import { Collider } from "babylonjs/Collisions/collider";
  35548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35549. /** @hidden */
  35550. export interface ICollisionCoordinator {
  35551. createCollider(): Collider;
  35552. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35553. init(scene: Scene): void;
  35554. }
  35555. /** @hidden */
  35556. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35557. private _scene;
  35558. private _scaledPosition;
  35559. private _scaledVelocity;
  35560. private _finalPosition;
  35561. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35562. createCollider(): Collider;
  35563. init(scene: Scene): void;
  35564. private _collideWithWorld;
  35565. }
  35566. }
  35567. declare module "babylonjs/Inputs/scene.inputManager" {
  35568. import { Nullable } from "babylonjs/types";
  35569. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35570. import { Vector2 } from "babylonjs/Maths/math.vector";
  35571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35572. import { Scene } from "babylonjs/scene";
  35573. /**
  35574. * Class used to manage all inputs for the scene.
  35575. */
  35576. export class InputManager {
  35577. /** The distance in pixel that you have to move to prevent some events */
  35578. static DragMovementThreshold: number;
  35579. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35580. static LongPressDelay: number;
  35581. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35582. static DoubleClickDelay: number;
  35583. /** If you need to check double click without raising a single click at first click, enable this flag */
  35584. static ExclusiveDoubleClickMode: boolean;
  35585. private _wheelEventName;
  35586. private _onPointerMove;
  35587. private _onPointerDown;
  35588. private _onPointerUp;
  35589. private _initClickEvent;
  35590. private _initActionManager;
  35591. private _delayedSimpleClick;
  35592. private _delayedSimpleClickTimeout;
  35593. private _previousDelayedSimpleClickTimeout;
  35594. private _meshPickProceed;
  35595. private _previousButtonPressed;
  35596. private _currentPickResult;
  35597. private _previousPickResult;
  35598. private _totalPointersPressed;
  35599. private _doubleClickOccured;
  35600. private _pointerOverMesh;
  35601. private _pickedDownMesh;
  35602. private _pickedUpMesh;
  35603. private _pointerX;
  35604. private _pointerY;
  35605. private _unTranslatedPointerX;
  35606. private _unTranslatedPointerY;
  35607. private _startingPointerPosition;
  35608. private _previousStartingPointerPosition;
  35609. private _startingPointerTime;
  35610. private _previousStartingPointerTime;
  35611. private _pointerCaptures;
  35612. private _onKeyDown;
  35613. private _onKeyUp;
  35614. private _onCanvasFocusObserver;
  35615. private _onCanvasBlurObserver;
  35616. private _scene;
  35617. /**
  35618. * Creates a new InputManager
  35619. * @param scene defines the hosting scene
  35620. */
  35621. constructor(scene: Scene);
  35622. /**
  35623. * Gets the mesh that is currently under the pointer
  35624. */
  35625. get meshUnderPointer(): Nullable<AbstractMesh>;
  35626. /**
  35627. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35628. */
  35629. get unTranslatedPointer(): Vector2;
  35630. /**
  35631. * Gets or sets the current on-screen X position of the pointer
  35632. */
  35633. get pointerX(): number;
  35634. set pointerX(value: number);
  35635. /**
  35636. * Gets or sets the current on-screen Y position of the pointer
  35637. */
  35638. get pointerY(): number;
  35639. set pointerY(value: number);
  35640. private _updatePointerPosition;
  35641. private _processPointerMove;
  35642. private _setRayOnPointerInfo;
  35643. private _checkPrePointerObservable;
  35644. /**
  35645. * Use this method to simulate a pointer move on a mesh
  35646. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35647. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35648. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35649. */
  35650. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35651. /**
  35652. * Use this method to simulate a pointer down on a mesh
  35653. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35654. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35655. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35656. */
  35657. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35658. private _processPointerDown;
  35659. /** @hidden */
  35660. _isPointerSwiping(): boolean;
  35661. /**
  35662. * Use this method to simulate a pointer up on a mesh
  35663. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35664. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35665. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35666. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35667. */
  35668. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35669. private _processPointerUp;
  35670. /**
  35671. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35672. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35673. * @returns true if the pointer was captured
  35674. */
  35675. isPointerCaptured(pointerId?: number): boolean;
  35676. /**
  35677. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35678. * @param attachUp defines if you want to attach events to pointerup
  35679. * @param attachDown defines if you want to attach events to pointerdown
  35680. * @param attachMove defines if you want to attach events to pointermove
  35681. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35682. */
  35683. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35684. /**
  35685. * Detaches all event handlers
  35686. */
  35687. detachControl(): void;
  35688. /**
  35689. * Force the value of meshUnderPointer
  35690. * @param mesh defines the mesh to use
  35691. */
  35692. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35693. /**
  35694. * Gets the mesh under the pointer
  35695. * @returns a Mesh or null if no mesh is under the pointer
  35696. */
  35697. getPointerOverMesh(): Nullable<AbstractMesh>;
  35698. }
  35699. }
  35700. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35701. /**
  35702. * Helper class used to generate session unique ID
  35703. */
  35704. export class UniqueIdGenerator {
  35705. private static _UniqueIdCounter;
  35706. /**
  35707. * Gets an unique (relatively to the current scene) Id
  35708. */
  35709. static get UniqueId(): number;
  35710. }
  35711. }
  35712. declare module "babylonjs/Animations/animationGroup" {
  35713. import { Animatable } from "babylonjs/Animations/animatable";
  35714. import { Animation } from "babylonjs/Animations/animation";
  35715. import { Scene, IDisposable } from "babylonjs/scene";
  35716. import { Observable } from "babylonjs/Misc/observable";
  35717. import { Nullable } from "babylonjs/types";
  35718. import "babylonjs/Animations/animatable";
  35719. /**
  35720. * This class defines the direct association between an animation and a target
  35721. */
  35722. export class TargetedAnimation {
  35723. /**
  35724. * Animation to perform
  35725. */
  35726. animation: Animation;
  35727. /**
  35728. * Target to animate
  35729. */
  35730. target: any;
  35731. /**
  35732. * Serialize the object
  35733. * @returns the JSON object representing the current entity
  35734. */
  35735. serialize(): any;
  35736. }
  35737. /**
  35738. * Use this class to create coordinated animations on multiple targets
  35739. */
  35740. export class AnimationGroup implements IDisposable {
  35741. /** The name of the animation group */
  35742. name: string;
  35743. private _scene;
  35744. private _targetedAnimations;
  35745. private _animatables;
  35746. private _from;
  35747. private _to;
  35748. private _isStarted;
  35749. private _isPaused;
  35750. private _speedRatio;
  35751. private _loopAnimation;
  35752. /**
  35753. * Gets or sets the unique id of the node
  35754. */
  35755. uniqueId: number;
  35756. /**
  35757. * This observable will notify when one animation have ended
  35758. */
  35759. onAnimationEndObservable: Observable<TargetedAnimation>;
  35760. /**
  35761. * Observer raised when one animation loops
  35762. */
  35763. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35764. /**
  35765. * Observer raised when all animations have looped
  35766. */
  35767. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35768. /**
  35769. * This observable will notify when all animations have ended.
  35770. */
  35771. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35772. /**
  35773. * This observable will notify when all animations have paused.
  35774. */
  35775. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35776. /**
  35777. * This observable will notify when all animations are playing.
  35778. */
  35779. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35780. /**
  35781. * Gets the first frame
  35782. */
  35783. get from(): number;
  35784. /**
  35785. * Gets the last frame
  35786. */
  35787. get to(): number;
  35788. /**
  35789. * Define if the animations are started
  35790. */
  35791. get isStarted(): boolean;
  35792. /**
  35793. * Gets a value indicating that the current group is playing
  35794. */
  35795. get isPlaying(): boolean;
  35796. /**
  35797. * Gets or sets the speed ratio to use for all animations
  35798. */
  35799. get speedRatio(): number;
  35800. /**
  35801. * Gets or sets the speed ratio to use for all animations
  35802. */
  35803. set speedRatio(value: number);
  35804. /**
  35805. * Gets or sets if all animations should loop or not
  35806. */
  35807. get loopAnimation(): boolean;
  35808. set loopAnimation(value: boolean);
  35809. /**
  35810. * Gets the targeted animations for this animation group
  35811. */
  35812. get targetedAnimations(): Array<TargetedAnimation>;
  35813. /**
  35814. * returning the list of animatables controlled by this animation group.
  35815. */
  35816. get animatables(): Array<Animatable>;
  35817. /**
  35818. * Instantiates a new Animation Group.
  35819. * This helps managing several animations at once.
  35820. * @see http://doc.babylonjs.com/how_to/group
  35821. * @param name Defines the name of the group
  35822. * @param scene Defines the scene the group belongs to
  35823. */
  35824. constructor(
  35825. /** The name of the animation group */
  35826. name: string, scene?: Nullable<Scene>);
  35827. /**
  35828. * Add an animation (with its target) in the group
  35829. * @param animation defines the animation we want to add
  35830. * @param target defines the target of the animation
  35831. * @returns the TargetedAnimation object
  35832. */
  35833. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35834. /**
  35835. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35836. * It can add constant keys at begin or end
  35837. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35838. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35839. * @returns the animation group
  35840. */
  35841. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35842. private _animationLoopCount;
  35843. private _animationLoopFlags;
  35844. private _processLoop;
  35845. /**
  35846. * Start all animations on given targets
  35847. * @param loop defines if animations must loop
  35848. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35849. * @param from defines the from key (optional)
  35850. * @param to defines the to key (optional)
  35851. * @returns the current animation group
  35852. */
  35853. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35854. /**
  35855. * Pause all animations
  35856. * @returns the animation group
  35857. */
  35858. pause(): AnimationGroup;
  35859. /**
  35860. * Play all animations to initial state
  35861. * This function will start() the animations if they were not started or will restart() them if they were paused
  35862. * @param loop defines if animations must loop
  35863. * @returns the animation group
  35864. */
  35865. play(loop?: boolean): AnimationGroup;
  35866. /**
  35867. * Reset all animations to initial state
  35868. * @returns the animation group
  35869. */
  35870. reset(): AnimationGroup;
  35871. /**
  35872. * Restart animations from key 0
  35873. * @returns the animation group
  35874. */
  35875. restart(): AnimationGroup;
  35876. /**
  35877. * Stop all animations
  35878. * @returns the animation group
  35879. */
  35880. stop(): AnimationGroup;
  35881. /**
  35882. * Set animation weight for all animatables
  35883. * @param weight defines the weight to use
  35884. * @return the animationGroup
  35885. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35886. */
  35887. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35888. /**
  35889. * Synchronize and normalize all animatables with a source animatable
  35890. * @param root defines the root animatable to synchronize with
  35891. * @return the animationGroup
  35892. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35893. */
  35894. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35895. /**
  35896. * Goes to a specific frame in this animation group
  35897. * @param frame the frame number to go to
  35898. * @return the animationGroup
  35899. */
  35900. goToFrame(frame: number): AnimationGroup;
  35901. /**
  35902. * Dispose all associated resources
  35903. */
  35904. dispose(): void;
  35905. private _checkAnimationGroupEnded;
  35906. /**
  35907. * Clone the current animation group and returns a copy
  35908. * @param newName defines the name of the new group
  35909. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35910. * @returns the new aniamtion group
  35911. */
  35912. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35913. /**
  35914. * Serializes the animationGroup to an object
  35915. * @returns Serialized object
  35916. */
  35917. serialize(): any;
  35918. /**
  35919. * Returns a new AnimationGroup object parsed from the source provided.
  35920. * @param parsedAnimationGroup defines the source
  35921. * @param scene defines the scene that will receive the animationGroup
  35922. * @returns a new AnimationGroup
  35923. */
  35924. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35925. /**
  35926. * Returns the string "AnimationGroup"
  35927. * @returns "AnimationGroup"
  35928. */
  35929. getClassName(): string;
  35930. /**
  35931. * Creates a detailled string about the object
  35932. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35933. * @returns a string representing the object
  35934. */
  35935. toString(fullDetails?: boolean): string;
  35936. }
  35937. }
  35938. declare module "babylonjs/scene" {
  35939. import { Nullable } from "babylonjs/types";
  35940. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35941. import { Observable } from "babylonjs/Misc/observable";
  35942. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35943. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35944. import { Geometry } from "babylonjs/Meshes/geometry";
  35945. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35946. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35948. import { Mesh } from "babylonjs/Meshes/mesh";
  35949. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35950. import { Bone } from "babylonjs/Bones/bone";
  35951. import { Skeleton } from "babylonjs/Bones/skeleton";
  35952. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35953. import { Camera } from "babylonjs/Cameras/camera";
  35954. import { AbstractScene } from "babylonjs/abstractScene";
  35955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35956. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35957. import { Material } from "babylonjs/Materials/material";
  35958. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35959. import { Effect } from "babylonjs/Materials/effect";
  35960. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35961. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35962. import { Light } from "babylonjs/Lights/light";
  35963. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35964. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35965. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35966. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35968. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35969. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35970. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35971. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35972. import { Engine } from "babylonjs/Engines/engine";
  35973. import { Node } from "babylonjs/node";
  35974. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35975. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35976. import { WebRequest } from "babylonjs/Misc/webRequest";
  35977. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35978. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35979. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35980. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35981. import { Plane } from "babylonjs/Maths/math.plane";
  35982. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35983. import { Ray } from "babylonjs/Culling/ray";
  35984. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35985. import { Animation } from "babylonjs/Animations/animation";
  35986. import { Animatable } from "babylonjs/Animations/animatable";
  35987. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35988. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35989. import { Collider } from "babylonjs/Collisions/collider";
  35990. /**
  35991. * Define an interface for all classes that will hold resources
  35992. */
  35993. export interface IDisposable {
  35994. /**
  35995. * Releases all held resources
  35996. */
  35997. dispose(): void;
  35998. }
  35999. /** Interface defining initialization parameters for Scene class */
  36000. export interface SceneOptions {
  36001. /**
  36002. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36003. * It will improve performance when the number of geometries becomes important.
  36004. */
  36005. useGeometryUniqueIdsMap?: boolean;
  36006. /**
  36007. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36008. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36009. */
  36010. useMaterialMeshMap?: boolean;
  36011. /**
  36012. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36013. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36014. */
  36015. useClonedMeshMap?: boolean;
  36016. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36017. virtual?: boolean;
  36018. }
  36019. /**
  36020. * Represents a scene to be rendered by the engine.
  36021. * @see http://doc.babylonjs.com/features/scene
  36022. */
  36023. export class Scene extends AbstractScene implements IAnimatable {
  36024. /** The fog is deactivated */
  36025. static readonly FOGMODE_NONE: number;
  36026. /** The fog density is following an exponential function */
  36027. static readonly FOGMODE_EXP: number;
  36028. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36029. static readonly FOGMODE_EXP2: number;
  36030. /** The fog density is following a linear function. */
  36031. static readonly FOGMODE_LINEAR: number;
  36032. /**
  36033. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36034. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36035. */
  36036. static MinDeltaTime: number;
  36037. /**
  36038. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36039. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36040. */
  36041. static MaxDeltaTime: number;
  36042. /**
  36043. * Factory used to create the default material.
  36044. * @param name The name of the material to create
  36045. * @param scene The scene to create the material for
  36046. * @returns The default material
  36047. */
  36048. static DefaultMaterialFactory(scene: Scene): Material;
  36049. /**
  36050. * Factory used to create the a collision coordinator.
  36051. * @returns The collision coordinator
  36052. */
  36053. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36054. /** @hidden */
  36055. _inputManager: InputManager;
  36056. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36057. cameraToUseForPointers: Nullable<Camera>;
  36058. /** @hidden */
  36059. readonly _isScene: boolean;
  36060. /**
  36061. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36062. */
  36063. autoClear: boolean;
  36064. /**
  36065. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36066. */
  36067. autoClearDepthAndStencil: boolean;
  36068. /**
  36069. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36070. */
  36071. clearColor: Color4;
  36072. /**
  36073. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36074. */
  36075. ambientColor: Color3;
  36076. /**
  36077. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36078. * It should only be one of the following (if not the default embedded one):
  36079. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36080. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36081. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36082. * The material properties need to be setup according to the type of texture in use.
  36083. */
  36084. environmentBRDFTexture: BaseTexture;
  36085. /** @hidden */
  36086. protected _environmentTexture: Nullable<BaseTexture>;
  36087. /**
  36088. * Texture used in all pbr material as the reflection texture.
  36089. * As in the majority of the scene they are the same (exception for multi room and so on),
  36090. * this is easier to reference from here than from all the materials.
  36091. */
  36092. get environmentTexture(): Nullable<BaseTexture>;
  36093. /**
  36094. * Texture used in all pbr material as the reflection texture.
  36095. * As in the majority of the scene they are the same (exception for multi room and so on),
  36096. * this is easier to set here than in all the materials.
  36097. */
  36098. set environmentTexture(value: Nullable<BaseTexture>);
  36099. /** @hidden */
  36100. protected _environmentIntensity: number;
  36101. /**
  36102. * Intensity of the environment in all pbr material.
  36103. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36104. * As in the majority of the scene they are the same (exception for multi room and so on),
  36105. * this is easier to reference from here than from all the materials.
  36106. */
  36107. get environmentIntensity(): number;
  36108. /**
  36109. * Intensity of the environment in all pbr material.
  36110. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36111. * As in the majority of the scene they are the same (exception for multi room and so on),
  36112. * this is easier to set here than in all the materials.
  36113. */
  36114. set environmentIntensity(value: number);
  36115. /** @hidden */
  36116. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36117. /**
  36118. * Default image processing configuration used either in the rendering
  36119. * Forward main pass or through the imageProcessingPostProcess if present.
  36120. * As in the majority of the scene they are the same (exception for multi camera),
  36121. * this is easier to reference from here than from all the materials and post process.
  36122. *
  36123. * No setter as we it is a shared configuration, you can set the values instead.
  36124. */
  36125. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36126. private _forceWireframe;
  36127. /**
  36128. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36129. */
  36130. set forceWireframe(value: boolean);
  36131. get forceWireframe(): boolean;
  36132. private _skipFrustumClipping;
  36133. /**
  36134. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36135. */
  36136. set skipFrustumClipping(value: boolean);
  36137. get skipFrustumClipping(): boolean;
  36138. private _forcePointsCloud;
  36139. /**
  36140. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36141. */
  36142. set forcePointsCloud(value: boolean);
  36143. get forcePointsCloud(): boolean;
  36144. /**
  36145. * Gets or sets the active clipplane 1
  36146. */
  36147. clipPlane: Nullable<Plane>;
  36148. /**
  36149. * Gets or sets the active clipplane 2
  36150. */
  36151. clipPlane2: Nullable<Plane>;
  36152. /**
  36153. * Gets or sets the active clipplane 3
  36154. */
  36155. clipPlane3: Nullable<Plane>;
  36156. /**
  36157. * Gets or sets the active clipplane 4
  36158. */
  36159. clipPlane4: Nullable<Plane>;
  36160. /**
  36161. * Gets or sets the active clipplane 5
  36162. */
  36163. clipPlane5: Nullable<Plane>;
  36164. /**
  36165. * Gets or sets the active clipplane 6
  36166. */
  36167. clipPlane6: Nullable<Plane>;
  36168. /**
  36169. * Gets or sets a boolean indicating if animations are enabled
  36170. */
  36171. animationsEnabled: boolean;
  36172. private _animationPropertiesOverride;
  36173. /**
  36174. * Gets or sets the animation properties override
  36175. */
  36176. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36177. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36178. /**
  36179. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36180. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36181. */
  36182. useConstantAnimationDeltaTime: boolean;
  36183. /**
  36184. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36185. * Please note that it requires to run a ray cast through the scene on every frame
  36186. */
  36187. constantlyUpdateMeshUnderPointer: boolean;
  36188. /**
  36189. * Defines the HTML cursor to use when hovering over interactive elements
  36190. */
  36191. hoverCursor: string;
  36192. /**
  36193. * Defines the HTML default cursor to use (empty by default)
  36194. */
  36195. defaultCursor: string;
  36196. /**
  36197. * Defines wether cursors are handled by the scene.
  36198. */
  36199. doNotHandleCursors: boolean;
  36200. /**
  36201. * This is used to call preventDefault() on pointer down
  36202. * in order to block unwanted artifacts like system double clicks
  36203. */
  36204. preventDefaultOnPointerDown: boolean;
  36205. /**
  36206. * This is used to call preventDefault() on pointer up
  36207. * in order to block unwanted artifacts like system double clicks
  36208. */
  36209. preventDefaultOnPointerUp: boolean;
  36210. /**
  36211. * Gets or sets user defined metadata
  36212. */
  36213. metadata: any;
  36214. /**
  36215. * For internal use only. Please do not use.
  36216. */
  36217. reservedDataStore: any;
  36218. /**
  36219. * Gets the name of the plugin used to load this scene (null by default)
  36220. */
  36221. loadingPluginName: string;
  36222. /**
  36223. * Use this array to add regular expressions used to disable offline support for specific urls
  36224. */
  36225. disableOfflineSupportExceptionRules: RegExp[];
  36226. /**
  36227. * An event triggered when the scene is disposed.
  36228. */
  36229. onDisposeObservable: Observable<Scene>;
  36230. private _onDisposeObserver;
  36231. /** Sets a function to be executed when this scene is disposed. */
  36232. set onDispose(callback: () => void);
  36233. /**
  36234. * An event triggered before rendering the scene (right after animations and physics)
  36235. */
  36236. onBeforeRenderObservable: Observable<Scene>;
  36237. private _onBeforeRenderObserver;
  36238. /** Sets a function to be executed before rendering this scene */
  36239. set beforeRender(callback: Nullable<() => void>);
  36240. /**
  36241. * An event triggered after rendering the scene
  36242. */
  36243. onAfterRenderObservable: Observable<Scene>;
  36244. /**
  36245. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36246. */
  36247. onAfterRenderCameraObservable: Observable<Camera>;
  36248. private _onAfterRenderObserver;
  36249. /** Sets a function to be executed after rendering this scene */
  36250. set afterRender(callback: Nullable<() => void>);
  36251. /**
  36252. * An event triggered before animating the scene
  36253. */
  36254. onBeforeAnimationsObservable: Observable<Scene>;
  36255. /**
  36256. * An event triggered after animations processing
  36257. */
  36258. onAfterAnimationsObservable: Observable<Scene>;
  36259. /**
  36260. * An event triggered before draw calls are ready to be sent
  36261. */
  36262. onBeforeDrawPhaseObservable: Observable<Scene>;
  36263. /**
  36264. * An event triggered after draw calls have been sent
  36265. */
  36266. onAfterDrawPhaseObservable: Observable<Scene>;
  36267. /**
  36268. * An event triggered when the scene is ready
  36269. */
  36270. onReadyObservable: Observable<Scene>;
  36271. /**
  36272. * An event triggered before rendering a camera
  36273. */
  36274. onBeforeCameraRenderObservable: Observable<Camera>;
  36275. private _onBeforeCameraRenderObserver;
  36276. /** Sets a function to be executed before rendering a camera*/
  36277. set beforeCameraRender(callback: () => void);
  36278. /**
  36279. * An event triggered after rendering a camera
  36280. */
  36281. onAfterCameraRenderObservable: Observable<Camera>;
  36282. private _onAfterCameraRenderObserver;
  36283. /** Sets a function to be executed after rendering a camera*/
  36284. set afterCameraRender(callback: () => void);
  36285. /**
  36286. * An event triggered when active meshes evaluation is about to start
  36287. */
  36288. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36289. /**
  36290. * An event triggered when active meshes evaluation is done
  36291. */
  36292. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36293. /**
  36294. * An event triggered when particles rendering is about to start
  36295. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36296. */
  36297. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36298. /**
  36299. * An event triggered when particles rendering is done
  36300. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36301. */
  36302. onAfterParticlesRenderingObservable: Observable<Scene>;
  36303. /**
  36304. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36305. */
  36306. onDataLoadedObservable: Observable<Scene>;
  36307. /**
  36308. * An event triggered when a camera is created
  36309. */
  36310. onNewCameraAddedObservable: Observable<Camera>;
  36311. /**
  36312. * An event triggered when a camera is removed
  36313. */
  36314. onCameraRemovedObservable: Observable<Camera>;
  36315. /**
  36316. * An event triggered when a light is created
  36317. */
  36318. onNewLightAddedObservable: Observable<Light>;
  36319. /**
  36320. * An event triggered when a light is removed
  36321. */
  36322. onLightRemovedObservable: Observable<Light>;
  36323. /**
  36324. * An event triggered when a geometry is created
  36325. */
  36326. onNewGeometryAddedObservable: Observable<Geometry>;
  36327. /**
  36328. * An event triggered when a geometry is removed
  36329. */
  36330. onGeometryRemovedObservable: Observable<Geometry>;
  36331. /**
  36332. * An event triggered when a transform node is created
  36333. */
  36334. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36335. /**
  36336. * An event triggered when a transform node is removed
  36337. */
  36338. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36339. /**
  36340. * An event triggered when a mesh is created
  36341. */
  36342. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36343. /**
  36344. * An event triggered when a mesh is removed
  36345. */
  36346. onMeshRemovedObservable: Observable<AbstractMesh>;
  36347. /**
  36348. * An event triggered when a skeleton is created
  36349. */
  36350. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36351. /**
  36352. * An event triggered when a skeleton is removed
  36353. */
  36354. onSkeletonRemovedObservable: Observable<Skeleton>;
  36355. /**
  36356. * An event triggered when a material is created
  36357. */
  36358. onNewMaterialAddedObservable: Observable<Material>;
  36359. /**
  36360. * An event triggered when a material is removed
  36361. */
  36362. onMaterialRemovedObservable: Observable<Material>;
  36363. /**
  36364. * An event triggered when a texture is created
  36365. */
  36366. onNewTextureAddedObservable: Observable<BaseTexture>;
  36367. /**
  36368. * An event triggered when a texture is removed
  36369. */
  36370. onTextureRemovedObservable: Observable<BaseTexture>;
  36371. /**
  36372. * An event triggered when render targets are about to be rendered
  36373. * Can happen multiple times per frame.
  36374. */
  36375. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36376. /**
  36377. * An event triggered when render targets were rendered.
  36378. * Can happen multiple times per frame.
  36379. */
  36380. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36381. /**
  36382. * An event triggered before calculating deterministic simulation step
  36383. */
  36384. onBeforeStepObservable: Observable<Scene>;
  36385. /**
  36386. * An event triggered after calculating deterministic simulation step
  36387. */
  36388. onAfterStepObservable: Observable<Scene>;
  36389. /**
  36390. * An event triggered when the activeCamera property is updated
  36391. */
  36392. onActiveCameraChanged: Observable<Scene>;
  36393. /**
  36394. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36395. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36396. * 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)
  36397. */
  36398. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36399. /**
  36400. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36401. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36402. * 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)
  36403. */
  36404. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36405. /**
  36406. * This Observable will when a mesh has been imported into the scene.
  36407. */
  36408. onMeshImportedObservable: Observable<AbstractMesh>;
  36409. /**
  36410. * This Observable will when an animation file has been imported into the scene.
  36411. */
  36412. onAnimationFileImportedObservable: Observable<Scene>;
  36413. /**
  36414. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36415. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36416. */
  36417. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36418. /** @hidden */
  36419. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36420. /**
  36421. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36422. */
  36423. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36424. /**
  36425. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36426. */
  36427. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36428. /**
  36429. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36430. */
  36431. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36432. /** Callback called when a pointer move is detected */
  36433. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36434. /** Callback called when a pointer down is detected */
  36435. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36436. /** Callback called when a pointer up is detected */
  36437. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36438. /** Callback called when a pointer pick is detected */
  36439. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36440. /**
  36441. * 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).
  36442. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36443. */
  36444. onPrePointerObservable: Observable<PointerInfoPre>;
  36445. /**
  36446. * Observable event triggered each time an input event is received from the rendering canvas
  36447. */
  36448. onPointerObservable: Observable<PointerInfo>;
  36449. /**
  36450. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36451. */
  36452. get unTranslatedPointer(): Vector2;
  36453. /**
  36454. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36455. */
  36456. static get DragMovementThreshold(): number;
  36457. static set DragMovementThreshold(value: number);
  36458. /**
  36459. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36460. */
  36461. static get LongPressDelay(): number;
  36462. static set LongPressDelay(value: number);
  36463. /**
  36464. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36465. */
  36466. static get DoubleClickDelay(): number;
  36467. static set DoubleClickDelay(value: number);
  36468. /** If you need to check double click without raising a single click at first click, enable this flag */
  36469. static get ExclusiveDoubleClickMode(): boolean;
  36470. static set ExclusiveDoubleClickMode(value: boolean);
  36471. /** @hidden */
  36472. _mirroredCameraPosition: Nullable<Vector3>;
  36473. /**
  36474. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36475. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36476. */
  36477. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36478. /**
  36479. * Observable event triggered each time an keyboard event is received from the hosting window
  36480. */
  36481. onKeyboardObservable: Observable<KeyboardInfo>;
  36482. private _useRightHandedSystem;
  36483. /**
  36484. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36485. */
  36486. set useRightHandedSystem(value: boolean);
  36487. get useRightHandedSystem(): boolean;
  36488. private _timeAccumulator;
  36489. private _currentStepId;
  36490. private _currentInternalStep;
  36491. /**
  36492. * Sets the step Id used by deterministic lock step
  36493. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36494. * @param newStepId defines the step Id
  36495. */
  36496. setStepId(newStepId: number): void;
  36497. /**
  36498. * Gets the step Id used by deterministic lock step
  36499. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36500. * @returns the step Id
  36501. */
  36502. getStepId(): number;
  36503. /**
  36504. * Gets the internal step used by deterministic lock step
  36505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36506. * @returns the internal step
  36507. */
  36508. getInternalStep(): number;
  36509. private _fogEnabled;
  36510. /**
  36511. * Gets or sets a boolean indicating if fog is enabled on this scene
  36512. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36513. * (Default is true)
  36514. */
  36515. set fogEnabled(value: boolean);
  36516. get fogEnabled(): boolean;
  36517. private _fogMode;
  36518. /**
  36519. * Gets or sets the fog mode to use
  36520. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36521. * | mode | value |
  36522. * | --- | --- |
  36523. * | FOGMODE_NONE | 0 |
  36524. * | FOGMODE_EXP | 1 |
  36525. * | FOGMODE_EXP2 | 2 |
  36526. * | FOGMODE_LINEAR | 3 |
  36527. */
  36528. set fogMode(value: number);
  36529. get fogMode(): number;
  36530. /**
  36531. * Gets or sets the fog color to use
  36532. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36533. * (Default is Color3(0.2, 0.2, 0.3))
  36534. */
  36535. fogColor: Color3;
  36536. /**
  36537. * Gets or sets the fog density to use
  36538. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36539. * (Default is 0.1)
  36540. */
  36541. fogDensity: number;
  36542. /**
  36543. * Gets or sets the fog start distance to use
  36544. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36545. * (Default is 0)
  36546. */
  36547. fogStart: number;
  36548. /**
  36549. * Gets or sets the fog end distance to use
  36550. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36551. * (Default is 1000)
  36552. */
  36553. fogEnd: number;
  36554. private _shadowsEnabled;
  36555. /**
  36556. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36557. */
  36558. set shadowsEnabled(value: boolean);
  36559. get shadowsEnabled(): boolean;
  36560. private _lightsEnabled;
  36561. /**
  36562. * Gets or sets a boolean indicating if lights are enabled on this scene
  36563. */
  36564. set lightsEnabled(value: boolean);
  36565. get lightsEnabled(): boolean;
  36566. /** All of the active cameras added to this scene. */
  36567. activeCameras: Camera[];
  36568. /** @hidden */
  36569. _activeCamera: Nullable<Camera>;
  36570. /** Gets or sets the current active camera */
  36571. get activeCamera(): Nullable<Camera>;
  36572. set activeCamera(value: Nullable<Camera>);
  36573. private _defaultMaterial;
  36574. /** The default material used on meshes when no material is affected */
  36575. get defaultMaterial(): Material;
  36576. /** The default material used on meshes when no material is affected */
  36577. set defaultMaterial(value: Material);
  36578. private _texturesEnabled;
  36579. /**
  36580. * Gets or sets a boolean indicating if textures are enabled on this scene
  36581. */
  36582. set texturesEnabled(value: boolean);
  36583. get texturesEnabled(): boolean;
  36584. /**
  36585. * Gets or sets a boolean indicating if particles are enabled on this scene
  36586. */
  36587. particlesEnabled: boolean;
  36588. /**
  36589. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36590. */
  36591. spritesEnabled: boolean;
  36592. private _skeletonsEnabled;
  36593. /**
  36594. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36595. */
  36596. set skeletonsEnabled(value: boolean);
  36597. get skeletonsEnabled(): boolean;
  36598. /**
  36599. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36600. */
  36601. lensFlaresEnabled: boolean;
  36602. /**
  36603. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36605. */
  36606. collisionsEnabled: boolean;
  36607. private _collisionCoordinator;
  36608. /** @hidden */
  36609. get collisionCoordinator(): ICollisionCoordinator;
  36610. /**
  36611. * Defines the gravity applied to this scene (used only for collisions)
  36612. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36613. */
  36614. gravity: Vector3;
  36615. /**
  36616. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36617. */
  36618. postProcessesEnabled: boolean;
  36619. /**
  36620. * The list of postprocesses added to the scene
  36621. */
  36622. postProcesses: PostProcess[];
  36623. /**
  36624. * Gets the current postprocess manager
  36625. */
  36626. postProcessManager: PostProcessManager;
  36627. /**
  36628. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36629. */
  36630. renderTargetsEnabled: boolean;
  36631. /**
  36632. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36633. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36634. */
  36635. dumpNextRenderTargets: boolean;
  36636. /**
  36637. * The list of user defined render targets added to the scene
  36638. */
  36639. customRenderTargets: RenderTargetTexture[];
  36640. /**
  36641. * Defines if texture loading must be delayed
  36642. * If true, textures will only be loaded when they need to be rendered
  36643. */
  36644. useDelayedTextureLoading: boolean;
  36645. /**
  36646. * Gets the list of meshes imported to the scene through SceneLoader
  36647. */
  36648. importedMeshesFiles: String[];
  36649. /**
  36650. * Gets or sets a boolean indicating if probes are enabled on this scene
  36651. */
  36652. probesEnabled: boolean;
  36653. /**
  36654. * Gets or sets the current offline provider to use to store scene data
  36655. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36656. */
  36657. offlineProvider: IOfflineProvider;
  36658. /**
  36659. * Gets or sets the action manager associated with the scene
  36660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36661. */
  36662. actionManager: AbstractActionManager;
  36663. private _meshesForIntersections;
  36664. /**
  36665. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36666. */
  36667. proceduralTexturesEnabled: boolean;
  36668. private _engine;
  36669. private _totalVertices;
  36670. /** @hidden */
  36671. _activeIndices: PerfCounter;
  36672. /** @hidden */
  36673. _activeParticles: PerfCounter;
  36674. /** @hidden */
  36675. _activeBones: PerfCounter;
  36676. private _animationRatio;
  36677. /** @hidden */
  36678. _animationTimeLast: number;
  36679. /** @hidden */
  36680. _animationTime: number;
  36681. /**
  36682. * Gets or sets a general scale for animation speed
  36683. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36684. */
  36685. animationTimeScale: number;
  36686. /** @hidden */
  36687. _cachedMaterial: Nullable<Material>;
  36688. /** @hidden */
  36689. _cachedEffect: Nullable<Effect>;
  36690. /** @hidden */
  36691. _cachedVisibility: Nullable<number>;
  36692. private _renderId;
  36693. private _frameId;
  36694. private _executeWhenReadyTimeoutId;
  36695. private _intermediateRendering;
  36696. private _viewUpdateFlag;
  36697. private _projectionUpdateFlag;
  36698. /** @hidden */
  36699. _toBeDisposed: Nullable<IDisposable>[];
  36700. private _activeRequests;
  36701. /** @hidden */
  36702. _pendingData: any[];
  36703. private _isDisposed;
  36704. /**
  36705. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36706. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36707. */
  36708. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36709. private _activeMeshes;
  36710. private _processedMaterials;
  36711. private _renderTargets;
  36712. /** @hidden */
  36713. _activeParticleSystems: SmartArray<IParticleSystem>;
  36714. private _activeSkeletons;
  36715. private _softwareSkinnedMeshes;
  36716. private _renderingManager;
  36717. /** @hidden */
  36718. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36719. private _transformMatrix;
  36720. private _sceneUbo;
  36721. /** @hidden */
  36722. _viewMatrix: Matrix;
  36723. private _projectionMatrix;
  36724. /** @hidden */
  36725. _forcedViewPosition: Nullable<Vector3>;
  36726. /** @hidden */
  36727. _frustumPlanes: Plane[];
  36728. /**
  36729. * Gets the list of frustum planes (built from the active camera)
  36730. */
  36731. get frustumPlanes(): Plane[];
  36732. /**
  36733. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36734. * This is useful if there are more lights that the maximum simulteanous authorized
  36735. */
  36736. requireLightSorting: boolean;
  36737. /** @hidden */
  36738. readonly useMaterialMeshMap: boolean;
  36739. /** @hidden */
  36740. readonly useClonedMeshMap: boolean;
  36741. private _externalData;
  36742. private _uid;
  36743. /**
  36744. * @hidden
  36745. * Backing store of defined scene components.
  36746. */
  36747. _components: ISceneComponent[];
  36748. /**
  36749. * @hidden
  36750. * Backing store of defined scene components.
  36751. */
  36752. _serializableComponents: ISceneSerializableComponent[];
  36753. /**
  36754. * List of components to register on the next registration step.
  36755. */
  36756. private _transientComponents;
  36757. /**
  36758. * Registers the transient components if needed.
  36759. */
  36760. private _registerTransientComponents;
  36761. /**
  36762. * @hidden
  36763. * Add a component to the scene.
  36764. * Note that the ccomponent could be registered on th next frame if this is called after
  36765. * the register component stage.
  36766. * @param component Defines the component to add to the scene
  36767. */
  36768. _addComponent(component: ISceneComponent): void;
  36769. /**
  36770. * @hidden
  36771. * Gets a component from the scene.
  36772. * @param name defines the name of the component to retrieve
  36773. * @returns the component or null if not present
  36774. */
  36775. _getComponent(name: string): Nullable<ISceneComponent>;
  36776. /**
  36777. * @hidden
  36778. * Defines the actions happening before camera updates.
  36779. */
  36780. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36781. /**
  36782. * @hidden
  36783. * Defines the actions happening before clear the canvas.
  36784. */
  36785. _beforeClearStage: Stage<SimpleStageAction>;
  36786. /**
  36787. * @hidden
  36788. * Defines the actions when collecting render targets for the frame.
  36789. */
  36790. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36791. /**
  36792. * @hidden
  36793. * Defines the actions happening for one camera in the frame.
  36794. */
  36795. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36796. /**
  36797. * @hidden
  36798. * Defines the actions happening during the per mesh ready checks.
  36799. */
  36800. _isReadyForMeshStage: Stage<MeshStageAction>;
  36801. /**
  36802. * @hidden
  36803. * Defines the actions happening before evaluate active mesh checks.
  36804. */
  36805. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36806. /**
  36807. * @hidden
  36808. * Defines the actions happening during the evaluate sub mesh checks.
  36809. */
  36810. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36811. /**
  36812. * @hidden
  36813. * Defines the actions happening during the active mesh stage.
  36814. */
  36815. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36816. /**
  36817. * @hidden
  36818. * Defines the actions happening during the per camera render target step.
  36819. */
  36820. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36821. /**
  36822. * @hidden
  36823. * Defines the actions happening just before the active camera is drawing.
  36824. */
  36825. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36826. /**
  36827. * @hidden
  36828. * Defines the actions happening just before a render target is drawing.
  36829. */
  36830. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36831. /**
  36832. * @hidden
  36833. * Defines the actions happening just before a rendering group is drawing.
  36834. */
  36835. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36836. /**
  36837. * @hidden
  36838. * Defines the actions happening just before a mesh is drawing.
  36839. */
  36840. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36841. /**
  36842. * @hidden
  36843. * Defines the actions happening just after a mesh has been drawn.
  36844. */
  36845. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36846. /**
  36847. * @hidden
  36848. * Defines the actions happening just after a rendering group has been drawn.
  36849. */
  36850. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36851. /**
  36852. * @hidden
  36853. * Defines the actions happening just after the active camera has been drawn.
  36854. */
  36855. _afterCameraDrawStage: Stage<CameraStageAction>;
  36856. /**
  36857. * @hidden
  36858. * Defines the actions happening just after a render target has been drawn.
  36859. */
  36860. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36861. /**
  36862. * @hidden
  36863. * Defines the actions happening just after rendering all cameras and computing intersections.
  36864. */
  36865. _afterRenderStage: Stage<SimpleStageAction>;
  36866. /**
  36867. * @hidden
  36868. * Defines the actions happening when a pointer move event happens.
  36869. */
  36870. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36871. /**
  36872. * @hidden
  36873. * Defines the actions happening when a pointer down event happens.
  36874. */
  36875. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36876. /**
  36877. * @hidden
  36878. * Defines the actions happening when a pointer up event happens.
  36879. */
  36880. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36881. /**
  36882. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36883. */
  36884. private geometriesByUniqueId;
  36885. /**
  36886. * Creates a new Scene
  36887. * @param engine defines the engine to use to render this scene
  36888. * @param options defines the scene options
  36889. */
  36890. constructor(engine: Engine, options?: SceneOptions);
  36891. /**
  36892. * Gets a string idenfifying the name of the class
  36893. * @returns "Scene" string
  36894. */
  36895. getClassName(): string;
  36896. private _defaultMeshCandidates;
  36897. /**
  36898. * @hidden
  36899. */
  36900. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36901. private _defaultSubMeshCandidates;
  36902. /**
  36903. * @hidden
  36904. */
  36905. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36906. /**
  36907. * Sets the default candidate providers for the scene.
  36908. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36909. * and getCollidingSubMeshCandidates to their default function
  36910. */
  36911. setDefaultCandidateProviders(): void;
  36912. /**
  36913. * Gets the mesh that is currently under the pointer
  36914. */
  36915. get meshUnderPointer(): Nullable<AbstractMesh>;
  36916. /**
  36917. * Gets or sets the current on-screen X position of the pointer
  36918. */
  36919. get pointerX(): number;
  36920. set pointerX(value: number);
  36921. /**
  36922. * Gets or sets the current on-screen Y position of the pointer
  36923. */
  36924. get pointerY(): number;
  36925. set pointerY(value: number);
  36926. /**
  36927. * Gets the cached material (ie. the latest rendered one)
  36928. * @returns the cached material
  36929. */
  36930. getCachedMaterial(): Nullable<Material>;
  36931. /**
  36932. * Gets the cached effect (ie. the latest rendered one)
  36933. * @returns the cached effect
  36934. */
  36935. getCachedEffect(): Nullable<Effect>;
  36936. /**
  36937. * Gets the cached visibility state (ie. the latest rendered one)
  36938. * @returns the cached visibility state
  36939. */
  36940. getCachedVisibility(): Nullable<number>;
  36941. /**
  36942. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36943. * @param material defines the current material
  36944. * @param effect defines the current effect
  36945. * @param visibility defines the current visibility state
  36946. * @returns true if one parameter is not cached
  36947. */
  36948. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36949. /**
  36950. * Gets the engine associated with the scene
  36951. * @returns an Engine
  36952. */
  36953. getEngine(): Engine;
  36954. /**
  36955. * Gets the total number of vertices rendered per frame
  36956. * @returns the total number of vertices rendered per frame
  36957. */
  36958. getTotalVertices(): number;
  36959. /**
  36960. * Gets the performance counter for total vertices
  36961. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36962. */
  36963. get totalVerticesPerfCounter(): PerfCounter;
  36964. /**
  36965. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36966. * @returns the total number of active indices rendered per frame
  36967. */
  36968. getActiveIndices(): number;
  36969. /**
  36970. * Gets the performance counter for active indices
  36971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36972. */
  36973. get totalActiveIndicesPerfCounter(): PerfCounter;
  36974. /**
  36975. * Gets the total number of active particles rendered per frame
  36976. * @returns the total number of active particles rendered per frame
  36977. */
  36978. getActiveParticles(): number;
  36979. /**
  36980. * Gets the performance counter for active particles
  36981. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36982. */
  36983. get activeParticlesPerfCounter(): PerfCounter;
  36984. /**
  36985. * Gets the total number of active bones rendered per frame
  36986. * @returns the total number of active bones rendered per frame
  36987. */
  36988. getActiveBones(): number;
  36989. /**
  36990. * Gets the performance counter for active bones
  36991. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36992. */
  36993. get activeBonesPerfCounter(): PerfCounter;
  36994. /**
  36995. * Gets the array of active meshes
  36996. * @returns an array of AbstractMesh
  36997. */
  36998. getActiveMeshes(): SmartArray<AbstractMesh>;
  36999. /**
  37000. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37001. * @returns a number
  37002. */
  37003. getAnimationRatio(): number;
  37004. /**
  37005. * Gets an unique Id for the current render phase
  37006. * @returns a number
  37007. */
  37008. getRenderId(): number;
  37009. /**
  37010. * Gets an unique Id for the current frame
  37011. * @returns a number
  37012. */
  37013. getFrameId(): number;
  37014. /** Call this function if you want to manually increment the render Id*/
  37015. incrementRenderId(): void;
  37016. private _createUbo;
  37017. /**
  37018. * Use this method to simulate a pointer move on a mesh
  37019. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37020. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37021. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37022. * @returns the current scene
  37023. */
  37024. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37025. /**
  37026. * Use this method to simulate a pointer down on a mesh
  37027. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37028. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37029. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37030. * @returns the current scene
  37031. */
  37032. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37033. /**
  37034. * Use this method to simulate a pointer up on a mesh
  37035. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37036. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37037. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37038. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37039. * @returns the current scene
  37040. */
  37041. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37042. /**
  37043. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37044. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37045. * @returns true if the pointer was captured
  37046. */
  37047. isPointerCaptured(pointerId?: number): boolean;
  37048. /**
  37049. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37050. * @param attachUp defines if you want to attach events to pointerup
  37051. * @param attachDown defines if you want to attach events to pointerdown
  37052. * @param attachMove defines if you want to attach events to pointermove
  37053. */
  37054. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37055. /** Detaches all event handlers*/
  37056. detachControl(): void;
  37057. /**
  37058. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37059. * Delay loaded resources are not taking in account
  37060. * @return true if all required resources are ready
  37061. */
  37062. isReady(): boolean;
  37063. /** Resets all cached information relative to material (including effect and visibility) */
  37064. resetCachedMaterial(): void;
  37065. /**
  37066. * Registers a function to be called before every frame render
  37067. * @param func defines the function to register
  37068. */
  37069. registerBeforeRender(func: () => void): void;
  37070. /**
  37071. * Unregisters a function called before every frame render
  37072. * @param func defines the function to unregister
  37073. */
  37074. unregisterBeforeRender(func: () => void): void;
  37075. /**
  37076. * Registers a function to be called after every frame render
  37077. * @param func defines the function to register
  37078. */
  37079. registerAfterRender(func: () => void): void;
  37080. /**
  37081. * Unregisters a function called after every frame render
  37082. * @param func defines the function to unregister
  37083. */
  37084. unregisterAfterRender(func: () => void): void;
  37085. private _executeOnceBeforeRender;
  37086. /**
  37087. * The provided function will run before render once and will be disposed afterwards.
  37088. * A timeout delay can be provided so that the function will be executed in N ms.
  37089. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37090. * @param func The function to be executed.
  37091. * @param timeout optional delay in ms
  37092. */
  37093. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37094. /** @hidden */
  37095. _addPendingData(data: any): void;
  37096. /** @hidden */
  37097. _removePendingData(data: any): void;
  37098. /**
  37099. * Returns the number of items waiting to be loaded
  37100. * @returns the number of items waiting to be loaded
  37101. */
  37102. getWaitingItemsCount(): number;
  37103. /**
  37104. * Returns a boolean indicating if the scene is still loading data
  37105. */
  37106. get isLoading(): boolean;
  37107. /**
  37108. * Registers a function to be executed when the scene is ready
  37109. * @param {Function} func - the function to be executed
  37110. */
  37111. executeWhenReady(func: () => void): void;
  37112. /**
  37113. * Returns a promise that resolves when the scene is ready
  37114. * @returns A promise that resolves when the scene is ready
  37115. */
  37116. whenReadyAsync(): Promise<void>;
  37117. /** @hidden */
  37118. _checkIsReady(): void;
  37119. /**
  37120. * Gets all animatable attached to the scene
  37121. */
  37122. get animatables(): Animatable[];
  37123. /**
  37124. * Resets the last animation time frame.
  37125. * Useful to override when animations start running when loading a scene for the first time.
  37126. */
  37127. resetLastAnimationTimeFrame(): void;
  37128. /**
  37129. * Gets the current view matrix
  37130. * @returns a Matrix
  37131. */
  37132. getViewMatrix(): Matrix;
  37133. /**
  37134. * Gets the current projection matrix
  37135. * @returns a Matrix
  37136. */
  37137. getProjectionMatrix(): Matrix;
  37138. /**
  37139. * Gets the current transform matrix
  37140. * @returns a Matrix made of View * Projection
  37141. */
  37142. getTransformMatrix(): Matrix;
  37143. /**
  37144. * Sets the current transform matrix
  37145. * @param viewL defines the View matrix to use
  37146. * @param projectionL defines the Projection matrix to use
  37147. * @param viewR defines the right View matrix to use (if provided)
  37148. * @param projectionR defines the right Projection matrix to use (if provided)
  37149. */
  37150. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37151. /**
  37152. * Gets the uniform buffer used to store scene data
  37153. * @returns a UniformBuffer
  37154. */
  37155. getSceneUniformBuffer(): UniformBuffer;
  37156. /**
  37157. * Gets an unique (relatively to the current scene) Id
  37158. * @returns an unique number for the scene
  37159. */
  37160. getUniqueId(): number;
  37161. /**
  37162. * Add a mesh to the list of scene's meshes
  37163. * @param newMesh defines the mesh to add
  37164. * @param recursive if all child meshes should also be added to the scene
  37165. */
  37166. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37167. /**
  37168. * Remove a mesh for the list of scene's meshes
  37169. * @param toRemove defines the mesh to remove
  37170. * @param recursive if all child meshes should also be removed from the scene
  37171. * @returns the index where the mesh was in the mesh list
  37172. */
  37173. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37174. /**
  37175. * Add a transform node to the list of scene's transform nodes
  37176. * @param newTransformNode defines the transform node to add
  37177. */
  37178. addTransformNode(newTransformNode: TransformNode): void;
  37179. /**
  37180. * Remove a transform node for the list of scene's transform nodes
  37181. * @param toRemove defines the transform node to remove
  37182. * @returns the index where the transform node was in the transform node list
  37183. */
  37184. removeTransformNode(toRemove: TransformNode): number;
  37185. /**
  37186. * Remove a skeleton for the list of scene's skeletons
  37187. * @param toRemove defines the skeleton to remove
  37188. * @returns the index where the skeleton was in the skeleton list
  37189. */
  37190. removeSkeleton(toRemove: Skeleton): number;
  37191. /**
  37192. * Remove a morph target for the list of scene's morph targets
  37193. * @param toRemove defines the morph target to remove
  37194. * @returns the index where the morph target was in the morph target list
  37195. */
  37196. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37197. /**
  37198. * Remove a light for the list of scene's lights
  37199. * @param toRemove defines the light to remove
  37200. * @returns the index where the light was in the light list
  37201. */
  37202. removeLight(toRemove: Light): number;
  37203. /**
  37204. * Remove a camera for the list of scene's cameras
  37205. * @param toRemove defines the camera to remove
  37206. * @returns the index where the camera was in the camera list
  37207. */
  37208. removeCamera(toRemove: Camera): number;
  37209. /**
  37210. * Remove a particle system for the list of scene's particle systems
  37211. * @param toRemove defines the particle system to remove
  37212. * @returns the index where the particle system was in the particle system list
  37213. */
  37214. removeParticleSystem(toRemove: IParticleSystem): number;
  37215. /**
  37216. * Remove a animation for the list of scene's animations
  37217. * @param toRemove defines the animation to remove
  37218. * @returns the index where the animation was in the animation list
  37219. */
  37220. removeAnimation(toRemove: Animation): number;
  37221. /**
  37222. * Will stop the animation of the given target
  37223. * @param target - the target
  37224. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37225. * @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)
  37226. */
  37227. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37228. /**
  37229. * Removes the given animation group from this scene.
  37230. * @param toRemove The animation group to remove
  37231. * @returns The index of the removed animation group
  37232. */
  37233. removeAnimationGroup(toRemove: AnimationGroup): number;
  37234. /**
  37235. * Removes the given multi-material from this scene.
  37236. * @param toRemove The multi-material to remove
  37237. * @returns The index of the removed multi-material
  37238. */
  37239. removeMultiMaterial(toRemove: MultiMaterial): number;
  37240. /**
  37241. * Removes the given material from this scene.
  37242. * @param toRemove The material to remove
  37243. * @returns The index of the removed material
  37244. */
  37245. removeMaterial(toRemove: Material): number;
  37246. /**
  37247. * Removes the given action manager from this scene.
  37248. * @param toRemove The action manager to remove
  37249. * @returns The index of the removed action manager
  37250. */
  37251. removeActionManager(toRemove: AbstractActionManager): number;
  37252. /**
  37253. * Removes the given texture from this scene.
  37254. * @param toRemove The texture to remove
  37255. * @returns The index of the removed texture
  37256. */
  37257. removeTexture(toRemove: BaseTexture): number;
  37258. /**
  37259. * Adds the given light to this scene
  37260. * @param newLight The light to add
  37261. */
  37262. addLight(newLight: Light): void;
  37263. /**
  37264. * Sorts the list list based on light priorities
  37265. */
  37266. sortLightsByPriority(): void;
  37267. /**
  37268. * Adds the given camera to this scene
  37269. * @param newCamera The camera to add
  37270. */
  37271. addCamera(newCamera: Camera): void;
  37272. /**
  37273. * Adds the given skeleton to this scene
  37274. * @param newSkeleton The skeleton to add
  37275. */
  37276. addSkeleton(newSkeleton: Skeleton): void;
  37277. /**
  37278. * Adds the given particle system to this scene
  37279. * @param newParticleSystem The particle system to add
  37280. */
  37281. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37282. /**
  37283. * Adds the given animation to this scene
  37284. * @param newAnimation The animation to add
  37285. */
  37286. addAnimation(newAnimation: Animation): void;
  37287. /**
  37288. * Adds the given animation group to this scene.
  37289. * @param newAnimationGroup The animation group to add
  37290. */
  37291. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37292. /**
  37293. * Adds the given multi-material to this scene
  37294. * @param newMultiMaterial The multi-material to add
  37295. */
  37296. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37297. /**
  37298. * Adds the given material to this scene
  37299. * @param newMaterial The material to add
  37300. */
  37301. addMaterial(newMaterial: Material): void;
  37302. /**
  37303. * Adds the given morph target to this scene
  37304. * @param newMorphTargetManager The morph target to add
  37305. */
  37306. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37307. /**
  37308. * Adds the given geometry to this scene
  37309. * @param newGeometry The geometry to add
  37310. */
  37311. addGeometry(newGeometry: Geometry): void;
  37312. /**
  37313. * Adds the given action manager to this scene
  37314. * @param newActionManager The action manager to add
  37315. */
  37316. addActionManager(newActionManager: AbstractActionManager): void;
  37317. /**
  37318. * Adds the given texture to this scene.
  37319. * @param newTexture The texture to add
  37320. */
  37321. addTexture(newTexture: BaseTexture): void;
  37322. /**
  37323. * Switch active camera
  37324. * @param newCamera defines the new active camera
  37325. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37326. */
  37327. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37328. /**
  37329. * sets the active camera of the scene using its ID
  37330. * @param id defines the camera's ID
  37331. * @return the new active camera or null if none found.
  37332. */
  37333. setActiveCameraByID(id: string): Nullable<Camera>;
  37334. /**
  37335. * sets the active camera of the scene using its name
  37336. * @param name defines the camera's name
  37337. * @returns the new active camera or null if none found.
  37338. */
  37339. setActiveCameraByName(name: string): Nullable<Camera>;
  37340. /**
  37341. * get an animation group using its name
  37342. * @param name defines the material's name
  37343. * @return the animation group or null if none found.
  37344. */
  37345. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37346. /**
  37347. * Get a material using its unique id
  37348. * @param uniqueId defines the material's unique id
  37349. * @return the material or null if none found.
  37350. */
  37351. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37352. /**
  37353. * get a material using its id
  37354. * @param id defines the material's ID
  37355. * @return the material or null if none found.
  37356. */
  37357. getMaterialByID(id: string): Nullable<Material>;
  37358. /**
  37359. * Gets a the last added material using a given id
  37360. * @param id defines the material's ID
  37361. * @return the last material with the given id or null if none found.
  37362. */
  37363. getLastMaterialByID(id: string): Nullable<Material>;
  37364. /**
  37365. * Gets a material using its name
  37366. * @param name defines the material's name
  37367. * @return the material or null if none found.
  37368. */
  37369. getMaterialByName(name: string): Nullable<Material>;
  37370. /**
  37371. * Get a texture using its unique id
  37372. * @param uniqueId defines the texture's unique id
  37373. * @return the texture or null if none found.
  37374. */
  37375. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37376. /**
  37377. * Gets a camera using its id
  37378. * @param id defines the id to look for
  37379. * @returns the camera or null if not found
  37380. */
  37381. getCameraByID(id: string): Nullable<Camera>;
  37382. /**
  37383. * Gets a camera using its unique id
  37384. * @param uniqueId defines the unique id to look for
  37385. * @returns the camera or null if not found
  37386. */
  37387. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37388. /**
  37389. * Gets a camera using its name
  37390. * @param name defines the camera's name
  37391. * @return the camera or null if none found.
  37392. */
  37393. getCameraByName(name: string): Nullable<Camera>;
  37394. /**
  37395. * Gets a bone using its id
  37396. * @param id defines the bone's id
  37397. * @return the bone or null if not found
  37398. */
  37399. getBoneByID(id: string): Nullable<Bone>;
  37400. /**
  37401. * Gets a bone using its id
  37402. * @param name defines the bone's name
  37403. * @return the bone or null if not found
  37404. */
  37405. getBoneByName(name: string): Nullable<Bone>;
  37406. /**
  37407. * Gets a light node using its name
  37408. * @param name defines the the light's name
  37409. * @return the light or null if none found.
  37410. */
  37411. getLightByName(name: string): Nullable<Light>;
  37412. /**
  37413. * Gets a light node using its id
  37414. * @param id defines the light's id
  37415. * @return the light or null if none found.
  37416. */
  37417. getLightByID(id: string): Nullable<Light>;
  37418. /**
  37419. * Gets a light node using its scene-generated unique ID
  37420. * @param uniqueId defines the light's unique id
  37421. * @return the light or null if none found.
  37422. */
  37423. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37424. /**
  37425. * Gets a particle system by id
  37426. * @param id defines the particle system id
  37427. * @return the corresponding system or null if none found
  37428. */
  37429. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37430. /**
  37431. * Gets a geometry using its ID
  37432. * @param id defines the geometry's id
  37433. * @return the geometry or null if none found.
  37434. */
  37435. getGeometryByID(id: string): Nullable<Geometry>;
  37436. private _getGeometryByUniqueID;
  37437. /**
  37438. * Add a new geometry to this scene
  37439. * @param geometry defines the geometry to be added to the scene.
  37440. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37441. * @return a boolean defining if the geometry was added or not
  37442. */
  37443. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37444. /**
  37445. * Removes an existing geometry
  37446. * @param geometry defines the geometry to be removed from the scene
  37447. * @return a boolean defining if the geometry was removed or not
  37448. */
  37449. removeGeometry(geometry: Geometry): boolean;
  37450. /**
  37451. * Gets the list of geometries attached to the scene
  37452. * @returns an array of Geometry
  37453. */
  37454. getGeometries(): Geometry[];
  37455. /**
  37456. * Gets the first added mesh found of a given ID
  37457. * @param id defines the id to search for
  37458. * @return the mesh found or null if not found at all
  37459. */
  37460. getMeshByID(id: string): Nullable<AbstractMesh>;
  37461. /**
  37462. * Gets a list of meshes using their id
  37463. * @param id defines the id to search for
  37464. * @returns a list of meshes
  37465. */
  37466. getMeshesByID(id: string): Array<AbstractMesh>;
  37467. /**
  37468. * Gets the first added transform node found of a given ID
  37469. * @param id defines the id to search for
  37470. * @return the found transform node or null if not found at all.
  37471. */
  37472. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37473. /**
  37474. * Gets a transform node with its auto-generated unique id
  37475. * @param uniqueId efines the unique id to search for
  37476. * @return the found transform node or null if not found at all.
  37477. */
  37478. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37479. /**
  37480. * Gets a list of transform nodes using their id
  37481. * @param id defines the id to search for
  37482. * @returns a list of transform nodes
  37483. */
  37484. getTransformNodesByID(id: string): Array<TransformNode>;
  37485. /**
  37486. * Gets a mesh with its auto-generated unique id
  37487. * @param uniqueId defines the unique id to search for
  37488. * @return the found mesh or null if not found at all.
  37489. */
  37490. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37491. /**
  37492. * Gets a the last added mesh using a given id
  37493. * @param id defines the id to search for
  37494. * @return the found mesh or null if not found at all.
  37495. */
  37496. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37497. /**
  37498. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37499. * @param id defines the id to search for
  37500. * @return the found node or null if not found at all
  37501. */
  37502. getLastEntryByID(id: string): Nullable<Node>;
  37503. /**
  37504. * Gets a node (Mesh, Camera, Light) using a given id
  37505. * @param id defines the id to search for
  37506. * @return the found node or null if not found at all
  37507. */
  37508. getNodeByID(id: string): Nullable<Node>;
  37509. /**
  37510. * Gets a node (Mesh, Camera, Light) using a given name
  37511. * @param name defines the name to search for
  37512. * @return the found node or null if not found at all.
  37513. */
  37514. getNodeByName(name: string): Nullable<Node>;
  37515. /**
  37516. * Gets a mesh using a given name
  37517. * @param name defines the name to search for
  37518. * @return the found mesh or null if not found at all.
  37519. */
  37520. getMeshByName(name: string): Nullable<AbstractMesh>;
  37521. /**
  37522. * Gets a transform node using a given name
  37523. * @param name defines the name to search for
  37524. * @return the found transform node or null if not found at all.
  37525. */
  37526. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37527. /**
  37528. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37529. * @param id defines the id to search for
  37530. * @return the found skeleton or null if not found at all.
  37531. */
  37532. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37533. /**
  37534. * Gets a skeleton using a given auto generated unique id
  37535. * @param uniqueId defines the unique id to search for
  37536. * @return the found skeleton or null if not found at all.
  37537. */
  37538. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37539. /**
  37540. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37541. * @param id defines the id to search for
  37542. * @return the found skeleton or null if not found at all.
  37543. */
  37544. getSkeletonById(id: string): Nullable<Skeleton>;
  37545. /**
  37546. * Gets a skeleton using a given name
  37547. * @param name defines the name to search for
  37548. * @return the found skeleton or null if not found at all.
  37549. */
  37550. getSkeletonByName(name: string): Nullable<Skeleton>;
  37551. /**
  37552. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37553. * @param id defines the id to search for
  37554. * @return the found morph target manager or null if not found at all.
  37555. */
  37556. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37557. /**
  37558. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37559. * @param id defines the id to search for
  37560. * @return the found morph target or null if not found at all.
  37561. */
  37562. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37563. /**
  37564. * Gets a boolean indicating if the given mesh is active
  37565. * @param mesh defines the mesh to look for
  37566. * @returns true if the mesh is in the active list
  37567. */
  37568. isActiveMesh(mesh: AbstractMesh): boolean;
  37569. /**
  37570. * Return a unique id as a string which can serve as an identifier for the scene
  37571. */
  37572. get uid(): string;
  37573. /**
  37574. * Add an externaly attached data from its key.
  37575. * This method call will fail and return false, if such key already exists.
  37576. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37577. * @param key the unique key that identifies the data
  37578. * @param data the data object to associate to the key for this Engine instance
  37579. * @return true if no such key were already present and the data was added successfully, false otherwise
  37580. */
  37581. addExternalData<T>(key: string, data: T): boolean;
  37582. /**
  37583. * Get an externaly attached data from its key
  37584. * @param key the unique key that identifies the data
  37585. * @return the associated data, if present (can be null), or undefined if not present
  37586. */
  37587. getExternalData<T>(key: string): Nullable<T>;
  37588. /**
  37589. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37590. * @param key the unique key that identifies the data
  37591. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37592. * @return the associated data, can be null if the factory returned null.
  37593. */
  37594. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37595. /**
  37596. * Remove an externaly attached data from the Engine instance
  37597. * @param key the unique key that identifies the data
  37598. * @return true if the data was successfully removed, false if it doesn't exist
  37599. */
  37600. removeExternalData(key: string): boolean;
  37601. private _evaluateSubMesh;
  37602. /**
  37603. * Clear the processed materials smart array preventing retention point in material dispose.
  37604. */
  37605. freeProcessedMaterials(): void;
  37606. private _preventFreeActiveMeshesAndRenderingGroups;
  37607. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37608. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37609. * when disposing several meshes in a row or a hierarchy of meshes.
  37610. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37611. */
  37612. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37613. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37614. /**
  37615. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37616. */
  37617. freeActiveMeshes(): void;
  37618. /**
  37619. * Clear the info related to rendering groups preventing retention points during dispose.
  37620. */
  37621. freeRenderingGroups(): void;
  37622. /** @hidden */
  37623. _isInIntermediateRendering(): boolean;
  37624. /**
  37625. * Lambda returning the list of potentially active meshes.
  37626. */
  37627. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37628. /**
  37629. * Lambda returning the list of potentially active sub meshes.
  37630. */
  37631. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37632. /**
  37633. * Lambda returning the list of potentially intersecting sub meshes.
  37634. */
  37635. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37636. /**
  37637. * Lambda returning the list of potentially colliding sub meshes.
  37638. */
  37639. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37640. private _activeMeshesFrozen;
  37641. private _skipEvaluateActiveMeshesCompletely;
  37642. /**
  37643. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37644. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37645. * @returns the current scene
  37646. */
  37647. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37648. /**
  37649. * Use this function to restart evaluating active meshes on every frame
  37650. * @returns the current scene
  37651. */
  37652. unfreezeActiveMeshes(): Scene;
  37653. private _evaluateActiveMeshes;
  37654. private _activeMesh;
  37655. /**
  37656. * Update the transform matrix to update from the current active camera
  37657. * @param force defines a boolean used to force the update even if cache is up to date
  37658. */
  37659. updateTransformMatrix(force?: boolean): void;
  37660. private _bindFrameBuffer;
  37661. /** @hidden */
  37662. _allowPostProcessClearColor: boolean;
  37663. /** @hidden */
  37664. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37665. private _processSubCameras;
  37666. private _checkIntersections;
  37667. /** @hidden */
  37668. _advancePhysicsEngineStep(step: number): void;
  37669. /**
  37670. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37671. */
  37672. getDeterministicFrameTime: () => number;
  37673. /** @hidden */
  37674. _animate(): void;
  37675. /** Execute all animations (for a frame) */
  37676. animate(): void;
  37677. /**
  37678. * Render the scene
  37679. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37680. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37681. */
  37682. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37683. /**
  37684. * Freeze all materials
  37685. * A frozen material will not be updatable but should be faster to render
  37686. */
  37687. freezeMaterials(): void;
  37688. /**
  37689. * Unfreeze all materials
  37690. * A frozen material will not be updatable but should be faster to render
  37691. */
  37692. unfreezeMaterials(): void;
  37693. /**
  37694. * Releases all held ressources
  37695. */
  37696. dispose(): void;
  37697. /**
  37698. * Gets if the scene is already disposed
  37699. */
  37700. get isDisposed(): boolean;
  37701. /**
  37702. * Call this function to reduce memory footprint of the scene.
  37703. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37704. */
  37705. clearCachedVertexData(): void;
  37706. /**
  37707. * This function will remove the local cached buffer data from texture.
  37708. * It will save memory but will prevent the texture from being rebuilt
  37709. */
  37710. cleanCachedTextureBuffer(): void;
  37711. /**
  37712. * Get the world extend vectors with an optional filter
  37713. *
  37714. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37715. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37716. */
  37717. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37718. min: Vector3;
  37719. max: Vector3;
  37720. };
  37721. /**
  37722. * Creates a ray that can be used to pick in the scene
  37723. * @param x defines the x coordinate of the origin (on-screen)
  37724. * @param y defines the y coordinate of the origin (on-screen)
  37725. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37726. * @param camera defines the camera to use for the picking
  37727. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37728. * @returns a Ray
  37729. */
  37730. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37731. /**
  37732. * Creates a ray that can be used to pick in the scene
  37733. * @param x defines the x coordinate of the origin (on-screen)
  37734. * @param y defines the y coordinate of the origin (on-screen)
  37735. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37736. * @param result defines the ray where to store the picking ray
  37737. * @param camera defines the camera to use for the picking
  37738. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37739. * @returns the current scene
  37740. */
  37741. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37742. /**
  37743. * Creates a ray that can be used to pick in the scene
  37744. * @param x defines the x coordinate of the origin (on-screen)
  37745. * @param y defines the y coordinate of the origin (on-screen)
  37746. * @param camera defines the camera to use for the picking
  37747. * @returns a Ray
  37748. */
  37749. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37750. /**
  37751. * Creates a ray that can be used to pick in the scene
  37752. * @param x defines the x coordinate of the origin (on-screen)
  37753. * @param y defines the y coordinate of the origin (on-screen)
  37754. * @param result defines the ray where to store the picking ray
  37755. * @param camera defines the camera to use for the picking
  37756. * @returns the current scene
  37757. */
  37758. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37759. /** Launch a ray to try to pick a mesh in the scene
  37760. * @param x position on screen
  37761. * @param y position on screen
  37762. * @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
  37763. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37764. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37765. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37766. * @returns a PickingInfo
  37767. */
  37768. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37769. /** Use the given ray to pick a mesh in the scene
  37770. * @param ray The ray to use to pick meshes
  37771. * @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
  37772. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37773. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37774. * @returns a PickingInfo
  37775. */
  37776. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37777. /**
  37778. * Launch a ray to try to pick a mesh in the scene
  37779. * @param x X position on screen
  37780. * @param y Y position on screen
  37781. * @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
  37782. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37783. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37784. * @returns an array of PickingInfo
  37785. */
  37786. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37787. /**
  37788. * Launch a ray to try to pick a mesh in the scene
  37789. * @param ray Ray to use
  37790. * @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
  37791. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37792. * @returns an array of PickingInfo
  37793. */
  37794. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37795. /**
  37796. * Force the value of meshUnderPointer
  37797. * @param mesh defines the mesh to use
  37798. */
  37799. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37800. /**
  37801. * Gets the mesh under the pointer
  37802. * @returns a Mesh or null if no mesh is under the pointer
  37803. */
  37804. getPointerOverMesh(): Nullable<AbstractMesh>;
  37805. /** @hidden */
  37806. _rebuildGeometries(): void;
  37807. /** @hidden */
  37808. _rebuildTextures(): void;
  37809. private _getByTags;
  37810. /**
  37811. * Get a list of meshes by tags
  37812. * @param tagsQuery defines the tags query to use
  37813. * @param forEach defines a predicate used to filter results
  37814. * @returns an array of Mesh
  37815. */
  37816. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37817. /**
  37818. * Get a list of cameras by tags
  37819. * @param tagsQuery defines the tags query to use
  37820. * @param forEach defines a predicate used to filter results
  37821. * @returns an array of Camera
  37822. */
  37823. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37824. /**
  37825. * Get a list of lights by tags
  37826. * @param tagsQuery defines the tags query to use
  37827. * @param forEach defines a predicate used to filter results
  37828. * @returns an array of Light
  37829. */
  37830. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37831. /**
  37832. * Get a list of materials by tags
  37833. * @param tagsQuery defines the tags query to use
  37834. * @param forEach defines a predicate used to filter results
  37835. * @returns an array of Material
  37836. */
  37837. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37838. /**
  37839. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37840. * This allowed control for front to back rendering or reversly depending of the special needs.
  37841. *
  37842. * @param renderingGroupId The rendering group id corresponding to its index
  37843. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37844. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37845. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37846. */
  37847. 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;
  37848. /**
  37849. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37850. *
  37851. * @param renderingGroupId The rendering group id corresponding to its index
  37852. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37853. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37854. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37855. */
  37856. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37857. /**
  37858. * Gets the current auto clear configuration for one rendering group of the rendering
  37859. * manager.
  37860. * @param index the rendering group index to get the information for
  37861. * @returns The auto clear setup for the requested rendering group
  37862. */
  37863. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37864. private _blockMaterialDirtyMechanism;
  37865. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37866. get blockMaterialDirtyMechanism(): boolean;
  37867. set blockMaterialDirtyMechanism(value: boolean);
  37868. /**
  37869. * Will flag all materials as dirty to trigger new shader compilation
  37870. * @param flag defines the flag used to specify which material part must be marked as dirty
  37871. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37872. */
  37873. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37874. /** @hidden */
  37875. _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;
  37876. /** @hidden */
  37877. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37878. /** @hidden */
  37879. _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;
  37880. /** @hidden */
  37881. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37882. /** @hidden */
  37883. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37884. /** @hidden */
  37885. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37886. }
  37887. }
  37888. declare module "babylonjs/assetContainer" {
  37889. import { AbstractScene } from "babylonjs/abstractScene";
  37890. import { Scene } from "babylonjs/scene";
  37891. import { Mesh } from "babylonjs/Meshes/mesh";
  37892. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37893. import { Skeleton } from "babylonjs/Bones/skeleton";
  37894. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37895. import { Animatable } from "babylonjs/Animations/animatable";
  37896. import { Nullable } from "babylonjs/types";
  37897. import { Node } from "babylonjs/node";
  37898. /**
  37899. * Set of assets to keep when moving a scene into an asset container.
  37900. */
  37901. export class KeepAssets extends AbstractScene {
  37902. }
  37903. /**
  37904. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37905. */
  37906. export class InstantiatedEntries {
  37907. /**
  37908. * List of new root nodes (eg. nodes with no parent)
  37909. */
  37910. rootNodes: TransformNode[];
  37911. /**
  37912. * List of new skeletons
  37913. */
  37914. skeletons: Skeleton[];
  37915. /**
  37916. * List of new animation groups
  37917. */
  37918. animationGroups: AnimationGroup[];
  37919. }
  37920. /**
  37921. * Container with a set of assets that can be added or removed from a scene.
  37922. */
  37923. export class AssetContainer extends AbstractScene {
  37924. /**
  37925. * The scene the AssetContainer belongs to.
  37926. */
  37927. scene: Scene;
  37928. /**
  37929. * Instantiates an AssetContainer.
  37930. * @param scene The scene the AssetContainer belongs to.
  37931. */
  37932. constructor(scene: Scene);
  37933. /**
  37934. * Instantiate or clone all meshes and add the new ones to the scene.
  37935. * Skeletons and animation groups will all be cloned
  37936. * @param nameFunction defines an optional function used to get new names for clones
  37937. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37938. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37939. */
  37940. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37941. /**
  37942. * Adds all the assets from the container to the scene.
  37943. */
  37944. addAllToScene(): void;
  37945. /**
  37946. * Removes all the assets in the container from the scene
  37947. */
  37948. removeAllFromScene(): void;
  37949. /**
  37950. * Disposes all the assets in the container
  37951. */
  37952. dispose(): void;
  37953. private _moveAssets;
  37954. /**
  37955. * Removes all the assets contained in the scene and adds them to the container.
  37956. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37957. */
  37958. moveAllFromScene(keepAssets?: KeepAssets): void;
  37959. /**
  37960. * 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.
  37961. * @returns the root mesh
  37962. */
  37963. createRootMesh(): Mesh;
  37964. /**
  37965. * Merge animations from this asset container into a scene
  37966. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37967. * @param animatables set of animatables to retarget to a node from the scene
  37968. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37969. */
  37970. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37971. }
  37972. }
  37973. declare module "babylonjs/abstractScene" {
  37974. import { Scene } from "babylonjs/scene";
  37975. import { Nullable } from "babylonjs/types";
  37976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37978. import { Geometry } from "babylonjs/Meshes/geometry";
  37979. import { Skeleton } from "babylonjs/Bones/skeleton";
  37980. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37981. import { AssetContainer } from "babylonjs/assetContainer";
  37982. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37983. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37985. import { Material } from "babylonjs/Materials/material";
  37986. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37987. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37988. import { Camera } from "babylonjs/Cameras/camera";
  37989. import { Light } from "babylonjs/Lights/light";
  37990. import { Node } from "babylonjs/node";
  37991. import { Animation } from "babylonjs/Animations/animation";
  37992. /**
  37993. * Defines how the parser contract is defined.
  37994. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37995. */
  37996. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37997. /**
  37998. * Defines how the individual parser contract is defined.
  37999. * These parser can parse an individual asset
  38000. */
  38001. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38002. /**
  38003. * Base class of the scene acting as a container for the different elements composing a scene.
  38004. * This class is dynamically extended by the different components of the scene increasing
  38005. * flexibility and reducing coupling
  38006. */
  38007. export abstract class AbstractScene {
  38008. /**
  38009. * Stores the list of available parsers in the application.
  38010. */
  38011. private static _BabylonFileParsers;
  38012. /**
  38013. * Stores the list of available individual parsers in the application.
  38014. */
  38015. private static _IndividualBabylonFileParsers;
  38016. /**
  38017. * Adds a parser in the list of available ones
  38018. * @param name Defines the name of the parser
  38019. * @param parser Defines the parser to add
  38020. */
  38021. static AddParser(name: string, parser: BabylonFileParser): void;
  38022. /**
  38023. * Gets a general parser from the list of avaialble ones
  38024. * @param name Defines the name of the parser
  38025. * @returns the requested parser or null
  38026. */
  38027. static GetParser(name: string): Nullable<BabylonFileParser>;
  38028. /**
  38029. * Adds n individual parser in the list of available ones
  38030. * @param name Defines the name of the parser
  38031. * @param parser Defines the parser to add
  38032. */
  38033. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38034. /**
  38035. * Gets an individual parser from the list of avaialble ones
  38036. * @param name Defines the name of the parser
  38037. * @returns the requested parser or null
  38038. */
  38039. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38040. /**
  38041. * Parser json data and populate both a scene and its associated container object
  38042. * @param jsonData Defines the data to parse
  38043. * @param scene Defines the scene to parse the data for
  38044. * @param container Defines the container attached to the parsing sequence
  38045. * @param rootUrl Defines the root url of the data
  38046. */
  38047. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38048. /**
  38049. * Gets the list of root nodes (ie. nodes with no parent)
  38050. */
  38051. rootNodes: Node[];
  38052. /** All of the cameras added to this scene
  38053. * @see http://doc.babylonjs.com/babylon101/cameras
  38054. */
  38055. cameras: Camera[];
  38056. /**
  38057. * All of the lights added to this scene
  38058. * @see http://doc.babylonjs.com/babylon101/lights
  38059. */
  38060. lights: Light[];
  38061. /**
  38062. * All of the (abstract) meshes added to this scene
  38063. */
  38064. meshes: AbstractMesh[];
  38065. /**
  38066. * The list of skeletons added to the scene
  38067. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38068. */
  38069. skeletons: Skeleton[];
  38070. /**
  38071. * All of the particle systems added to this scene
  38072. * @see http://doc.babylonjs.com/babylon101/particles
  38073. */
  38074. particleSystems: IParticleSystem[];
  38075. /**
  38076. * Gets a list of Animations associated with the scene
  38077. */
  38078. animations: Animation[];
  38079. /**
  38080. * All of the animation groups added to this scene
  38081. * @see http://doc.babylonjs.com/how_to/group
  38082. */
  38083. animationGroups: AnimationGroup[];
  38084. /**
  38085. * All of the multi-materials added to this scene
  38086. * @see http://doc.babylonjs.com/how_to/multi_materials
  38087. */
  38088. multiMaterials: MultiMaterial[];
  38089. /**
  38090. * All of the materials added to this scene
  38091. * In the context of a Scene, it is not supposed to be modified manually.
  38092. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38093. * Note also that the order of the Material within the array is not significant and might change.
  38094. * @see http://doc.babylonjs.com/babylon101/materials
  38095. */
  38096. materials: Material[];
  38097. /**
  38098. * The list of morph target managers added to the scene
  38099. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38100. */
  38101. morphTargetManagers: MorphTargetManager[];
  38102. /**
  38103. * The list of geometries used in the scene.
  38104. */
  38105. geometries: Geometry[];
  38106. /**
  38107. * All of the tranform nodes added to this scene
  38108. * In the context of a Scene, it is not supposed to be modified manually.
  38109. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38110. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38111. * @see http://doc.babylonjs.com/how_to/transformnode
  38112. */
  38113. transformNodes: TransformNode[];
  38114. /**
  38115. * ActionManagers available on the scene.
  38116. */
  38117. actionManagers: AbstractActionManager[];
  38118. /**
  38119. * Textures to keep.
  38120. */
  38121. textures: BaseTexture[];
  38122. /**
  38123. * Environment texture for the scene
  38124. */
  38125. environmentTexture: Nullable<BaseTexture>;
  38126. /**
  38127. * @returns all meshes, lights, cameras, transformNodes and bones
  38128. */
  38129. getNodes(): Array<Node>;
  38130. }
  38131. }
  38132. declare module "babylonjs/Audio/sound" {
  38133. import { Observable } from "babylonjs/Misc/observable";
  38134. import { Vector3 } from "babylonjs/Maths/math.vector";
  38135. import { Nullable } from "babylonjs/types";
  38136. import { Scene } from "babylonjs/scene";
  38137. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38138. /**
  38139. * Interface used to define options for Sound class
  38140. */
  38141. export interface ISoundOptions {
  38142. /**
  38143. * Does the sound autoplay once loaded.
  38144. */
  38145. autoplay?: boolean;
  38146. /**
  38147. * Does the sound loop after it finishes playing once.
  38148. */
  38149. loop?: boolean;
  38150. /**
  38151. * Sound's volume
  38152. */
  38153. volume?: number;
  38154. /**
  38155. * Is it a spatial sound?
  38156. */
  38157. spatialSound?: boolean;
  38158. /**
  38159. * Maximum distance to hear that sound
  38160. */
  38161. maxDistance?: number;
  38162. /**
  38163. * Uses user defined attenuation function
  38164. */
  38165. useCustomAttenuation?: boolean;
  38166. /**
  38167. * Define the roll off factor of spatial sounds.
  38168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38169. */
  38170. rolloffFactor?: number;
  38171. /**
  38172. * Define the reference distance the sound should be heard perfectly.
  38173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38174. */
  38175. refDistance?: number;
  38176. /**
  38177. * Define the distance attenuation model the sound will follow.
  38178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38179. */
  38180. distanceModel?: string;
  38181. /**
  38182. * Defines the playback speed (1 by default)
  38183. */
  38184. playbackRate?: number;
  38185. /**
  38186. * Defines if the sound is from a streaming source
  38187. */
  38188. streaming?: boolean;
  38189. /**
  38190. * Defines an optional length (in seconds) inside the sound file
  38191. */
  38192. length?: number;
  38193. /**
  38194. * Defines an optional offset (in seconds) inside the sound file
  38195. */
  38196. offset?: number;
  38197. /**
  38198. * If true, URLs will not be required to state the audio file codec to use.
  38199. */
  38200. skipCodecCheck?: boolean;
  38201. }
  38202. /**
  38203. * Defines a sound that can be played in the application.
  38204. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38206. */
  38207. export class Sound {
  38208. /**
  38209. * The name of the sound in the scene.
  38210. */
  38211. name: string;
  38212. /**
  38213. * Does the sound autoplay once loaded.
  38214. */
  38215. autoplay: boolean;
  38216. /**
  38217. * Does the sound loop after it finishes playing once.
  38218. */
  38219. loop: boolean;
  38220. /**
  38221. * Does the sound use a custom attenuation curve to simulate the falloff
  38222. * happening when the source gets further away from the camera.
  38223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38224. */
  38225. useCustomAttenuation: boolean;
  38226. /**
  38227. * The sound track id this sound belongs to.
  38228. */
  38229. soundTrackId: number;
  38230. /**
  38231. * Is this sound currently played.
  38232. */
  38233. isPlaying: boolean;
  38234. /**
  38235. * Is this sound currently paused.
  38236. */
  38237. isPaused: boolean;
  38238. /**
  38239. * Does this sound enables spatial sound.
  38240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38241. */
  38242. spatialSound: boolean;
  38243. /**
  38244. * Define the reference distance the sound should be heard perfectly.
  38245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38246. */
  38247. refDistance: number;
  38248. /**
  38249. * Define the roll off factor of spatial sounds.
  38250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38251. */
  38252. rolloffFactor: number;
  38253. /**
  38254. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38256. */
  38257. maxDistance: number;
  38258. /**
  38259. * Define the distance attenuation model the sound will follow.
  38260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38261. */
  38262. distanceModel: string;
  38263. /**
  38264. * @hidden
  38265. * Back Compat
  38266. **/
  38267. onended: () => any;
  38268. /**
  38269. * Observable event when the current playing sound finishes.
  38270. */
  38271. onEndedObservable: Observable<Sound>;
  38272. private _panningModel;
  38273. private _playbackRate;
  38274. private _streaming;
  38275. private _startTime;
  38276. private _startOffset;
  38277. private _position;
  38278. /** @hidden */
  38279. _positionInEmitterSpace: boolean;
  38280. private _localDirection;
  38281. private _volume;
  38282. private _isReadyToPlay;
  38283. private _isDirectional;
  38284. private _readyToPlayCallback;
  38285. private _audioBuffer;
  38286. private _soundSource;
  38287. private _streamingSource;
  38288. private _soundPanner;
  38289. private _soundGain;
  38290. private _inputAudioNode;
  38291. private _outputAudioNode;
  38292. private _coneInnerAngle;
  38293. private _coneOuterAngle;
  38294. private _coneOuterGain;
  38295. private _scene;
  38296. private _connectedTransformNode;
  38297. private _customAttenuationFunction;
  38298. private _registerFunc;
  38299. private _isOutputConnected;
  38300. private _htmlAudioElement;
  38301. private _urlType;
  38302. private _length?;
  38303. private _offset?;
  38304. /** @hidden */
  38305. static _SceneComponentInitialization: (scene: Scene) => void;
  38306. /**
  38307. * Create a sound and attach it to a scene
  38308. * @param name Name of your sound
  38309. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38310. * @param scene defines the scene the sound belongs to
  38311. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38312. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38313. */
  38314. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38315. /**
  38316. * Release the sound and its associated resources
  38317. */
  38318. dispose(): void;
  38319. /**
  38320. * Gets if the sounds is ready to be played or not.
  38321. * @returns true if ready, otherwise false
  38322. */
  38323. isReady(): boolean;
  38324. private _soundLoaded;
  38325. /**
  38326. * Sets the data of the sound from an audiobuffer
  38327. * @param audioBuffer The audioBuffer containing the data
  38328. */
  38329. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38330. /**
  38331. * Updates the current sounds options such as maxdistance, loop...
  38332. * @param options A JSON object containing values named as the object properties
  38333. */
  38334. updateOptions(options: ISoundOptions): void;
  38335. private _createSpatialParameters;
  38336. private _updateSpatialParameters;
  38337. /**
  38338. * Switch the panning model to HRTF:
  38339. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38341. */
  38342. switchPanningModelToHRTF(): void;
  38343. /**
  38344. * Switch the panning model to Equal Power:
  38345. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38347. */
  38348. switchPanningModelToEqualPower(): void;
  38349. private _switchPanningModel;
  38350. /**
  38351. * Connect this sound to a sound track audio node like gain...
  38352. * @param soundTrackAudioNode the sound track audio node to connect to
  38353. */
  38354. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38355. /**
  38356. * Transform this sound into a directional source
  38357. * @param coneInnerAngle Size of the inner cone in degree
  38358. * @param coneOuterAngle Size of the outer cone in degree
  38359. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38360. */
  38361. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38362. /**
  38363. * Gets or sets the inner angle for the directional cone.
  38364. */
  38365. get directionalConeInnerAngle(): number;
  38366. /**
  38367. * Gets or sets the inner angle for the directional cone.
  38368. */
  38369. set directionalConeInnerAngle(value: number);
  38370. /**
  38371. * Gets or sets the outer angle for the directional cone.
  38372. */
  38373. get directionalConeOuterAngle(): number;
  38374. /**
  38375. * Gets or sets the outer angle for the directional cone.
  38376. */
  38377. set directionalConeOuterAngle(value: number);
  38378. /**
  38379. * Sets the position of the emitter if spatial sound is enabled
  38380. * @param newPosition Defines the new posisiton
  38381. */
  38382. setPosition(newPosition: Vector3): void;
  38383. /**
  38384. * Sets the local direction of the emitter if spatial sound is enabled
  38385. * @param newLocalDirection Defines the new local direction
  38386. */
  38387. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38388. private _updateDirection;
  38389. /** @hidden */
  38390. updateDistanceFromListener(): void;
  38391. /**
  38392. * Sets a new custom attenuation function for the sound.
  38393. * @param callback Defines the function used for the attenuation
  38394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38395. */
  38396. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38397. /**
  38398. * Play the sound
  38399. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38400. * @param offset (optional) Start the sound at a specific time in seconds
  38401. * @param length (optional) Sound duration (in seconds)
  38402. */
  38403. play(time?: number, offset?: number, length?: number): void;
  38404. private _onended;
  38405. /**
  38406. * Stop the sound
  38407. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38408. */
  38409. stop(time?: number): void;
  38410. /**
  38411. * Put the sound in pause
  38412. */
  38413. pause(): void;
  38414. /**
  38415. * Sets a dedicated volume for this sounds
  38416. * @param newVolume Define the new volume of the sound
  38417. * @param time Define time for gradual change to new volume
  38418. */
  38419. setVolume(newVolume: number, time?: number): void;
  38420. /**
  38421. * Set the sound play back rate
  38422. * @param newPlaybackRate Define the playback rate the sound should be played at
  38423. */
  38424. setPlaybackRate(newPlaybackRate: number): void;
  38425. /**
  38426. * Gets the volume of the sound.
  38427. * @returns the volume of the sound
  38428. */
  38429. getVolume(): number;
  38430. /**
  38431. * Attach the sound to a dedicated mesh
  38432. * @param transformNode The transform node to connect the sound with
  38433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38434. */
  38435. attachToMesh(transformNode: TransformNode): void;
  38436. /**
  38437. * Detach the sound from the previously attached mesh
  38438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38439. */
  38440. detachFromMesh(): void;
  38441. private _onRegisterAfterWorldMatrixUpdate;
  38442. /**
  38443. * Clone the current sound in the scene.
  38444. * @returns the new sound clone
  38445. */
  38446. clone(): Nullable<Sound>;
  38447. /**
  38448. * Gets the current underlying audio buffer containing the data
  38449. * @returns the audio buffer
  38450. */
  38451. getAudioBuffer(): Nullable<AudioBuffer>;
  38452. /**
  38453. * Serializes the Sound in a JSON representation
  38454. * @returns the JSON representation of the sound
  38455. */
  38456. serialize(): any;
  38457. /**
  38458. * Parse a JSON representation of a sound to innstantiate in a given scene
  38459. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38460. * @param scene Define the scene the new parsed sound should be created in
  38461. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38462. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38463. * @returns the newly parsed sound
  38464. */
  38465. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38466. }
  38467. }
  38468. declare module "babylonjs/Actions/directAudioActions" {
  38469. import { Action } from "babylonjs/Actions/action";
  38470. import { Condition } from "babylonjs/Actions/condition";
  38471. import { Sound } from "babylonjs/Audio/sound";
  38472. /**
  38473. * This defines an action helpful to play a defined sound on a triggered action.
  38474. */
  38475. export class PlaySoundAction extends Action {
  38476. private _sound;
  38477. /**
  38478. * Instantiate the action
  38479. * @param triggerOptions defines the trigger options
  38480. * @param sound defines the sound to play
  38481. * @param condition defines the trigger related conditions
  38482. */
  38483. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38484. /** @hidden */
  38485. _prepare(): void;
  38486. /**
  38487. * Execute the action and play the sound.
  38488. */
  38489. execute(): void;
  38490. /**
  38491. * Serializes the actions and its related information.
  38492. * @param parent defines the object to serialize in
  38493. * @returns the serialized object
  38494. */
  38495. serialize(parent: any): any;
  38496. }
  38497. /**
  38498. * This defines an action helpful to stop a defined sound on a triggered action.
  38499. */
  38500. export class StopSoundAction extends Action {
  38501. private _sound;
  38502. /**
  38503. * Instantiate the action
  38504. * @param triggerOptions defines the trigger options
  38505. * @param sound defines the sound to stop
  38506. * @param condition defines the trigger related conditions
  38507. */
  38508. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38509. /** @hidden */
  38510. _prepare(): void;
  38511. /**
  38512. * Execute the action and stop the sound.
  38513. */
  38514. execute(): void;
  38515. /**
  38516. * Serializes the actions and its related information.
  38517. * @param parent defines the object to serialize in
  38518. * @returns the serialized object
  38519. */
  38520. serialize(parent: any): any;
  38521. }
  38522. }
  38523. declare module "babylonjs/Actions/interpolateValueAction" {
  38524. import { Action } from "babylonjs/Actions/action";
  38525. import { Condition } from "babylonjs/Actions/condition";
  38526. import { Observable } from "babylonjs/Misc/observable";
  38527. /**
  38528. * This defines an action responsible to change the value of a property
  38529. * by interpolating between its current value and the newly set one once triggered.
  38530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38531. */
  38532. export class InterpolateValueAction extends Action {
  38533. /**
  38534. * Defines the path of the property where the value should be interpolated
  38535. */
  38536. propertyPath: string;
  38537. /**
  38538. * Defines the target value at the end of the interpolation.
  38539. */
  38540. value: any;
  38541. /**
  38542. * Defines the time it will take for the property to interpolate to the value.
  38543. */
  38544. duration: number;
  38545. /**
  38546. * Defines if the other scene animations should be stopped when the action has been triggered
  38547. */
  38548. stopOtherAnimations?: boolean;
  38549. /**
  38550. * Defines a callback raised once the interpolation animation has been done.
  38551. */
  38552. onInterpolationDone?: () => void;
  38553. /**
  38554. * Observable triggered once the interpolation animation has been done.
  38555. */
  38556. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38557. private _target;
  38558. private _effectiveTarget;
  38559. private _property;
  38560. /**
  38561. * Instantiate the action
  38562. * @param triggerOptions defines the trigger options
  38563. * @param target defines the object containing the value to interpolate
  38564. * @param propertyPath defines the path to the property in the target object
  38565. * @param value defines the target value at the end of the interpolation
  38566. * @param duration deines the time it will take for the property to interpolate to the value.
  38567. * @param condition defines the trigger related conditions
  38568. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38569. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38570. */
  38571. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38572. /** @hidden */
  38573. _prepare(): void;
  38574. /**
  38575. * Execute the action starts the value interpolation.
  38576. */
  38577. execute(): void;
  38578. /**
  38579. * Serializes the actions and its related information.
  38580. * @param parent defines the object to serialize in
  38581. * @returns the serialized object
  38582. */
  38583. serialize(parent: any): any;
  38584. }
  38585. }
  38586. declare module "babylonjs/Actions/index" {
  38587. export * from "babylonjs/Actions/abstractActionManager";
  38588. export * from "babylonjs/Actions/action";
  38589. export * from "babylonjs/Actions/actionEvent";
  38590. export * from "babylonjs/Actions/actionManager";
  38591. export * from "babylonjs/Actions/condition";
  38592. export * from "babylonjs/Actions/directActions";
  38593. export * from "babylonjs/Actions/directAudioActions";
  38594. export * from "babylonjs/Actions/interpolateValueAction";
  38595. }
  38596. declare module "babylonjs/Animations/index" {
  38597. export * from "babylonjs/Animations/animatable";
  38598. export * from "babylonjs/Animations/animation";
  38599. export * from "babylonjs/Animations/animationGroup";
  38600. export * from "babylonjs/Animations/animationPropertiesOverride";
  38601. export * from "babylonjs/Animations/easing";
  38602. export * from "babylonjs/Animations/runtimeAnimation";
  38603. export * from "babylonjs/Animations/animationEvent";
  38604. export * from "babylonjs/Animations/animationGroup";
  38605. export * from "babylonjs/Animations/animationKey";
  38606. export * from "babylonjs/Animations/animationRange";
  38607. export * from "babylonjs/Animations/animatable.interface";
  38608. }
  38609. declare module "babylonjs/Audio/soundTrack" {
  38610. import { Sound } from "babylonjs/Audio/sound";
  38611. import { Analyser } from "babylonjs/Audio/analyser";
  38612. import { Scene } from "babylonjs/scene";
  38613. /**
  38614. * Options allowed during the creation of a sound track.
  38615. */
  38616. export interface ISoundTrackOptions {
  38617. /**
  38618. * The volume the sound track should take during creation
  38619. */
  38620. volume?: number;
  38621. /**
  38622. * Define if the sound track is the main sound track of the scene
  38623. */
  38624. mainTrack?: boolean;
  38625. }
  38626. /**
  38627. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38628. * It will be also used in a future release to apply effects on a specific track.
  38629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38630. */
  38631. export class SoundTrack {
  38632. /**
  38633. * The unique identifier of the sound track in the scene.
  38634. */
  38635. id: number;
  38636. /**
  38637. * The list of sounds included in the sound track.
  38638. */
  38639. soundCollection: Array<Sound>;
  38640. private _outputAudioNode;
  38641. private _scene;
  38642. private _connectedAnalyser;
  38643. private _options;
  38644. private _isInitialized;
  38645. /**
  38646. * Creates a new sound track.
  38647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38648. * @param scene Define the scene the sound track belongs to
  38649. * @param options
  38650. */
  38651. constructor(scene: Scene, options?: ISoundTrackOptions);
  38652. private _initializeSoundTrackAudioGraph;
  38653. /**
  38654. * Release the sound track and its associated resources
  38655. */
  38656. dispose(): void;
  38657. /**
  38658. * Adds a sound to this sound track
  38659. * @param sound define the cound to add
  38660. * @ignoreNaming
  38661. */
  38662. AddSound(sound: Sound): void;
  38663. /**
  38664. * Removes a sound to this sound track
  38665. * @param sound define the cound to remove
  38666. * @ignoreNaming
  38667. */
  38668. RemoveSound(sound: Sound): void;
  38669. /**
  38670. * Set a global volume for the full sound track.
  38671. * @param newVolume Define the new volume of the sound track
  38672. */
  38673. setVolume(newVolume: number): void;
  38674. /**
  38675. * Switch the panning model to HRTF:
  38676. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38678. */
  38679. switchPanningModelToHRTF(): void;
  38680. /**
  38681. * Switch the panning model to Equal Power:
  38682. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38684. */
  38685. switchPanningModelToEqualPower(): void;
  38686. /**
  38687. * Connect the sound track to an audio analyser allowing some amazing
  38688. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38690. * @param analyser The analyser to connect to the engine
  38691. */
  38692. connectToAnalyser(analyser: Analyser): void;
  38693. }
  38694. }
  38695. declare module "babylonjs/Audio/audioSceneComponent" {
  38696. import { Sound } from "babylonjs/Audio/sound";
  38697. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38698. import { Nullable } from "babylonjs/types";
  38699. import { Vector3 } from "babylonjs/Maths/math.vector";
  38700. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38701. import { Scene } from "babylonjs/scene";
  38702. import { AbstractScene } from "babylonjs/abstractScene";
  38703. import "babylonjs/Audio/audioEngine";
  38704. module "babylonjs/abstractScene" {
  38705. interface AbstractScene {
  38706. /**
  38707. * The list of sounds used in the scene.
  38708. */
  38709. sounds: Nullable<Array<Sound>>;
  38710. }
  38711. }
  38712. module "babylonjs/scene" {
  38713. interface Scene {
  38714. /**
  38715. * @hidden
  38716. * Backing field
  38717. */
  38718. _mainSoundTrack: SoundTrack;
  38719. /**
  38720. * The main sound track played by the scene.
  38721. * It cotains your primary collection of sounds.
  38722. */
  38723. mainSoundTrack: SoundTrack;
  38724. /**
  38725. * The list of sound tracks added to the scene
  38726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38727. */
  38728. soundTracks: Nullable<Array<SoundTrack>>;
  38729. /**
  38730. * Gets a sound using a given name
  38731. * @param name defines the name to search for
  38732. * @return the found sound or null if not found at all.
  38733. */
  38734. getSoundByName(name: string): Nullable<Sound>;
  38735. /**
  38736. * Gets or sets if audio support is enabled
  38737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38738. */
  38739. audioEnabled: boolean;
  38740. /**
  38741. * Gets or sets if audio will be output to headphones
  38742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38743. */
  38744. headphone: boolean;
  38745. /**
  38746. * Gets or sets custom audio listener position provider
  38747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38748. */
  38749. audioListenerPositionProvider: Nullable<() => Vector3>;
  38750. /**
  38751. * Gets or sets a refresh rate when using 3D audio positioning
  38752. */
  38753. audioPositioningRefreshRate: number;
  38754. }
  38755. }
  38756. /**
  38757. * Defines the sound scene component responsible to manage any sounds
  38758. * in a given scene.
  38759. */
  38760. export class AudioSceneComponent implements ISceneSerializableComponent {
  38761. /**
  38762. * The component name helpfull to identify the component in the list of scene components.
  38763. */
  38764. readonly name: string;
  38765. /**
  38766. * The scene the component belongs to.
  38767. */
  38768. scene: Scene;
  38769. private _audioEnabled;
  38770. /**
  38771. * Gets whether audio is enabled or not.
  38772. * Please use related enable/disable method to switch state.
  38773. */
  38774. get audioEnabled(): boolean;
  38775. private _headphone;
  38776. /**
  38777. * Gets whether audio is outputing to headphone or not.
  38778. * Please use the according Switch methods to change output.
  38779. */
  38780. get headphone(): boolean;
  38781. /**
  38782. * Gets or sets a refresh rate when using 3D audio positioning
  38783. */
  38784. audioPositioningRefreshRate: number;
  38785. private _audioListenerPositionProvider;
  38786. /**
  38787. * Gets the current audio listener position provider
  38788. */
  38789. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38790. /**
  38791. * Sets a custom listener position for all sounds in the scene
  38792. * By default, this is the position of the first active camera
  38793. */
  38794. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38795. /**
  38796. * Creates a new instance of the component for the given scene
  38797. * @param scene Defines the scene to register the component in
  38798. */
  38799. constructor(scene: Scene);
  38800. /**
  38801. * Registers the component in a given scene
  38802. */
  38803. register(): void;
  38804. /**
  38805. * Rebuilds the elements related to this component in case of
  38806. * context lost for instance.
  38807. */
  38808. rebuild(): void;
  38809. /**
  38810. * Serializes the component data to the specified json object
  38811. * @param serializationObject The object to serialize to
  38812. */
  38813. serialize(serializationObject: any): void;
  38814. /**
  38815. * Adds all the elements from the container to the scene
  38816. * @param container the container holding the elements
  38817. */
  38818. addFromContainer(container: AbstractScene): void;
  38819. /**
  38820. * Removes all the elements in the container from the scene
  38821. * @param container contains the elements to remove
  38822. * @param dispose if the removed element should be disposed (default: false)
  38823. */
  38824. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38825. /**
  38826. * Disposes the component and the associated ressources.
  38827. */
  38828. dispose(): void;
  38829. /**
  38830. * Disables audio in the associated scene.
  38831. */
  38832. disableAudio(): void;
  38833. /**
  38834. * Enables audio in the associated scene.
  38835. */
  38836. enableAudio(): void;
  38837. /**
  38838. * Switch audio to headphone output.
  38839. */
  38840. switchAudioModeForHeadphones(): void;
  38841. /**
  38842. * Switch audio to normal speakers.
  38843. */
  38844. switchAudioModeForNormalSpeakers(): void;
  38845. private _cachedCameraDirection;
  38846. private _cachedCameraPosition;
  38847. private _lastCheck;
  38848. private _afterRender;
  38849. }
  38850. }
  38851. declare module "babylonjs/Audio/weightedsound" {
  38852. import { Sound } from "babylonjs/Audio/sound";
  38853. /**
  38854. * Wraps one or more Sound objects and selects one with random weight for playback.
  38855. */
  38856. export class WeightedSound {
  38857. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38858. loop: boolean;
  38859. private _coneInnerAngle;
  38860. private _coneOuterAngle;
  38861. private _volume;
  38862. /** A Sound is currently playing. */
  38863. isPlaying: boolean;
  38864. /** A Sound is currently paused. */
  38865. isPaused: boolean;
  38866. private _sounds;
  38867. private _weights;
  38868. private _currentIndex?;
  38869. /**
  38870. * Creates a new WeightedSound from the list of sounds given.
  38871. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38872. * @param sounds Array of Sounds that will be selected from.
  38873. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38874. */
  38875. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38876. /**
  38877. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38878. */
  38879. get directionalConeInnerAngle(): number;
  38880. /**
  38881. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38882. */
  38883. set directionalConeInnerAngle(value: number);
  38884. /**
  38885. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38886. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38887. */
  38888. get directionalConeOuterAngle(): number;
  38889. /**
  38890. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38891. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38892. */
  38893. set directionalConeOuterAngle(value: number);
  38894. /**
  38895. * Playback volume.
  38896. */
  38897. get volume(): number;
  38898. /**
  38899. * Playback volume.
  38900. */
  38901. set volume(value: number);
  38902. private _onended;
  38903. /**
  38904. * Suspend playback
  38905. */
  38906. pause(): void;
  38907. /**
  38908. * Stop playback
  38909. */
  38910. stop(): void;
  38911. /**
  38912. * Start playback.
  38913. * @param startOffset Position the clip head at a specific time in seconds.
  38914. */
  38915. play(startOffset?: number): void;
  38916. }
  38917. }
  38918. declare module "babylonjs/Audio/index" {
  38919. export * from "babylonjs/Audio/analyser";
  38920. export * from "babylonjs/Audio/audioEngine";
  38921. export * from "babylonjs/Audio/audioSceneComponent";
  38922. export * from "babylonjs/Audio/sound";
  38923. export * from "babylonjs/Audio/soundTrack";
  38924. export * from "babylonjs/Audio/weightedsound";
  38925. }
  38926. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38927. import { Behavior } from "babylonjs/Behaviors/behavior";
  38928. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38929. import { BackEase } from "babylonjs/Animations/easing";
  38930. /**
  38931. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38932. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38933. */
  38934. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38935. /**
  38936. * Gets the name of the behavior.
  38937. */
  38938. get name(): string;
  38939. /**
  38940. * The easing function used by animations
  38941. */
  38942. static EasingFunction: BackEase;
  38943. /**
  38944. * The easing mode used by animations
  38945. */
  38946. static EasingMode: number;
  38947. /**
  38948. * The duration of the animation, in milliseconds
  38949. */
  38950. transitionDuration: number;
  38951. /**
  38952. * Length of the distance animated by the transition when lower radius is reached
  38953. */
  38954. lowerRadiusTransitionRange: number;
  38955. /**
  38956. * Length of the distance animated by the transition when upper radius is reached
  38957. */
  38958. upperRadiusTransitionRange: number;
  38959. private _autoTransitionRange;
  38960. /**
  38961. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38962. */
  38963. get autoTransitionRange(): boolean;
  38964. /**
  38965. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38966. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38967. */
  38968. set autoTransitionRange(value: boolean);
  38969. private _attachedCamera;
  38970. private _onAfterCheckInputsObserver;
  38971. private _onMeshTargetChangedObserver;
  38972. /**
  38973. * Initializes the behavior.
  38974. */
  38975. init(): void;
  38976. /**
  38977. * Attaches the behavior to its arc rotate camera.
  38978. * @param camera Defines the camera to attach the behavior to
  38979. */
  38980. attach(camera: ArcRotateCamera): void;
  38981. /**
  38982. * Detaches the behavior from its current arc rotate camera.
  38983. */
  38984. detach(): void;
  38985. private _radiusIsAnimating;
  38986. private _radiusBounceTransition;
  38987. private _animatables;
  38988. private _cachedWheelPrecision;
  38989. /**
  38990. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38991. * @param radiusLimit The limit to check against.
  38992. * @return Bool to indicate if at limit.
  38993. */
  38994. private _isRadiusAtLimit;
  38995. /**
  38996. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38997. * @param radiusDelta The delta by which to animate to. Can be negative.
  38998. */
  38999. private _applyBoundRadiusAnimation;
  39000. /**
  39001. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39002. */
  39003. protected _clearAnimationLocks(): void;
  39004. /**
  39005. * Stops and removes all animations that have been applied to the camera
  39006. */
  39007. stopAllAnimations(): void;
  39008. }
  39009. }
  39010. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39011. import { Behavior } from "babylonjs/Behaviors/behavior";
  39012. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39013. import { ExponentialEase } from "babylonjs/Animations/easing";
  39014. import { Nullable } from "babylonjs/types";
  39015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39016. import { Vector3 } from "babylonjs/Maths/math.vector";
  39017. /**
  39018. * 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.
  39019. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39020. */
  39021. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39022. /**
  39023. * Gets the name of the behavior.
  39024. */
  39025. get name(): string;
  39026. private _mode;
  39027. private _radiusScale;
  39028. private _positionScale;
  39029. private _defaultElevation;
  39030. private _elevationReturnTime;
  39031. private _elevationReturnWaitTime;
  39032. private _zoomStopsAnimation;
  39033. private _framingTime;
  39034. /**
  39035. * The easing function used by animations
  39036. */
  39037. static EasingFunction: ExponentialEase;
  39038. /**
  39039. * The easing mode used by animations
  39040. */
  39041. static EasingMode: number;
  39042. /**
  39043. * Sets the current mode used by the behavior
  39044. */
  39045. set mode(mode: number);
  39046. /**
  39047. * Gets current mode used by the behavior.
  39048. */
  39049. get mode(): number;
  39050. /**
  39051. * Sets the scale applied to the radius (1 by default)
  39052. */
  39053. set radiusScale(radius: number);
  39054. /**
  39055. * Gets the scale applied to the radius
  39056. */
  39057. get radiusScale(): number;
  39058. /**
  39059. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39060. */
  39061. set positionScale(scale: number);
  39062. /**
  39063. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39064. */
  39065. get positionScale(): number;
  39066. /**
  39067. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39068. * behaviour is triggered, in radians.
  39069. */
  39070. set defaultElevation(elevation: number);
  39071. /**
  39072. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39073. * behaviour is triggered, in radians.
  39074. */
  39075. get defaultElevation(): number;
  39076. /**
  39077. * Sets the time (in milliseconds) taken to return to the default beta position.
  39078. * Negative value indicates camera should not return to default.
  39079. */
  39080. set elevationReturnTime(speed: number);
  39081. /**
  39082. * Gets the time (in milliseconds) taken to return to the default beta position.
  39083. * Negative value indicates camera should not return to default.
  39084. */
  39085. get elevationReturnTime(): number;
  39086. /**
  39087. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39088. */
  39089. set elevationReturnWaitTime(time: number);
  39090. /**
  39091. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39092. */
  39093. get elevationReturnWaitTime(): number;
  39094. /**
  39095. * Sets the flag that indicates if user zooming should stop animation.
  39096. */
  39097. set zoomStopsAnimation(flag: boolean);
  39098. /**
  39099. * Gets the flag that indicates if user zooming should stop animation.
  39100. */
  39101. get zoomStopsAnimation(): boolean;
  39102. /**
  39103. * Sets the transition time when framing the mesh, in milliseconds
  39104. */
  39105. set framingTime(time: number);
  39106. /**
  39107. * Gets the transition time when framing the mesh, in milliseconds
  39108. */
  39109. get framingTime(): number;
  39110. /**
  39111. * Define if the behavior should automatically change the configured
  39112. * camera limits and sensibilities.
  39113. */
  39114. autoCorrectCameraLimitsAndSensibility: boolean;
  39115. private _onPrePointerObservableObserver;
  39116. private _onAfterCheckInputsObserver;
  39117. private _onMeshTargetChangedObserver;
  39118. private _attachedCamera;
  39119. private _isPointerDown;
  39120. private _lastInteractionTime;
  39121. /**
  39122. * Initializes the behavior.
  39123. */
  39124. init(): void;
  39125. /**
  39126. * Attaches the behavior to its arc rotate camera.
  39127. * @param camera Defines the camera to attach the behavior to
  39128. */
  39129. attach(camera: ArcRotateCamera): void;
  39130. /**
  39131. * Detaches the behavior from its current arc rotate camera.
  39132. */
  39133. detach(): void;
  39134. private _animatables;
  39135. private _betaIsAnimating;
  39136. private _betaTransition;
  39137. private _radiusTransition;
  39138. private _vectorTransition;
  39139. /**
  39140. * Targets the given mesh and updates zoom level accordingly.
  39141. * @param mesh The mesh to target.
  39142. * @param radius Optional. If a cached radius position already exists, overrides default.
  39143. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39144. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39145. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39146. */
  39147. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39148. /**
  39149. * Targets the given mesh with its children and updates zoom level accordingly.
  39150. * @param mesh The mesh to target.
  39151. * @param radius Optional. If a cached radius position already exists, overrides default.
  39152. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39153. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39154. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39155. */
  39156. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39157. /**
  39158. * Targets the given meshes with their children and updates zoom level accordingly.
  39159. * @param meshes The mesh to target.
  39160. * @param radius Optional. If a cached radius position already exists, overrides default.
  39161. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39162. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39163. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39164. */
  39165. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39166. /**
  39167. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39168. * @param minimumWorld Determines the smaller position of the bounding box extend
  39169. * @param maximumWorld Determines the bigger position of the bounding box extend
  39170. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39171. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39172. */
  39173. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39174. /**
  39175. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39176. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39177. * frustum width.
  39178. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39179. * to fully enclose the mesh in the viewing frustum.
  39180. */
  39181. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39182. /**
  39183. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39184. * is automatically returned to its default position (expected to be above ground plane).
  39185. */
  39186. private _maintainCameraAboveGround;
  39187. /**
  39188. * Returns the frustum slope based on the canvas ratio and camera FOV
  39189. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39190. */
  39191. private _getFrustumSlope;
  39192. /**
  39193. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39194. */
  39195. private _clearAnimationLocks;
  39196. /**
  39197. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39198. */
  39199. private _applyUserInteraction;
  39200. /**
  39201. * Stops and removes all animations that have been applied to the camera
  39202. */
  39203. stopAllAnimations(): void;
  39204. /**
  39205. * Gets a value indicating if the user is moving the camera
  39206. */
  39207. get isUserIsMoving(): boolean;
  39208. /**
  39209. * The camera can move all the way towards the mesh.
  39210. */
  39211. static IgnoreBoundsSizeMode: number;
  39212. /**
  39213. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39214. */
  39215. static FitFrustumSidesMode: number;
  39216. }
  39217. }
  39218. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39219. import { Nullable } from "babylonjs/types";
  39220. import { Camera } from "babylonjs/Cameras/camera";
  39221. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39222. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39223. /**
  39224. * Base class for Camera Pointer Inputs.
  39225. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39226. * for example usage.
  39227. */
  39228. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39229. /**
  39230. * Defines the camera the input is attached to.
  39231. */
  39232. abstract camera: Camera;
  39233. /**
  39234. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39235. */
  39236. protected _altKey: boolean;
  39237. protected _ctrlKey: boolean;
  39238. protected _metaKey: boolean;
  39239. protected _shiftKey: boolean;
  39240. /**
  39241. * Which mouse buttons were pressed at time of last mouse event.
  39242. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39243. */
  39244. protected _buttonsPressed: number;
  39245. /**
  39246. * Defines the buttons associated with the input to handle camera move.
  39247. */
  39248. buttons: number[];
  39249. /**
  39250. * Attach the input controls to a specific dom element to get the input from.
  39251. * @param element Defines the element the controls should be listened from
  39252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39253. */
  39254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39255. /**
  39256. * Detach the current controls from the specified dom element.
  39257. * @param element Defines the element to stop listening the inputs from
  39258. */
  39259. detachControl(element: Nullable<HTMLElement>): void;
  39260. /**
  39261. * Gets the class name of the current input.
  39262. * @returns the class name
  39263. */
  39264. getClassName(): string;
  39265. /**
  39266. * Get the friendly name associated with the input class.
  39267. * @returns the input friendly name
  39268. */
  39269. getSimpleName(): string;
  39270. /**
  39271. * Called on pointer POINTERDOUBLETAP event.
  39272. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39273. */
  39274. protected onDoubleTap(type: string): void;
  39275. /**
  39276. * Called on pointer POINTERMOVE event if only a single touch is active.
  39277. * Override this method to provide functionality.
  39278. */
  39279. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39280. /**
  39281. * Called on pointer POINTERMOVE event if multiple touches are active.
  39282. * Override this method to provide functionality.
  39283. */
  39284. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39285. /**
  39286. * Called on JS contextmenu event.
  39287. * Override this method to provide functionality.
  39288. */
  39289. protected onContextMenu(evt: PointerEvent): void;
  39290. /**
  39291. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39292. * press.
  39293. * Override this method to provide functionality.
  39294. */
  39295. protected onButtonDown(evt: PointerEvent): void;
  39296. /**
  39297. * Called each time a new POINTERUP event occurs. Ie, for each button
  39298. * release.
  39299. * Override this method to provide functionality.
  39300. */
  39301. protected onButtonUp(evt: PointerEvent): void;
  39302. /**
  39303. * Called when window becomes inactive.
  39304. * Override this method to provide functionality.
  39305. */
  39306. protected onLostFocus(): void;
  39307. private _pointerInput;
  39308. private _observer;
  39309. private _onLostFocus;
  39310. private pointA;
  39311. private pointB;
  39312. }
  39313. }
  39314. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39315. import { Nullable } from "babylonjs/types";
  39316. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39317. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39318. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39319. /**
  39320. * Manage the pointers inputs to control an arc rotate camera.
  39321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39322. */
  39323. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39324. /**
  39325. * Defines the camera the input is attached to.
  39326. */
  39327. camera: ArcRotateCamera;
  39328. /**
  39329. * Gets the class name of the current input.
  39330. * @returns the class name
  39331. */
  39332. getClassName(): string;
  39333. /**
  39334. * Defines the buttons associated with the input to handle camera move.
  39335. */
  39336. buttons: number[];
  39337. /**
  39338. * Defines the pointer angular sensibility along the X axis or how fast is
  39339. * the camera rotating.
  39340. */
  39341. angularSensibilityX: number;
  39342. /**
  39343. * Defines the pointer angular sensibility along the Y axis or how fast is
  39344. * the camera rotating.
  39345. */
  39346. angularSensibilityY: number;
  39347. /**
  39348. * Defines the pointer pinch precision or how fast is the camera zooming.
  39349. */
  39350. pinchPrecision: number;
  39351. /**
  39352. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39353. * from 0.
  39354. * It defines the percentage of current camera.radius to use as delta when
  39355. * pinch zoom is used.
  39356. */
  39357. pinchDeltaPercentage: number;
  39358. /**
  39359. * Defines the pointer panning sensibility or how fast is the camera moving.
  39360. */
  39361. panningSensibility: number;
  39362. /**
  39363. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39364. */
  39365. multiTouchPanning: boolean;
  39366. /**
  39367. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39368. * zoom (pinch) through multitouch.
  39369. */
  39370. multiTouchPanAndZoom: boolean;
  39371. /**
  39372. * Revers pinch action direction.
  39373. */
  39374. pinchInwards: boolean;
  39375. private _isPanClick;
  39376. private _twoFingerActivityCount;
  39377. private _isPinching;
  39378. /**
  39379. * Called on pointer POINTERMOVE event if only a single touch is active.
  39380. */
  39381. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39382. /**
  39383. * Called on pointer POINTERDOUBLETAP event.
  39384. */
  39385. protected onDoubleTap(type: string): void;
  39386. /**
  39387. * Called on pointer POINTERMOVE event if multiple touches are active.
  39388. */
  39389. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39390. /**
  39391. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39392. * press.
  39393. */
  39394. protected onButtonDown(evt: PointerEvent): void;
  39395. /**
  39396. * Called each time a new POINTERUP event occurs. Ie, for each button
  39397. * release.
  39398. */
  39399. protected onButtonUp(evt: PointerEvent): void;
  39400. /**
  39401. * Called when window becomes inactive.
  39402. */
  39403. protected onLostFocus(): void;
  39404. }
  39405. }
  39406. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39407. import { Nullable } from "babylonjs/types";
  39408. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39409. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39410. /**
  39411. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39413. */
  39414. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39415. /**
  39416. * Defines the camera the input is attached to.
  39417. */
  39418. camera: ArcRotateCamera;
  39419. /**
  39420. * Defines the list of key codes associated with the up action (increase alpha)
  39421. */
  39422. keysUp: number[];
  39423. /**
  39424. * Defines the list of key codes associated with the down action (decrease alpha)
  39425. */
  39426. keysDown: number[];
  39427. /**
  39428. * Defines the list of key codes associated with the left action (increase beta)
  39429. */
  39430. keysLeft: number[];
  39431. /**
  39432. * Defines the list of key codes associated with the right action (decrease beta)
  39433. */
  39434. keysRight: number[];
  39435. /**
  39436. * Defines the list of key codes associated with the reset action.
  39437. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39438. */
  39439. keysReset: number[];
  39440. /**
  39441. * Defines the panning sensibility of the inputs.
  39442. * (How fast is the camera paning)
  39443. */
  39444. panningSensibility: number;
  39445. /**
  39446. * Defines the zooming sensibility of the inputs.
  39447. * (How fast is the camera zooming)
  39448. */
  39449. zoomingSensibility: number;
  39450. /**
  39451. * Defines wether maintaining the alt key down switch the movement mode from
  39452. * orientation to zoom.
  39453. */
  39454. useAltToZoom: boolean;
  39455. /**
  39456. * Rotation speed of the camera
  39457. */
  39458. angularSpeed: number;
  39459. private _keys;
  39460. private _ctrlPressed;
  39461. private _altPressed;
  39462. private _onCanvasBlurObserver;
  39463. private _onKeyboardObserver;
  39464. private _engine;
  39465. private _scene;
  39466. /**
  39467. * Attach the input controls to a specific dom element to get the input from.
  39468. * @param element Defines the element the controls should be listened from
  39469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39470. */
  39471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39472. /**
  39473. * Detach the current controls from the specified dom element.
  39474. * @param element Defines the element to stop listening the inputs from
  39475. */
  39476. detachControl(element: Nullable<HTMLElement>): void;
  39477. /**
  39478. * Update the current camera state depending on the inputs that have been used this frame.
  39479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39480. */
  39481. checkInputs(): void;
  39482. /**
  39483. * Gets the class name of the current intput.
  39484. * @returns the class name
  39485. */
  39486. getClassName(): string;
  39487. /**
  39488. * Get the friendly name associated with the input class.
  39489. * @returns the input friendly name
  39490. */
  39491. getSimpleName(): string;
  39492. }
  39493. }
  39494. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39495. import { Nullable } from "babylonjs/types";
  39496. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39497. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39498. /**
  39499. * Manage the mouse wheel inputs to control an arc rotate camera.
  39500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39501. */
  39502. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39503. /**
  39504. * Defines the camera the input is attached to.
  39505. */
  39506. camera: ArcRotateCamera;
  39507. /**
  39508. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39509. */
  39510. wheelPrecision: number;
  39511. /**
  39512. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39513. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39514. */
  39515. wheelDeltaPercentage: number;
  39516. private _wheel;
  39517. private _observer;
  39518. private computeDeltaFromMouseWheelLegacyEvent;
  39519. /**
  39520. * Attach the input controls to a specific dom element to get the input from.
  39521. * @param element Defines the element the controls should be listened from
  39522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39523. */
  39524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39525. /**
  39526. * Detach the current controls from the specified dom element.
  39527. * @param element Defines the element to stop listening the inputs from
  39528. */
  39529. detachControl(element: Nullable<HTMLElement>): void;
  39530. /**
  39531. * Gets the class name of the current intput.
  39532. * @returns the class name
  39533. */
  39534. getClassName(): string;
  39535. /**
  39536. * Get the friendly name associated with the input class.
  39537. * @returns the input friendly name
  39538. */
  39539. getSimpleName(): string;
  39540. }
  39541. }
  39542. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39543. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39544. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39545. /**
  39546. * Default Inputs manager for the ArcRotateCamera.
  39547. * It groups all the default supported inputs for ease of use.
  39548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39549. */
  39550. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39551. /**
  39552. * Instantiates a new ArcRotateCameraInputsManager.
  39553. * @param camera Defines the camera the inputs belong to
  39554. */
  39555. constructor(camera: ArcRotateCamera);
  39556. /**
  39557. * Add mouse wheel input support to the input manager.
  39558. * @returns the current input manager
  39559. */
  39560. addMouseWheel(): ArcRotateCameraInputsManager;
  39561. /**
  39562. * Add pointers input support to the input manager.
  39563. * @returns the current input manager
  39564. */
  39565. addPointers(): ArcRotateCameraInputsManager;
  39566. /**
  39567. * Add keyboard input support to the input manager.
  39568. * @returns the current input manager
  39569. */
  39570. addKeyboard(): ArcRotateCameraInputsManager;
  39571. }
  39572. }
  39573. declare module "babylonjs/Cameras/arcRotateCamera" {
  39574. import { Observable } from "babylonjs/Misc/observable";
  39575. import { Nullable } from "babylonjs/types";
  39576. import { Scene } from "babylonjs/scene";
  39577. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39579. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39580. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39581. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39582. import { Camera } from "babylonjs/Cameras/camera";
  39583. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39584. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39585. import { Collider } from "babylonjs/Collisions/collider";
  39586. /**
  39587. * This represents an orbital type of camera.
  39588. *
  39589. * 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.
  39590. * 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.
  39591. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39592. */
  39593. export class ArcRotateCamera extends TargetCamera {
  39594. /**
  39595. * Defines the rotation angle of the camera along the longitudinal axis.
  39596. */
  39597. alpha: number;
  39598. /**
  39599. * Defines the rotation angle of the camera along the latitudinal axis.
  39600. */
  39601. beta: number;
  39602. /**
  39603. * Defines the radius of the camera from it s target point.
  39604. */
  39605. radius: number;
  39606. protected _target: Vector3;
  39607. protected _targetHost: Nullable<AbstractMesh>;
  39608. /**
  39609. * Defines the target point of the camera.
  39610. * The camera looks towards it form the radius distance.
  39611. */
  39612. get target(): Vector3;
  39613. set target(value: Vector3);
  39614. /**
  39615. * Define the current local position of the camera in the scene
  39616. */
  39617. get position(): Vector3;
  39618. set position(newPosition: Vector3);
  39619. protected _upVector: Vector3;
  39620. protected _upToYMatrix: Matrix;
  39621. protected _YToUpMatrix: Matrix;
  39622. /**
  39623. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39624. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39625. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39626. */
  39627. set upVector(vec: Vector3);
  39628. get upVector(): Vector3;
  39629. /**
  39630. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39631. */
  39632. setMatUp(): void;
  39633. /**
  39634. * Current inertia value on the longitudinal axis.
  39635. * The bigger this number the longer it will take for the camera to stop.
  39636. */
  39637. inertialAlphaOffset: number;
  39638. /**
  39639. * Current inertia value on the latitudinal axis.
  39640. * The bigger this number the longer it will take for the camera to stop.
  39641. */
  39642. inertialBetaOffset: number;
  39643. /**
  39644. * Current inertia value on the radius axis.
  39645. * The bigger this number the longer it will take for the camera to stop.
  39646. */
  39647. inertialRadiusOffset: number;
  39648. /**
  39649. * Minimum allowed angle on the longitudinal axis.
  39650. * This can help limiting how the Camera is able to move in the scene.
  39651. */
  39652. lowerAlphaLimit: Nullable<number>;
  39653. /**
  39654. * Maximum allowed angle on the longitudinal axis.
  39655. * This can help limiting how the Camera is able to move in the scene.
  39656. */
  39657. upperAlphaLimit: Nullable<number>;
  39658. /**
  39659. * Minimum allowed angle on the latitudinal axis.
  39660. * This can help limiting how the Camera is able to move in the scene.
  39661. */
  39662. lowerBetaLimit: number;
  39663. /**
  39664. * Maximum allowed angle on the latitudinal axis.
  39665. * This can help limiting how the Camera is able to move in the scene.
  39666. */
  39667. upperBetaLimit: number;
  39668. /**
  39669. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39670. * This can help limiting how the Camera is able to move in the scene.
  39671. */
  39672. lowerRadiusLimit: Nullable<number>;
  39673. /**
  39674. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39675. * This can help limiting how the Camera is able to move in the scene.
  39676. */
  39677. upperRadiusLimit: Nullable<number>;
  39678. /**
  39679. * Defines the current inertia value used during panning of the camera along the X axis.
  39680. */
  39681. inertialPanningX: number;
  39682. /**
  39683. * Defines the current inertia value used during panning of the camera along the Y axis.
  39684. */
  39685. inertialPanningY: number;
  39686. /**
  39687. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39688. * Basically if your fingers moves away from more than this distance you will be considered
  39689. * in pinch mode.
  39690. */
  39691. pinchToPanMaxDistance: number;
  39692. /**
  39693. * Defines the maximum distance the camera can pan.
  39694. * This could help keeping the cammera always in your scene.
  39695. */
  39696. panningDistanceLimit: Nullable<number>;
  39697. /**
  39698. * Defines the target of the camera before paning.
  39699. */
  39700. panningOriginTarget: Vector3;
  39701. /**
  39702. * Defines the value of the inertia used during panning.
  39703. * 0 would mean stop inertia and one would mean no decelleration at all.
  39704. */
  39705. panningInertia: number;
  39706. /**
  39707. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39708. */
  39709. get angularSensibilityX(): number;
  39710. set angularSensibilityX(value: number);
  39711. /**
  39712. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39713. */
  39714. get angularSensibilityY(): number;
  39715. set angularSensibilityY(value: number);
  39716. /**
  39717. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39718. */
  39719. get pinchPrecision(): number;
  39720. set pinchPrecision(value: number);
  39721. /**
  39722. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39723. * It will be used instead of pinchDeltaPrecision if different from 0.
  39724. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39725. */
  39726. get pinchDeltaPercentage(): number;
  39727. set pinchDeltaPercentage(value: number);
  39728. /**
  39729. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39730. */
  39731. get panningSensibility(): number;
  39732. set panningSensibility(value: number);
  39733. /**
  39734. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39735. */
  39736. get keysUp(): number[];
  39737. set keysUp(value: number[]);
  39738. /**
  39739. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39740. */
  39741. get keysDown(): number[];
  39742. set keysDown(value: number[]);
  39743. /**
  39744. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39745. */
  39746. get keysLeft(): number[];
  39747. set keysLeft(value: number[]);
  39748. /**
  39749. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39750. */
  39751. get keysRight(): number[];
  39752. set keysRight(value: number[]);
  39753. /**
  39754. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39755. */
  39756. get wheelPrecision(): number;
  39757. set wheelPrecision(value: number);
  39758. /**
  39759. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39760. * It will be used instead of pinchDeltaPrecision if different from 0.
  39761. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39762. */
  39763. get wheelDeltaPercentage(): number;
  39764. set wheelDeltaPercentage(value: number);
  39765. /**
  39766. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39767. */
  39768. zoomOnFactor: number;
  39769. /**
  39770. * Defines a screen offset for the camera position.
  39771. */
  39772. targetScreenOffset: Vector2;
  39773. /**
  39774. * Allows the camera to be completely reversed.
  39775. * If false the camera can not arrive upside down.
  39776. */
  39777. allowUpsideDown: boolean;
  39778. /**
  39779. * Define if double tap/click is used to restore the previously saved state of the camera.
  39780. */
  39781. useInputToRestoreState: boolean;
  39782. /** @hidden */
  39783. _viewMatrix: Matrix;
  39784. /** @hidden */
  39785. _useCtrlForPanning: boolean;
  39786. /** @hidden */
  39787. _panningMouseButton: number;
  39788. /**
  39789. * Defines the input associated to the camera.
  39790. */
  39791. inputs: ArcRotateCameraInputsManager;
  39792. /** @hidden */
  39793. _reset: () => void;
  39794. /**
  39795. * Defines the allowed panning axis.
  39796. */
  39797. panningAxis: Vector3;
  39798. protected _localDirection: Vector3;
  39799. protected _transformedDirection: Vector3;
  39800. private _bouncingBehavior;
  39801. /**
  39802. * Gets the bouncing behavior of the camera if it has been enabled.
  39803. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39804. */
  39805. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39806. /**
  39807. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39808. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39809. */
  39810. get useBouncingBehavior(): boolean;
  39811. set useBouncingBehavior(value: boolean);
  39812. private _framingBehavior;
  39813. /**
  39814. * Gets the framing behavior of the camera if it has been enabled.
  39815. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39816. */
  39817. get framingBehavior(): Nullable<FramingBehavior>;
  39818. /**
  39819. * Defines if the framing behavior of the camera is enabled on the camera.
  39820. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39821. */
  39822. get useFramingBehavior(): boolean;
  39823. set useFramingBehavior(value: boolean);
  39824. private _autoRotationBehavior;
  39825. /**
  39826. * Gets the auto rotation behavior of the camera if it has been enabled.
  39827. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39828. */
  39829. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39830. /**
  39831. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39832. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39833. */
  39834. get useAutoRotationBehavior(): boolean;
  39835. set useAutoRotationBehavior(value: boolean);
  39836. /**
  39837. * Observable triggered when the mesh target has been changed on the camera.
  39838. */
  39839. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39840. /**
  39841. * Event raised when the camera is colliding with a mesh.
  39842. */
  39843. onCollide: (collidedMesh: AbstractMesh) => void;
  39844. /**
  39845. * Defines whether the camera should check collision with the objects oh the scene.
  39846. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39847. */
  39848. checkCollisions: boolean;
  39849. /**
  39850. * Defines the collision radius of the camera.
  39851. * This simulates a sphere around the camera.
  39852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39853. */
  39854. collisionRadius: Vector3;
  39855. protected _collider: Collider;
  39856. protected _previousPosition: Vector3;
  39857. protected _collisionVelocity: Vector3;
  39858. protected _newPosition: Vector3;
  39859. protected _previousAlpha: number;
  39860. protected _previousBeta: number;
  39861. protected _previousRadius: number;
  39862. protected _collisionTriggered: boolean;
  39863. protected _targetBoundingCenter: Nullable<Vector3>;
  39864. private _computationVector;
  39865. /**
  39866. * Instantiates a new ArcRotateCamera in a given scene
  39867. * @param name Defines the name of the camera
  39868. * @param alpha Defines the camera rotation along the logitudinal axis
  39869. * @param beta Defines the camera rotation along the latitudinal axis
  39870. * @param radius Defines the camera distance from its target
  39871. * @param target Defines the camera target
  39872. * @param scene Defines the scene the camera belongs to
  39873. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39874. */
  39875. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39876. /** @hidden */
  39877. _initCache(): void;
  39878. /** @hidden */
  39879. _updateCache(ignoreParentClass?: boolean): void;
  39880. protected _getTargetPosition(): Vector3;
  39881. private _storedAlpha;
  39882. private _storedBeta;
  39883. private _storedRadius;
  39884. private _storedTarget;
  39885. private _storedTargetScreenOffset;
  39886. /**
  39887. * Stores the current state of the camera (alpha, beta, radius and target)
  39888. * @returns the camera itself
  39889. */
  39890. storeState(): Camera;
  39891. /**
  39892. * @hidden
  39893. * Restored camera state. You must call storeState() first
  39894. */
  39895. _restoreStateValues(): boolean;
  39896. /** @hidden */
  39897. _isSynchronizedViewMatrix(): boolean;
  39898. /**
  39899. * Attached controls to the current camera.
  39900. * @param element Defines the element the controls should be listened from
  39901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39902. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39903. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39904. */
  39905. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39906. /**
  39907. * Detach the current controls from the camera.
  39908. * The camera will stop reacting to inputs.
  39909. * @param element Defines the element to stop listening the inputs from
  39910. */
  39911. detachControl(element: HTMLElement): void;
  39912. /** @hidden */
  39913. _checkInputs(): void;
  39914. protected _checkLimits(): void;
  39915. /**
  39916. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39917. */
  39918. rebuildAnglesAndRadius(): void;
  39919. /**
  39920. * Use a position to define the current camera related information like alpha, beta and radius
  39921. * @param position Defines the position to set the camera at
  39922. */
  39923. setPosition(position: Vector3): void;
  39924. /**
  39925. * Defines the target the camera should look at.
  39926. * This will automatically adapt alpha beta and radius to fit within the new target.
  39927. * @param target Defines the new target as a Vector or a mesh
  39928. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39929. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39930. */
  39931. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39932. /** @hidden */
  39933. _getViewMatrix(): Matrix;
  39934. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39935. /**
  39936. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39937. * @param meshes Defines the mesh to zoom on
  39938. * @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)
  39939. */
  39940. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39941. /**
  39942. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39943. * The target will be changed but the radius
  39944. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39945. * @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)
  39946. */
  39947. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39948. min: Vector3;
  39949. max: Vector3;
  39950. distance: number;
  39951. }, doNotUpdateMaxZ?: boolean): void;
  39952. /**
  39953. * @override
  39954. * Override Camera.createRigCamera
  39955. */
  39956. createRigCamera(name: string, cameraIndex: number): Camera;
  39957. /**
  39958. * @hidden
  39959. * @override
  39960. * Override Camera._updateRigCameras
  39961. */
  39962. _updateRigCameras(): void;
  39963. /**
  39964. * Destroy the camera and release the current resources hold by it.
  39965. */
  39966. dispose(): void;
  39967. /**
  39968. * Gets the current object class name.
  39969. * @return the class name
  39970. */
  39971. getClassName(): string;
  39972. }
  39973. }
  39974. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39975. import { Behavior } from "babylonjs/Behaviors/behavior";
  39976. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39977. /**
  39978. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39979. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39980. */
  39981. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39982. /**
  39983. * Gets the name of the behavior.
  39984. */
  39985. get name(): string;
  39986. private _zoomStopsAnimation;
  39987. private _idleRotationSpeed;
  39988. private _idleRotationWaitTime;
  39989. private _idleRotationSpinupTime;
  39990. /**
  39991. * Sets the flag that indicates if user zooming should stop animation.
  39992. */
  39993. set zoomStopsAnimation(flag: boolean);
  39994. /**
  39995. * Gets the flag that indicates if user zooming should stop animation.
  39996. */
  39997. get zoomStopsAnimation(): boolean;
  39998. /**
  39999. * Sets the default speed at which the camera rotates around the model.
  40000. */
  40001. set idleRotationSpeed(speed: number);
  40002. /**
  40003. * Gets the default speed at which the camera rotates around the model.
  40004. */
  40005. get idleRotationSpeed(): number;
  40006. /**
  40007. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40008. */
  40009. set idleRotationWaitTime(time: number);
  40010. /**
  40011. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40012. */
  40013. get idleRotationWaitTime(): number;
  40014. /**
  40015. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40016. */
  40017. set idleRotationSpinupTime(time: number);
  40018. /**
  40019. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40020. */
  40021. get idleRotationSpinupTime(): number;
  40022. /**
  40023. * Gets a value indicating if the camera is currently rotating because of this behavior
  40024. */
  40025. get rotationInProgress(): boolean;
  40026. private _onPrePointerObservableObserver;
  40027. private _onAfterCheckInputsObserver;
  40028. private _attachedCamera;
  40029. private _isPointerDown;
  40030. private _lastFrameTime;
  40031. private _lastInteractionTime;
  40032. private _cameraRotationSpeed;
  40033. /**
  40034. * Initializes the behavior.
  40035. */
  40036. init(): void;
  40037. /**
  40038. * Attaches the behavior to its arc rotate camera.
  40039. * @param camera Defines the camera to attach the behavior to
  40040. */
  40041. attach(camera: ArcRotateCamera): void;
  40042. /**
  40043. * Detaches the behavior from its current arc rotate camera.
  40044. */
  40045. detach(): void;
  40046. /**
  40047. * Returns true if user is scrolling.
  40048. * @return true if user is scrolling.
  40049. */
  40050. private _userIsZooming;
  40051. private _lastFrameRadius;
  40052. private _shouldAnimationStopForInteraction;
  40053. /**
  40054. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40055. */
  40056. private _applyUserInteraction;
  40057. private _userIsMoving;
  40058. }
  40059. }
  40060. declare module "babylonjs/Behaviors/Cameras/index" {
  40061. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40062. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40063. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40064. }
  40065. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40066. import { Mesh } from "babylonjs/Meshes/mesh";
  40067. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40068. import { Behavior } from "babylonjs/Behaviors/behavior";
  40069. /**
  40070. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40071. */
  40072. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40073. private ui;
  40074. /**
  40075. * The name of the behavior
  40076. */
  40077. name: string;
  40078. /**
  40079. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40080. */
  40081. distanceAwayFromFace: number;
  40082. /**
  40083. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40084. */
  40085. distanceAwayFromBottomOfFace: number;
  40086. private _faceVectors;
  40087. private _target;
  40088. private _scene;
  40089. private _onRenderObserver;
  40090. private _tmpMatrix;
  40091. private _tmpVector;
  40092. /**
  40093. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40094. * @param ui The transform node that should be attched to the mesh
  40095. */
  40096. constructor(ui: TransformNode);
  40097. /**
  40098. * Initializes the behavior
  40099. */
  40100. init(): void;
  40101. private _closestFace;
  40102. private _zeroVector;
  40103. private _lookAtTmpMatrix;
  40104. private _lookAtToRef;
  40105. /**
  40106. * Attaches the AttachToBoxBehavior to the passed in mesh
  40107. * @param target The mesh that the specified node will be attached to
  40108. */
  40109. attach(target: Mesh): void;
  40110. /**
  40111. * Detaches the behavior from the mesh
  40112. */
  40113. detach(): void;
  40114. }
  40115. }
  40116. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40117. import { Behavior } from "babylonjs/Behaviors/behavior";
  40118. import { Mesh } from "babylonjs/Meshes/mesh";
  40119. /**
  40120. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40121. */
  40122. export class FadeInOutBehavior implements Behavior<Mesh> {
  40123. /**
  40124. * Time in milliseconds to delay before fading in (Default: 0)
  40125. */
  40126. delay: number;
  40127. /**
  40128. * Time in milliseconds for the mesh to fade in (Default: 300)
  40129. */
  40130. fadeInTime: number;
  40131. private _millisecondsPerFrame;
  40132. private _hovered;
  40133. private _hoverValue;
  40134. private _ownerNode;
  40135. /**
  40136. * Instatiates the FadeInOutBehavior
  40137. */
  40138. constructor();
  40139. /**
  40140. * The name of the behavior
  40141. */
  40142. get name(): string;
  40143. /**
  40144. * Initializes the behavior
  40145. */
  40146. init(): void;
  40147. /**
  40148. * Attaches the fade behavior on the passed in mesh
  40149. * @param ownerNode The mesh that will be faded in/out once attached
  40150. */
  40151. attach(ownerNode: Mesh): void;
  40152. /**
  40153. * Detaches the behavior from the mesh
  40154. */
  40155. detach(): void;
  40156. /**
  40157. * Triggers the mesh to begin fading in or out
  40158. * @param value if the object should fade in or out (true to fade in)
  40159. */
  40160. fadeIn(value: boolean): void;
  40161. private _update;
  40162. private _setAllVisibility;
  40163. }
  40164. }
  40165. declare module "babylonjs/Misc/pivotTools" {
  40166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40167. /**
  40168. * Class containing a set of static utilities functions for managing Pivots
  40169. * @hidden
  40170. */
  40171. export class PivotTools {
  40172. private static _PivotCached;
  40173. private static _OldPivotPoint;
  40174. private static _PivotTranslation;
  40175. private static _PivotTmpVector;
  40176. /** @hidden */
  40177. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40178. /** @hidden */
  40179. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40180. }
  40181. }
  40182. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40183. import { Scene } from "babylonjs/scene";
  40184. import { Vector4 } from "babylonjs/Maths/math.vector";
  40185. import { Mesh } from "babylonjs/Meshes/mesh";
  40186. import { Nullable } from "babylonjs/types";
  40187. import { Plane } from "babylonjs/Maths/math.plane";
  40188. /**
  40189. * Class containing static functions to help procedurally build meshes
  40190. */
  40191. export class PlaneBuilder {
  40192. /**
  40193. * Creates a plane mesh
  40194. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40195. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40196. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40200. * @param name defines the name of the mesh
  40201. * @param options defines the options used to create the mesh
  40202. * @param scene defines the hosting scene
  40203. * @returns the plane mesh
  40204. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40205. */
  40206. static CreatePlane(name: string, options: {
  40207. size?: number;
  40208. width?: number;
  40209. height?: number;
  40210. sideOrientation?: number;
  40211. frontUVs?: Vector4;
  40212. backUVs?: Vector4;
  40213. updatable?: boolean;
  40214. sourcePlane?: Plane;
  40215. }, scene?: Nullable<Scene>): Mesh;
  40216. }
  40217. }
  40218. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40219. import { Behavior } from "babylonjs/Behaviors/behavior";
  40220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40221. import { Observable } from "babylonjs/Misc/observable";
  40222. import { Vector3 } from "babylonjs/Maths/math.vector";
  40223. import { Ray } from "babylonjs/Culling/ray";
  40224. import "babylonjs/Meshes/Builders/planeBuilder";
  40225. /**
  40226. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40227. */
  40228. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40229. private static _AnyMouseID;
  40230. /**
  40231. * Abstract mesh the behavior is set on
  40232. */
  40233. attachedNode: AbstractMesh;
  40234. private _dragPlane;
  40235. private _scene;
  40236. private _pointerObserver;
  40237. private _beforeRenderObserver;
  40238. private static _planeScene;
  40239. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40240. /**
  40241. * 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)
  40242. */
  40243. maxDragAngle: number;
  40244. /**
  40245. * @hidden
  40246. */
  40247. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40248. /**
  40249. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40250. */
  40251. currentDraggingPointerID: number;
  40252. /**
  40253. * The last position where the pointer hit the drag plane in world space
  40254. */
  40255. lastDragPosition: Vector3;
  40256. /**
  40257. * If the behavior is currently in a dragging state
  40258. */
  40259. dragging: boolean;
  40260. /**
  40261. * 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)
  40262. */
  40263. dragDeltaRatio: number;
  40264. /**
  40265. * If the drag plane orientation should be updated during the dragging (Default: true)
  40266. */
  40267. updateDragPlane: boolean;
  40268. private _debugMode;
  40269. private _moving;
  40270. /**
  40271. * Fires each time the attached mesh is dragged with the pointer
  40272. * * delta between last drag position and current drag position in world space
  40273. * * dragDistance along the drag axis
  40274. * * dragPlaneNormal normal of the current drag plane used during the drag
  40275. * * dragPlanePoint in world space where the drag intersects the drag plane
  40276. */
  40277. onDragObservable: Observable<{
  40278. delta: Vector3;
  40279. dragPlanePoint: Vector3;
  40280. dragPlaneNormal: Vector3;
  40281. dragDistance: number;
  40282. pointerId: number;
  40283. }>;
  40284. /**
  40285. * Fires each time a drag begins (eg. mouse down on mesh)
  40286. */
  40287. onDragStartObservable: Observable<{
  40288. dragPlanePoint: Vector3;
  40289. pointerId: number;
  40290. }>;
  40291. /**
  40292. * Fires each time a drag ends (eg. mouse release after drag)
  40293. */
  40294. onDragEndObservable: Observable<{
  40295. dragPlanePoint: Vector3;
  40296. pointerId: number;
  40297. }>;
  40298. /**
  40299. * If the attached mesh should be moved when dragged
  40300. */
  40301. moveAttached: boolean;
  40302. /**
  40303. * If the drag behavior will react to drag events (Default: true)
  40304. */
  40305. enabled: boolean;
  40306. /**
  40307. * If pointer events should start and release the drag (Default: true)
  40308. */
  40309. startAndReleaseDragOnPointerEvents: boolean;
  40310. /**
  40311. * If camera controls should be detached during the drag
  40312. */
  40313. detachCameraControls: boolean;
  40314. /**
  40315. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40316. */
  40317. useObjectOrientationForDragging: boolean;
  40318. private _options;
  40319. /**
  40320. * Gets the options used by the behavior
  40321. */
  40322. get options(): {
  40323. dragAxis?: Vector3;
  40324. dragPlaneNormal?: Vector3;
  40325. };
  40326. /**
  40327. * Sets the options used by the behavior
  40328. */
  40329. set options(options: {
  40330. dragAxis?: Vector3;
  40331. dragPlaneNormal?: Vector3;
  40332. });
  40333. /**
  40334. * Creates a pointer drag behavior that can be attached to a mesh
  40335. * @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)
  40336. */
  40337. constructor(options?: {
  40338. dragAxis?: Vector3;
  40339. dragPlaneNormal?: Vector3;
  40340. });
  40341. /**
  40342. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40343. */
  40344. validateDrag: (targetPosition: Vector3) => boolean;
  40345. /**
  40346. * The name of the behavior
  40347. */
  40348. get name(): string;
  40349. /**
  40350. * Initializes the behavior
  40351. */
  40352. init(): void;
  40353. private _tmpVector;
  40354. private _alternatePickedPoint;
  40355. private _worldDragAxis;
  40356. private _targetPosition;
  40357. private _attachedElement;
  40358. /**
  40359. * Attaches the drag behavior the passed in mesh
  40360. * @param ownerNode The mesh that will be dragged around once attached
  40361. * @param predicate Predicate to use for pick filtering
  40362. */
  40363. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40364. /**
  40365. * Force relase the drag action by code.
  40366. */
  40367. releaseDrag(): void;
  40368. private _startDragRay;
  40369. private _lastPointerRay;
  40370. /**
  40371. * Simulates the start of a pointer drag event on the behavior
  40372. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40373. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40374. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40375. */
  40376. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40377. private _startDrag;
  40378. private _dragDelta;
  40379. private _moveDrag;
  40380. private _pickWithRayOnDragPlane;
  40381. private _pointA;
  40382. private _pointB;
  40383. private _pointC;
  40384. private _lineA;
  40385. private _lineB;
  40386. private _localAxis;
  40387. private _lookAt;
  40388. private _updateDragPlanePosition;
  40389. /**
  40390. * Detaches the behavior from the mesh
  40391. */
  40392. detach(): void;
  40393. }
  40394. }
  40395. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40396. import { Mesh } from "babylonjs/Meshes/mesh";
  40397. import { Behavior } from "babylonjs/Behaviors/behavior";
  40398. /**
  40399. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40400. */
  40401. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40402. private _dragBehaviorA;
  40403. private _dragBehaviorB;
  40404. private _startDistance;
  40405. private _initialScale;
  40406. private _targetScale;
  40407. private _ownerNode;
  40408. private _sceneRenderObserver;
  40409. /**
  40410. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40411. */
  40412. constructor();
  40413. /**
  40414. * The name of the behavior
  40415. */
  40416. get name(): string;
  40417. /**
  40418. * Initializes the behavior
  40419. */
  40420. init(): void;
  40421. private _getCurrentDistance;
  40422. /**
  40423. * Attaches the scale behavior the passed in mesh
  40424. * @param ownerNode The mesh that will be scaled around once attached
  40425. */
  40426. attach(ownerNode: Mesh): void;
  40427. /**
  40428. * Detaches the behavior from the mesh
  40429. */
  40430. detach(): void;
  40431. }
  40432. }
  40433. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40434. import { Behavior } from "babylonjs/Behaviors/behavior";
  40435. import { Mesh } from "babylonjs/Meshes/mesh";
  40436. import { Observable } from "babylonjs/Misc/observable";
  40437. /**
  40438. * 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
  40439. */
  40440. export class SixDofDragBehavior implements Behavior<Mesh> {
  40441. private static _virtualScene;
  40442. private _ownerNode;
  40443. private _sceneRenderObserver;
  40444. private _scene;
  40445. private _targetPosition;
  40446. private _virtualOriginMesh;
  40447. private _virtualDragMesh;
  40448. private _pointerObserver;
  40449. private _moving;
  40450. private _startingOrientation;
  40451. /**
  40452. * 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)
  40453. */
  40454. private zDragFactor;
  40455. /**
  40456. * If the object should rotate to face the drag origin
  40457. */
  40458. rotateDraggedObject: boolean;
  40459. /**
  40460. * If the behavior is currently in a dragging state
  40461. */
  40462. dragging: boolean;
  40463. /**
  40464. * 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)
  40465. */
  40466. dragDeltaRatio: number;
  40467. /**
  40468. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40469. */
  40470. currentDraggingPointerID: number;
  40471. /**
  40472. * If camera controls should be detached during the drag
  40473. */
  40474. detachCameraControls: boolean;
  40475. /**
  40476. * Fires each time a drag starts
  40477. */
  40478. onDragStartObservable: Observable<{}>;
  40479. /**
  40480. * Fires each time a drag ends (eg. mouse release after drag)
  40481. */
  40482. onDragEndObservable: Observable<{}>;
  40483. /**
  40484. * 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
  40485. */
  40486. constructor();
  40487. /**
  40488. * The name of the behavior
  40489. */
  40490. get name(): string;
  40491. /**
  40492. * Initializes the behavior
  40493. */
  40494. init(): void;
  40495. /**
  40496. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40497. */
  40498. private get _pointerCamera();
  40499. /**
  40500. * Attaches the scale behavior the passed in mesh
  40501. * @param ownerNode The mesh that will be scaled around once attached
  40502. */
  40503. attach(ownerNode: Mesh): void;
  40504. /**
  40505. * Detaches the behavior from the mesh
  40506. */
  40507. detach(): void;
  40508. }
  40509. }
  40510. declare module "babylonjs/Behaviors/Meshes/index" {
  40511. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40512. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40513. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40514. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40515. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40516. }
  40517. declare module "babylonjs/Behaviors/index" {
  40518. export * from "babylonjs/Behaviors/behavior";
  40519. export * from "babylonjs/Behaviors/Cameras/index";
  40520. export * from "babylonjs/Behaviors/Meshes/index";
  40521. }
  40522. declare module "babylonjs/Bones/boneIKController" {
  40523. import { Bone } from "babylonjs/Bones/bone";
  40524. import { Vector3 } from "babylonjs/Maths/math.vector";
  40525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40526. import { Nullable } from "babylonjs/types";
  40527. /**
  40528. * Class used to apply inverse kinematics to bones
  40529. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40530. */
  40531. export class BoneIKController {
  40532. private static _tmpVecs;
  40533. private static _tmpQuat;
  40534. private static _tmpMats;
  40535. /**
  40536. * Gets or sets the target mesh
  40537. */
  40538. targetMesh: AbstractMesh;
  40539. /** Gets or sets the mesh used as pole */
  40540. poleTargetMesh: AbstractMesh;
  40541. /**
  40542. * Gets or sets the bone used as pole
  40543. */
  40544. poleTargetBone: Nullable<Bone>;
  40545. /**
  40546. * Gets or sets the target position
  40547. */
  40548. targetPosition: Vector3;
  40549. /**
  40550. * Gets or sets the pole target position
  40551. */
  40552. poleTargetPosition: Vector3;
  40553. /**
  40554. * Gets or sets the pole target local offset
  40555. */
  40556. poleTargetLocalOffset: Vector3;
  40557. /**
  40558. * Gets or sets the pole angle
  40559. */
  40560. poleAngle: number;
  40561. /**
  40562. * Gets or sets the mesh associated with the controller
  40563. */
  40564. mesh: AbstractMesh;
  40565. /**
  40566. * 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)
  40567. */
  40568. slerpAmount: number;
  40569. private _bone1Quat;
  40570. private _bone1Mat;
  40571. private _bone2Ang;
  40572. private _bone1;
  40573. private _bone2;
  40574. private _bone1Length;
  40575. private _bone2Length;
  40576. private _maxAngle;
  40577. private _maxReach;
  40578. private _rightHandedSystem;
  40579. private _bendAxis;
  40580. private _slerping;
  40581. private _adjustRoll;
  40582. /**
  40583. * Gets or sets maximum allowed angle
  40584. */
  40585. get maxAngle(): number;
  40586. set maxAngle(value: number);
  40587. /**
  40588. * Creates a new BoneIKController
  40589. * @param mesh defines the mesh to control
  40590. * @param bone defines the bone to control
  40591. * @param options defines options to set up the controller
  40592. */
  40593. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40594. targetMesh?: AbstractMesh;
  40595. poleTargetMesh?: AbstractMesh;
  40596. poleTargetBone?: Bone;
  40597. poleTargetLocalOffset?: Vector3;
  40598. poleAngle?: number;
  40599. bendAxis?: Vector3;
  40600. maxAngle?: number;
  40601. slerpAmount?: number;
  40602. });
  40603. private _setMaxAngle;
  40604. /**
  40605. * Force the controller to update the bones
  40606. */
  40607. update(): void;
  40608. }
  40609. }
  40610. declare module "babylonjs/Bones/boneLookController" {
  40611. import { Vector3 } from "babylonjs/Maths/math.vector";
  40612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40613. import { Bone } from "babylonjs/Bones/bone";
  40614. import { Space } from "babylonjs/Maths/math.axis";
  40615. /**
  40616. * Class used to make a bone look toward a point in space
  40617. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40618. */
  40619. export class BoneLookController {
  40620. private static _tmpVecs;
  40621. private static _tmpQuat;
  40622. private static _tmpMats;
  40623. /**
  40624. * The target Vector3 that the bone will look at
  40625. */
  40626. target: Vector3;
  40627. /**
  40628. * The mesh that the bone is attached to
  40629. */
  40630. mesh: AbstractMesh;
  40631. /**
  40632. * The bone that will be looking to the target
  40633. */
  40634. bone: Bone;
  40635. /**
  40636. * The up axis of the coordinate system that is used when the bone is rotated
  40637. */
  40638. upAxis: Vector3;
  40639. /**
  40640. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40641. */
  40642. upAxisSpace: Space;
  40643. /**
  40644. * Used to make an adjustment to the yaw of the bone
  40645. */
  40646. adjustYaw: number;
  40647. /**
  40648. * Used to make an adjustment to the pitch of the bone
  40649. */
  40650. adjustPitch: number;
  40651. /**
  40652. * Used to make an adjustment to the roll of the bone
  40653. */
  40654. adjustRoll: number;
  40655. /**
  40656. * 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)
  40657. */
  40658. slerpAmount: number;
  40659. private _minYaw;
  40660. private _maxYaw;
  40661. private _minPitch;
  40662. private _maxPitch;
  40663. private _minYawSin;
  40664. private _minYawCos;
  40665. private _maxYawSin;
  40666. private _maxYawCos;
  40667. private _midYawConstraint;
  40668. private _minPitchTan;
  40669. private _maxPitchTan;
  40670. private _boneQuat;
  40671. private _slerping;
  40672. private _transformYawPitch;
  40673. private _transformYawPitchInv;
  40674. private _firstFrameSkipped;
  40675. private _yawRange;
  40676. private _fowardAxis;
  40677. /**
  40678. * Gets or sets the minimum yaw angle that the bone can look to
  40679. */
  40680. get minYaw(): number;
  40681. set minYaw(value: number);
  40682. /**
  40683. * Gets or sets the maximum yaw angle that the bone can look to
  40684. */
  40685. get maxYaw(): number;
  40686. set maxYaw(value: number);
  40687. /**
  40688. * Gets or sets the minimum pitch angle that the bone can look to
  40689. */
  40690. get minPitch(): number;
  40691. set minPitch(value: number);
  40692. /**
  40693. * Gets or sets the maximum pitch angle that the bone can look to
  40694. */
  40695. get maxPitch(): number;
  40696. set maxPitch(value: number);
  40697. /**
  40698. * Create a BoneLookController
  40699. * @param mesh the mesh that the bone belongs to
  40700. * @param bone the bone that will be looking to the target
  40701. * @param target the target Vector3 to look at
  40702. * @param options optional settings:
  40703. * * maxYaw: the maximum angle the bone will yaw to
  40704. * * minYaw: the minimum angle the bone will yaw to
  40705. * * maxPitch: the maximum angle the bone will pitch to
  40706. * * minPitch: the minimum angle the bone will yaw to
  40707. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40708. * * upAxis: the up axis of the coordinate system
  40709. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40710. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40711. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40712. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40713. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40714. * * adjustRoll: used to make an adjustment to the roll of the bone
  40715. **/
  40716. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40717. maxYaw?: number;
  40718. minYaw?: number;
  40719. maxPitch?: number;
  40720. minPitch?: number;
  40721. slerpAmount?: number;
  40722. upAxis?: Vector3;
  40723. upAxisSpace?: Space;
  40724. yawAxis?: Vector3;
  40725. pitchAxis?: Vector3;
  40726. adjustYaw?: number;
  40727. adjustPitch?: number;
  40728. adjustRoll?: number;
  40729. });
  40730. /**
  40731. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40732. */
  40733. update(): void;
  40734. private _getAngleDiff;
  40735. private _getAngleBetween;
  40736. private _isAngleBetween;
  40737. }
  40738. }
  40739. declare module "babylonjs/Bones/index" {
  40740. export * from "babylonjs/Bones/bone";
  40741. export * from "babylonjs/Bones/boneIKController";
  40742. export * from "babylonjs/Bones/boneLookController";
  40743. export * from "babylonjs/Bones/skeleton";
  40744. }
  40745. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40746. import { Nullable } from "babylonjs/types";
  40747. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40749. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40750. /**
  40751. * Manage the gamepad inputs to control an arc rotate camera.
  40752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40753. */
  40754. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40755. /**
  40756. * Defines the camera the input is attached to.
  40757. */
  40758. camera: ArcRotateCamera;
  40759. /**
  40760. * Defines the gamepad the input is gathering event from.
  40761. */
  40762. gamepad: Nullable<Gamepad>;
  40763. /**
  40764. * Defines the gamepad rotation sensiblity.
  40765. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40766. */
  40767. gamepadRotationSensibility: number;
  40768. /**
  40769. * Defines the gamepad move sensiblity.
  40770. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40771. */
  40772. gamepadMoveSensibility: number;
  40773. private _yAxisScale;
  40774. /**
  40775. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40776. */
  40777. get invertYAxis(): boolean;
  40778. set invertYAxis(value: boolean);
  40779. private _onGamepadConnectedObserver;
  40780. private _onGamepadDisconnectedObserver;
  40781. /**
  40782. * Attach the input controls to a specific dom element to get the input from.
  40783. * @param element Defines the element the controls should be listened from
  40784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40785. */
  40786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40787. /**
  40788. * Detach the current controls from the specified dom element.
  40789. * @param element Defines the element to stop listening the inputs from
  40790. */
  40791. detachControl(element: Nullable<HTMLElement>): void;
  40792. /**
  40793. * Update the current camera state depending on the inputs that have been used this frame.
  40794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40795. */
  40796. checkInputs(): void;
  40797. /**
  40798. * Gets the class name of the current intput.
  40799. * @returns the class name
  40800. */
  40801. getClassName(): string;
  40802. /**
  40803. * Get the friendly name associated with the input class.
  40804. * @returns the input friendly name
  40805. */
  40806. getSimpleName(): string;
  40807. }
  40808. }
  40809. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40810. import { Nullable } from "babylonjs/types";
  40811. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40812. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40813. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40814. interface ArcRotateCameraInputsManager {
  40815. /**
  40816. * Add orientation input support to the input manager.
  40817. * @returns the current input manager
  40818. */
  40819. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40820. }
  40821. }
  40822. /**
  40823. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40825. */
  40826. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40827. /**
  40828. * Defines the camera the input is attached to.
  40829. */
  40830. camera: ArcRotateCamera;
  40831. /**
  40832. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40833. */
  40834. alphaCorrection: number;
  40835. /**
  40836. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40837. */
  40838. gammaCorrection: number;
  40839. private _alpha;
  40840. private _gamma;
  40841. private _dirty;
  40842. private _deviceOrientationHandler;
  40843. /**
  40844. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40845. */
  40846. constructor();
  40847. /**
  40848. * Attach the input controls to a specific dom element to get the input from.
  40849. * @param element Defines the element the controls should be listened from
  40850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40851. */
  40852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40853. /** @hidden */
  40854. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40855. /**
  40856. * Update the current camera state depending on the inputs that have been used this frame.
  40857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40858. */
  40859. checkInputs(): void;
  40860. /**
  40861. * Detach the current controls from the specified dom element.
  40862. * @param element Defines the element to stop listening the inputs from
  40863. */
  40864. detachControl(element: Nullable<HTMLElement>): void;
  40865. /**
  40866. * Gets the class name of the current intput.
  40867. * @returns the class name
  40868. */
  40869. getClassName(): string;
  40870. /**
  40871. * Get the friendly name associated with the input class.
  40872. * @returns the input friendly name
  40873. */
  40874. getSimpleName(): string;
  40875. }
  40876. }
  40877. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40878. import { Nullable } from "babylonjs/types";
  40879. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40880. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40881. /**
  40882. * Listen to mouse events to control the camera.
  40883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40884. */
  40885. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40886. /**
  40887. * Defines the camera the input is attached to.
  40888. */
  40889. camera: FlyCamera;
  40890. /**
  40891. * Defines if touch is enabled. (Default is true.)
  40892. */
  40893. touchEnabled: boolean;
  40894. /**
  40895. * Defines the buttons associated with the input to handle camera rotation.
  40896. */
  40897. buttons: number[];
  40898. /**
  40899. * Assign buttons for Yaw control.
  40900. */
  40901. buttonsYaw: number[];
  40902. /**
  40903. * Assign buttons for Pitch control.
  40904. */
  40905. buttonsPitch: number[];
  40906. /**
  40907. * Assign buttons for Roll control.
  40908. */
  40909. buttonsRoll: number[];
  40910. /**
  40911. * Detect if any button is being pressed while mouse is moved.
  40912. * -1 = Mouse locked.
  40913. * 0 = Left button.
  40914. * 1 = Middle Button.
  40915. * 2 = Right Button.
  40916. */
  40917. activeButton: number;
  40918. /**
  40919. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40920. * Higher values reduce its sensitivity.
  40921. */
  40922. angularSensibility: number;
  40923. private _mousemoveCallback;
  40924. private _observer;
  40925. private _rollObserver;
  40926. private previousPosition;
  40927. private noPreventDefault;
  40928. private element;
  40929. /**
  40930. * Listen to mouse events to control the camera.
  40931. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40933. */
  40934. constructor(touchEnabled?: boolean);
  40935. /**
  40936. * Attach the mouse control to the HTML DOM element.
  40937. * @param element Defines the element that listens to the input events.
  40938. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40939. */
  40940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40941. /**
  40942. * Detach the current controls from the specified dom element.
  40943. * @param element Defines the element to stop listening the inputs from
  40944. */
  40945. detachControl(element: Nullable<HTMLElement>): void;
  40946. /**
  40947. * Gets the class name of the current input.
  40948. * @returns the class name.
  40949. */
  40950. getClassName(): string;
  40951. /**
  40952. * Get the friendly name associated with the input class.
  40953. * @returns the input's friendly name.
  40954. */
  40955. getSimpleName(): string;
  40956. private _pointerInput;
  40957. private _onMouseMove;
  40958. /**
  40959. * Rotate camera by mouse offset.
  40960. */
  40961. private rotateCamera;
  40962. }
  40963. }
  40964. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40965. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40966. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40967. /**
  40968. * Default Inputs manager for the FlyCamera.
  40969. * It groups all the default supported inputs for ease of use.
  40970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40971. */
  40972. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40973. /**
  40974. * Instantiates a new FlyCameraInputsManager.
  40975. * @param camera Defines the camera the inputs belong to.
  40976. */
  40977. constructor(camera: FlyCamera);
  40978. /**
  40979. * Add keyboard input support to the input manager.
  40980. * @returns the new FlyCameraKeyboardMoveInput().
  40981. */
  40982. addKeyboard(): FlyCameraInputsManager;
  40983. /**
  40984. * Add mouse input support to the input manager.
  40985. * @param touchEnabled Enable touch screen support.
  40986. * @returns the new FlyCameraMouseInput().
  40987. */
  40988. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40989. }
  40990. }
  40991. declare module "babylonjs/Cameras/flyCamera" {
  40992. import { Scene } from "babylonjs/scene";
  40993. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40995. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40996. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40997. /**
  40998. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40999. * such as in a 3D Space Shooter or a Flight Simulator.
  41000. */
  41001. export class FlyCamera extends TargetCamera {
  41002. /**
  41003. * Define the collision ellipsoid of the camera.
  41004. * This is helpful for simulating a camera body, like a player's body.
  41005. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41006. */
  41007. ellipsoid: Vector3;
  41008. /**
  41009. * Define an offset for the position of the ellipsoid around the camera.
  41010. * This can be helpful if the camera is attached away from the player's body center,
  41011. * such as at its head.
  41012. */
  41013. ellipsoidOffset: Vector3;
  41014. /**
  41015. * Enable or disable collisions of the camera with the rest of the scene objects.
  41016. */
  41017. checkCollisions: boolean;
  41018. /**
  41019. * Enable or disable gravity on the camera.
  41020. */
  41021. applyGravity: boolean;
  41022. /**
  41023. * Define the current direction the camera is moving to.
  41024. */
  41025. cameraDirection: Vector3;
  41026. /**
  41027. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41028. * This overrides and empties cameraRotation.
  41029. */
  41030. rotationQuaternion: Quaternion;
  41031. /**
  41032. * Track Roll to maintain the wanted Rolling when looking around.
  41033. */
  41034. _trackRoll: number;
  41035. /**
  41036. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41037. */
  41038. rollCorrect: number;
  41039. /**
  41040. * Mimic a banked turn, Rolling the camera when Yawing.
  41041. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41042. */
  41043. bankedTurn: boolean;
  41044. /**
  41045. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41046. */
  41047. bankedTurnLimit: number;
  41048. /**
  41049. * Value of 0 disables the banked Roll.
  41050. * Value of 1 is equal to the Yaw angle in radians.
  41051. */
  41052. bankedTurnMultiplier: number;
  41053. /**
  41054. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41055. */
  41056. inputs: FlyCameraInputsManager;
  41057. /**
  41058. * Gets the input sensibility for mouse input.
  41059. * Higher values reduce sensitivity.
  41060. */
  41061. get angularSensibility(): number;
  41062. /**
  41063. * Sets the input sensibility for a mouse input.
  41064. * Higher values reduce sensitivity.
  41065. */
  41066. set angularSensibility(value: number);
  41067. /**
  41068. * Get the keys for camera movement forward.
  41069. */
  41070. get keysForward(): number[];
  41071. /**
  41072. * Set the keys for camera movement forward.
  41073. */
  41074. set keysForward(value: number[]);
  41075. /**
  41076. * Get the keys for camera movement backward.
  41077. */
  41078. get keysBackward(): number[];
  41079. set keysBackward(value: number[]);
  41080. /**
  41081. * Get the keys for camera movement up.
  41082. */
  41083. get keysUp(): number[];
  41084. /**
  41085. * Set the keys for camera movement up.
  41086. */
  41087. set keysUp(value: number[]);
  41088. /**
  41089. * Get the keys for camera movement down.
  41090. */
  41091. get keysDown(): number[];
  41092. /**
  41093. * Set the keys for camera movement down.
  41094. */
  41095. set keysDown(value: number[]);
  41096. /**
  41097. * Get the keys for camera movement left.
  41098. */
  41099. get keysLeft(): number[];
  41100. /**
  41101. * Set the keys for camera movement left.
  41102. */
  41103. set keysLeft(value: number[]);
  41104. /**
  41105. * Set the keys for camera movement right.
  41106. */
  41107. get keysRight(): number[];
  41108. /**
  41109. * Set the keys for camera movement right.
  41110. */
  41111. set keysRight(value: number[]);
  41112. /**
  41113. * Event raised when the camera collides with a mesh in the scene.
  41114. */
  41115. onCollide: (collidedMesh: AbstractMesh) => void;
  41116. private _collider;
  41117. private _needMoveForGravity;
  41118. private _oldPosition;
  41119. private _diffPosition;
  41120. private _newPosition;
  41121. /** @hidden */
  41122. _localDirection: Vector3;
  41123. /** @hidden */
  41124. _transformedDirection: Vector3;
  41125. /**
  41126. * Instantiates a FlyCamera.
  41127. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41128. * such as in a 3D Space Shooter or a Flight Simulator.
  41129. * @param name Define the name of the camera in the scene.
  41130. * @param position Define the starting position of the camera in the scene.
  41131. * @param scene Define the scene the camera belongs to.
  41132. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41133. */
  41134. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41135. /**
  41136. * Attach a control to the HTML DOM element.
  41137. * @param element Defines the element that listens to the input events.
  41138. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41139. */
  41140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41141. /**
  41142. * Detach a control from the HTML DOM element.
  41143. * The camera will stop reacting to that input.
  41144. * @param element Defines the element that listens to the input events.
  41145. */
  41146. detachControl(element: HTMLElement): void;
  41147. private _collisionMask;
  41148. /**
  41149. * Get the mask that the camera ignores in collision events.
  41150. */
  41151. get collisionMask(): number;
  41152. /**
  41153. * Set the mask that the camera ignores in collision events.
  41154. */
  41155. set collisionMask(mask: number);
  41156. /** @hidden */
  41157. _collideWithWorld(displacement: Vector3): void;
  41158. /** @hidden */
  41159. private _onCollisionPositionChange;
  41160. /** @hidden */
  41161. _checkInputs(): void;
  41162. /** @hidden */
  41163. _decideIfNeedsToMove(): boolean;
  41164. /** @hidden */
  41165. _updatePosition(): void;
  41166. /**
  41167. * Restore the Roll to its target value at the rate specified.
  41168. * @param rate - Higher means slower restoring.
  41169. * @hidden
  41170. */
  41171. restoreRoll(rate: number): void;
  41172. /**
  41173. * Destroy the camera and release the current resources held by it.
  41174. */
  41175. dispose(): void;
  41176. /**
  41177. * Get the current object class name.
  41178. * @returns the class name.
  41179. */
  41180. getClassName(): string;
  41181. }
  41182. }
  41183. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41184. import { Nullable } from "babylonjs/types";
  41185. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41186. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41187. /**
  41188. * Listen to keyboard events to control the camera.
  41189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41190. */
  41191. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41192. /**
  41193. * Defines the camera the input is attached to.
  41194. */
  41195. camera: FlyCamera;
  41196. /**
  41197. * The list of keyboard keys used to control the forward move of the camera.
  41198. */
  41199. keysForward: number[];
  41200. /**
  41201. * The list of keyboard keys used to control the backward move of the camera.
  41202. */
  41203. keysBackward: number[];
  41204. /**
  41205. * The list of keyboard keys used to control the forward move of the camera.
  41206. */
  41207. keysUp: number[];
  41208. /**
  41209. * The list of keyboard keys used to control the backward move of the camera.
  41210. */
  41211. keysDown: number[];
  41212. /**
  41213. * The list of keyboard keys used to control the right strafe move of the camera.
  41214. */
  41215. keysRight: number[];
  41216. /**
  41217. * The list of keyboard keys used to control the left strafe move of the camera.
  41218. */
  41219. keysLeft: number[];
  41220. private _keys;
  41221. private _onCanvasBlurObserver;
  41222. private _onKeyboardObserver;
  41223. private _engine;
  41224. private _scene;
  41225. /**
  41226. * Attach the input controls to a specific dom element to get the input from.
  41227. * @param element Defines the element the controls should be listened from
  41228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41229. */
  41230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41231. /**
  41232. * Detach the current controls from the specified dom element.
  41233. * @param element Defines the element to stop listening the inputs from
  41234. */
  41235. detachControl(element: Nullable<HTMLElement>): void;
  41236. /**
  41237. * Gets the class name of the current intput.
  41238. * @returns the class name
  41239. */
  41240. getClassName(): string;
  41241. /** @hidden */
  41242. _onLostFocus(e: FocusEvent): void;
  41243. /**
  41244. * Get the friendly name associated with the input class.
  41245. * @returns the input friendly name
  41246. */
  41247. getSimpleName(): string;
  41248. /**
  41249. * Update the current camera state depending on the inputs that have been used this frame.
  41250. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41251. */
  41252. checkInputs(): void;
  41253. }
  41254. }
  41255. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41256. import { Nullable } from "babylonjs/types";
  41257. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41258. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41259. /**
  41260. * Manage the mouse wheel inputs to control a follow camera.
  41261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41262. */
  41263. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41264. /**
  41265. * Defines the camera the input is attached to.
  41266. */
  41267. camera: FollowCamera;
  41268. /**
  41269. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41270. */
  41271. axisControlRadius: boolean;
  41272. /**
  41273. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41274. */
  41275. axisControlHeight: boolean;
  41276. /**
  41277. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41278. */
  41279. axisControlRotation: boolean;
  41280. /**
  41281. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41282. * relation to mouseWheel events.
  41283. */
  41284. wheelPrecision: number;
  41285. /**
  41286. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41287. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41288. */
  41289. wheelDeltaPercentage: number;
  41290. private _wheel;
  41291. private _observer;
  41292. /**
  41293. * Attach the input controls to a specific dom element to get the input from.
  41294. * @param element Defines the element the controls should be listened from
  41295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41296. */
  41297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41298. /**
  41299. * Detach the current controls from the specified dom element.
  41300. * @param element Defines the element to stop listening the inputs from
  41301. */
  41302. detachControl(element: Nullable<HTMLElement>): void;
  41303. /**
  41304. * Gets the class name of the current intput.
  41305. * @returns the class name
  41306. */
  41307. getClassName(): string;
  41308. /**
  41309. * Get the friendly name associated with the input class.
  41310. * @returns the input friendly name
  41311. */
  41312. getSimpleName(): string;
  41313. }
  41314. }
  41315. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41316. import { Nullable } from "babylonjs/types";
  41317. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41318. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41319. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41320. /**
  41321. * Manage the pointers inputs to control an follow camera.
  41322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41323. */
  41324. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41325. /**
  41326. * Defines the camera the input is attached to.
  41327. */
  41328. camera: FollowCamera;
  41329. /**
  41330. * Gets the class name of the current input.
  41331. * @returns the class name
  41332. */
  41333. getClassName(): string;
  41334. /**
  41335. * Defines the pointer angular sensibility along the X axis or how fast is
  41336. * the camera rotating.
  41337. * A negative number will reverse the axis direction.
  41338. */
  41339. angularSensibilityX: number;
  41340. /**
  41341. * Defines the pointer angular sensibility along the Y axis or how fast is
  41342. * the camera rotating.
  41343. * A negative number will reverse the axis direction.
  41344. */
  41345. angularSensibilityY: number;
  41346. /**
  41347. * Defines the pointer pinch precision or how fast is the camera zooming.
  41348. * A negative number will reverse the axis direction.
  41349. */
  41350. pinchPrecision: number;
  41351. /**
  41352. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41353. * from 0.
  41354. * It defines the percentage of current camera.radius to use as delta when
  41355. * pinch zoom is used.
  41356. */
  41357. pinchDeltaPercentage: number;
  41358. /**
  41359. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41360. */
  41361. axisXControlRadius: boolean;
  41362. /**
  41363. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41364. */
  41365. axisXControlHeight: boolean;
  41366. /**
  41367. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41368. */
  41369. axisXControlRotation: boolean;
  41370. /**
  41371. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41372. */
  41373. axisYControlRadius: boolean;
  41374. /**
  41375. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41376. */
  41377. axisYControlHeight: boolean;
  41378. /**
  41379. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41380. */
  41381. axisYControlRotation: boolean;
  41382. /**
  41383. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41384. */
  41385. axisPinchControlRadius: boolean;
  41386. /**
  41387. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41388. */
  41389. axisPinchControlHeight: boolean;
  41390. /**
  41391. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41392. */
  41393. axisPinchControlRotation: boolean;
  41394. /**
  41395. * Log error messages if basic misconfiguration has occurred.
  41396. */
  41397. warningEnable: boolean;
  41398. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41399. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41400. private _warningCounter;
  41401. private _warning;
  41402. }
  41403. }
  41404. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41405. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41406. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41407. /**
  41408. * Default Inputs manager for the FollowCamera.
  41409. * It groups all the default supported inputs for ease of use.
  41410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41411. */
  41412. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41413. /**
  41414. * Instantiates a new FollowCameraInputsManager.
  41415. * @param camera Defines the camera the inputs belong to
  41416. */
  41417. constructor(camera: FollowCamera);
  41418. /**
  41419. * Add keyboard input support to the input manager.
  41420. * @returns the current input manager
  41421. */
  41422. addKeyboard(): FollowCameraInputsManager;
  41423. /**
  41424. * Add mouse wheel input support to the input manager.
  41425. * @returns the current input manager
  41426. */
  41427. addMouseWheel(): FollowCameraInputsManager;
  41428. /**
  41429. * Add pointers input support to the input manager.
  41430. * @returns the current input manager
  41431. */
  41432. addPointers(): FollowCameraInputsManager;
  41433. /**
  41434. * Add orientation input support to the input manager.
  41435. * @returns the current input manager
  41436. */
  41437. addVRDeviceOrientation(): FollowCameraInputsManager;
  41438. }
  41439. }
  41440. declare module "babylonjs/Cameras/followCamera" {
  41441. import { Nullable } from "babylonjs/types";
  41442. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41443. import { Scene } from "babylonjs/scene";
  41444. import { Vector3 } from "babylonjs/Maths/math.vector";
  41445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41446. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41447. /**
  41448. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41449. * an arc rotate version arcFollowCamera are available.
  41450. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41451. */
  41452. export class FollowCamera extends TargetCamera {
  41453. /**
  41454. * Distance the follow camera should follow an object at
  41455. */
  41456. radius: number;
  41457. /**
  41458. * Minimum allowed distance of the camera to the axis of rotation
  41459. * (The camera can not get closer).
  41460. * This can help limiting how the Camera is able to move in the scene.
  41461. */
  41462. lowerRadiusLimit: Nullable<number>;
  41463. /**
  41464. * Maximum allowed distance of the camera to the axis of rotation
  41465. * (The camera can not get further).
  41466. * This can help limiting how the Camera is able to move in the scene.
  41467. */
  41468. upperRadiusLimit: Nullable<number>;
  41469. /**
  41470. * Define a rotation offset between the camera and the object it follows
  41471. */
  41472. rotationOffset: number;
  41473. /**
  41474. * Minimum allowed angle to camera position relative to target object.
  41475. * This can help limiting how the Camera is able to move in the scene.
  41476. */
  41477. lowerRotationOffsetLimit: Nullable<number>;
  41478. /**
  41479. * Maximum allowed angle to camera position relative to target object.
  41480. * This can help limiting how the Camera is able to move in the scene.
  41481. */
  41482. upperRotationOffsetLimit: Nullable<number>;
  41483. /**
  41484. * Define a height offset between the camera and the object it follows.
  41485. * It can help following an object from the top (like a car chaing a plane)
  41486. */
  41487. heightOffset: number;
  41488. /**
  41489. * Minimum allowed height of camera position relative to target object.
  41490. * This can help limiting how the Camera is able to move in the scene.
  41491. */
  41492. lowerHeightOffsetLimit: Nullable<number>;
  41493. /**
  41494. * Maximum allowed height of camera position relative to target object.
  41495. * This can help limiting how the Camera is able to move in the scene.
  41496. */
  41497. upperHeightOffsetLimit: Nullable<number>;
  41498. /**
  41499. * Define how fast the camera can accelerate to follow it s target.
  41500. */
  41501. cameraAcceleration: number;
  41502. /**
  41503. * Define the speed limit of the camera following an object.
  41504. */
  41505. maxCameraSpeed: number;
  41506. /**
  41507. * Define the target of the camera.
  41508. */
  41509. lockedTarget: Nullable<AbstractMesh>;
  41510. /**
  41511. * Defines the input associated with the camera.
  41512. */
  41513. inputs: FollowCameraInputsManager;
  41514. /**
  41515. * Instantiates the follow camera.
  41516. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41517. * @param name Define the name of the camera in the scene
  41518. * @param position Define the position of the camera
  41519. * @param scene Define the scene the camera belong to
  41520. * @param lockedTarget Define the target of the camera
  41521. */
  41522. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41523. private _follow;
  41524. /**
  41525. * Attached controls to the current camera.
  41526. * @param element Defines the element the controls should be listened from
  41527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41528. */
  41529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41530. /**
  41531. * Detach the current controls from the camera.
  41532. * The camera will stop reacting to inputs.
  41533. * @param element Defines the element to stop listening the inputs from
  41534. */
  41535. detachControl(element: HTMLElement): void;
  41536. /** @hidden */
  41537. _checkInputs(): void;
  41538. private _checkLimits;
  41539. /**
  41540. * Gets the camera class name.
  41541. * @returns the class name
  41542. */
  41543. getClassName(): string;
  41544. }
  41545. /**
  41546. * Arc Rotate version of the follow camera.
  41547. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41548. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41549. */
  41550. export class ArcFollowCamera extends TargetCamera {
  41551. /** The longitudinal angle of the camera */
  41552. alpha: number;
  41553. /** The latitudinal angle of the camera */
  41554. beta: number;
  41555. /** The radius of the camera from its target */
  41556. radius: number;
  41557. /** Define the camera target (the messh it should follow) */
  41558. target: Nullable<AbstractMesh>;
  41559. private _cartesianCoordinates;
  41560. /**
  41561. * Instantiates a new ArcFollowCamera
  41562. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41563. * @param name Define the name of the camera
  41564. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41565. * @param beta Define the rotation angle of the camera around the elevation axis
  41566. * @param radius Define the radius of the camera from its target point
  41567. * @param target Define the target of the camera
  41568. * @param scene Define the scene the camera belongs to
  41569. */
  41570. constructor(name: string,
  41571. /** The longitudinal angle of the camera */
  41572. alpha: number,
  41573. /** The latitudinal angle of the camera */
  41574. beta: number,
  41575. /** The radius of the camera from its target */
  41576. radius: number,
  41577. /** Define the camera target (the messh it should follow) */
  41578. target: Nullable<AbstractMesh>, scene: Scene);
  41579. private _follow;
  41580. /** @hidden */
  41581. _checkInputs(): void;
  41582. /**
  41583. * Returns the class name of the object.
  41584. * It is mostly used internally for serialization purposes.
  41585. */
  41586. getClassName(): string;
  41587. }
  41588. }
  41589. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41590. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41591. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41592. import { Nullable } from "babylonjs/types";
  41593. /**
  41594. * Manage the keyboard inputs to control the movement of a follow camera.
  41595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41596. */
  41597. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41598. /**
  41599. * Defines the camera the input is attached to.
  41600. */
  41601. camera: FollowCamera;
  41602. /**
  41603. * Defines the list of key codes associated with the up action (increase heightOffset)
  41604. */
  41605. keysHeightOffsetIncr: number[];
  41606. /**
  41607. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41608. */
  41609. keysHeightOffsetDecr: number[];
  41610. /**
  41611. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41612. */
  41613. keysHeightOffsetModifierAlt: boolean;
  41614. /**
  41615. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41616. */
  41617. keysHeightOffsetModifierCtrl: boolean;
  41618. /**
  41619. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41620. */
  41621. keysHeightOffsetModifierShift: boolean;
  41622. /**
  41623. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41624. */
  41625. keysRotationOffsetIncr: number[];
  41626. /**
  41627. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41628. */
  41629. keysRotationOffsetDecr: number[];
  41630. /**
  41631. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41632. */
  41633. keysRotationOffsetModifierAlt: boolean;
  41634. /**
  41635. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41636. */
  41637. keysRotationOffsetModifierCtrl: boolean;
  41638. /**
  41639. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41640. */
  41641. keysRotationOffsetModifierShift: boolean;
  41642. /**
  41643. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41644. */
  41645. keysRadiusIncr: number[];
  41646. /**
  41647. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41648. */
  41649. keysRadiusDecr: number[];
  41650. /**
  41651. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41652. */
  41653. keysRadiusModifierAlt: boolean;
  41654. /**
  41655. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41656. */
  41657. keysRadiusModifierCtrl: boolean;
  41658. /**
  41659. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41660. */
  41661. keysRadiusModifierShift: boolean;
  41662. /**
  41663. * Defines the rate of change of heightOffset.
  41664. */
  41665. heightSensibility: number;
  41666. /**
  41667. * Defines the rate of change of rotationOffset.
  41668. */
  41669. rotationSensibility: number;
  41670. /**
  41671. * Defines the rate of change of radius.
  41672. */
  41673. radiusSensibility: number;
  41674. private _keys;
  41675. private _ctrlPressed;
  41676. private _altPressed;
  41677. private _shiftPressed;
  41678. private _onCanvasBlurObserver;
  41679. private _onKeyboardObserver;
  41680. private _engine;
  41681. private _scene;
  41682. /**
  41683. * Attach the input controls to a specific dom element to get the input from.
  41684. * @param element Defines the element the controls should be listened from
  41685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41686. */
  41687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41688. /**
  41689. * Detach the current controls from the specified dom element.
  41690. * @param element Defines the element to stop listening the inputs from
  41691. */
  41692. detachControl(element: Nullable<HTMLElement>): void;
  41693. /**
  41694. * Update the current camera state depending on the inputs that have been used this frame.
  41695. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41696. */
  41697. checkInputs(): void;
  41698. /**
  41699. * Gets the class name of the current input.
  41700. * @returns the class name
  41701. */
  41702. getClassName(): string;
  41703. /**
  41704. * Get the friendly name associated with the input class.
  41705. * @returns the input friendly name
  41706. */
  41707. getSimpleName(): string;
  41708. /**
  41709. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41710. * allow modification of the heightOffset value.
  41711. */
  41712. private _modifierHeightOffset;
  41713. /**
  41714. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41715. * allow modification of the rotationOffset value.
  41716. */
  41717. private _modifierRotationOffset;
  41718. /**
  41719. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41720. * allow modification of the radius value.
  41721. */
  41722. private _modifierRadius;
  41723. }
  41724. }
  41725. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41726. import { Nullable } from "babylonjs/types";
  41727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41728. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41729. import { Observable } from "babylonjs/Misc/observable";
  41730. module "babylonjs/Cameras/freeCameraInputsManager" {
  41731. interface FreeCameraInputsManager {
  41732. /**
  41733. * @hidden
  41734. */
  41735. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41736. /**
  41737. * Add orientation input support to the input manager.
  41738. * @returns the current input manager
  41739. */
  41740. addDeviceOrientation(): FreeCameraInputsManager;
  41741. }
  41742. }
  41743. /**
  41744. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41745. * Screen rotation is taken into account.
  41746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41747. */
  41748. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41749. private _camera;
  41750. private _screenOrientationAngle;
  41751. private _constantTranform;
  41752. private _screenQuaternion;
  41753. private _alpha;
  41754. private _beta;
  41755. private _gamma;
  41756. /**
  41757. * Can be used to detect if a device orientation sensor is available on a device
  41758. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41759. * @returns a promise that will resolve on orientation change
  41760. */
  41761. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41762. /**
  41763. * @hidden
  41764. */
  41765. _onDeviceOrientationChangedObservable: Observable<void>;
  41766. /**
  41767. * Instantiates a new input
  41768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41769. */
  41770. constructor();
  41771. /**
  41772. * Define the camera controlled by the input.
  41773. */
  41774. get camera(): FreeCamera;
  41775. set camera(camera: FreeCamera);
  41776. /**
  41777. * Attach the input controls to a specific dom element to get the input from.
  41778. * @param element Defines the element the controls should be listened from
  41779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41780. */
  41781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41782. private _orientationChanged;
  41783. private _deviceOrientation;
  41784. /**
  41785. * Detach the current controls from the specified dom element.
  41786. * @param element Defines the element to stop listening the inputs from
  41787. */
  41788. detachControl(element: Nullable<HTMLElement>): void;
  41789. /**
  41790. * Update the current camera state depending on the inputs that have been used this frame.
  41791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41792. */
  41793. checkInputs(): void;
  41794. /**
  41795. * Gets the class name of the current intput.
  41796. * @returns the class name
  41797. */
  41798. getClassName(): string;
  41799. /**
  41800. * Get the friendly name associated with the input class.
  41801. * @returns the input friendly name
  41802. */
  41803. getSimpleName(): string;
  41804. }
  41805. }
  41806. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41807. import { Nullable } from "babylonjs/types";
  41808. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41809. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41810. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41811. /**
  41812. * Manage the gamepad inputs to control a free camera.
  41813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41814. */
  41815. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41816. /**
  41817. * Define the camera the input is attached to.
  41818. */
  41819. camera: FreeCamera;
  41820. /**
  41821. * Define the Gamepad controlling the input
  41822. */
  41823. gamepad: Nullable<Gamepad>;
  41824. /**
  41825. * Defines the gamepad rotation sensiblity.
  41826. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41827. */
  41828. gamepadAngularSensibility: number;
  41829. /**
  41830. * Defines the gamepad move sensiblity.
  41831. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41832. */
  41833. gamepadMoveSensibility: number;
  41834. private _yAxisScale;
  41835. /**
  41836. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41837. */
  41838. get invertYAxis(): boolean;
  41839. set invertYAxis(value: boolean);
  41840. private _onGamepadConnectedObserver;
  41841. private _onGamepadDisconnectedObserver;
  41842. private _cameraTransform;
  41843. private _deltaTransform;
  41844. private _vector3;
  41845. private _vector2;
  41846. /**
  41847. * Attach the input controls to a specific dom element to get the input from.
  41848. * @param element Defines the element the controls should be listened from
  41849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41850. */
  41851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41852. /**
  41853. * Detach the current controls from the specified dom element.
  41854. * @param element Defines the element to stop listening the inputs from
  41855. */
  41856. detachControl(element: Nullable<HTMLElement>): void;
  41857. /**
  41858. * Update the current camera state depending on the inputs that have been used this frame.
  41859. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41860. */
  41861. checkInputs(): void;
  41862. /**
  41863. * Gets the class name of the current intput.
  41864. * @returns the class name
  41865. */
  41866. getClassName(): string;
  41867. /**
  41868. * Get the friendly name associated with the input class.
  41869. * @returns the input friendly name
  41870. */
  41871. getSimpleName(): string;
  41872. }
  41873. }
  41874. declare module "babylonjs/Misc/virtualJoystick" {
  41875. import { Nullable } from "babylonjs/types";
  41876. import { Vector3 } from "babylonjs/Maths/math.vector";
  41877. /**
  41878. * Defines the potential axis of a Joystick
  41879. */
  41880. export enum JoystickAxis {
  41881. /** X axis */
  41882. X = 0,
  41883. /** Y axis */
  41884. Y = 1,
  41885. /** Z axis */
  41886. Z = 2
  41887. }
  41888. /**
  41889. * Class used to define virtual joystick (used in touch mode)
  41890. */
  41891. export class VirtualJoystick {
  41892. /**
  41893. * Gets or sets a boolean indicating that left and right values must be inverted
  41894. */
  41895. reverseLeftRight: boolean;
  41896. /**
  41897. * Gets or sets a boolean indicating that up and down values must be inverted
  41898. */
  41899. reverseUpDown: boolean;
  41900. /**
  41901. * Gets the offset value for the position (ie. the change of the position value)
  41902. */
  41903. deltaPosition: Vector3;
  41904. /**
  41905. * Gets a boolean indicating if the virtual joystick was pressed
  41906. */
  41907. pressed: boolean;
  41908. /**
  41909. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41910. */
  41911. static Canvas: Nullable<HTMLCanvasElement>;
  41912. private static _globalJoystickIndex;
  41913. private static vjCanvasContext;
  41914. private static vjCanvasWidth;
  41915. private static vjCanvasHeight;
  41916. private static halfWidth;
  41917. private _action;
  41918. private _axisTargetedByLeftAndRight;
  41919. private _axisTargetedByUpAndDown;
  41920. private _joystickSensibility;
  41921. private _inversedSensibility;
  41922. private _joystickPointerID;
  41923. private _joystickColor;
  41924. private _joystickPointerPos;
  41925. private _joystickPreviousPointerPos;
  41926. private _joystickPointerStartPos;
  41927. private _deltaJoystickVector;
  41928. private _leftJoystick;
  41929. private _touches;
  41930. private _onPointerDownHandlerRef;
  41931. private _onPointerMoveHandlerRef;
  41932. private _onPointerUpHandlerRef;
  41933. private _onResize;
  41934. /**
  41935. * Creates a new virtual joystick
  41936. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41937. */
  41938. constructor(leftJoystick?: boolean);
  41939. /**
  41940. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41941. * @param newJoystickSensibility defines the new sensibility
  41942. */
  41943. setJoystickSensibility(newJoystickSensibility: number): void;
  41944. private _onPointerDown;
  41945. private _onPointerMove;
  41946. private _onPointerUp;
  41947. /**
  41948. * Change the color of the virtual joystick
  41949. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41950. */
  41951. setJoystickColor(newColor: string): void;
  41952. /**
  41953. * Defines a callback to call when the joystick is touched
  41954. * @param action defines the callback
  41955. */
  41956. setActionOnTouch(action: () => any): void;
  41957. /**
  41958. * Defines which axis you'd like to control for left & right
  41959. * @param axis defines the axis to use
  41960. */
  41961. setAxisForLeftRight(axis: JoystickAxis): void;
  41962. /**
  41963. * Defines which axis you'd like to control for up & down
  41964. * @param axis defines the axis to use
  41965. */
  41966. setAxisForUpDown(axis: JoystickAxis): void;
  41967. private _drawVirtualJoystick;
  41968. /**
  41969. * Release internal HTML canvas
  41970. */
  41971. releaseCanvas(): void;
  41972. }
  41973. }
  41974. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41975. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41976. import { Nullable } from "babylonjs/types";
  41977. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41979. module "babylonjs/Cameras/freeCameraInputsManager" {
  41980. interface FreeCameraInputsManager {
  41981. /**
  41982. * Add virtual joystick input support to the input manager.
  41983. * @returns the current input manager
  41984. */
  41985. addVirtualJoystick(): FreeCameraInputsManager;
  41986. }
  41987. }
  41988. /**
  41989. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41991. */
  41992. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41993. /**
  41994. * Defines the camera the input is attached to.
  41995. */
  41996. camera: FreeCamera;
  41997. private _leftjoystick;
  41998. private _rightjoystick;
  41999. /**
  42000. * Gets the left stick of the virtual joystick.
  42001. * @returns The virtual Joystick
  42002. */
  42003. getLeftJoystick(): VirtualJoystick;
  42004. /**
  42005. * Gets the right stick of the virtual joystick.
  42006. * @returns The virtual Joystick
  42007. */
  42008. getRightJoystick(): VirtualJoystick;
  42009. /**
  42010. * Update the current camera state depending on the inputs that have been used this frame.
  42011. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42012. */
  42013. checkInputs(): void;
  42014. /**
  42015. * Attach the input controls to a specific dom element to get the input from.
  42016. * @param element Defines the element the controls should be listened from
  42017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42018. */
  42019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42020. /**
  42021. * Detach the current controls from the specified dom element.
  42022. * @param element Defines the element to stop listening the inputs from
  42023. */
  42024. detachControl(element: Nullable<HTMLElement>): void;
  42025. /**
  42026. * Gets the class name of the current intput.
  42027. * @returns the class name
  42028. */
  42029. getClassName(): string;
  42030. /**
  42031. * Get the friendly name associated with the input class.
  42032. * @returns the input friendly name
  42033. */
  42034. getSimpleName(): string;
  42035. }
  42036. }
  42037. declare module "babylonjs/Cameras/Inputs/index" {
  42038. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42039. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42040. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42041. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42042. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42043. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42044. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42045. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42046. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42047. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42048. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42049. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42050. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42051. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42052. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42053. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42054. }
  42055. declare module "babylonjs/Cameras/touchCamera" {
  42056. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42057. import { Scene } from "babylonjs/scene";
  42058. import { Vector3 } from "babylonjs/Maths/math.vector";
  42059. /**
  42060. * This represents a FPS type of camera controlled by touch.
  42061. * This is like a universal camera minus the Gamepad controls.
  42062. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42063. */
  42064. export class TouchCamera extends FreeCamera {
  42065. /**
  42066. * Defines the touch sensibility for rotation.
  42067. * The higher the faster.
  42068. */
  42069. get touchAngularSensibility(): number;
  42070. set touchAngularSensibility(value: number);
  42071. /**
  42072. * Defines the touch sensibility for move.
  42073. * The higher the faster.
  42074. */
  42075. get touchMoveSensibility(): number;
  42076. set touchMoveSensibility(value: number);
  42077. /**
  42078. * Instantiates a new touch camera.
  42079. * This represents a FPS type of camera controlled by touch.
  42080. * This is like a universal camera minus the Gamepad controls.
  42081. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42082. * @param name Define the name of the camera in the scene
  42083. * @param position Define the start position of the camera in the scene
  42084. * @param scene Define the scene the camera belongs to
  42085. */
  42086. constructor(name: string, position: Vector3, scene: Scene);
  42087. /**
  42088. * Gets the current object class name.
  42089. * @return the class name
  42090. */
  42091. getClassName(): string;
  42092. /** @hidden */
  42093. _setupInputs(): void;
  42094. }
  42095. }
  42096. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42097. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42098. import { Scene } from "babylonjs/scene";
  42099. import { Vector3 } from "babylonjs/Maths/math.vector";
  42100. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42101. import { Axis } from "babylonjs/Maths/math.axis";
  42102. /**
  42103. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42104. * being tilted forward or back and left or right.
  42105. */
  42106. export class DeviceOrientationCamera extends FreeCamera {
  42107. private _initialQuaternion;
  42108. private _quaternionCache;
  42109. private _tmpDragQuaternion;
  42110. private _disablePointerInputWhenUsingDeviceOrientation;
  42111. /**
  42112. * Creates a new device orientation camera
  42113. * @param name The name of the camera
  42114. * @param position The start position camera
  42115. * @param scene The scene the camera belongs to
  42116. */
  42117. constructor(name: string, position: Vector3, scene: Scene);
  42118. /**
  42119. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42120. */
  42121. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42122. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42123. private _dragFactor;
  42124. /**
  42125. * Enabled turning on the y axis when the orientation sensor is active
  42126. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42127. */
  42128. enableHorizontalDragging(dragFactor?: number): void;
  42129. /**
  42130. * Gets the current instance class name ("DeviceOrientationCamera").
  42131. * This helps avoiding instanceof at run time.
  42132. * @returns the class name
  42133. */
  42134. getClassName(): string;
  42135. /**
  42136. * @hidden
  42137. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42138. */
  42139. _checkInputs(): void;
  42140. /**
  42141. * Reset the camera to its default orientation on the specified axis only.
  42142. * @param axis The axis to reset
  42143. */
  42144. resetToCurrentRotation(axis?: Axis): void;
  42145. }
  42146. }
  42147. declare module "babylonjs/Gamepads/xboxGamepad" {
  42148. import { Observable } from "babylonjs/Misc/observable";
  42149. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42150. /**
  42151. * Defines supported buttons for XBox360 compatible gamepads
  42152. */
  42153. export enum Xbox360Button {
  42154. /** A */
  42155. A = 0,
  42156. /** B */
  42157. B = 1,
  42158. /** X */
  42159. X = 2,
  42160. /** Y */
  42161. Y = 3,
  42162. /** Start */
  42163. Start = 4,
  42164. /** Back */
  42165. Back = 5,
  42166. /** Left button */
  42167. LB = 6,
  42168. /** Right button */
  42169. RB = 7,
  42170. /** Left stick */
  42171. LeftStick = 8,
  42172. /** Right stick */
  42173. RightStick = 9
  42174. }
  42175. /** Defines values for XBox360 DPad */
  42176. export enum Xbox360Dpad {
  42177. /** Up */
  42178. Up = 0,
  42179. /** Down */
  42180. Down = 1,
  42181. /** Left */
  42182. Left = 2,
  42183. /** Right */
  42184. Right = 3
  42185. }
  42186. /**
  42187. * Defines a XBox360 gamepad
  42188. */
  42189. export class Xbox360Pad extends Gamepad {
  42190. private _leftTrigger;
  42191. private _rightTrigger;
  42192. private _onlefttriggerchanged;
  42193. private _onrighttriggerchanged;
  42194. private _onbuttondown;
  42195. private _onbuttonup;
  42196. private _ondpaddown;
  42197. private _ondpadup;
  42198. /** Observable raised when a button is pressed */
  42199. onButtonDownObservable: Observable<Xbox360Button>;
  42200. /** Observable raised when a button is released */
  42201. onButtonUpObservable: Observable<Xbox360Button>;
  42202. /** Observable raised when a pad is pressed */
  42203. onPadDownObservable: Observable<Xbox360Dpad>;
  42204. /** Observable raised when a pad is released */
  42205. onPadUpObservable: Observable<Xbox360Dpad>;
  42206. private _buttonA;
  42207. private _buttonB;
  42208. private _buttonX;
  42209. private _buttonY;
  42210. private _buttonBack;
  42211. private _buttonStart;
  42212. private _buttonLB;
  42213. private _buttonRB;
  42214. private _buttonLeftStick;
  42215. private _buttonRightStick;
  42216. private _dPadUp;
  42217. private _dPadDown;
  42218. private _dPadLeft;
  42219. private _dPadRight;
  42220. private _isXboxOnePad;
  42221. /**
  42222. * Creates a new XBox360 gamepad object
  42223. * @param id defines the id of this gamepad
  42224. * @param index defines its index
  42225. * @param gamepad defines the internal HTML gamepad object
  42226. * @param xboxOne defines if it is a XBox One gamepad
  42227. */
  42228. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42229. /**
  42230. * Defines the callback to call when left trigger is pressed
  42231. * @param callback defines the callback to use
  42232. */
  42233. onlefttriggerchanged(callback: (value: number) => void): void;
  42234. /**
  42235. * Defines the callback to call when right trigger is pressed
  42236. * @param callback defines the callback to use
  42237. */
  42238. onrighttriggerchanged(callback: (value: number) => void): void;
  42239. /**
  42240. * Gets the left trigger value
  42241. */
  42242. get leftTrigger(): number;
  42243. /**
  42244. * Sets the left trigger value
  42245. */
  42246. set leftTrigger(newValue: number);
  42247. /**
  42248. * Gets the right trigger value
  42249. */
  42250. get rightTrigger(): number;
  42251. /**
  42252. * Sets the right trigger value
  42253. */
  42254. set rightTrigger(newValue: number);
  42255. /**
  42256. * Defines the callback to call when a button is pressed
  42257. * @param callback defines the callback to use
  42258. */
  42259. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42260. /**
  42261. * Defines the callback to call when a button is released
  42262. * @param callback defines the callback to use
  42263. */
  42264. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42265. /**
  42266. * Defines the callback to call when a pad is pressed
  42267. * @param callback defines the callback to use
  42268. */
  42269. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42270. /**
  42271. * Defines the callback to call when a pad is released
  42272. * @param callback defines the callback to use
  42273. */
  42274. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42275. private _setButtonValue;
  42276. private _setDPadValue;
  42277. /**
  42278. * Gets the value of the `A` button
  42279. */
  42280. get buttonA(): number;
  42281. /**
  42282. * Sets the value of the `A` button
  42283. */
  42284. set buttonA(value: number);
  42285. /**
  42286. * Gets the value of the `B` button
  42287. */
  42288. get buttonB(): number;
  42289. /**
  42290. * Sets the value of the `B` button
  42291. */
  42292. set buttonB(value: number);
  42293. /**
  42294. * Gets the value of the `X` button
  42295. */
  42296. get buttonX(): number;
  42297. /**
  42298. * Sets the value of the `X` button
  42299. */
  42300. set buttonX(value: number);
  42301. /**
  42302. * Gets the value of the `Y` button
  42303. */
  42304. get buttonY(): number;
  42305. /**
  42306. * Sets the value of the `Y` button
  42307. */
  42308. set buttonY(value: number);
  42309. /**
  42310. * Gets the value of the `Start` button
  42311. */
  42312. get buttonStart(): number;
  42313. /**
  42314. * Sets the value of the `Start` button
  42315. */
  42316. set buttonStart(value: number);
  42317. /**
  42318. * Gets the value of the `Back` button
  42319. */
  42320. get buttonBack(): number;
  42321. /**
  42322. * Sets the value of the `Back` button
  42323. */
  42324. set buttonBack(value: number);
  42325. /**
  42326. * Gets the value of the `Left` button
  42327. */
  42328. get buttonLB(): number;
  42329. /**
  42330. * Sets the value of the `Left` button
  42331. */
  42332. set buttonLB(value: number);
  42333. /**
  42334. * Gets the value of the `Right` button
  42335. */
  42336. get buttonRB(): number;
  42337. /**
  42338. * Sets the value of the `Right` button
  42339. */
  42340. set buttonRB(value: number);
  42341. /**
  42342. * Gets the value of the Left joystick
  42343. */
  42344. get buttonLeftStick(): number;
  42345. /**
  42346. * Sets the value of the Left joystick
  42347. */
  42348. set buttonLeftStick(value: number);
  42349. /**
  42350. * Gets the value of the Right joystick
  42351. */
  42352. get buttonRightStick(): number;
  42353. /**
  42354. * Sets the value of the Right joystick
  42355. */
  42356. set buttonRightStick(value: number);
  42357. /**
  42358. * Gets the value of D-pad up
  42359. */
  42360. get dPadUp(): number;
  42361. /**
  42362. * Sets the value of D-pad up
  42363. */
  42364. set dPadUp(value: number);
  42365. /**
  42366. * Gets the value of D-pad down
  42367. */
  42368. get dPadDown(): number;
  42369. /**
  42370. * Sets the value of D-pad down
  42371. */
  42372. set dPadDown(value: number);
  42373. /**
  42374. * Gets the value of D-pad left
  42375. */
  42376. get dPadLeft(): number;
  42377. /**
  42378. * Sets the value of D-pad left
  42379. */
  42380. set dPadLeft(value: number);
  42381. /**
  42382. * Gets the value of D-pad right
  42383. */
  42384. get dPadRight(): number;
  42385. /**
  42386. * Sets the value of D-pad right
  42387. */
  42388. set dPadRight(value: number);
  42389. /**
  42390. * Force the gamepad to synchronize with device values
  42391. */
  42392. update(): void;
  42393. /**
  42394. * Disposes the gamepad
  42395. */
  42396. dispose(): void;
  42397. }
  42398. }
  42399. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42400. import { Observable } from "babylonjs/Misc/observable";
  42401. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42402. /**
  42403. * Defines supported buttons for DualShock compatible gamepads
  42404. */
  42405. export enum DualShockButton {
  42406. /** Cross */
  42407. Cross = 0,
  42408. /** Circle */
  42409. Circle = 1,
  42410. /** Square */
  42411. Square = 2,
  42412. /** Triangle */
  42413. Triangle = 3,
  42414. /** Options */
  42415. Options = 4,
  42416. /** Share */
  42417. Share = 5,
  42418. /** L1 */
  42419. L1 = 6,
  42420. /** R1 */
  42421. R1 = 7,
  42422. /** Left stick */
  42423. LeftStick = 8,
  42424. /** Right stick */
  42425. RightStick = 9
  42426. }
  42427. /** Defines values for DualShock DPad */
  42428. export enum DualShockDpad {
  42429. /** Up */
  42430. Up = 0,
  42431. /** Down */
  42432. Down = 1,
  42433. /** Left */
  42434. Left = 2,
  42435. /** Right */
  42436. Right = 3
  42437. }
  42438. /**
  42439. * Defines a DualShock gamepad
  42440. */
  42441. export class DualShockPad extends Gamepad {
  42442. private _leftTrigger;
  42443. private _rightTrigger;
  42444. private _onlefttriggerchanged;
  42445. private _onrighttriggerchanged;
  42446. private _onbuttondown;
  42447. private _onbuttonup;
  42448. private _ondpaddown;
  42449. private _ondpadup;
  42450. /** Observable raised when a button is pressed */
  42451. onButtonDownObservable: Observable<DualShockButton>;
  42452. /** Observable raised when a button is released */
  42453. onButtonUpObservable: Observable<DualShockButton>;
  42454. /** Observable raised when a pad is pressed */
  42455. onPadDownObservable: Observable<DualShockDpad>;
  42456. /** Observable raised when a pad is released */
  42457. onPadUpObservable: Observable<DualShockDpad>;
  42458. private _buttonCross;
  42459. private _buttonCircle;
  42460. private _buttonSquare;
  42461. private _buttonTriangle;
  42462. private _buttonShare;
  42463. private _buttonOptions;
  42464. private _buttonL1;
  42465. private _buttonR1;
  42466. private _buttonLeftStick;
  42467. private _buttonRightStick;
  42468. private _dPadUp;
  42469. private _dPadDown;
  42470. private _dPadLeft;
  42471. private _dPadRight;
  42472. /**
  42473. * Creates a new DualShock gamepad object
  42474. * @param id defines the id of this gamepad
  42475. * @param index defines its index
  42476. * @param gamepad defines the internal HTML gamepad object
  42477. */
  42478. constructor(id: string, index: number, gamepad: any);
  42479. /**
  42480. * Defines the callback to call when left trigger is pressed
  42481. * @param callback defines the callback to use
  42482. */
  42483. onlefttriggerchanged(callback: (value: number) => void): void;
  42484. /**
  42485. * Defines the callback to call when right trigger is pressed
  42486. * @param callback defines the callback to use
  42487. */
  42488. onrighttriggerchanged(callback: (value: number) => void): void;
  42489. /**
  42490. * Gets the left trigger value
  42491. */
  42492. get leftTrigger(): number;
  42493. /**
  42494. * Sets the left trigger value
  42495. */
  42496. set leftTrigger(newValue: number);
  42497. /**
  42498. * Gets the right trigger value
  42499. */
  42500. get rightTrigger(): number;
  42501. /**
  42502. * Sets the right trigger value
  42503. */
  42504. set rightTrigger(newValue: number);
  42505. /**
  42506. * Defines the callback to call when a button is pressed
  42507. * @param callback defines the callback to use
  42508. */
  42509. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42510. /**
  42511. * Defines the callback to call when a button is released
  42512. * @param callback defines the callback to use
  42513. */
  42514. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42515. /**
  42516. * Defines the callback to call when a pad is pressed
  42517. * @param callback defines the callback to use
  42518. */
  42519. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42520. /**
  42521. * Defines the callback to call when a pad is released
  42522. * @param callback defines the callback to use
  42523. */
  42524. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42525. private _setButtonValue;
  42526. private _setDPadValue;
  42527. /**
  42528. * Gets the value of the `Cross` button
  42529. */
  42530. get buttonCross(): number;
  42531. /**
  42532. * Sets the value of the `Cross` button
  42533. */
  42534. set buttonCross(value: number);
  42535. /**
  42536. * Gets the value of the `Circle` button
  42537. */
  42538. get buttonCircle(): number;
  42539. /**
  42540. * Sets the value of the `Circle` button
  42541. */
  42542. set buttonCircle(value: number);
  42543. /**
  42544. * Gets the value of the `Square` button
  42545. */
  42546. get buttonSquare(): number;
  42547. /**
  42548. * Sets the value of the `Square` button
  42549. */
  42550. set buttonSquare(value: number);
  42551. /**
  42552. * Gets the value of the `Triangle` button
  42553. */
  42554. get buttonTriangle(): number;
  42555. /**
  42556. * Sets the value of the `Triangle` button
  42557. */
  42558. set buttonTriangle(value: number);
  42559. /**
  42560. * Gets the value of the `Options` button
  42561. */
  42562. get buttonOptions(): number;
  42563. /**
  42564. * Sets the value of the `Options` button
  42565. */
  42566. set buttonOptions(value: number);
  42567. /**
  42568. * Gets the value of the `Share` button
  42569. */
  42570. get buttonShare(): number;
  42571. /**
  42572. * Sets the value of the `Share` button
  42573. */
  42574. set buttonShare(value: number);
  42575. /**
  42576. * Gets the value of the `L1` button
  42577. */
  42578. get buttonL1(): number;
  42579. /**
  42580. * Sets the value of the `L1` button
  42581. */
  42582. set buttonL1(value: number);
  42583. /**
  42584. * Gets the value of the `R1` button
  42585. */
  42586. get buttonR1(): number;
  42587. /**
  42588. * Sets the value of the `R1` button
  42589. */
  42590. set buttonR1(value: number);
  42591. /**
  42592. * Gets the value of the Left joystick
  42593. */
  42594. get buttonLeftStick(): number;
  42595. /**
  42596. * Sets the value of the Left joystick
  42597. */
  42598. set buttonLeftStick(value: number);
  42599. /**
  42600. * Gets the value of the Right joystick
  42601. */
  42602. get buttonRightStick(): number;
  42603. /**
  42604. * Sets the value of the Right joystick
  42605. */
  42606. set buttonRightStick(value: number);
  42607. /**
  42608. * Gets the value of D-pad up
  42609. */
  42610. get dPadUp(): number;
  42611. /**
  42612. * Sets the value of D-pad up
  42613. */
  42614. set dPadUp(value: number);
  42615. /**
  42616. * Gets the value of D-pad down
  42617. */
  42618. get dPadDown(): number;
  42619. /**
  42620. * Sets the value of D-pad down
  42621. */
  42622. set dPadDown(value: number);
  42623. /**
  42624. * Gets the value of D-pad left
  42625. */
  42626. get dPadLeft(): number;
  42627. /**
  42628. * Sets the value of D-pad left
  42629. */
  42630. set dPadLeft(value: number);
  42631. /**
  42632. * Gets the value of D-pad right
  42633. */
  42634. get dPadRight(): number;
  42635. /**
  42636. * Sets the value of D-pad right
  42637. */
  42638. set dPadRight(value: number);
  42639. /**
  42640. * Force the gamepad to synchronize with device values
  42641. */
  42642. update(): void;
  42643. /**
  42644. * Disposes the gamepad
  42645. */
  42646. dispose(): void;
  42647. }
  42648. }
  42649. declare module "babylonjs/Gamepads/gamepadManager" {
  42650. import { Observable } from "babylonjs/Misc/observable";
  42651. import { Nullable } from "babylonjs/types";
  42652. import { Scene } from "babylonjs/scene";
  42653. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42654. /**
  42655. * Manager for handling gamepads
  42656. */
  42657. export class GamepadManager {
  42658. private _scene?;
  42659. private _babylonGamepads;
  42660. private _oneGamepadConnected;
  42661. /** @hidden */
  42662. _isMonitoring: boolean;
  42663. private _gamepadEventSupported;
  42664. private _gamepadSupport?;
  42665. /**
  42666. * observable to be triggered when the gamepad controller has been connected
  42667. */
  42668. onGamepadConnectedObservable: Observable<Gamepad>;
  42669. /**
  42670. * observable to be triggered when the gamepad controller has been disconnected
  42671. */
  42672. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42673. private _onGamepadConnectedEvent;
  42674. private _onGamepadDisconnectedEvent;
  42675. /**
  42676. * Initializes the gamepad manager
  42677. * @param _scene BabylonJS scene
  42678. */
  42679. constructor(_scene?: Scene | undefined);
  42680. /**
  42681. * The gamepads in the game pad manager
  42682. */
  42683. get gamepads(): Gamepad[];
  42684. /**
  42685. * Get the gamepad controllers based on type
  42686. * @param type The type of gamepad controller
  42687. * @returns Nullable gamepad
  42688. */
  42689. getGamepadByType(type?: number): Nullable<Gamepad>;
  42690. /**
  42691. * Disposes the gamepad manager
  42692. */
  42693. dispose(): void;
  42694. private _addNewGamepad;
  42695. private _startMonitoringGamepads;
  42696. private _stopMonitoringGamepads;
  42697. /** @hidden */
  42698. _checkGamepadsStatus(): void;
  42699. private _updateGamepadObjects;
  42700. }
  42701. }
  42702. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42703. import { Nullable } from "babylonjs/types";
  42704. import { Scene } from "babylonjs/scene";
  42705. import { ISceneComponent } from "babylonjs/sceneComponent";
  42706. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42707. module "babylonjs/scene" {
  42708. interface Scene {
  42709. /** @hidden */
  42710. _gamepadManager: Nullable<GamepadManager>;
  42711. /**
  42712. * Gets the gamepad manager associated with the scene
  42713. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42714. */
  42715. gamepadManager: GamepadManager;
  42716. }
  42717. }
  42718. module "babylonjs/Cameras/freeCameraInputsManager" {
  42719. /**
  42720. * Interface representing a free camera inputs manager
  42721. */
  42722. interface FreeCameraInputsManager {
  42723. /**
  42724. * Adds gamepad input support to the FreeCameraInputsManager.
  42725. * @returns the FreeCameraInputsManager
  42726. */
  42727. addGamepad(): FreeCameraInputsManager;
  42728. }
  42729. }
  42730. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42731. /**
  42732. * Interface representing an arc rotate camera inputs manager
  42733. */
  42734. interface ArcRotateCameraInputsManager {
  42735. /**
  42736. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42737. * @returns the camera inputs manager
  42738. */
  42739. addGamepad(): ArcRotateCameraInputsManager;
  42740. }
  42741. }
  42742. /**
  42743. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42744. */
  42745. export class GamepadSystemSceneComponent implements ISceneComponent {
  42746. /**
  42747. * The component name helpfull to identify the component in the list of scene components.
  42748. */
  42749. readonly name: string;
  42750. /**
  42751. * The scene the component belongs to.
  42752. */
  42753. scene: Scene;
  42754. /**
  42755. * Creates a new instance of the component for the given scene
  42756. * @param scene Defines the scene to register the component in
  42757. */
  42758. constructor(scene: Scene);
  42759. /**
  42760. * Registers the component in a given scene
  42761. */
  42762. register(): void;
  42763. /**
  42764. * Rebuilds the elements related to this component in case of
  42765. * context lost for instance.
  42766. */
  42767. rebuild(): void;
  42768. /**
  42769. * Disposes the component and the associated ressources
  42770. */
  42771. dispose(): void;
  42772. private _beforeCameraUpdate;
  42773. }
  42774. }
  42775. declare module "babylonjs/Cameras/universalCamera" {
  42776. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42777. import { Scene } from "babylonjs/scene";
  42778. import { Vector3 } from "babylonjs/Maths/math.vector";
  42779. import "babylonjs/Gamepads/gamepadSceneComponent";
  42780. /**
  42781. * 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,
  42782. * which still works and will still be found in many Playgrounds.
  42783. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42784. */
  42785. export class UniversalCamera extends TouchCamera {
  42786. /**
  42787. * Defines the gamepad rotation sensiblity.
  42788. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42789. */
  42790. get gamepadAngularSensibility(): number;
  42791. set gamepadAngularSensibility(value: number);
  42792. /**
  42793. * Defines the gamepad move sensiblity.
  42794. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42795. */
  42796. get gamepadMoveSensibility(): number;
  42797. set gamepadMoveSensibility(value: number);
  42798. /**
  42799. * 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,
  42800. * which still works and will still be found in many Playgrounds.
  42801. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42802. * @param name Define the name of the camera in the scene
  42803. * @param position Define the start position of the camera in the scene
  42804. * @param scene Define the scene the camera belongs to
  42805. */
  42806. constructor(name: string, position: Vector3, scene: Scene);
  42807. /**
  42808. * Gets the current object class name.
  42809. * @return the class name
  42810. */
  42811. getClassName(): string;
  42812. }
  42813. }
  42814. declare module "babylonjs/Cameras/gamepadCamera" {
  42815. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42816. import { Scene } from "babylonjs/scene";
  42817. import { Vector3 } from "babylonjs/Maths/math.vector";
  42818. /**
  42819. * This represents a FPS type of camera. This is only here for back compat purpose.
  42820. * Please use the UniversalCamera instead as both are identical.
  42821. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42822. */
  42823. export class GamepadCamera extends UniversalCamera {
  42824. /**
  42825. * Instantiates a new Gamepad Camera
  42826. * This represents a FPS type of camera. This is only here for back compat purpose.
  42827. * Please use the UniversalCamera instead as both are identical.
  42828. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42829. * @param name Define the name of the camera in the scene
  42830. * @param position Define the start position of the camera in the scene
  42831. * @param scene Define the scene the camera belongs to
  42832. */
  42833. constructor(name: string, position: Vector3, scene: Scene);
  42834. /**
  42835. * Gets the current object class name.
  42836. * @return the class name
  42837. */
  42838. getClassName(): string;
  42839. }
  42840. }
  42841. declare module "babylonjs/Shaders/pass.fragment" {
  42842. /** @hidden */
  42843. export var passPixelShader: {
  42844. name: string;
  42845. shader: string;
  42846. };
  42847. }
  42848. declare module "babylonjs/Shaders/passCube.fragment" {
  42849. /** @hidden */
  42850. export var passCubePixelShader: {
  42851. name: string;
  42852. shader: string;
  42853. };
  42854. }
  42855. declare module "babylonjs/PostProcesses/passPostProcess" {
  42856. import { Nullable } from "babylonjs/types";
  42857. import { Camera } from "babylonjs/Cameras/camera";
  42858. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42859. import { Engine } from "babylonjs/Engines/engine";
  42860. import "babylonjs/Shaders/pass.fragment";
  42861. import "babylonjs/Shaders/passCube.fragment";
  42862. /**
  42863. * PassPostProcess which produces an output the same as it's input
  42864. */
  42865. export class PassPostProcess extends PostProcess {
  42866. /**
  42867. * Creates the PassPostProcess
  42868. * @param name The name of the effect.
  42869. * @param options The required width/height ratio to downsize to before computing the render pass.
  42870. * @param camera The camera to apply the render pass to.
  42871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42872. * @param engine The engine which the post process will be applied. (default: current engine)
  42873. * @param reusable If the post process can be reused on the same frame. (default: false)
  42874. * @param textureType The type of texture to be used when performing the post processing.
  42875. * @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)
  42876. */
  42877. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42878. }
  42879. /**
  42880. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42881. */
  42882. export class PassCubePostProcess extends PostProcess {
  42883. private _face;
  42884. /**
  42885. * Gets or sets the cube face to display.
  42886. * * 0 is +X
  42887. * * 1 is -X
  42888. * * 2 is +Y
  42889. * * 3 is -Y
  42890. * * 4 is +Z
  42891. * * 5 is -Z
  42892. */
  42893. get face(): number;
  42894. set face(value: number);
  42895. /**
  42896. * Creates the PassCubePostProcess
  42897. * @param name The name of the effect.
  42898. * @param options The required width/height ratio to downsize to before computing the render pass.
  42899. * @param camera The camera to apply the render pass to.
  42900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42901. * @param engine The engine which the post process will be applied. (default: current engine)
  42902. * @param reusable If the post process can be reused on the same frame. (default: false)
  42903. * @param textureType The type of texture to be used when performing the post processing.
  42904. * @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)
  42905. */
  42906. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42907. }
  42908. }
  42909. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42910. /** @hidden */
  42911. export var anaglyphPixelShader: {
  42912. name: string;
  42913. shader: string;
  42914. };
  42915. }
  42916. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42917. import { Engine } from "babylonjs/Engines/engine";
  42918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42919. import { Camera } from "babylonjs/Cameras/camera";
  42920. import "babylonjs/Shaders/anaglyph.fragment";
  42921. /**
  42922. * Postprocess used to generate anaglyphic rendering
  42923. */
  42924. export class AnaglyphPostProcess extends PostProcess {
  42925. private _passedProcess;
  42926. /**
  42927. * Creates a new AnaglyphPostProcess
  42928. * @param name defines postprocess name
  42929. * @param options defines creation options or target ratio scale
  42930. * @param rigCameras defines cameras using this postprocess
  42931. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42932. * @param engine defines hosting engine
  42933. * @param reusable defines if the postprocess will be reused multiple times per frame
  42934. */
  42935. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42936. }
  42937. }
  42938. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42939. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42940. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42941. import { Scene } from "babylonjs/scene";
  42942. import { Vector3 } from "babylonjs/Maths/math.vector";
  42943. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42944. /**
  42945. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42946. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42947. */
  42948. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42949. /**
  42950. * Creates a new AnaglyphArcRotateCamera
  42951. * @param name defines camera name
  42952. * @param alpha defines alpha angle (in radians)
  42953. * @param beta defines beta angle (in radians)
  42954. * @param radius defines radius
  42955. * @param target defines camera target
  42956. * @param interaxialDistance defines distance between each color axis
  42957. * @param scene defines the hosting scene
  42958. */
  42959. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42960. /**
  42961. * Gets camera class name
  42962. * @returns AnaglyphArcRotateCamera
  42963. */
  42964. getClassName(): string;
  42965. }
  42966. }
  42967. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42968. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42969. import { Scene } from "babylonjs/scene";
  42970. import { Vector3 } from "babylonjs/Maths/math.vector";
  42971. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42972. /**
  42973. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42974. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42975. */
  42976. export class AnaglyphFreeCamera extends FreeCamera {
  42977. /**
  42978. * Creates a new AnaglyphFreeCamera
  42979. * @param name defines camera name
  42980. * @param position defines initial position
  42981. * @param interaxialDistance defines distance between each color axis
  42982. * @param scene defines the hosting scene
  42983. */
  42984. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42985. /**
  42986. * Gets camera class name
  42987. * @returns AnaglyphFreeCamera
  42988. */
  42989. getClassName(): string;
  42990. }
  42991. }
  42992. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42993. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42994. import { Scene } from "babylonjs/scene";
  42995. import { Vector3 } from "babylonjs/Maths/math.vector";
  42996. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42997. /**
  42998. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42999. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43000. */
  43001. export class AnaglyphGamepadCamera extends GamepadCamera {
  43002. /**
  43003. * Creates a new AnaglyphGamepadCamera
  43004. * @param name defines camera name
  43005. * @param position defines initial position
  43006. * @param interaxialDistance defines distance between each color axis
  43007. * @param scene defines the hosting scene
  43008. */
  43009. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43010. /**
  43011. * Gets camera class name
  43012. * @returns AnaglyphGamepadCamera
  43013. */
  43014. getClassName(): string;
  43015. }
  43016. }
  43017. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43018. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43019. import { Scene } from "babylonjs/scene";
  43020. import { Vector3 } from "babylonjs/Maths/math.vector";
  43021. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43022. /**
  43023. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43024. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43025. */
  43026. export class AnaglyphUniversalCamera extends UniversalCamera {
  43027. /**
  43028. * Creates a new AnaglyphUniversalCamera
  43029. * @param name defines camera name
  43030. * @param position defines initial position
  43031. * @param interaxialDistance defines distance between each color axis
  43032. * @param scene defines the hosting scene
  43033. */
  43034. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43035. /**
  43036. * Gets camera class name
  43037. * @returns AnaglyphUniversalCamera
  43038. */
  43039. getClassName(): string;
  43040. }
  43041. }
  43042. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43043. /** @hidden */
  43044. export var stereoscopicInterlacePixelShader: {
  43045. name: string;
  43046. shader: string;
  43047. };
  43048. }
  43049. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43050. import { Camera } from "babylonjs/Cameras/camera";
  43051. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43052. import { Engine } from "babylonjs/Engines/engine";
  43053. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43054. /**
  43055. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43056. */
  43057. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43058. private _stepSize;
  43059. private _passedProcess;
  43060. /**
  43061. * Initializes a StereoscopicInterlacePostProcessI
  43062. * @param name The name of the effect.
  43063. * @param rigCameras The rig cameras to be appled to the post process
  43064. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43065. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43067. * @param engine The engine which the post process will be applied. (default: current engine)
  43068. * @param reusable If the post process can be reused on the same frame. (default: false)
  43069. */
  43070. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43071. }
  43072. /**
  43073. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43074. */
  43075. export class StereoscopicInterlacePostProcess extends PostProcess {
  43076. private _stepSize;
  43077. private _passedProcess;
  43078. /**
  43079. * Initializes a StereoscopicInterlacePostProcess
  43080. * @param name The name of the effect.
  43081. * @param rigCameras The rig cameras to be appled to the post process
  43082. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43084. * @param engine The engine which the post process will be applied. (default: current engine)
  43085. * @param reusable If the post process can be reused on the same frame. (default: false)
  43086. */
  43087. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43088. }
  43089. }
  43090. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43091. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43092. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43093. import { Scene } from "babylonjs/scene";
  43094. import { Vector3 } from "babylonjs/Maths/math.vector";
  43095. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43096. /**
  43097. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43098. * @see http://doc.babylonjs.com/features/cameras
  43099. */
  43100. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43101. /**
  43102. * Creates a new StereoscopicArcRotateCamera
  43103. * @param name defines camera name
  43104. * @param alpha defines alpha angle (in radians)
  43105. * @param beta defines beta angle (in radians)
  43106. * @param radius defines radius
  43107. * @param target defines camera target
  43108. * @param interaxialDistance defines distance between each color axis
  43109. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43110. * @param scene defines the hosting scene
  43111. */
  43112. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43113. /**
  43114. * Gets camera class name
  43115. * @returns StereoscopicArcRotateCamera
  43116. */
  43117. getClassName(): string;
  43118. }
  43119. }
  43120. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43121. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43122. import { Scene } from "babylonjs/scene";
  43123. import { Vector3 } from "babylonjs/Maths/math.vector";
  43124. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43125. /**
  43126. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43127. * @see http://doc.babylonjs.com/features/cameras
  43128. */
  43129. export class StereoscopicFreeCamera extends FreeCamera {
  43130. /**
  43131. * Creates a new StereoscopicFreeCamera
  43132. * @param name defines camera name
  43133. * @param position defines initial position
  43134. * @param interaxialDistance defines distance between each color axis
  43135. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43136. * @param scene defines the hosting scene
  43137. */
  43138. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43139. /**
  43140. * Gets camera class name
  43141. * @returns StereoscopicFreeCamera
  43142. */
  43143. getClassName(): string;
  43144. }
  43145. }
  43146. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43147. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43148. import { Scene } from "babylonjs/scene";
  43149. import { Vector3 } from "babylonjs/Maths/math.vector";
  43150. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43151. /**
  43152. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43153. * @see http://doc.babylonjs.com/features/cameras
  43154. */
  43155. export class StereoscopicGamepadCamera extends GamepadCamera {
  43156. /**
  43157. * Creates a new StereoscopicGamepadCamera
  43158. * @param name defines camera name
  43159. * @param position defines initial position
  43160. * @param interaxialDistance defines distance between each color axis
  43161. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43162. * @param scene defines the hosting scene
  43163. */
  43164. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43165. /**
  43166. * Gets camera class name
  43167. * @returns StereoscopicGamepadCamera
  43168. */
  43169. getClassName(): string;
  43170. }
  43171. }
  43172. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43173. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43174. import { Scene } from "babylonjs/scene";
  43175. import { Vector3 } from "babylonjs/Maths/math.vector";
  43176. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43177. /**
  43178. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43179. * @see http://doc.babylonjs.com/features/cameras
  43180. */
  43181. export class StereoscopicUniversalCamera extends UniversalCamera {
  43182. /**
  43183. * Creates a new StereoscopicUniversalCamera
  43184. * @param name defines camera name
  43185. * @param position defines initial position
  43186. * @param interaxialDistance defines distance between each color axis
  43187. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43188. * @param scene defines the hosting scene
  43189. */
  43190. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43191. /**
  43192. * Gets camera class name
  43193. * @returns StereoscopicUniversalCamera
  43194. */
  43195. getClassName(): string;
  43196. }
  43197. }
  43198. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43199. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43200. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43201. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43202. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43203. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43204. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43205. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43206. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43207. }
  43208. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43209. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43210. import { Scene } from "babylonjs/scene";
  43211. import { Vector3 } from "babylonjs/Maths/math.vector";
  43212. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43213. /**
  43214. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43215. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43216. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43217. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43218. */
  43219. export class VirtualJoysticksCamera extends FreeCamera {
  43220. /**
  43221. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43222. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43223. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43224. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43225. * @param name Define the name of the camera in the scene
  43226. * @param position Define the start position of the camera in the scene
  43227. * @param scene Define the scene the camera belongs to
  43228. */
  43229. constructor(name: string, position: Vector3, scene: Scene);
  43230. /**
  43231. * Gets the current object class name.
  43232. * @return the class name
  43233. */
  43234. getClassName(): string;
  43235. }
  43236. }
  43237. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43238. import { Matrix } from "babylonjs/Maths/math.vector";
  43239. /**
  43240. * This represents all the required metrics to create a VR camera.
  43241. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43242. */
  43243. export class VRCameraMetrics {
  43244. /**
  43245. * Define the horizontal resolution off the screen.
  43246. */
  43247. hResolution: number;
  43248. /**
  43249. * Define the vertical resolution off the screen.
  43250. */
  43251. vResolution: number;
  43252. /**
  43253. * Define the horizontal screen size.
  43254. */
  43255. hScreenSize: number;
  43256. /**
  43257. * Define the vertical screen size.
  43258. */
  43259. vScreenSize: number;
  43260. /**
  43261. * Define the vertical screen center position.
  43262. */
  43263. vScreenCenter: number;
  43264. /**
  43265. * Define the distance of the eyes to the screen.
  43266. */
  43267. eyeToScreenDistance: number;
  43268. /**
  43269. * Define the distance between both lenses
  43270. */
  43271. lensSeparationDistance: number;
  43272. /**
  43273. * Define the distance between both viewer's eyes.
  43274. */
  43275. interpupillaryDistance: number;
  43276. /**
  43277. * Define the distortion factor of the VR postprocess.
  43278. * Please, touch with care.
  43279. */
  43280. distortionK: number[];
  43281. /**
  43282. * Define the chromatic aberration correction factors for the VR post process.
  43283. */
  43284. chromaAbCorrection: number[];
  43285. /**
  43286. * Define the scale factor of the post process.
  43287. * The smaller the better but the slower.
  43288. */
  43289. postProcessScaleFactor: number;
  43290. /**
  43291. * Define an offset for the lens center.
  43292. */
  43293. lensCenterOffset: number;
  43294. /**
  43295. * Define if the current vr camera should compensate the distortion of the lense or not.
  43296. */
  43297. compensateDistortion: boolean;
  43298. /**
  43299. * Defines if multiview should be enabled when rendering (Default: false)
  43300. */
  43301. multiviewEnabled: boolean;
  43302. /**
  43303. * Gets the rendering aspect ratio based on the provided resolutions.
  43304. */
  43305. get aspectRatio(): number;
  43306. /**
  43307. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43308. */
  43309. get aspectRatioFov(): number;
  43310. /**
  43311. * @hidden
  43312. */
  43313. get leftHMatrix(): Matrix;
  43314. /**
  43315. * @hidden
  43316. */
  43317. get rightHMatrix(): Matrix;
  43318. /**
  43319. * @hidden
  43320. */
  43321. get leftPreViewMatrix(): Matrix;
  43322. /**
  43323. * @hidden
  43324. */
  43325. get rightPreViewMatrix(): Matrix;
  43326. /**
  43327. * Get the default VRMetrics based on the most generic setup.
  43328. * @returns the default vr metrics
  43329. */
  43330. static GetDefault(): VRCameraMetrics;
  43331. }
  43332. }
  43333. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43334. /** @hidden */
  43335. export var vrDistortionCorrectionPixelShader: {
  43336. name: string;
  43337. shader: string;
  43338. };
  43339. }
  43340. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43341. import { Camera } from "babylonjs/Cameras/camera";
  43342. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43343. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43344. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43345. /**
  43346. * VRDistortionCorrectionPostProcess used for mobile VR
  43347. */
  43348. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43349. private _isRightEye;
  43350. private _distortionFactors;
  43351. private _postProcessScaleFactor;
  43352. private _lensCenterOffset;
  43353. private _scaleIn;
  43354. private _scaleFactor;
  43355. private _lensCenter;
  43356. /**
  43357. * Initializes the VRDistortionCorrectionPostProcess
  43358. * @param name The name of the effect.
  43359. * @param camera The camera to apply the render pass to.
  43360. * @param isRightEye If this is for the right eye distortion
  43361. * @param vrMetrics All the required metrics for the VR camera
  43362. */
  43363. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43364. }
  43365. }
  43366. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43367. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43368. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43369. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43370. import { Scene } from "babylonjs/scene";
  43371. import { Vector3 } from "babylonjs/Maths/math.vector";
  43372. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43373. import "babylonjs/Cameras/RigModes/vrRigMode";
  43374. /**
  43375. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43376. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43377. */
  43378. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43379. /**
  43380. * Creates a new VRDeviceOrientationArcRotateCamera
  43381. * @param name defines camera name
  43382. * @param alpha defines the camera rotation along the logitudinal axis
  43383. * @param beta defines the camera rotation along the latitudinal axis
  43384. * @param radius defines the camera distance from its target
  43385. * @param target defines the camera target
  43386. * @param scene defines the scene the camera belongs to
  43387. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43388. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43389. */
  43390. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43391. /**
  43392. * Gets camera class name
  43393. * @returns VRDeviceOrientationArcRotateCamera
  43394. */
  43395. getClassName(): string;
  43396. }
  43397. }
  43398. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43399. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43400. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43401. import { Scene } from "babylonjs/scene";
  43402. import { Vector3 } from "babylonjs/Maths/math.vector";
  43403. import "babylonjs/Cameras/RigModes/vrRigMode";
  43404. /**
  43405. * Camera used to simulate VR rendering (based on FreeCamera)
  43406. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43407. */
  43408. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43409. /**
  43410. * Creates a new VRDeviceOrientationFreeCamera
  43411. * @param name defines camera name
  43412. * @param position defines the start position of the camera
  43413. * @param scene defines the scene the camera belongs to
  43414. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43415. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43416. */
  43417. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43418. /**
  43419. * Gets camera class name
  43420. * @returns VRDeviceOrientationFreeCamera
  43421. */
  43422. getClassName(): string;
  43423. }
  43424. }
  43425. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43426. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43427. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43428. import { Scene } from "babylonjs/scene";
  43429. import { Vector3 } from "babylonjs/Maths/math.vector";
  43430. import "babylonjs/Gamepads/gamepadSceneComponent";
  43431. /**
  43432. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43433. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43434. */
  43435. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43436. /**
  43437. * Creates a new VRDeviceOrientationGamepadCamera
  43438. * @param name defines camera name
  43439. * @param position defines the start position of the camera
  43440. * @param scene defines the scene the camera belongs to
  43441. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43442. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43443. */
  43444. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43445. /**
  43446. * Gets camera class name
  43447. * @returns VRDeviceOrientationGamepadCamera
  43448. */
  43449. getClassName(): string;
  43450. }
  43451. }
  43452. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43453. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43454. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43455. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43456. /** @hidden */
  43457. export var imageProcessingPixelShader: {
  43458. name: string;
  43459. shader: string;
  43460. };
  43461. }
  43462. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43463. import { Nullable } from "babylonjs/types";
  43464. import { Color4 } from "babylonjs/Maths/math.color";
  43465. import { Camera } from "babylonjs/Cameras/camera";
  43466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43467. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43468. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43469. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43470. import { Engine } from "babylonjs/Engines/engine";
  43471. import "babylonjs/Shaders/imageProcessing.fragment";
  43472. import "babylonjs/Shaders/postprocess.vertex";
  43473. /**
  43474. * ImageProcessingPostProcess
  43475. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43476. */
  43477. export class ImageProcessingPostProcess extends PostProcess {
  43478. /**
  43479. * Default configuration related to image processing available in the PBR Material.
  43480. */
  43481. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43482. /**
  43483. * Gets the image processing configuration used either in this material.
  43484. */
  43485. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43486. /**
  43487. * Sets the Default image processing configuration used either in the this material.
  43488. *
  43489. * If sets to null, the scene one is in use.
  43490. */
  43491. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43492. /**
  43493. * Keep track of the image processing observer to allow dispose and replace.
  43494. */
  43495. private _imageProcessingObserver;
  43496. /**
  43497. * Attaches a new image processing configuration to the PBR Material.
  43498. * @param configuration
  43499. */
  43500. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43501. /**
  43502. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43503. */
  43504. get colorCurves(): Nullable<ColorCurves>;
  43505. /**
  43506. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43507. */
  43508. set colorCurves(value: Nullable<ColorCurves>);
  43509. /**
  43510. * Gets wether the color curves effect is enabled.
  43511. */
  43512. get colorCurvesEnabled(): boolean;
  43513. /**
  43514. * Sets wether the color curves effect is enabled.
  43515. */
  43516. set colorCurvesEnabled(value: boolean);
  43517. /**
  43518. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43519. */
  43520. get colorGradingTexture(): Nullable<BaseTexture>;
  43521. /**
  43522. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43523. */
  43524. set colorGradingTexture(value: Nullable<BaseTexture>);
  43525. /**
  43526. * Gets wether the color grading effect is enabled.
  43527. */
  43528. get colorGradingEnabled(): boolean;
  43529. /**
  43530. * Gets wether the color grading effect is enabled.
  43531. */
  43532. set colorGradingEnabled(value: boolean);
  43533. /**
  43534. * Gets exposure used in the effect.
  43535. */
  43536. get exposure(): number;
  43537. /**
  43538. * Sets exposure used in the effect.
  43539. */
  43540. set exposure(value: number);
  43541. /**
  43542. * Gets wether tonemapping is enabled or not.
  43543. */
  43544. get toneMappingEnabled(): boolean;
  43545. /**
  43546. * Sets wether tonemapping is enabled or not
  43547. */
  43548. set toneMappingEnabled(value: boolean);
  43549. /**
  43550. * Gets the type of tone mapping effect.
  43551. */
  43552. get toneMappingType(): number;
  43553. /**
  43554. * Sets the type of tone mapping effect.
  43555. */
  43556. set toneMappingType(value: number);
  43557. /**
  43558. * Gets contrast used in the effect.
  43559. */
  43560. get contrast(): number;
  43561. /**
  43562. * Sets contrast used in the effect.
  43563. */
  43564. set contrast(value: number);
  43565. /**
  43566. * Gets Vignette stretch size.
  43567. */
  43568. get vignetteStretch(): number;
  43569. /**
  43570. * Sets Vignette stretch size.
  43571. */
  43572. set vignetteStretch(value: number);
  43573. /**
  43574. * Gets Vignette centre X Offset.
  43575. */
  43576. get vignetteCentreX(): number;
  43577. /**
  43578. * Sets Vignette centre X Offset.
  43579. */
  43580. set vignetteCentreX(value: number);
  43581. /**
  43582. * Gets Vignette centre Y Offset.
  43583. */
  43584. get vignetteCentreY(): number;
  43585. /**
  43586. * Sets Vignette centre Y Offset.
  43587. */
  43588. set vignetteCentreY(value: number);
  43589. /**
  43590. * Gets Vignette weight or intensity of the vignette effect.
  43591. */
  43592. get vignetteWeight(): number;
  43593. /**
  43594. * Sets Vignette weight or intensity of the vignette effect.
  43595. */
  43596. set vignetteWeight(value: number);
  43597. /**
  43598. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43599. * if vignetteEnabled is set to true.
  43600. */
  43601. get vignetteColor(): Color4;
  43602. /**
  43603. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43604. * if vignetteEnabled is set to true.
  43605. */
  43606. set vignetteColor(value: Color4);
  43607. /**
  43608. * Gets Camera field of view used by the Vignette effect.
  43609. */
  43610. get vignetteCameraFov(): number;
  43611. /**
  43612. * Sets Camera field of view used by the Vignette effect.
  43613. */
  43614. set vignetteCameraFov(value: number);
  43615. /**
  43616. * Gets the vignette blend mode allowing different kind of effect.
  43617. */
  43618. get vignetteBlendMode(): number;
  43619. /**
  43620. * Sets the vignette blend mode allowing different kind of effect.
  43621. */
  43622. set vignetteBlendMode(value: number);
  43623. /**
  43624. * Gets wether the vignette effect is enabled.
  43625. */
  43626. get vignetteEnabled(): boolean;
  43627. /**
  43628. * Sets wether the vignette effect is enabled.
  43629. */
  43630. set vignetteEnabled(value: boolean);
  43631. private _fromLinearSpace;
  43632. /**
  43633. * Gets wether the input of the processing is in Gamma or Linear Space.
  43634. */
  43635. get fromLinearSpace(): boolean;
  43636. /**
  43637. * Sets wether the input of the processing is in Gamma or Linear Space.
  43638. */
  43639. set fromLinearSpace(value: boolean);
  43640. /**
  43641. * Defines cache preventing GC.
  43642. */
  43643. private _defines;
  43644. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43645. /**
  43646. * "ImageProcessingPostProcess"
  43647. * @returns "ImageProcessingPostProcess"
  43648. */
  43649. getClassName(): string;
  43650. protected _updateParameters(): void;
  43651. dispose(camera?: Camera): void;
  43652. }
  43653. }
  43654. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43655. import { Scene } from "babylonjs/scene";
  43656. import { Color3 } from "babylonjs/Maths/math.color";
  43657. import { Mesh } from "babylonjs/Meshes/mesh";
  43658. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43659. import { Nullable } from "babylonjs/types";
  43660. /**
  43661. * Class containing static functions to help procedurally build meshes
  43662. */
  43663. export class GroundBuilder {
  43664. /**
  43665. * Creates a ground mesh
  43666. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43667. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43669. * @param name defines the name of the mesh
  43670. * @param options defines the options used to create the mesh
  43671. * @param scene defines the hosting scene
  43672. * @returns the ground mesh
  43673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43674. */
  43675. static CreateGround(name: string, options: {
  43676. width?: number;
  43677. height?: number;
  43678. subdivisions?: number;
  43679. subdivisionsX?: number;
  43680. subdivisionsY?: number;
  43681. updatable?: boolean;
  43682. }, scene: any): Mesh;
  43683. /**
  43684. * Creates a tiled ground mesh
  43685. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43686. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43687. * * 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
  43688. * * 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
  43689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43690. * @param name defines the name of the mesh
  43691. * @param options defines the options used to create the mesh
  43692. * @param scene defines the hosting scene
  43693. * @returns the tiled ground mesh
  43694. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43695. */
  43696. static CreateTiledGround(name: string, options: {
  43697. xmin: number;
  43698. zmin: number;
  43699. xmax: number;
  43700. zmax: number;
  43701. subdivisions?: {
  43702. w: number;
  43703. h: number;
  43704. };
  43705. precision?: {
  43706. w: number;
  43707. h: number;
  43708. };
  43709. updatable?: boolean;
  43710. }, scene?: Nullable<Scene>): Mesh;
  43711. /**
  43712. * Creates a ground mesh from a height map
  43713. * * The parameter `url` sets the URL of the height map image resource.
  43714. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43715. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43716. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43717. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43718. * * 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.
  43719. * * 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).
  43720. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43722. * @param name defines the name of the mesh
  43723. * @param url defines the url to the height map
  43724. * @param options defines the options used to create the mesh
  43725. * @param scene defines the hosting scene
  43726. * @returns the ground mesh
  43727. * @see https://doc.babylonjs.com/babylon101/height_map
  43728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43729. */
  43730. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43731. width?: number;
  43732. height?: number;
  43733. subdivisions?: number;
  43734. minHeight?: number;
  43735. maxHeight?: number;
  43736. colorFilter?: Color3;
  43737. alphaFilter?: number;
  43738. updatable?: boolean;
  43739. onReady?: (mesh: GroundMesh) => void;
  43740. }, scene?: Nullable<Scene>): GroundMesh;
  43741. }
  43742. }
  43743. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43744. import { Vector4 } from "babylonjs/Maths/math.vector";
  43745. import { Mesh } from "babylonjs/Meshes/mesh";
  43746. /**
  43747. * Class containing static functions to help procedurally build meshes
  43748. */
  43749. export class TorusBuilder {
  43750. /**
  43751. * Creates a torus mesh
  43752. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43753. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43754. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43758. * @param name defines the name of the mesh
  43759. * @param options defines the options used to create the mesh
  43760. * @param scene defines the hosting scene
  43761. * @returns the torus mesh
  43762. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43763. */
  43764. static CreateTorus(name: string, options: {
  43765. diameter?: number;
  43766. thickness?: number;
  43767. tessellation?: number;
  43768. updatable?: boolean;
  43769. sideOrientation?: number;
  43770. frontUVs?: Vector4;
  43771. backUVs?: Vector4;
  43772. }, scene: any): Mesh;
  43773. }
  43774. }
  43775. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43776. import { Vector4 } from "babylonjs/Maths/math.vector";
  43777. import { Color4 } from "babylonjs/Maths/math.color";
  43778. import { Mesh } from "babylonjs/Meshes/mesh";
  43779. /**
  43780. * Class containing static functions to help procedurally build meshes
  43781. */
  43782. export class CylinderBuilder {
  43783. /**
  43784. * Creates a cylinder or a cone mesh
  43785. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43786. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43787. * * 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.
  43788. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43789. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43790. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43791. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43792. * * 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).
  43793. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43794. * * 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).
  43795. * * 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
  43796. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43797. * * 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
  43798. * * 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.
  43799. * * If `enclose` is false, a ring surface is one element.
  43800. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43801. * * 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
  43802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43805. * @param name defines the name of the mesh
  43806. * @param options defines the options used to create the mesh
  43807. * @param scene defines the hosting scene
  43808. * @returns the cylinder mesh
  43809. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43810. */
  43811. static CreateCylinder(name: string, options: {
  43812. height?: number;
  43813. diameterTop?: number;
  43814. diameterBottom?: number;
  43815. diameter?: number;
  43816. tessellation?: number;
  43817. subdivisions?: number;
  43818. arc?: number;
  43819. faceColors?: Color4[];
  43820. faceUV?: Vector4[];
  43821. updatable?: boolean;
  43822. hasRings?: boolean;
  43823. enclose?: boolean;
  43824. cap?: number;
  43825. sideOrientation?: number;
  43826. frontUVs?: Vector4;
  43827. backUVs?: Vector4;
  43828. }, scene: any): Mesh;
  43829. }
  43830. }
  43831. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43832. import { Nullable } from "babylonjs/types";
  43833. import { IDisposable } from "babylonjs/scene";
  43834. /**
  43835. * States of the webXR experience
  43836. */
  43837. export enum WebXRState {
  43838. /**
  43839. * Transitioning to being in XR mode
  43840. */
  43841. ENTERING_XR = 0,
  43842. /**
  43843. * Transitioning to non XR mode
  43844. */
  43845. EXITING_XR = 1,
  43846. /**
  43847. * In XR mode and presenting
  43848. */
  43849. IN_XR = 2,
  43850. /**
  43851. * Not entered XR mode
  43852. */
  43853. NOT_IN_XR = 3
  43854. }
  43855. /**
  43856. * Abstraction of the XR render target
  43857. */
  43858. export interface WebXRRenderTarget extends IDisposable {
  43859. /**
  43860. * xrpresent context of the canvas which can be used to display/mirror xr content
  43861. */
  43862. canvasContext: WebGLRenderingContext;
  43863. /**
  43864. * xr layer for the canvas
  43865. */
  43866. xrLayer: Nullable<XRWebGLLayer>;
  43867. /**
  43868. * Initializes the xr layer for the session
  43869. * @param xrSession xr session
  43870. * @returns a promise that will resolve once the XR Layer has been created
  43871. */
  43872. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43873. }
  43874. }
  43875. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43876. import { Nullable } from "babylonjs/types";
  43877. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43878. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43879. /**
  43880. * COnfiguration object for WebXR output canvas
  43881. */
  43882. export class WebXRManagedOutputCanvasOptions {
  43883. /**
  43884. * Options for this XR Layer output
  43885. */
  43886. canvasOptions?: XRWebGLLayerOptions;
  43887. /**
  43888. * CSS styling for a newly created canvas (if not provided)
  43889. */
  43890. newCanvasCssStyle?: string;
  43891. /**
  43892. * An optional canvas in case you wish to create it yourself and provide it here.
  43893. * If not provided, a new canvas will be created
  43894. */
  43895. canvasElement?: HTMLCanvasElement;
  43896. /**
  43897. * Get the default values of the configuration object
  43898. * @returns default values of this configuration object
  43899. */
  43900. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43901. }
  43902. /**
  43903. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43904. */
  43905. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43906. private _options;
  43907. private _engine;
  43908. private _canvas;
  43909. /**
  43910. * Rendering context of the canvas which can be used to display/mirror xr content
  43911. */
  43912. canvasContext: WebGLRenderingContext;
  43913. /**
  43914. * xr layer for the canvas
  43915. */
  43916. xrLayer: Nullable<XRWebGLLayer>;
  43917. /**
  43918. * Initializes the xr layer for the session
  43919. * @param xrSession xr session
  43920. * @returns a promise that will resolve once the XR Layer has been created
  43921. */
  43922. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43923. /**
  43924. * Initializes the canvas to be added/removed upon entering/exiting xr
  43925. * @param _xrSessionManager The XR Session manager
  43926. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43927. */
  43928. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43929. /**
  43930. * Disposes of the object
  43931. */
  43932. dispose(): void;
  43933. private _setManagedOutputCanvas;
  43934. private _addCanvas;
  43935. private _removeCanvas;
  43936. }
  43937. }
  43938. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43939. import { Observable } from "babylonjs/Misc/observable";
  43940. import { Nullable } from "babylonjs/types";
  43941. import { IDisposable, Scene } from "babylonjs/scene";
  43942. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43943. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43944. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43945. /**
  43946. * Manages an XRSession to work with Babylon's engine
  43947. * @see https://doc.babylonjs.com/how_to/webxr
  43948. */
  43949. export class WebXRSessionManager implements IDisposable {
  43950. /** The scene which the session should be created for */
  43951. scene: Scene;
  43952. /**
  43953. * Fires every time a new xrFrame arrives which can be used to update the camera
  43954. */
  43955. onXRFrameObservable: Observable<XRFrame>;
  43956. /**
  43957. * Fires when the xr session is ended either by the device or manually done
  43958. */
  43959. onXRSessionEnded: Observable<any>;
  43960. /**
  43961. * Fires when the xr session is ended either by the device or manually done
  43962. */
  43963. onXRSessionInit: Observable<XRSession>;
  43964. /**
  43965. * Fires when the reference space changed
  43966. */
  43967. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43968. /**
  43969. * Underlying xr session
  43970. */
  43971. session: XRSession;
  43972. /**
  43973. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43974. * or get the offset the player is currently at.
  43975. */
  43976. viewerReferenceSpace: XRReferenceSpace;
  43977. private _referenceSpace;
  43978. /**
  43979. * The current reference space used in this session. This reference space can constantly change!
  43980. * It is mainly used to offset the camera's position.
  43981. */
  43982. get referenceSpace(): XRReferenceSpace;
  43983. /**
  43984. * Set a new reference space and triggers the observable
  43985. */
  43986. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43987. /**
  43988. * The base reference space from which the session started. good if you want to reset your
  43989. * reference space
  43990. */
  43991. baseReferenceSpace: XRReferenceSpace;
  43992. /**
  43993. * Used just in case of a failure to initialize an immersive session.
  43994. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43995. */
  43996. defaultHeightCompensation: number;
  43997. /**
  43998. * Current XR frame
  43999. */
  44000. currentFrame: Nullable<XRFrame>;
  44001. /** WebXR timestamp updated every frame */
  44002. currentTimestamp: number;
  44003. private _xrNavigator;
  44004. private baseLayer;
  44005. private _rttProvider;
  44006. private _sessionEnded;
  44007. /**
  44008. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44009. * @param scene The scene which the session should be created for
  44010. */
  44011. constructor(
  44012. /** The scene which the session should be created for */
  44013. scene: Scene);
  44014. /**
  44015. * Initializes the manager
  44016. * After initialization enterXR can be called to start an XR session
  44017. * @returns Promise which resolves after it is initialized
  44018. */
  44019. initializeAsync(): Promise<void>;
  44020. /**
  44021. * Initializes an xr session
  44022. * @param xrSessionMode mode to initialize
  44023. * @param xrSessionInit defines optional and required values to pass to the session builder
  44024. * @returns a promise which will resolve once the session has been initialized
  44025. */
  44026. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44027. /**
  44028. * Sets the reference space on the xr session
  44029. * @param referenceSpace space to set
  44030. * @returns a promise that will resolve once the reference space has been set
  44031. */
  44032. setReferenceSpaceAsync(referenceSpace?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44033. /**
  44034. * Resets the reference space to the one started the session
  44035. */
  44036. resetReferenceSpace(): void;
  44037. /**
  44038. * Updates the render state of the session
  44039. * @param state state to set
  44040. * @returns a promise that resolves once the render state has been updated
  44041. */
  44042. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44043. /**
  44044. * Starts rendering to the xr layer
  44045. */
  44046. runXRRenderLoop(): void;
  44047. /**
  44048. * Gets the correct render target texture to be rendered this frame for this eye
  44049. * @param eye the eye for which to get the render target
  44050. * @returns the render target for the specified eye
  44051. */
  44052. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44053. /**
  44054. * Stops the xrSession and restores the renderloop
  44055. * @returns Promise which resolves after it exits XR
  44056. */
  44057. exitXRAsync(): Promise<void>;
  44058. /**
  44059. * Checks if a session would be supported for the creation options specified
  44060. * @param sessionMode session mode to check if supported eg. immersive-vr
  44061. * @returns true if supported
  44062. */
  44063. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44064. /**
  44065. * Creates a WebXRRenderTarget object for the XR session
  44066. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44067. * @param options optional options to provide when creating a new render target
  44068. * @returns a WebXR render target to which the session can render
  44069. */
  44070. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44071. /**
  44072. * @hidden
  44073. * Converts the render layer of xrSession to a render target
  44074. * @param session session to create render target for
  44075. * @param scene scene the new render target should be created for
  44076. * @param baseLayer the webgl layer to create the render target for
  44077. */
  44078. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44079. /**
  44080. * Disposes of the session manager
  44081. */
  44082. dispose(): void;
  44083. /**
  44084. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44085. * @param sessionMode defines the session to test
  44086. * @returns a promise with boolean as final value
  44087. */
  44088. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44089. }
  44090. }
  44091. declare module "babylonjs/Cameras/XR/webXRCamera" {
  44092. import { Scene } from "babylonjs/scene";
  44093. import { Camera } from "babylonjs/Cameras/camera";
  44094. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44095. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44096. /**
  44097. * WebXR Camera which holds the views for the xrSession
  44098. * @see https://doc.babylonjs.com/how_to/webxr
  44099. */
  44100. export class WebXRCamera extends FreeCamera {
  44101. private _xrSessionManager;
  44102. /**
  44103. * Is the camera in debug mode. Used when using an emulator
  44104. */
  44105. debugMode: boolean;
  44106. private _firstFrame;
  44107. private _referencedPosition;
  44108. private _referenceQuaternion;
  44109. private _xrInvPositionCache;
  44110. private _xrInvQuaternionCache;
  44111. /**
  44112. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44113. * @param name the name of the camera
  44114. * @param scene the scene to add the camera to
  44115. */
  44116. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44117. private _updateNumberOfRigCameras;
  44118. /**
  44119. * Sets this camera's transformation based on a non-vr camera
  44120. * @param otherCamera the non-vr camera to copy the transformation from
  44121. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44122. */
  44123. setTransformationFromNonVRCamera(otherCamera: Camera, resetToBaseReferenceSpace?: boolean): void;
  44124. /** @hidden */
  44125. _updateForDualEyeDebugging(): void;
  44126. private _updateReferenceSpace;
  44127. private _updateReferenceSpaceOffset;
  44128. private _updateFromXRSession;
  44129. }
  44130. }
  44131. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  44132. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44133. import { IDisposable } from "babylonjs/scene";
  44134. /**
  44135. * Defining the interface required for a (webxr) feature
  44136. */
  44137. export interface IWebXRFeature extends IDisposable {
  44138. /**
  44139. * Is this feature attached
  44140. */
  44141. attached: boolean;
  44142. /**
  44143. * Attach the feature to the session
  44144. * Will usually be called by the features manager
  44145. *
  44146. * @returns true if successful.
  44147. */
  44148. attach(): boolean;
  44149. /**
  44150. * Detach the feature from the session
  44151. * Will usually be called by the features manager
  44152. *
  44153. * @returns true if successful.
  44154. */
  44155. detach(): boolean;
  44156. }
  44157. /**
  44158. * Defining the constructor of a feature. Used to register the modules.
  44159. */
  44160. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44161. /**
  44162. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44163. * It is mainly used in AR sessions.
  44164. *
  44165. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44166. */
  44167. export class WebXRFeaturesManager implements IDisposable {
  44168. private _xrSessionManager;
  44169. private static readonly _AvailableFeatures;
  44170. /**
  44171. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44172. * Mainly used internally.
  44173. *
  44174. * @param featureName the name of the feature to register
  44175. * @param constructorFunction the function used to construct the module
  44176. * @param version the (babylon) version of the module
  44177. * @param stable is that a stable version of this module
  44178. */
  44179. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44180. /**
  44181. * Returns a constructor of a specific feature.
  44182. *
  44183. * @param featureName the name of the feature to construct
  44184. * @param version the version of the feature to load
  44185. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44186. * @param options optional options provided to the module.
  44187. * @returns a function that, when called, will return a new instance of this feature
  44188. */
  44189. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44190. /**
  44191. * Return the latest unstable version of this feature
  44192. * @param featureName the name of the feature to search
  44193. * @returns the version number. if not found will return -1
  44194. */
  44195. static GetLatestVersionOfFeature(featureName: string): number;
  44196. /**
  44197. * Return the latest stable version of this feature
  44198. * @param featureName the name of the feature to search
  44199. * @returns the version number. if not found will return -1
  44200. */
  44201. static GetStableVersionOfFeature(featureName: string): number;
  44202. /**
  44203. * Can be used to return the list of features currently registered
  44204. *
  44205. * @returns an Array of available features
  44206. */
  44207. static GetAvailableFeatures(): string[];
  44208. /**
  44209. * Gets the versions available for a specific feature
  44210. * @param featureName the name of the feature
  44211. * @returns an array with the available versions
  44212. */
  44213. static GetAvailableVersions(featureName: string): string[];
  44214. private _features;
  44215. /**
  44216. * constructs a new features manages.
  44217. *
  44218. * @param _xrSessionManager an instance of WebXRSessionManager
  44219. */
  44220. constructor(_xrSessionManager: WebXRSessionManager);
  44221. /**
  44222. * 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.
  44223. * 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.
  44224. *
  44225. * @param featureName the name of the feature to load or the class of the feature
  44226. * @param version optional version to load. if not provided the latest version will be enabled
  44227. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44228. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44229. * @returns a new constructed feature or throws an error if feature not found.
  44230. */
  44231. enableFeature(featureName: string | {
  44232. Name: string;
  44233. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44234. /**
  44235. * Used to disable an already-enabled feature
  44236. * The feature will be disposed and will be recreated once enabled.
  44237. * @param featureName the feature to disable
  44238. * @returns true if disable was successful
  44239. */
  44240. disableFeature(featureName: string | {
  44241. Name: string;
  44242. }): boolean;
  44243. /**
  44244. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44245. * Can be used during a session to start a feature
  44246. * @param featureName the name of feature to attach
  44247. */
  44248. attachFeature(featureName: string): void;
  44249. /**
  44250. * Can be used inside a session or when the session ends to detach a specific feature
  44251. * @param featureName the name of the feature to detach
  44252. */
  44253. detachFeature(featureName: string): void;
  44254. /**
  44255. * Get the list of enabled features
  44256. * @returns an array of enabled features
  44257. */
  44258. getEnabledFeatures(): string[];
  44259. /**
  44260. * get the implementation of an enabled feature.
  44261. * @param featureName the name of the feature to load
  44262. * @returns the feature class, if found
  44263. */
  44264. getEnabledFeature(featureName: string): IWebXRFeature;
  44265. /**
  44266. * dispose this features manager
  44267. */
  44268. dispose(): void;
  44269. }
  44270. }
  44271. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44272. import { Observable } from "babylonjs/Misc/observable";
  44273. import { IDisposable, Scene } from "babylonjs/scene";
  44274. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44275. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44276. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44277. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44278. /**
  44279. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44280. * @see https://doc.babylonjs.com/how_to/webxr
  44281. */
  44282. export class WebXRExperienceHelper implements IDisposable {
  44283. private scene;
  44284. /**
  44285. * Camera used to render xr content
  44286. */
  44287. camera: WebXRCamera;
  44288. /**
  44289. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44290. */
  44291. state: WebXRState;
  44292. private _setState;
  44293. /**
  44294. * Fires when the state of the experience helper has changed
  44295. */
  44296. onStateChangedObservable: Observable<WebXRState>;
  44297. /**
  44298. * Observers registered here will be triggered after the camera's initial transformation is set
  44299. * This can be used to set a different ground level or an extra rotation.
  44300. *
  44301. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44302. * to the position set after this observable is done executing.
  44303. */
  44304. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44305. /** Session manager used to keep track of xr session */
  44306. sessionManager: WebXRSessionManager;
  44307. /** A features manager for this xr session */
  44308. featuresManager: WebXRFeaturesManager;
  44309. private _nonVRCamera;
  44310. private _originalSceneAutoClear;
  44311. private _supported;
  44312. /**
  44313. * Creates the experience helper
  44314. * @param scene the scene to attach the experience helper to
  44315. * @returns a promise for the experience helper
  44316. */
  44317. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44318. /**
  44319. * Creates a WebXRExperienceHelper
  44320. * @param scene The scene the helper should be created in
  44321. */
  44322. private constructor();
  44323. /**
  44324. * Exits XR mode and returns the scene to its original state
  44325. * @returns promise that resolves after xr mode has exited
  44326. */
  44327. exitXRAsync(): Promise<void>;
  44328. /**
  44329. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44330. * @param sessionMode options for the XR session
  44331. * @param referenceSpaceType frame of reference of the XR session
  44332. * @param renderTarget the output canvas that will be used to enter XR mode
  44333. * @returns promise that resolves after xr mode has entered
  44334. */
  44335. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44336. /**
  44337. * Disposes of the experience helper
  44338. */
  44339. dispose(): void;
  44340. private _nonXRToXRCamera;
  44341. }
  44342. }
  44343. declare module "babylonjs/Cameras/XR/motionController/webXRControllerComponent" {
  44344. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  44345. import { Observable } from "babylonjs/Misc/observable";
  44346. import { IDisposable } from "babylonjs/scene";
  44347. /**
  44348. * X-Y values for axes in WebXR
  44349. */
  44350. export interface IWebXRMotionControllerAxesValue {
  44351. /**
  44352. * The value of the x axis
  44353. */
  44354. x: number;
  44355. /**
  44356. * The value of the y-axis
  44357. */
  44358. y: number;
  44359. }
  44360. /**
  44361. * changed / previous values for the values of this component
  44362. */
  44363. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44364. /**
  44365. * current (this frame) value
  44366. */
  44367. current: T;
  44368. /**
  44369. * previous (last change) value
  44370. */
  44371. previous: T;
  44372. }
  44373. /**
  44374. * Represents changes in the component between current frame and last values recorded
  44375. */
  44376. export interface IWebXRMotionControllerComponentChanges {
  44377. /**
  44378. * will be populated with previous and current values if touched changed
  44379. */
  44380. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44381. /**
  44382. * will be populated with previous and current values if pressed changed
  44383. */
  44384. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44385. /**
  44386. * will be populated with previous and current values if value changed
  44387. */
  44388. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44389. /**
  44390. * will be populated with previous and current values if axes changed
  44391. */
  44392. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44393. }
  44394. /**
  44395. * This class represents a single component (for example button or thumbstick) of a motion controller
  44396. */
  44397. export class WebXRControllerComponent implements IDisposable {
  44398. /**
  44399. * the id of this component
  44400. */
  44401. id: string;
  44402. /**
  44403. * the type of the component
  44404. */
  44405. type: MotionControllerComponentType;
  44406. private _buttonIndex;
  44407. private _axesIndices;
  44408. /**
  44409. * Thumbstick component type
  44410. */
  44411. static THUMBSTICK: string;
  44412. /**
  44413. * Touchpad component type
  44414. */
  44415. static TOUCHPAD: string;
  44416. /**
  44417. * trigger component type
  44418. */
  44419. static TRIGGER: string;
  44420. /**
  44421. * squeeze component type
  44422. */
  44423. static SQUEEZE: string;
  44424. /**
  44425. * Observers registered here will be triggered when the state of a button changes
  44426. * State change is either pressed / touched / value
  44427. */
  44428. onButtonStateChanged: Observable<WebXRControllerComponent>;
  44429. /**
  44430. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44431. * the axes data changes
  44432. */
  44433. onAxisValueChanged: Observable<{
  44434. x: number;
  44435. y: number;
  44436. }>;
  44437. private _currentValue;
  44438. private _touched;
  44439. private _pressed;
  44440. private _axes;
  44441. private _changes;
  44442. /**
  44443. * Creates a new component for a motion controller.
  44444. * It is created by the motion controller itself
  44445. *
  44446. * @param id the id of this component
  44447. * @param type the type of the component
  44448. * @param _buttonIndex index in the buttons array of the gamepad
  44449. * @param _axesIndices indices of the values in the axes array of the gamepad
  44450. */
  44451. constructor(
  44452. /**
  44453. * the id of this component
  44454. */
  44455. id: string,
  44456. /**
  44457. * the type of the component
  44458. */
  44459. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44460. /**
  44461. * Get the current value of this component
  44462. */
  44463. get value(): number;
  44464. /**
  44465. * is the button currently pressed
  44466. */
  44467. get pressed(): boolean;
  44468. /**
  44469. * is the button currently touched
  44470. */
  44471. get touched(): boolean;
  44472. /**
  44473. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44474. */
  44475. get axes(): IWebXRMotionControllerAxesValue;
  44476. /**
  44477. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44478. */
  44479. get changes(): IWebXRMotionControllerComponentChanges;
  44480. /**
  44481. * Is this component a button (hence - pressable)
  44482. * @returns true if can be pressed
  44483. */
  44484. isButton(): boolean;
  44485. /**
  44486. * Are there axes correlating to this component
  44487. * @return true is axes data is available
  44488. */
  44489. isAxes(): boolean;
  44490. /**
  44491. * update this component using the gamepad object it is in. Called on every frame
  44492. * @param nativeController the native gamepad controller object
  44493. */
  44494. update(nativeController: IMinimalMotionControllerObject): void;
  44495. /**
  44496. * Dispose this component
  44497. */
  44498. dispose(): void;
  44499. }
  44500. }
  44501. declare module "babylonjs/Loading/sceneLoader" {
  44502. import { Observable } from "babylonjs/Misc/observable";
  44503. import { Nullable } from "babylonjs/types";
  44504. import { Scene } from "babylonjs/scene";
  44505. import { Engine } from "babylonjs/Engines/engine";
  44506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44507. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44508. import { AssetContainer } from "babylonjs/assetContainer";
  44509. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44510. import { Skeleton } from "babylonjs/Bones/skeleton";
  44511. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44512. import { WebRequest } from "babylonjs/Misc/webRequest";
  44513. /**
  44514. * Class used to represent data loading progression
  44515. */
  44516. export class SceneLoaderProgressEvent {
  44517. /** defines if data length to load can be evaluated */
  44518. readonly lengthComputable: boolean;
  44519. /** defines the loaded data length */
  44520. readonly loaded: number;
  44521. /** defines the data length to load */
  44522. readonly total: number;
  44523. /**
  44524. * Create a new progress event
  44525. * @param lengthComputable defines if data length to load can be evaluated
  44526. * @param loaded defines the loaded data length
  44527. * @param total defines the data length to load
  44528. */
  44529. constructor(
  44530. /** defines if data length to load can be evaluated */
  44531. lengthComputable: boolean,
  44532. /** defines the loaded data length */
  44533. loaded: number,
  44534. /** defines the data length to load */
  44535. total: number);
  44536. /**
  44537. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44538. * @param event defines the source event
  44539. * @returns a new SceneLoaderProgressEvent
  44540. */
  44541. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44542. }
  44543. /**
  44544. * Interface used by SceneLoader plugins to define supported file extensions
  44545. */
  44546. export interface ISceneLoaderPluginExtensions {
  44547. /**
  44548. * Defines the list of supported extensions
  44549. */
  44550. [extension: string]: {
  44551. isBinary: boolean;
  44552. };
  44553. }
  44554. /**
  44555. * Interface used by SceneLoader plugin factory
  44556. */
  44557. export interface ISceneLoaderPluginFactory {
  44558. /**
  44559. * Defines the name of the factory
  44560. */
  44561. name: string;
  44562. /**
  44563. * Function called to create a new plugin
  44564. * @return the new plugin
  44565. */
  44566. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44567. /**
  44568. * The callback that returns true if the data can be directly loaded.
  44569. * @param data string containing the file data
  44570. * @returns if the data can be loaded directly
  44571. */
  44572. canDirectLoad?(data: string): boolean;
  44573. }
  44574. /**
  44575. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44576. */
  44577. export interface ISceneLoaderPluginBase {
  44578. /**
  44579. * The friendly name of this plugin.
  44580. */
  44581. name: string;
  44582. /**
  44583. * The file extensions supported by this plugin.
  44584. */
  44585. extensions: string | ISceneLoaderPluginExtensions;
  44586. /**
  44587. * The callback called when loading from a url.
  44588. * @param scene scene loading this url
  44589. * @param url url to load
  44590. * @param onSuccess callback called when the file successfully loads
  44591. * @param onProgress callback called while file is loading (if the server supports this mode)
  44592. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44593. * @param onError callback called when the file fails to load
  44594. * @returns a file request object
  44595. */
  44596. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44597. /**
  44598. * The callback called when loading from a file object.
  44599. * @param scene scene loading this file
  44600. * @param file defines the file to load
  44601. * @param onSuccess defines the callback to call when data is loaded
  44602. * @param onProgress defines the callback to call during loading process
  44603. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44604. * @param onError defines the callback to call when an error occurs
  44605. * @returns a file request object
  44606. */
  44607. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44608. /**
  44609. * The callback that returns true if the data can be directly loaded.
  44610. * @param data string containing the file data
  44611. * @returns if the data can be loaded directly
  44612. */
  44613. canDirectLoad?(data: string): boolean;
  44614. /**
  44615. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44616. * @param scene scene loading this data
  44617. * @param data string containing the data
  44618. * @returns data to pass to the plugin
  44619. */
  44620. directLoad?(scene: Scene, data: string): any;
  44621. /**
  44622. * The callback that allows custom handling of the root url based on the response url.
  44623. * @param rootUrl the original root url
  44624. * @param responseURL the response url if available
  44625. * @returns the new root url
  44626. */
  44627. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44628. }
  44629. /**
  44630. * Interface used to define a SceneLoader plugin
  44631. */
  44632. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44633. /**
  44634. * Import meshes into a scene.
  44635. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44636. * @param scene The scene to import into
  44637. * @param data The data to import
  44638. * @param rootUrl The root url for scene and resources
  44639. * @param meshes The meshes array to import into
  44640. * @param particleSystems The particle systems array to import into
  44641. * @param skeletons The skeletons array to import into
  44642. * @param onError The callback when import fails
  44643. * @returns True if successful or false otherwise
  44644. */
  44645. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44646. /**
  44647. * Load into a scene.
  44648. * @param scene The scene to load into
  44649. * @param data The data to import
  44650. * @param rootUrl The root url for scene and resources
  44651. * @param onError The callback when import fails
  44652. * @returns True if successful or false otherwise
  44653. */
  44654. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44655. /**
  44656. * Load into an asset container.
  44657. * @param scene The scene to load into
  44658. * @param data The data to import
  44659. * @param rootUrl The root url for scene and resources
  44660. * @param onError The callback when import fails
  44661. * @returns The loaded asset container
  44662. */
  44663. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44664. }
  44665. /**
  44666. * Interface used to define an async SceneLoader plugin
  44667. */
  44668. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44669. /**
  44670. * Import meshes into a scene.
  44671. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44672. * @param scene The scene to import into
  44673. * @param data The data to import
  44674. * @param rootUrl The root url for scene and resources
  44675. * @param onProgress The callback when the load progresses
  44676. * @param fileName Defines the name of the file to load
  44677. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44678. */
  44679. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44680. meshes: AbstractMesh[];
  44681. particleSystems: IParticleSystem[];
  44682. skeletons: Skeleton[];
  44683. animationGroups: AnimationGroup[];
  44684. }>;
  44685. /**
  44686. * Load into a scene.
  44687. * @param scene The scene to load into
  44688. * @param data The data to import
  44689. * @param rootUrl The root url for scene and resources
  44690. * @param onProgress The callback when the load progresses
  44691. * @param fileName Defines the name of the file to load
  44692. * @returns Nothing
  44693. */
  44694. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44695. /**
  44696. * Load into an asset container.
  44697. * @param scene The scene to load into
  44698. * @param data The data to import
  44699. * @param rootUrl The root url for scene and resources
  44700. * @param onProgress The callback when the load progresses
  44701. * @param fileName Defines the name of the file to load
  44702. * @returns The loaded asset container
  44703. */
  44704. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44705. }
  44706. /**
  44707. * Mode that determines how to handle old animation groups before loading new ones.
  44708. */
  44709. export enum SceneLoaderAnimationGroupLoadingMode {
  44710. /**
  44711. * Reset all old animations to initial state then dispose them.
  44712. */
  44713. Clean = 0,
  44714. /**
  44715. * Stop all old animations.
  44716. */
  44717. Stop = 1,
  44718. /**
  44719. * Restart old animations from first frame.
  44720. */
  44721. Sync = 2,
  44722. /**
  44723. * Old animations remains untouched.
  44724. */
  44725. NoSync = 3
  44726. }
  44727. /**
  44728. * Class used to load scene from various file formats using registered plugins
  44729. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44730. */
  44731. export class SceneLoader {
  44732. /**
  44733. * No logging while loading
  44734. */
  44735. static readonly NO_LOGGING: number;
  44736. /**
  44737. * Minimal logging while loading
  44738. */
  44739. static readonly MINIMAL_LOGGING: number;
  44740. /**
  44741. * Summary logging while loading
  44742. */
  44743. static readonly SUMMARY_LOGGING: number;
  44744. /**
  44745. * Detailled logging while loading
  44746. */
  44747. static readonly DETAILED_LOGGING: number;
  44748. /**
  44749. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44750. */
  44751. static get ForceFullSceneLoadingForIncremental(): boolean;
  44752. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44753. /**
  44754. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44755. */
  44756. static get ShowLoadingScreen(): boolean;
  44757. static set ShowLoadingScreen(value: boolean);
  44758. /**
  44759. * Defines the current logging level (while loading the scene)
  44760. * @ignorenaming
  44761. */
  44762. static get loggingLevel(): number;
  44763. static set loggingLevel(value: number);
  44764. /**
  44765. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44766. */
  44767. static get CleanBoneMatrixWeights(): boolean;
  44768. static set CleanBoneMatrixWeights(value: boolean);
  44769. /**
  44770. * Event raised when a plugin is used to load a scene
  44771. */
  44772. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44773. private static _registeredPlugins;
  44774. private static _getDefaultPlugin;
  44775. private static _getPluginForExtension;
  44776. private static _getPluginForDirectLoad;
  44777. private static _getPluginForFilename;
  44778. private static _getDirectLoad;
  44779. private static _loadData;
  44780. private static _getFileInfo;
  44781. /**
  44782. * Gets a plugin that can load the given extension
  44783. * @param extension defines the extension to load
  44784. * @returns a plugin or null if none works
  44785. */
  44786. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44787. /**
  44788. * Gets a boolean indicating that the given extension can be loaded
  44789. * @param extension defines the extension to load
  44790. * @returns true if the extension is supported
  44791. */
  44792. static IsPluginForExtensionAvailable(extension: string): boolean;
  44793. /**
  44794. * Adds a new plugin to the list of registered plugins
  44795. * @param plugin defines the plugin to add
  44796. */
  44797. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44798. /**
  44799. * Import meshes into a scene
  44800. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44801. * @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)
  44802. * @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)
  44803. * @param scene the instance of BABYLON.Scene to append to
  44804. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44805. * @param onProgress a callback with a progress event for each file being loaded
  44806. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44807. * @param pluginExtension the extension used to determine the plugin
  44808. * @returns The loaded plugin
  44809. */
  44810. 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>;
  44811. /**
  44812. * Import meshes into a scene
  44813. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44814. * @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)
  44815. * @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)
  44816. * @param scene the instance of BABYLON.Scene to append to
  44817. * @param onProgress a callback with a progress event for each file being loaded
  44818. * @param pluginExtension the extension used to determine the plugin
  44819. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44820. */
  44821. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44822. meshes: AbstractMesh[];
  44823. particleSystems: IParticleSystem[];
  44824. skeletons: Skeleton[];
  44825. animationGroups: AnimationGroup[];
  44826. }>;
  44827. /**
  44828. * Load a scene
  44829. * @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)
  44830. * @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)
  44831. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44832. * @param onSuccess a callback with the scene when import succeeds
  44833. * @param onProgress a callback with a progress event for each file being loaded
  44834. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44835. * @param pluginExtension the extension used to determine the plugin
  44836. * @returns The loaded plugin
  44837. */
  44838. 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>;
  44839. /**
  44840. * Load a scene
  44841. * @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)
  44842. * @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)
  44843. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44844. * @param onProgress a callback with a progress event for each file being loaded
  44845. * @param pluginExtension the extension used to determine the plugin
  44846. * @returns The loaded scene
  44847. */
  44848. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44849. /**
  44850. * Append a scene
  44851. * @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)
  44852. * @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)
  44853. * @param scene is the instance of BABYLON.Scene to append to
  44854. * @param onSuccess a callback with the scene when import succeeds
  44855. * @param onProgress a callback with a progress event for each file being loaded
  44856. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44857. * @param pluginExtension the extension used to determine the plugin
  44858. * @returns The loaded plugin
  44859. */
  44860. 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>;
  44861. /**
  44862. * Append a scene
  44863. * @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)
  44864. * @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)
  44865. * @param scene is the instance of BABYLON.Scene to append to
  44866. * @param onProgress a callback with a progress event for each file being loaded
  44867. * @param pluginExtension the extension used to determine the plugin
  44868. * @returns The given scene
  44869. */
  44870. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44871. /**
  44872. * Load a scene into an asset container
  44873. * @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)
  44874. * @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)
  44875. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44876. * @param onSuccess a callback with the scene when import succeeds
  44877. * @param onProgress a callback with a progress event for each file being loaded
  44878. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44879. * @param pluginExtension the extension used to determine the plugin
  44880. * @returns The loaded plugin
  44881. */
  44882. 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>;
  44883. /**
  44884. * Load a scene into an asset container
  44885. * @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)
  44886. * @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)
  44887. * @param scene is the instance of Scene to append to
  44888. * @param onProgress a callback with a progress event for each file being loaded
  44889. * @param pluginExtension the extension used to determine the plugin
  44890. * @returns The loaded asset container
  44891. */
  44892. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44893. /**
  44894. * Import animations from a file into a scene
  44895. * @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)
  44896. * @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)
  44897. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44898. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44899. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44900. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44901. * @param onSuccess a callback with the scene when import succeeds
  44902. * @param onProgress a callback with a progress event for each file being loaded
  44903. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44904. */
  44905. 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;
  44906. /**
  44907. * Import animations from a file into a scene
  44908. * @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)
  44909. * @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)
  44910. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44911. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44912. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44913. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44914. * @param onSuccess a callback with the scene when import succeeds
  44915. * @param onProgress a callback with a progress event for each file being loaded
  44916. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44917. * @returns the updated scene with imported animations
  44918. */
  44919. 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>;
  44920. }
  44921. }
  44922. declare module "babylonjs/Cameras/XR/motionController/webXRAbstractController" {
  44923. import { IDisposable, Scene } from "babylonjs/scene";
  44924. import { WebXRControllerComponent } from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  44925. import { Observable } from "babylonjs/Misc/observable";
  44926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44927. import { Nullable } from "babylonjs/types";
  44928. /**
  44929. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44930. */
  44931. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  44932. /**
  44933. * The type of components available in motion controllers.
  44934. * This is not the name of the component.
  44935. */
  44936. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44937. /**
  44938. * The schema of motion controller layout.
  44939. * No object will be initialized using this interface
  44940. * This is used just to define the profile.
  44941. */
  44942. export interface IMotionControllerLayout {
  44943. /**
  44944. * Defines the main button component id
  44945. */
  44946. selectComponentId: string;
  44947. /**
  44948. * Available components (unsorted)
  44949. */
  44950. components: {
  44951. /**
  44952. * A map of component Ids
  44953. */
  44954. [componentId: string]: {
  44955. /**
  44956. * The type of input the component outputs
  44957. */
  44958. type: MotionControllerComponentType;
  44959. };
  44960. };
  44961. /**
  44962. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  44963. */
  44964. gamepad?: {
  44965. /**
  44966. * Is the mapping based on the xr-standard defined here:
  44967. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  44968. */
  44969. mapping: "" | "xr-standard";
  44970. /**
  44971. * The buttons available in this input in the right order
  44972. * index of this button will be the index in the gamepadObject.buttons array
  44973. * correlates to the componentId in components
  44974. */
  44975. buttons: Array<string | null>;
  44976. /**
  44977. * Definition of the axes of the gamepad input, sorted
  44978. * Correlates to componentIds in the components map
  44979. */
  44980. axes: Array<{
  44981. /**
  44982. * The component id that the axis correlates to
  44983. */
  44984. componentId: string;
  44985. /**
  44986. * X or Y Axis
  44987. */
  44988. axis: "x-axis" | "y-axis";
  44989. } | null>;
  44990. };
  44991. }
  44992. /**
  44993. * A definition for the layout map in the input profile
  44994. */
  44995. export interface IMotionControllerLayoutMap {
  44996. /**
  44997. * Layouts with handness type as a key
  44998. */
  44999. [handness: string]: IMotionControllerLayout;
  45000. }
  45001. /**
  45002. * The XR Input profile schema
  45003. * Profiles can be found here:
  45004. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45005. */
  45006. export interface IMotionControllerProfile {
  45007. /**
  45008. * The id of this profile
  45009. * correlates to the profile(s) in the xrInput.profiles array
  45010. */
  45011. profileId: string;
  45012. /**
  45013. * fallback profiles for this profileId
  45014. */
  45015. fallbackProfileIds: string[];
  45016. /**
  45017. * The layout map, with handness as key
  45018. */
  45019. layouts: IMotionControllerLayoutMap;
  45020. }
  45021. /**
  45022. * A helper-interface for the 3 meshes needed for controller button animation
  45023. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45024. */
  45025. export interface IMotionControllerButtonMeshMap {
  45026. /**
  45027. * The mesh that will be changed when value changes
  45028. */
  45029. valueMesh: AbstractMesh;
  45030. /**
  45031. * the mesh that defines the pressed value mesh position.
  45032. * This is used to find the max-position of this button
  45033. */
  45034. pressedMesh: AbstractMesh;
  45035. /**
  45036. * the mesh that defines the unpressed value mesh position.
  45037. * This is used to find the min (or initial) position of this button
  45038. */
  45039. unpressedMesh: AbstractMesh;
  45040. }
  45041. /**
  45042. * A helper-interface for the 3 meshes needed for controller axis animation.
  45043. * This will be expanded when touchpad animations are fully supported
  45044. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45045. */
  45046. export interface IMotionControllerAxisMeshMap {
  45047. /**
  45048. * The mesh that will be changed when axis value changes
  45049. */
  45050. valueMesh: AbstractMesh;
  45051. /**
  45052. * the mesh that defines the minimum value mesh position.
  45053. */
  45054. minMesh: AbstractMesh;
  45055. /**
  45056. * the mesh that defines the maximum value mesh position.
  45057. */
  45058. maxMesh: AbstractMesh;
  45059. }
  45060. /**
  45061. * The elements needed for change-detection of the gamepad objects in motion controllers
  45062. */
  45063. export interface IMinimalMotionControllerObject {
  45064. /**
  45065. * An array of available buttons
  45066. */
  45067. buttons: Array<{
  45068. /**
  45069. * Value of the button/trigger
  45070. */
  45071. value: number;
  45072. /**
  45073. * If the button/trigger is currently touched
  45074. */
  45075. touched: boolean;
  45076. /**
  45077. * If the button/trigger is currently pressed
  45078. */
  45079. pressed: boolean;
  45080. }>;
  45081. /**
  45082. * Available axes of this controller
  45083. */
  45084. axes: number[];
  45085. }
  45086. /**
  45087. * An Abstract Motion controller
  45088. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45089. * Each component has an observable to check for changes in value and state
  45090. */
  45091. export abstract class WebXRAbstractMotionController implements IDisposable {
  45092. protected scene: Scene;
  45093. protected layout: IMotionControllerLayout;
  45094. /**
  45095. * The gamepad object correlating to this controller
  45096. */
  45097. gamepadObject: IMinimalMotionControllerObject;
  45098. /**
  45099. * handness (left/right/none) of this controller
  45100. */
  45101. handness: MotionControllerHandness;
  45102. /**
  45103. * Component type map
  45104. */
  45105. static ComponentType: {
  45106. TRIGGER: string;
  45107. SQUEEZE: string;
  45108. TOUCHPAD: string;
  45109. THUMBSTICK: string;
  45110. BUTTON: string;
  45111. };
  45112. /**
  45113. * The profile id of this motion controller
  45114. */
  45115. abstract profileId: string;
  45116. /**
  45117. * A map of components (WebXRControllerComponent) in this motion controller
  45118. * Components have a ComponentType and can also have both button and axis definitions
  45119. */
  45120. readonly components: {
  45121. [id: string]: WebXRControllerComponent;
  45122. };
  45123. /**
  45124. * Observers registered here will be triggered when the model of this controller is done loading
  45125. */
  45126. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45127. /**
  45128. * The root mesh of the model. It is null if the model was not yet initialized
  45129. */
  45130. rootMesh: Nullable<AbstractMesh>;
  45131. private _modelReady;
  45132. /**
  45133. * constructs a new abstract motion controller
  45134. * @param scene the scene to which the model of the controller will be added
  45135. * @param layout The profile layout to load
  45136. * @param gamepadObject The gamepad object correlating to this controller
  45137. * @param handness handness (left/right/none) of this controller
  45138. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45139. */
  45140. constructor(scene: Scene, layout: IMotionControllerLayout,
  45141. /**
  45142. * The gamepad object correlating to this controller
  45143. */
  45144. gamepadObject: IMinimalMotionControllerObject,
  45145. /**
  45146. * handness (left/right/none) of this controller
  45147. */
  45148. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45149. private _initComponent;
  45150. /**
  45151. * Update this model using the current XRFrame
  45152. * @param xrFrame the current xr frame to use and update the model
  45153. */
  45154. updateFromXRFrame(xrFrame: XRFrame): void;
  45155. /**
  45156. * Get the list of components available in this motion controller
  45157. * @returns an array of strings correlating to available components
  45158. */
  45159. getComponentTypes(): string[];
  45160. /**
  45161. * Get the main (Select) component of this controller as defined in the layout
  45162. * @returns the main component of this controller
  45163. */
  45164. getMainComponent(): WebXRControllerComponent;
  45165. /**
  45166. * get a component based an its component id as defined in layout.components
  45167. * @param id the id of the component
  45168. * @returns the component correlates to the id or undefined if not found
  45169. */
  45170. getComponent(id: string): WebXRControllerComponent;
  45171. /**
  45172. * Loads the model correlating to this controller
  45173. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45174. * @returns A promise fulfilled with the result of the model loading
  45175. */
  45176. loadModel(): Promise<boolean>;
  45177. /**
  45178. * Update the model itself with the current frame data
  45179. * @param xrFrame the frame to use for updating the model mesh
  45180. */
  45181. protected updateModel(xrFrame: XRFrame): void;
  45182. /**
  45183. * Moves the axis on the controller mesh based on its current state
  45184. * @param axis the index of the axis
  45185. * @param axisValue the value of the axis which determines the meshes new position
  45186. * @hidden
  45187. */
  45188. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  45189. /**
  45190. * Moves the buttons on the controller mesh based on their current state
  45191. * @param buttonName the name of the button to move
  45192. * @param buttonValue the value of the button which determines the buttons new position
  45193. */
  45194. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  45195. private _getGenericFilenameAndPath;
  45196. private _getGenericParentMesh;
  45197. /**
  45198. * Get the filename and path for this controller's model
  45199. * @returns a map of filename and path
  45200. */
  45201. protected abstract _getFilenameAndPath(): {
  45202. filename: string;
  45203. path: string;
  45204. };
  45205. /**
  45206. * This function will be called after the model was successfully loaded and can be used
  45207. * for mesh transformations before it is available for the user
  45208. * @param meshes the loaded meshes
  45209. */
  45210. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45211. /**
  45212. * Set the root mesh for this controller. Important for the WebXR controller class
  45213. * @param meshes the loaded meshes
  45214. */
  45215. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45216. /**
  45217. * A function executed each frame that updates the mesh (if needed)
  45218. * @param xrFrame the current xrFrame
  45219. */
  45220. protected abstract _updateModel(xrFrame: XRFrame): void;
  45221. /**
  45222. * This function is called before the mesh is loaded. It checks for loading constraints.
  45223. * For example, this function can check if the GLB loader is available
  45224. * If this function returns false, the generic controller will be loaded instead
  45225. * @returns Is the client ready to load the mesh
  45226. */
  45227. protected abstract _getModelLoadingConstraints(): boolean;
  45228. /**
  45229. * Dispose this controller, the model mesh and all its components
  45230. */
  45231. dispose(): void;
  45232. }
  45233. }
  45234. declare module "babylonjs/Cameras/XR/motionController/webXRGenericMotionController" {
  45235. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45237. import { Scene } from "babylonjs/scene";
  45238. /**
  45239. * A generic trigger-only motion controller for WebXR
  45240. */
  45241. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45242. /**
  45243. * Static version of the profile id of this controller
  45244. */
  45245. static ProfileId: string;
  45246. profileId: string;
  45247. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45248. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45249. protected _updateModel(): void;
  45250. protected _getFilenameAndPath(): {
  45251. filename: string;
  45252. path: string;
  45253. };
  45254. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45255. protected _getModelLoadingConstraints(): boolean;
  45256. }
  45257. }
  45258. declare module "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager" {
  45259. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45260. import { Scene } from "babylonjs/scene";
  45261. /**
  45262. * A construction function type to create a new controller based on an xrInput object
  45263. */
  45264. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45265. /**
  45266. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45267. *
  45268. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45269. * it should be replaced with auto-loaded controllers.
  45270. *
  45271. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45272. */
  45273. export class WebXRMotionControllerManager {
  45274. private static _AvailableControllers;
  45275. private static _Fallbacks;
  45276. /**
  45277. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45278. *
  45279. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45280. *
  45281. * @param type the profile type to register
  45282. * @param constructFunction the function to be called when loading this profile
  45283. */
  45284. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45285. /**
  45286. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45287. * The order of search:
  45288. *
  45289. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45290. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45291. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45292. * 4) return the generic trigger controller if none were found
  45293. *
  45294. * @param xrInput the xrInput to which a new controller is initialized
  45295. * @param scene the scene to which the model will be added
  45296. * @param forceProfile force a certain profile for this controller
  45297. * @return the motion controller class for this profile id or the generic standard class if none was found
  45298. */
  45299. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  45300. /**
  45301. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45302. * @param profileId the profile to which a fallback needs to be found
  45303. * @return an array with corresponding fallback profiles
  45304. */
  45305. static FindFallbackWithProfileId(profileId: string): string[];
  45306. /**
  45307. * Register a fallback to a specific profile.
  45308. * @param profileId the profileId that will receive the fallbacks
  45309. * @param fallbacks A list of fallback profiles
  45310. */
  45311. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45312. /**
  45313. * Register the default fallbacks.
  45314. * This function is called automatically when this file is imported.
  45315. */
  45316. static DefaultFallbacks(): void;
  45317. }
  45318. }
  45319. declare module "babylonjs/Cameras/XR/webXRController" {
  45320. import { Observable } from "babylonjs/Misc/observable";
  45321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45322. import { Ray } from "babylonjs/Culling/ray";
  45323. import { Scene } from "babylonjs/scene";
  45324. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45325. /**
  45326. * Configuration options for the WebXR controller creation
  45327. */
  45328. export interface IWebXRControllerOptions {
  45329. /**
  45330. * Force a specific controller type for this controller.
  45331. * This can be used when creating your own profile or when testing different controllers
  45332. */
  45333. forceControllerProfile?: string;
  45334. }
  45335. /**
  45336. * Represents an XR controller
  45337. */
  45338. export class WebXRController {
  45339. private _scene;
  45340. /** The underlying input source for the controller */
  45341. inputSource: XRInputSource;
  45342. private _options;
  45343. /**
  45344. * 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
  45345. */
  45346. grip?: AbstractMesh;
  45347. /**
  45348. * Pointer which can be used to select objects or attach a visible laser to
  45349. */
  45350. pointer: AbstractMesh;
  45351. /**
  45352. * If available, this is the gamepad object related to this controller.
  45353. * Using this object it is possible to get click events and trackpad changes of the
  45354. * webxr controller that is currently being used.
  45355. */
  45356. motionController?: WebXRAbstractMotionController;
  45357. /**
  45358. * Event that fires when the controller is removed/disposed
  45359. */
  45360. onDisposeObservable: Observable<{}>;
  45361. private _tmpQuaternion;
  45362. private _tmpVector;
  45363. private _uniqueId;
  45364. /**
  45365. * Creates the controller
  45366. * @see https://doc.babylonjs.com/how_to/webxr
  45367. * @param _scene the scene which the controller should be associated to
  45368. * @param inputSource the underlying input source for the controller
  45369. * @param _options options for this controller creation
  45370. */
  45371. constructor(_scene: Scene,
  45372. /** The underlying input source for the controller */
  45373. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45374. /**
  45375. * Get this controllers unique id
  45376. */
  45377. get uniqueId(): string;
  45378. /**
  45379. * Updates the controller pose based on the given XRFrame
  45380. * @param xrFrame xr frame to update the pose with
  45381. * @param referenceSpace reference space to use
  45382. */
  45383. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45384. /**
  45385. * Gets a world space ray coming from the controller
  45386. * @param result the resulting ray
  45387. */
  45388. getWorldPointerRayToRef(result: Ray): void;
  45389. /**
  45390. * Disposes of the object
  45391. */
  45392. dispose(): void;
  45393. }
  45394. }
  45395. declare module "babylonjs/Cameras/XR/webXRInput" {
  45396. import { Observable } from "babylonjs/Misc/observable";
  45397. import { IDisposable } from "babylonjs/scene";
  45398. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45399. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45400. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  45401. /**
  45402. * The schema for initialization options of the XR Input class
  45403. */
  45404. export interface IWebXRInputOptions {
  45405. /**
  45406. * If set to true no model will be automatically loaded
  45407. */
  45408. doNotLoadControllerMeshes?: boolean;
  45409. /**
  45410. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45411. * If not found, the xr input profile data will be used.
  45412. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45413. */
  45414. forceInputProfile?: string;
  45415. }
  45416. /**
  45417. * XR input used to track XR inputs such as controllers/rays
  45418. */
  45419. export class WebXRInput implements IDisposable {
  45420. /**
  45421. * the xr session manager for this session
  45422. */
  45423. xrSessionManager: WebXRSessionManager;
  45424. /**
  45425. * the WebXR camera for this session. Mainly used for teleportation
  45426. */
  45427. xrCamera: WebXRCamera;
  45428. private readonly options;
  45429. /**
  45430. * XR controllers being tracked
  45431. */
  45432. controllers: Array<WebXRController>;
  45433. private _frameObserver;
  45434. private _sessionEndedObserver;
  45435. private _sessionInitObserver;
  45436. /**
  45437. * Event when a controller has been connected/added
  45438. */
  45439. onControllerAddedObservable: Observable<WebXRController>;
  45440. /**
  45441. * Event when a controller has been removed/disconnected
  45442. */
  45443. onControllerRemovedObservable: Observable<WebXRController>;
  45444. /**
  45445. * Initializes the WebXRInput
  45446. * @param xrSessionManager the xr session manager for this session
  45447. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45448. * @param options = initialization options for this xr input
  45449. */
  45450. constructor(
  45451. /**
  45452. * the xr session manager for this session
  45453. */
  45454. xrSessionManager: WebXRSessionManager,
  45455. /**
  45456. * the WebXR camera for this session. Mainly used for teleportation
  45457. */
  45458. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45459. private _onInputSourcesChange;
  45460. private _addAndRemoveControllers;
  45461. /**
  45462. * Disposes of the object
  45463. */
  45464. dispose(): void;
  45465. }
  45466. }
  45467. declare module "babylonjs/Cameras/XR/features/WebXRAbstractFeature" {
  45468. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45469. import { Observable, EventState } from "babylonjs/Misc/observable";
  45470. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45471. /**
  45472. * This is the base class for all WebXR features.
  45473. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45474. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45475. */
  45476. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45477. protected _xrSessionManager: WebXRSessionManager;
  45478. /**
  45479. * Construct a new (abstract) webxr feature
  45480. * @param _xrSessionManager the xr session manager for this feature
  45481. */
  45482. constructor(_xrSessionManager: WebXRSessionManager);
  45483. private _attached;
  45484. private _removeOnDetach;
  45485. /**
  45486. * Is this feature attached
  45487. */
  45488. get attached(): boolean;
  45489. /**
  45490. * attach this feature
  45491. *
  45492. * @returns true if successful, false is failed or already attached
  45493. */
  45494. attach(): boolean;
  45495. /**
  45496. * detach this feature.
  45497. *
  45498. * @returns true if successful, false if failed or already detached
  45499. */
  45500. detach(): boolean;
  45501. /**
  45502. * Dispose this feature and all of the resources attached
  45503. */
  45504. dispose(): void;
  45505. /**
  45506. * Code in this function will be executed on each xrFrame received from the browser.
  45507. * This function will not execute after the feature is detached.
  45508. * @param _xrFrame the current frame
  45509. */
  45510. protected _onXRFrame(_xrFrame: XRFrame): void;
  45511. /**
  45512. * This is used to register callbacks that will automatically be removed when detach is called.
  45513. * @param observable the observable to which the observer will be attached
  45514. * @param callback the callback to register
  45515. */
  45516. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45517. }
  45518. }
  45519. declare module "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection" {
  45520. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45521. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45522. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45523. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45524. import { Nullable } from "babylonjs/types";
  45525. import { Color3 } from "babylonjs/Maths/math.color";
  45526. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  45527. /**
  45528. * Options interface for the pointer selection module
  45529. */
  45530. export interface IWebXRControllerPointerSelectionOptions {
  45531. /**
  45532. * the xr input to use with this pointer selection
  45533. */
  45534. xrInput: WebXRInput;
  45535. /**
  45536. * Different button type to use instead of the main component
  45537. */
  45538. overrideButtonId?: string;
  45539. /**
  45540. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  45541. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45542. * 3000 means 3 seconds between pointing at something and selecting it
  45543. */
  45544. timeToSelect?: number;
  45545. /**
  45546. * 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)
  45547. * If not disabled, the last picked point will be used to execute a pointer up event
  45548. * If disabled, pointer up event will be triggered right after the pointer down event.
  45549. * Used in screen and gaze target ray mode only
  45550. */
  45551. disablePointerUpOnTouchOut: boolean;
  45552. /**
  45553. * For gaze mode (time to select instead of press)
  45554. */
  45555. forceGazeMode: boolean;
  45556. /**
  45557. * 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
  45558. * to start a new countdown to the pointer down event.
  45559. * Defaults to 1.
  45560. */
  45561. gazeModePointerMovedFactor?: number;
  45562. }
  45563. /**
  45564. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45565. */
  45566. export class WebXRControllerPointerSelection extends WebXRAbstractFeature implements IWebXRFeature {
  45567. private readonly _options;
  45568. /**
  45569. * The module's name
  45570. */
  45571. static readonly Name: string;
  45572. /**
  45573. * The (Babylon) version of this module.
  45574. * This is an integer representing the implementation version.
  45575. * This number does not correspond to the webxr specs version
  45576. */
  45577. static readonly Version: number;
  45578. /**
  45579. * This color will be set to the laser pointer when selection is triggered
  45580. */
  45581. laserPointerPickedColor: Color3;
  45582. /**
  45583. * This color will be applied to the selection ring when selection is triggered
  45584. */
  45585. selectionMeshPickedColor: Color3;
  45586. /**
  45587. * default color of the selection ring
  45588. */
  45589. selectionMeshDefaultColor: Color3;
  45590. /**
  45591. * Default color of the laser pointer
  45592. */
  45593. lasterPointerDefaultColor: Color3;
  45594. /**
  45595. * Should the laser pointer be displayed
  45596. */
  45597. displayLaserPointer: boolean;
  45598. /**
  45599. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45600. */
  45601. displaySelectionMesh: boolean;
  45602. /**
  45603. * Disable lighting on the laser pointer (so it will always be visible)
  45604. */
  45605. disablePointerLighting: boolean;
  45606. /**
  45607. * Disable lighting on the selection mesh (so it will always be visible)
  45608. */
  45609. disableSelectionMeshLighting: boolean;
  45610. private static _idCounter;
  45611. private _tmpRay;
  45612. private _controllers;
  45613. private _scene;
  45614. /**
  45615. * constructs a new background remover module
  45616. * @param _xrSessionManager the session manager for this module
  45617. * @param _options read-only options to be used in this module
  45618. */
  45619. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45620. /**
  45621. * attach this feature
  45622. * Will usually be called by the features manager
  45623. *
  45624. * @returns true if successful.
  45625. */
  45626. attach(): boolean;
  45627. /**
  45628. * detach this feature.
  45629. * Will usually be called by the features manager
  45630. *
  45631. * @returns true if successful.
  45632. */
  45633. detach(): boolean;
  45634. /**
  45635. * Get the xr controller that correlates to the pointer id in the pointer event
  45636. *
  45637. * @param id the pointer id to search for
  45638. * @returns the controller that correlates to this id or null if not found
  45639. */
  45640. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  45641. protected _onXRFrame(_xrFrame: XRFrame): void;
  45642. private _attachController;
  45643. private _attachScreenRayMode;
  45644. private _attachGazeMode;
  45645. private _tmpVectorForPickCompare;
  45646. private _pickingMoved;
  45647. private _attachTrackedPointerRayMode;
  45648. private _detachController;
  45649. private _generateNewMeshPair;
  45650. private _convertNormalToDirectionOfRay;
  45651. private _updatePointerDistance;
  45652. }
  45653. }
  45654. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45655. import { Nullable } from "babylonjs/types";
  45656. import { Observable } from "babylonjs/Misc/observable";
  45657. import { IDisposable, Scene } from "babylonjs/scene";
  45658. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45659. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45660. /**
  45661. * Button which can be used to enter a different mode of XR
  45662. */
  45663. export class WebXREnterExitUIButton {
  45664. /** button element */
  45665. element: HTMLElement;
  45666. /** XR initialization options for the button */
  45667. sessionMode: XRSessionMode;
  45668. /** Reference space type */
  45669. referenceSpaceType: XRReferenceSpaceType;
  45670. /**
  45671. * Creates a WebXREnterExitUIButton
  45672. * @param element button element
  45673. * @param sessionMode XR initialization session mode
  45674. * @param referenceSpaceType the type of reference space to be used
  45675. */
  45676. constructor(
  45677. /** button element */
  45678. element: HTMLElement,
  45679. /** XR initialization options for the button */
  45680. sessionMode: XRSessionMode,
  45681. /** Reference space type */
  45682. referenceSpaceType: XRReferenceSpaceType);
  45683. /**
  45684. * Overwritable function which can be used to update the button's visuals when the state changes
  45685. * @param activeButton the current active button in the UI
  45686. */
  45687. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45688. }
  45689. /**
  45690. * Options to create the webXR UI
  45691. */
  45692. export class WebXREnterExitUIOptions {
  45693. /**
  45694. * Context to enter xr with
  45695. */
  45696. renderTarget?: Nullable<WebXRRenderTarget>;
  45697. /**
  45698. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45699. */
  45700. customButtons?: Array<WebXREnterExitUIButton>;
  45701. /**
  45702. * A session mode to use when creating the default button.
  45703. * Default is immersive-vr
  45704. */
  45705. sessionMode?: XRSessionMode;
  45706. /**
  45707. * A reference space type to use when creating the default button.
  45708. * Default is local-floor
  45709. */
  45710. referenceSpaceType?: XRReferenceSpaceType;
  45711. }
  45712. /**
  45713. * UI to allow the user to enter/exit XR mode
  45714. */
  45715. export class WebXREnterExitUI implements IDisposable {
  45716. private scene;
  45717. /** version of the options passed to this UI */
  45718. options: WebXREnterExitUIOptions;
  45719. private _overlay;
  45720. private _buttons;
  45721. private _activeButton;
  45722. /**
  45723. * Fired every time the active button is changed.
  45724. *
  45725. * When xr is entered via a button that launches xr that button will be the callback parameter
  45726. *
  45727. * When exiting xr the callback parameter will be null)
  45728. */
  45729. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45730. /**
  45731. * Creates UI to allow the user to enter/exit XR mode
  45732. * @param scene the scene to add the ui to
  45733. * @param helper the xr experience helper to enter/exit xr with
  45734. * @param options options to configure the UI
  45735. * @returns the created ui
  45736. */
  45737. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45738. /**
  45739. *
  45740. * @param scene babylon scene object to use
  45741. * @param options (read-only) version of the options passed to this UI
  45742. */
  45743. private constructor();
  45744. private _updateButtons;
  45745. /**
  45746. * Disposes of the object
  45747. */
  45748. dispose(): void;
  45749. }
  45750. }
  45751. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45752. import { Vector3 } from "babylonjs/Maths/math.vector";
  45753. import { Color4 } from "babylonjs/Maths/math.color";
  45754. import { Nullable } from "babylonjs/types";
  45755. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45756. import { Scene } from "babylonjs/scene";
  45757. /**
  45758. * Class containing static functions to help procedurally build meshes
  45759. */
  45760. export class LinesBuilder {
  45761. /**
  45762. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45763. * * 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
  45764. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45765. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45766. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45767. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45768. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45769. * * 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
  45770. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45773. * @param name defines the name of the new line system
  45774. * @param options defines the options used to create the line system
  45775. * @param scene defines the hosting scene
  45776. * @returns a new line system mesh
  45777. */
  45778. static CreateLineSystem(name: string, options: {
  45779. lines: Vector3[][];
  45780. updatable?: boolean;
  45781. instance?: Nullable<LinesMesh>;
  45782. colors?: Nullable<Color4[][]>;
  45783. useVertexAlpha?: boolean;
  45784. }, scene: Nullable<Scene>): LinesMesh;
  45785. /**
  45786. * Creates a line mesh
  45787. * 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
  45788. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45789. * * The parameter `points` is an array successive Vector3
  45790. * * 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
  45791. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45792. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45793. * * When updating an instance, remember that only point positions can change, not the number of points
  45794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45796. * @param name defines the name of the new line system
  45797. * @param options defines the options used to create the line system
  45798. * @param scene defines the hosting scene
  45799. * @returns a new line mesh
  45800. */
  45801. static CreateLines(name: string, options: {
  45802. points: Vector3[];
  45803. updatable?: boolean;
  45804. instance?: Nullable<LinesMesh>;
  45805. colors?: Color4[];
  45806. useVertexAlpha?: boolean;
  45807. }, scene?: Nullable<Scene>): LinesMesh;
  45808. /**
  45809. * Creates a dashed line mesh
  45810. * * 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
  45811. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45812. * * The parameter `points` is an array successive Vector3
  45813. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45814. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45815. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45816. * * 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
  45817. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45818. * * When updating an instance, remember that only point positions can change, not the number of points
  45819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45820. * @param name defines the name of the mesh
  45821. * @param options defines the options used to create the mesh
  45822. * @param scene defines the hosting scene
  45823. * @returns the dashed line mesh
  45824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45825. */
  45826. static CreateDashedLines(name: string, options: {
  45827. points: Vector3[];
  45828. dashSize?: number;
  45829. gapSize?: number;
  45830. dashNb?: number;
  45831. updatable?: boolean;
  45832. instance?: LinesMesh;
  45833. useVertexAlpha?: boolean;
  45834. }, scene?: Nullable<Scene>): LinesMesh;
  45835. }
  45836. }
  45837. declare module "babylonjs/Cameras/XR/features/WebXRControllerTeleportation" {
  45838. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45839. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45840. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45842. import { Material } from "babylonjs/Materials/material";
  45843. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  45844. /**
  45845. * The options container for the teleportation module
  45846. */
  45847. export interface IWebXRTeleportationOptions {
  45848. /**
  45849. * Babylon XR Input class for controller
  45850. */
  45851. xrInput: WebXRInput;
  45852. /**
  45853. * A list of meshes to use as floor meshes.
  45854. * Meshes can be added and removed after initializing the feature using the
  45855. * addFloorMesh and removeFloorMesh functions
  45856. * If empty, rotation will still work
  45857. */
  45858. floorMeshes?: AbstractMesh[];
  45859. /**
  45860. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45861. * If you want to support rotation, make sure your mesh has a direction indicator.
  45862. *
  45863. * When left untouched, the default mesh will be initialized.
  45864. */
  45865. teleportationTargetMesh?: AbstractMesh;
  45866. /**
  45867. * Values to configure the default target mesh
  45868. */
  45869. defaultTargetMeshOptions?: {
  45870. /**
  45871. * Fill color of the teleportation area
  45872. */
  45873. teleportationFillColor?: string;
  45874. /**
  45875. * Border color for the teleportation area
  45876. */
  45877. teleportationBorderColor?: string;
  45878. /**
  45879. * Override the default material of the torus and arrow
  45880. */
  45881. torusArrowMaterial?: Material;
  45882. /**
  45883. * Disable the mesh's animation sequence
  45884. */
  45885. disableAnimation?: boolean;
  45886. };
  45887. /**
  45888. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  45889. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  45890. */
  45891. useMainComponentOnly?: boolean;
  45892. /**
  45893. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  45894. */
  45895. timeToTeleport?: number;
  45896. }
  45897. /**
  45898. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  45899. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  45900. * the input of the attached controllers.
  45901. */
  45902. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature implements IWebXRFeature {
  45903. private _options;
  45904. /**
  45905. * The module's name
  45906. */
  45907. static readonly Name: string;
  45908. /**
  45909. * The (Babylon) version of this module.
  45910. * This is an integer representing the implementation version.
  45911. * This number does not correspond to the webxr specs version
  45912. */
  45913. static readonly Version: number;
  45914. /**
  45915. * Is rotation enabled when moving forward?
  45916. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45917. */
  45918. rotationEnabled: boolean;
  45919. /**
  45920. * Should the module support parabolic ray on top of direct ray
  45921. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45922. * Very helpful when moving between floors / different heights
  45923. */
  45924. parabolicRayEnabled: boolean;
  45925. /**
  45926. * The distance from the user to the inspection point in the direction of the controller
  45927. * A higher number will allow the user to move further
  45928. * defaults to 5 (meters, in xr units)
  45929. */
  45930. parabolicCheckRadius: number;
  45931. /**
  45932. * How much rotation should be applied when rotating right and left
  45933. */
  45934. rotationAngle: number;
  45935. /**
  45936. * Distance to travel when moving backwards
  45937. */
  45938. backwardsTeleportationDistance: number;
  45939. /**
  45940. * Add a new mesh to the floor meshes array
  45941. * @param mesh the mesh to use as floor mesh
  45942. */
  45943. addFloorMesh(mesh: AbstractMesh): void;
  45944. /**
  45945. * Remove a mesh from the floor meshes array
  45946. * @param mesh the mesh to remove
  45947. */
  45948. removeFloorMesh(mesh: AbstractMesh): void;
  45949. /**
  45950. * Remove a mesh from the floor meshes array using its name
  45951. * @param name the mesh name to remove
  45952. */
  45953. removeFloorMeshByName(name: string): void;
  45954. private _tmpRay;
  45955. private _tmpVector;
  45956. private _floorMeshes;
  45957. private _controllers;
  45958. /**
  45959. * constructs a new anchor system
  45960. * @param _xrSessionManager an instance of WebXRSessionManager
  45961. * @param _options configuration object for this feature
  45962. */
  45963. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45964. private _selectionFeature;
  45965. /**
  45966. * This function sets a selection feature that will be disabled when
  45967. * the forward ray is shown and will be reattached when hidden.
  45968. * This is used to remove the selection rays when moving.
  45969. * @param selectionFeature the feature to disable when forward movement is enabled
  45970. */
  45971. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45972. attach(): boolean;
  45973. detach(): boolean;
  45974. dispose(): void;
  45975. protected _onXRFrame(_xrFrame: XRFrame): void;
  45976. private _currentTeleportationControllerId;
  45977. private _attachController;
  45978. private _teleportForward;
  45979. private _detachController;
  45980. private createDefaultTargetMesh;
  45981. private setTargetMeshVisibility;
  45982. private setTargetMeshPosition;
  45983. private _quadraticBezierCurve;
  45984. private showParabolicPath;
  45985. }
  45986. }
  45987. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45988. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45989. import { Scene } from "babylonjs/scene";
  45990. import { WebXRInput, IWebXRInputOptions } from "babylonjs/Cameras/XR/webXRInput";
  45991. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection";
  45992. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45993. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45995. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45996. import { WebXRMotionControllerTeleportation } from "babylonjs/Cameras/XR/features/WebXRControllerTeleportation";
  45997. /**
  45998. * Options for the default xr helper
  45999. */
  46000. export class WebXRDefaultExperienceOptions {
  46001. /**
  46002. * Floor meshes that will be used for teleporting
  46003. */
  46004. floorMeshes?: Array<AbstractMesh>;
  46005. /**
  46006. * Enable or disable default UI to enter XR
  46007. */
  46008. disableDefaultUI?: boolean;
  46009. /**
  46010. * optional configuration for the output canvas
  46011. */
  46012. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46013. /**
  46014. * optional UI options. This can be used among other to change session mode and reference space type
  46015. */
  46016. uiOptions?: WebXREnterExitUIOptions;
  46017. /**
  46018. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46019. */
  46020. inputOptions?: IWebXRInputOptions;
  46021. /**
  46022. * Should teleportation not initialize. defaults to false.
  46023. */
  46024. disableTeleportation?: boolean;
  46025. }
  46026. /**
  46027. * Default experience which provides a similar setup to the previous webVRExperience
  46028. */
  46029. export class WebXRDefaultExperience {
  46030. /**
  46031. * Base experience
  46032. */
  46033. baseExperience: WebXRExperienceHelper;
  46034. /**
  46035. * Input experience extension
  46036. */
  46037. input: WebXRInput;
  46038. /**
  46039. * Enables laser pointer and selection
  46040. */
  46041. pointerSelection: WebXRControllerPointerSelection;
  46042. /**
  46043. * Enables teleportation
  46044. */
  46045. teleportation: WebXRMotionControllerTeleportation;
  46046. /**
  46047. * Enables ui for entering/exiting xr
  46048. */
  46049. enterExitUI: WebXREnterExitUI;
  46050. /**
  46051. * Default target xr should render to
  46052. */
  46053. renderTarget: WebXRRenderTarget;
  46054. /**
  46055. * Creates the default xr experience
  46056. * @param scene scene
  46057. * @param options options for basic configuration
  46058. * @returns resulting WebXRDefaultExperience
  46059. */
  46060. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46061. private constructor();
  46062. /**
  46063. * DIsposes of the experience helper
  46064. */
  46065. dispose(): void;
  46066. }
  46067. }
  46068. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46069. import { Observable } from "babylonjs/Misc/observable";
  46070. import { Nullable } from "babylonjs/types";
  46071. import { Camera } from "babylonjs/Cameras/camera";
  46072. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46073. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46074. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46075. import { Scene } from "babylonjs/scene";
  46076. import { Vector3 } from "babylonjs/Maths/math.vector";
  46077. import { Color3 } from "babylonjs/Maths/math.color";
  46078. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46080. import { Mesh } from "babylonjs/Meshes/mesh";
  46081. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46082. import { EasingFunction } from "babylonjs/Animations/easing";
  46083. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46084. import "babylonjs/Meshes/Builders/groundBuilder";
  46085. import "babylonjs/Meshes/Builders/torusBuilder";
  46086. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46087. import "babylonjs/Gamepads/gamepadSceneComponent";
  46088. import "babylonjs/Animations/animatable";
  46089. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46090. /**
  46091. * Options to modify the vr teleportation behavior.
  46092. */
  46093. export interface VRTeleportationOptions {
  46094. /**
  46095. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46096. */
  46097. floorMeshName?: string;
  46098. /**
  46099. * A list of meshes to be used as the teleportation floor. (default: empty)
  46100. */
  46101. floorMeshes?: Mesh[];
  46102. /**
  46103. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46104. */
  46105. teleportationMode?: number;
  46106. /**
  46107. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46108. */
  46109. teleportationTime?: number;
  46110. /**
  46111. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46112. */
  46113. teleportationSpeed?: number;
  46114. /**
  46115. * The easing function used in the animation or null for Linear. (default CircleEase)
  46116. */
  46117. easingFunction?: EasingFunction;
  46118. }
  46119. /**
  46120. * Options to modify the vr experience helper's behavior.
  46121. */
  46122. export interface VRExperienceHelperOptions extends WebVROptions {
  46123. /**
  46124. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46125. */
  46126. createDeviceOrientationCamera?: boolean;
  46127. /**
  46128. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46129. */
  46130. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46131. /**
  46132. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46133. */
  46134. laserToggle?: boolean;
  46135. /**
  46136. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46137. */
  46138. floorMeshes?: Mesh[];
  46139. /**
  46140. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46141. */
  46142. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46143. /**
  46144. * Defines if WebXR should be used instead of WebVR (if available)
  46145. */
  46146. useXR?: boolean;
  46147. }
  46148. /**
  46149. * Event containing information after VR has been entered
  46150. */
  46151. export class OnAfterEnteringVRObservableEvent {
  46152. /**
  46153. * If entering vr was successful
  46154. */
  46155. success: boolean;
  46156. }
  46157. /**
  46158. * Helps to quickly add VR support to an existing scene.
  46159. * See http://doc.babylonjs.com/how_to/webvr_helper
  46160. */
  46161. export class VRExperienceHelper {
  46162. /** Options to modify the vr experience helper's behavior. */
  46163. webVROptions: VRExperienceHelperOptions;
  46164. private _scene;
  46165. private _position;
  46166. private _btnVR;
  46167. private _btnVRDisplayed;
  46168. private _webVRsupported;
  46169. private _webVRready;
  46170. private _webVRrequesting;
  46171. private _webVRpresenting;
  46172. private _hasEnteredVR;
  46173. private _fullscreenVRpresenting;
  46174. private _inputElement;
  46175. private _webVRCamera;
  46176. private _vrDeviceOrientationCamera;
  46177. private _deviceOrientationCamera;
  46178. private _existingCamera;
  46179. private _onKeyDown;
  46180. private _onVrDisplayPresentChange;
  46181. private _onVRDisplayChanged;
  46182. private _onVRRequestPresentStart;
  46183. private _onVRRequestPresentComplete;
  46184. /**
  46185. * 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)
  46186. */
  46187. enableGazeEvenWhenNoPointerLock: boolean;
  46188. /**
  46189. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46190. */
  46191. exitVROnDoubleTap: boolean;
  46192. /**
  46193. * Observable raised right before entering VR.
  46194. */
  46195. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46196. /**
  46197. * Observable raised when entering VR has completed.
  46198. */
  46199. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46200. /**
  46201. * Observable raised when exiting VR.
  46202. */
  46203. onExitingVRObservable: Observable<VRExperienceHelper>;
  46204. /**
  46205. * Observable raised when controller mesh is loaded.
  46206. */
  46207. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46208. /** Return this.onEnteringVRObservable
  46209. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46210. */
  46211. get onEnteringVR(): Observable<VRExperienceHelper>;
  46212. /** Return this.onExitingVRObservable
  46213. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46214. */
  46215. get onExitingVR(): Observable<VRExperienceHelper>;
  46216. /** Return this.onControllerMeshLoadedObservable
  46217. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46218. */
  46219. get onControllerMeshLoaded(): Observable<WebVRController>;
  46220. private _rayLength;
  46221. private _useCustomVRButton;
  46222. private _teleportationRequested;
  46223. private _teleportActive;
  46224. private _floorMeshName;
  46225. private _floorMeshesCollection;
  46226. private _teleportationMode;
  46227. private _teleportationTime;
  46228. private _teleportationSpeed;
  46229. private _teleportationEasing;
  46230. private _rotationAllowed;
  46231. private _teleportBackwardsVector;
  46232. private _teleportationTarget;
  46233. private _isDefaultTeleportationTarget;
  46234. private _postProcessMove;
  46235. private _teleportationFillColor;
  46236. private _teleportationBorderColor;
  46237. private _rotationAngle;
  46238. private _haloCenter;
  46239. private _cameraGazer;
  46240. private _padSensibilityUp;
  46241. private _padSensibilityDown;
  46242. private _leftController;
  46243. private _rightController;
  46244. private _gazeColor;
  46245. private _laserColor;
  46246. private _pickedLaserColor;
  46247. private _pickedGazeColor;
  46248. /**
  46249. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46250. */
  46251. onNewMeshSelected: Observable<AbstractMesh>;
  46252. /**
  46253. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46254. * This observable will provide the mesh and the controller used to select the mesh
  46255. */
  46256. onMeshSelectedWithController: Observable<{
  46257. mesh: AbstractMesh;
  46258. controller: WebVRController;
  46259. }>;
  46260. /**
  46261. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46262. */
  46263. onNewMeshPicked: Observable<PickingInfo>;
  46264. private _circleEase;
  46265. /**
  46266. * Observable raised before camera teleportation
  46267. */
  46268. onBeforeCameraTeleport: Observable<Vector3>;
  46269. /**
  46270. * Observable raised after camera teleportation
  46271. */
  46272. onAfterCameraTeleport: Observable<Vector3>;
  46273. /**
  46274. * Observable raised when current selected mesh gets unselected
  46275. */
  46276. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46277. private _raySelectionPredicate;
  46278. /**
  46279. * To be optionaly changed by user to define custom ray selection
  46280. */
  46281. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46282. /**
  46283. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46284. */
  46285. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46286. /**
  46287. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46288. */
  46289. teleportationEnabled: boolean;
  46290. private _defaultHeight;
  46291. private _teleportationInitialized;
  46292. private _interactionsEnabled;
  46293. private _interactionsRequested;
  46294. private _displayGaze;
  46295. private _displayLaserPointer;
  46296. /**
  46297. * The mesh used to display where the user is going to teleport.
  46298. */
  46299. get teleportationTarget(): Mesh;
  46300. /**
  46301. * Sets the mesh to be used to display where the user is going to teleport.
  46302. */
  46303. set teleportationTarget(value: Mesh);
  46304. /**
  46305. * 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
  46306. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46307. * See http://doc.babylonjs.com/resources/baking_transformations
  46308. */
  46309. get gazeTrackerMesh(): Mesh;
  46310. set gazeTrackerMesh(value: Mesh);
  46311. /**
  46312. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46313. */
  46314. updateGazeTrackerScale: boolean;
  46315. /**
  46316. * If the gaze trackers color should be updated when selecting meshes
  46317. */
  46318. updateGazeTrackerColor: boolean;
  46319. /**
  46320. * If the controller laser color should be updated when selecting meshes
  46321. */
  46322. updateControllerLaserColor: boolean;
  46323. /**
  46324. * The gaze tracking mesh corresponding to the left controller
  46325. */
  46326. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46327. /**
  46328. * The gaze tracking mesh corresponding to the right controller
  46329. */
  46330. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46331. /**
  46332. * If the ray of the gaze should be displayed.
  46333. */
  46334. get displayGaze(): boolean;
  46335. /**
  46336. * Sets if the ray of the gaze should be displayed.
  46337. */
  46338. set displayGaze(value: boolean);
  46339. /**
  46340. * If the ray of the LaserPointer should be displayed.
  46341. */
  46342. get displayLaserPointer(): boolean;
  46343. /**
  46344. * Sets if the ray of the LaserPointer should be displayed.
  46345. */
  46346. set displayLaserPointer(value: boolean);
  46347. /**
  46348. * The deviceOrientationCamera used as the camera when not in VR.
  46349. */
  46350. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46351. /**
  46352. * Based on the current WebVR support, returns the current VR camera used.
  46353. */
  46354. get currentVRCamera(): Nullable<Camera>;
  46355. /**
  46356. * The webVRCamera which is used when in VR.
  46357. */
  46358. get webVRCamera(): WebVRFreeCamera;
  46359. /**
  46360. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46361. */
  46362. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46363. /**
  46364. * The html button that is used to trigger entering into VR.
  46365. */
  46366. get vrButton(): Nullable<HTMLButtonElement>;
  46367. private get _teleportationRequestInitiated();
  46368. /**
  46369. * Defines wether or not Pointer lock should be requested when switching to
  46370. * full screen.
  46371. */
  46372. requestPointerLockOnFullScreen: boolean;
  46373. /**
  46374. * If asking to force XR, this will be populated with the default xr experience
  46375. */
  46376. xr: WebXRDefaultExperience;
  46377. /**
  46378. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46379. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46380. */
  46381. xrTestDone: boolean;
  46382. /**
  46383. * Instantiates a VRExperienceHelper.
  46384. * Helps to quickly add VR support to an existing scene.
  46385. * @param scene The scene the VRExperienceHelper belongs to.
  46386. * @param webVROptions Options to modify the vr experience helper's behavior.
  46387. */
  46388. constructor(scene: Scene,
  46389. /** Options to modify the vr experience helper's behavior. */
  46390. webVROptions?: VRExperienceHelperOptions);
  46391. private completeVRInit;
  46392. private _onDefaultMeshLoaded;
  46393. private _onResize;
  46394. private _onFullscreenChange;
  46395. /**
  46396. * Gets a value indicating if we are currently in VR mode.
  46397. */
  46398. get isInVRMode(): boolean;
  46399. private onVrDisplayPresentChange;
  46400. private onVRDisplayChanged;
  46401. private moveButtonToBottomRight;
  46402. private displayVRButton;
  46403. private updateButtonVisibility;
  46404. private _cachedAngularSensibility;
  46405. /**
  46406. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46407. * Otherwise, will use the fullscreen API.
  46408. */
  46409. enterVR(): void;
  46410. /**
  46411. * Attempt to exit VR, or fullscreen.
  46412. */
  46413. exitVR(): void;
  46414. /**
  46415. * The position of the vr experience helper.
  46416. */
  46417. get position(): Vector3;
  46418. /**
  46419. * Sets the position of the vr experience helper.
  46420. */
  46421. set position(value: Vector3);
  46422. /**
  46423. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46424. */
  46425. enableInteractions(): void;
  46426. private get _noControllerIsActive();
  46427. private beforeRender;
  46428. private _isTeleportationFloor;
  46429. /**
  46430. * Adds a floor mesh to be used for teleportation.
  46431. * @param floorMesh the mesh to be used for teleportation.
  46432. */
  46433. addFloorMesh(floorMesh: Mesh): void;
  46434. /**
  46435. * Removes a floor mesh from being used for teleportation.
  46436. * @param floorMesh the mesh to be removed.
  46437. */
  46438. removeFloorMesh(floorMesh: Mesh): void;
  46439. /**
  46440. * Enables interactions and teleportation using the VR controllers and gaze.
  46441. * @param vrTeleportationOptions options to modify teleportation behavior.
  46442. */
  46443. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46444. private _onNewGamepadConnected;
  46445. private _tryEnableInteractionOnController;
  46446. private _onNewGamepadDisconnected;
  46447. private _enableInteractionOnController;
  46448. private _checkTeleportWithRay;
  46449. private _checkRotate;
  46450. private _checkTeleportBackwards;
  46451. private _enableTeleportationOnController;
  46452. private _createTeleportationCircles;
  46453. private _displayTeleportationTarget;
  46454. private _hideTeleportationTarget;
  46455. private _rotateCamera;
  46456. private _moveTeleportationSelectorTo;
  46457. private _workingVector;
  46458. private _workingQuaternion;
  46459. private _workingMatrix;
  46460. /**
  46461. * Time Constant Teleportation Mode
  46462. */
  46463. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46464. /**
  46465. * Speed Constant Teleportation Mode
  46466. */
  46467. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46468. /**
  46469. * Teleports the users feet to the desired location
  46470. * @param location The location where the user's feet should be placed
  46471. */
  46472. teleportCamera(location: Vector3): void;
  46473. private _convertNormalToDirectionOfRay;
  46474. private _castRayAndSelectObject;
  46475. private _notifySelectedMeshUnselected;
  46476. /**
  46477. * Permanently set new colors for the laser pointer
  46478. * @param color the new laser color
  46479. * @param pickedColor the new laser color when picked mesh detected
  46480. */
  46481. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46482. /**
  46483. * Set lighting enabled / disabled on the laser pointer of both controllers
  46484. * @param enabled should the lighting be enabled on the laser pointer
  46485. */
  46486. setLaserLightingState(enabled?: boolean): void;
  46487. /**
  46488. * Permanently set new colors for the gaze pointer
  46489. * @param color the new gaze color
  46490. * @param pickedColor the new gaze color when picked mesh detected
  46491. */
  46492. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46493. /**
  46494. * Sets the color of the laser ray from the vr controllers.
  46495. * @param color new color for the ray.
  46496. */
  46497. changeLaserColor(color: Color3): void;
  46498. /**
  46499. * Sets the color of the ray from the vr headsets gaze.
  46500. * @param color new color for the ray.
  46501. */
  46502. changeGazeColor(color: Color3): void;
  46503. /**
  46504. * Exits VR and disposes of the vr experience helper
  46505. */
  46506. dispose(): void;
  46507. /**
  46508. * Gets the name of the VRExperienceHelper class
  46509. * @returns "VRExperienceHelper"
  46510. */
  46511. getClassName(): string;
  46512. }
  46513. }
  46514. declare module "babylonjs/Cameras/VR/index" {
  46515. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  46516. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  46517. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46518. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  46519. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  46520. export * from "babylonjs/Cameras/VR/webVRCamera";
  46521. }
  46522. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  46523. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46524. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46525. import { Observable } from "babylonjs/Misc/observable";
  46526. import { Matrix } from "babylonjs/Maths/math.vector";
  46527. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46528. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46529. /**
  46530. * Options used for hit testing
  46531. */
  46532. export interface IWebXRHitTestOptions {
  46533. /**
  46534. * Only test when user interacted with the scene. Default - hit test every frame
  46535. */
  46536. testOnPointerDownOnly?: boolean;
  46537. /**
  46538. * The node to use to transform the local results to world coordinates
  46539. */
  46540. worldParentNode?: TransformNode;
  46541. }
  46542. /**
  46543. * Interface defining the babylon result of raycasting/hit-test
  46544. */
  46545. export interface IWebXRHitResult {
  46546. /**
  46547. * The native hit test result
  46548. */
  46549. xrHitResult: XRHitResult;
  46550. /**
  46551. * Transformation matrix that can be applied to a node that will put it in the hit point location
  46552. */
  46553. transformationMatrix: Matrix;
  46554. }
  46555. /**
  46556. * The currently-working hit-test module.
  46557. * Hit test (or raycasting) is used to interact with the real world.
  46558. * For further information read here - https://github.com/immersive-web/hit-test
  46559. */
  46560. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRFeature {
  46561. /**
  46562. * options to use when constructing this feature
  46563. */
  46564. readonly options: IWebXRHitTestOptions;
  46565. /**
  46566. * The module's name
  46567. */
  46568. static readonly Name: string;
  46569. /**
  46570. * The (Babylon) version of this module.
  46571. * This is an integer representing the implementation version.
  46572. * This number does not correspond to the webxr specs version
  46573. */
  46574. static readonly Version: number;
  46575. /**
  46576. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  46577. * @param event the (select) event to use to select with
  46578. * @param referenceSpace the reference space to use for this hit test
  46579. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46580. */
  46581. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  46582. /**
  46583. * execute a hit test with an XR Ray
  46584. *
  46585. * @param xrSession a native xrSession that will execute this hit test
  46586. * @param xrRay the ray (position and direction) to use for raycasting
  46587. * @param referenceSpace native XR reference space to use for the hit-test
  46588. * @param filter filter function that will filter the results
  46589. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46590. */
  46591. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  46592. /**
  46593. * Triggered when new babylon (transformed) hit test results are available
  46594. */
  46595. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  46596. private _onSelectEnabled;
  46597. /**
  46598. * Creates a new instance of the (legacy version) hit test feature
  46599. * @param _xrSessionManager an instance of WebXRSessionManager
  46600. * @param options options to use when constructing this feature
  46601. */
  46602. constructor(_xrSessionManager: WebXRSessionManager,
  46603. /**
  46604. * options to use when constructing this feature
  46605. */
  46606. options?: IWebXRHitTestOptions);
  46607. /**
  46608. * Populated with the last native XR Hit Results
  46609. */
  46610. lastNativeXRHitResults: XRHitResult[];
  46611. /**
  46612. * attach this feature
  46613. * Will usually be called by the features manager
  46614. *
  46615. * @returns true if successful.
  46616. */
  46617. attach(): boolean;
  46618. /**
  46619. * detach this feature.
  46620. * Will usually be called by the features manager
  46621. *
  46622. * @returns true if successful.
  46623. */
  46624. detach(): boolean;
  46625. private _onHitTestResults;
  46626. private _origin;
  46627. private _direction;
  46628. private _mat;
  46629. protected _onXRFrame(frame: XRFrame): void;
  46630. private _onSelect;
  46631. /**
  46632. * Dispose this feature and all of the resources attached
  46633. */
  46634. dispose(): void;
  46635. }
  46636. }
  46637. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  46638. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46639. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46640. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46641. import { Observable } from "babylonjs/Misc/observable";
  46642. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  46643. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46644. /**
  46645. * Options used in the plane detector module
  46646. */
  46647. export interface IWebXRPlaneDetectorOptions {
  46648. /**
  46649. * The node to use to transform the local results to world coordinates
  46650. */
  46651. worldParentNode?: TransformNode;
  46652. }
  46653. /**
  46654. * A babylon interface for a webxr plane.
  46655. * A Plane is actually a polygon, built from N points in space
  46656. */
  46657. export interface IWebXRPlane {
  46658. /**
  46659. * a babylon-assigned ID for this polygon
  46660. */
  46661. id: number;
  46662. /**
  46663. * the native xr-plane object
  46664. */
  46665. xrPlane: XRPlane;
  46666. /**
  46667. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  46668. */
  46669. polygonDefinition: Array<Vector3>;
  46670. /**
  46671. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  46672. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  46673. */
  46674. transformationMatrix: Matrix;
  46675. }
  46676. /**
  46677. * The plane detector is used to detect planes in the real world when in AR
  46678. * For more information see https://github.com/immersive-web/real-world-geometry/
  46679. */
  46680. export class WebXRPlaneDetector extends WebXRAbstractFeature implements IWebXRFeature {
  46681. private _options;
  46682. /**
  46683. * The module's name
  46684. */
  46685. static readonly Name: string;
  46686. /**
  46687. * The (Babylon) version of this module.
  46688. * This is an integer representing the implementation version.
  46689. * This number does not correspond to the webxr specs version
  46690. */
  46691. static readonly Version: number;
  46692. /**
  46693. * Observers registered here will be executed when a new plane was added to the session
  46694. */
  46695. onPlaneAddedObservable: Observable<IWebXRPlane>;
  46696. /**
  46697. * Observers registered here will be executed when a plane is no longer detected in the session
  46698. */
  46699. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  46700. /**
  46701. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  46702. * This can execute N times every frame
  46703. */
  46704. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  46705. private _enabled;
  46706. private _detectedPlanes;
  46707. private _lastFrameDetected;
  46708. /**
  46709. * construct a new Plane Detector
  46710. * @param _xrSessionManager an instance of xr Session manager
  46711. * @param _options configuration to use when constructing this feature
  46712. */
  46713. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  46714. protected _onXRFrame(frame: XRFrame): void;
  46715. /**
  46716. * Dispose this feature and all of the resources attached
  46717. */
  46718. dispose(): void;
  46719. private _updatePlaneWithXRPlane;
  46720. /**
  46721. * avoiding using Array.find for global support.
  46722. * @param xrPlane the plane to find in the array
  46723. */
  46724. private findIndexInPlaneArray;
  46725. }
  46726. }
  46727. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  46728. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46729. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46730. import { Observable } from "babylonjs/Misc/observable";
  46731. import { Matrix } from "babylonjs/Maths/math.vector";
  46732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46733. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46734. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46735. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46736. /**
  46737. * Configuration options of the anchor system
  46738. */
  46739. export interface IWebXRAnchorSystemOptions {
  46740. /**
  46741. * a node that will be used to convert local to world coordinates
  46742. */
  46743. worldParentNode?: TransformNode;
  46744. /**
  46745. * should the anchor system use plane detection.
  46746. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46747. */
  46748. usePlaneDetection?: boolean;
  46749. /**
  46750. * Should a new anchor be added every time a select event is triggered
  46751. */
  46752. addAnchorOnSelect?: boolean;
  46753. }
  46754. /**
  46755. * A babylon container for an XR Anchor
  46756. */
  46757. export interface IWebXRAnchor {
  46758. /**
  46759. * A babylon-assigned ID for this anchor
  46760. */
  46761. id: number;
  46762. /**
  46763. * The native anchor object
  46764. */
  46765. xrAnchor: XRAnchor;
  46766. /**
  46767. * Transformation matrix to apply to an object attached to this anchor
  46768. */
  46769. transformationMatrix: Matrix;
  46770. }
  46771. /**
  46772. * An implementation of the anchor system of WebXR.
  46773. * Note that the current documented implementation is not available in any browser. Future implementations
  46774. * will use the frame to create an anchor and not the session or a detected plane
  46775. * For further information see https://github.com/immersive-web/anchors/
  46776. */
  46777. export class WebXRAnchorSystem extends WebXRAbstractFeature implements IWebXRFeature {
  46778. private _options;
  46779. /**
  46780. * The module's name
  46781. */
  46782. static readonly Name: string;
  46783. /**
  46784. * The (Babylon) version of this module.
  46785. * This is an integer representing the implementation version.
  46786. * This number does not correspond to the webxr specs version
  46787. */
  46788. static readonly Version: number;
  46789. /**
  46790. * Observers registered here will be executed when a new anchor was added to the session
  46791. */
  46792. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46793. /**
  46794. * Observers registered here will be executed when an existing anchor updates
  46795. * This can execute N times every frame
  46796. */
  46797. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46798. /**
  46799. * Observers registered here will be executed when an anchor was removed from the session
  46800. */
  46801. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46802. private _planeDetector;
  46803. private _hitTestModule;
  46804. private _enabled;
  46805. private _trackedAnchors;
  46806. private _lastFrameDetected;
  46807. /**
  46808. * constructs a new anchor system
  46809. * @param _xrSessionManager an instance of WebXRSessionManager
  46810. * @param _options configuration object for this feature
  46811. */
  46812. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46813. /**
  46814. * set the plane detector to use in order to create anchors from frames
  46815. * @param planeDetector the plane-detector module to use
  46816. * @param enable enable plane-anchors. default is true
  46817. */
  46818. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46819. /**
  46820. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46821. * @param hitTestModule the hit-test module to use.
  46822. */
  46823. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46824. /**
  46825. * attach this feature
  46826. * Will usually be called by the features manager
  46827. *
  46828. * @returns true if successful.
  46829. */
  46830. attach(): boolean;
  46831. /**
  46832. * detach this feature.
  46833. * Will usually be called by the features manager
  46834. *
  46835. * @returns true if successful.
  46836. */
  46837. detach(): boolean;
  46838. /**
  46839. * Dispose this feature and all of the resources attached
  46840. */
  46841. dispose(): void;
  46842. protected _onXRFrame(frame: XRFrame): void;
  46843. private _onSelect;
  46844. /**
  46845. * Add anchor at a specific XR point.
  46846. *
  46847. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46848. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46849. * @returns a promise the fulfills when the anchor was created
  46850. */
  46851. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46852. private _updateAnchorWithXRFrame;
  46853. /**
  46854. * avoiding using Array.find for global support.
  46855. * @param xrAnchor the plane to find in the array
  46856. */
  46857. private _findIndexInAnchorArray;
  46858. }
  46859. }
  46860. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46861. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46862. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46864. import { Observable } from "babylonjs/Misc/observable";
  46865. import { WebXRAbstractFeature } from "babylonjs/Cameras/XR/features/WebXRAbstractFeature";
  46866. /**
  46867. * Options interface for the background remover plugin
  46868. */
  46869. export interface IWebXRBackgroundRemoverOptions {
  46870. /**
  46871. * don't disable the environment helper
  46872. */
  46873. ignoreEnvironmentHelper?: boolean;
  46874. /**
  46875. * flags to configure the removal of the environment helper.
  46876. * If not set, the entire background will be removed. If set, flags should be set as well.
  46877. */
  46878. environmentHelperRemovalFlags?: {
  46879. /**
  46880. * Should the skybox be removed (default false)
  46881. */
  46882. skyBox?: boolean;
  46883. /**
  46884. * Should the ground be removed (default false)
  46885. */
  46886. ground?: boolean;
  46887. };
  46888. /**
  46889. * Further background meshes to disable when entering AR
  46890. */
  46891. backgroundMeshes?: AbstractMesh[];
  46892. }
  46893. /**
  46894. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46895. */
  46896. export class WebXRBackgroundRemover extends WebXRAbstractFeature implements IWebXRFeature {
  46897. /**
  46898. * read-only options to be used in this module
  46899. */
  46900. readonly options: IWebXRBackgroundRemoverOptions;
  46901. /**
  46902. * The module's name
  46903. */
  46904. static readonly Name: string;
  46905. /**
  46906. * The (Babylon) version of this module.
  46907. * This is an integer representing the implementation version.
  46908. * This number does not correspond to the webxr specs version
  46909. */
  46910. static readonly Version: number;
  46911. /**
  46912. * registered observers will be triggered when the background state changes
  46913. */
  46914. onBackgroundStateChangedObservable: Observable<boolean>;
  46915. /**
  46916. * constructs a new background remover module
  46917. * @param _xrSessionManager the session manager for this module
  46918. * @param options read-only options to be used in this module
  46919. */
  46920. constructor(_xrSessionManager: WebXRSessionManager,
  46921. /**
  46922. * read-only options to be used in this module
  46923. */
  46924. options?: IWebXRBackgroundRemoverOptions);
  46925. /**
  46926. * attach this feature
  46927. * Will usually be called by the features manager
  46928. *
  46929. * @returns true if successful.
  46930. */
  46931. attach(): boolean;
  46932. /**
  46933. * detach this feature.
  46934. * Will usually be called by the features manager
  46935. *
  46936. * @returns true if successful.
  46937. */
  46938. detach(): boolean;
  46939. private _setBackgroundState;
  46940. /**
  46941. * Dispose this feature and all of the resources attached
  46942. */
  46943. dispose(): void;
  46944. }
  46945. }
  46946. declare module "babylonjs/Cameras/XR/features/index" {
  46947. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46948. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46949. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46950. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46951. export * from "babylonjs/Cameras/XR/features/WebXRControllerTeleportation";
  46952. export * from "babylonjs/Cameras/XR/features/WebXRControllerPointerSelection";
  46953. }
  46954. declare module "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController" {
  46955. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46957. import { Scene } from "babylonjs/scene";
  46958. /**
  46959. * The motion controller class for all microsoft mixed reality controllers
  46960. */
  46961. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  46962. /**
  46963. * The base url used to load the left and right controller models
  46964. */
  46965. static MODEL_BASE_URL: string;
  46966. /**
  46967. * The name of the left controller model file
  46968. */
  46969. static MODEL_LEFT_FILENAME: string;
  46970. /**
  46971. * The name of the right controller model file
  46972. */
  46973. static MODEL_RIGHT_FILENAME: string;
  46974. profileId: string;
  46975. protected readonly _mapping: {
  46976. defaultButton: {
  46977. "valueNodeName": string;
  46978. "unpressedNodeName": string;
  46979. "pressedNodeName": string;
  46980. };
  46981. defaultAxis: {
  46982. "valueNodeName": string;
  46983. "minNodeName": string;
  46984. "maxNodeName": string;
  46985. };
  46986. buttons: {
  46987. "xr-standard-trigger": {
  46988. "rootNodeName": string;
  46989. "componentProperty": string;
  46990. "states": string[];
  46991. };
  46992. "xr-standard-squeeze": {
  46993. "rootNodeName": string;
  46994. "componentProperty": string;
  46995. "states": string[];
  46996. };
  46997. "xr-standard-touchpad": {
  46998. "rootNodeName": string;
  46999. "labelAnchorNodeName": string;
  47000. "touchPointNodeName": string;
  47001. };
  47002. "xr-standard-thumbstick": {
  47003. "rootNodeName": string;
  47004. "componentProperty": string;
  47005. "states": string[];
  47006. };
  47007. };
  47008. axes: {
  47009. "xr-standard-touchpad": {
  47010. "x-axis": {
  47011. "rootNodeName": string;
  47012. };
  47013. "y-axis": {
  47014. "rootNodeName": string;
  47015. };
  47016. };
  47017. "xr-standard-thumbstick": {
  47018. "x-axis": {
  47019. "rootNodeName": string;
  47020. };
  47021. "y-axis": {
  47022. "rootNodeName": string;
  47023. };
  47024. };
  47025. };
  47026. };
  47027. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  47028. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47029. private _getChildByName;
  47030. private _getImmediateChildByName;
  47031. protected _getFilenameAndPath(): {
  47032. filename: string;
  47033. path: string;
  47034. };
  47035. protected _updateModel(): void;
  47036. protected _getModelLoadingConstraints(): boolean;
  47037. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47038. }
  47039. }
  47040. declare module "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController" {
  47041. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47043. import { Scene } from "babylonjs/scene";
  47044. /**
  47045. * The motion controller class for oculus touch (quest, rift).
  47046. * This class supports legacy mapping as well the standard xr mapping
  47047. */
  47048. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  47049. private _forceLegacyControllers;
  47050. /**
  47051. * The base url used to load the left and right controller models
  47052. */
  47053. static MODEL_BASE_URL: string;
  47054. /**
  47055. * The name of the left controller model file
  47056. */
  47057. static MODEL_LEFT_FILENAME: string;
  47058. /**
  47059. * The name of the right controller model file
  47060. */
  47061. static MODEL_RIGHT_FILENAME: string;
  47062. /**
  47063. * Base Url for the Quest controller model.
  47064. */
  47065. static QUEST_MODEL_BASE_URL: string;
  47066. profileId: string;
  47067. private _modelRootNode;
  47068. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  47069. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47070. protected _getFilenameAndPath(): {
  47071. filename: string;
  47072. path: string;
  47073. };
  47074. /**
  47075. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  47076. * between the touch and touch 2.
  47077. */
  47078. private _isQuest;
  47079. protected _updateModel(): void;
  47080. protected _getModelLoadingConstraints(): boolean;
  47081. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47082. }
  47083. }
  47084. declare module "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController" {
  47085. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47086. import { Scene } from "babylonjs/scene";
  47087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47088. /**
  47089. * The motion controller class for the standard HTC-Vive controllers
  47090. */
  47091. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  47092. /**
  47093. * The base url used to load the left and right controller models
  47094. */
  47095. static MODEL_BASE_URL: string;
  47096. /**
  47097. * File name for the controller model.
  47098. */
  47099. static MODEL_FILENAME: string;
  47100. profileId: string;
  47101. private _modelRootNode;
  47102. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  47103. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47104. protected _getFilenameAndPath(): {
  47105. filename: string;
  47106. path: string;
  47107. };
  47108. protected _updateModel(): void;
  47109. protected _getModelLoadingConstraints(): boolean;
  47110. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47111. }
  47112. }
  47113. declare module "babylonjs/Cameras/XR/motionController/index" {
  47114. export * from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  47115. export * from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  47116. export * from "babylonjs/Cameras/XR/motionController/webXRGenericMotionController";
  47117. export * from "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController";
  47118. export * from "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager";
  47119. export * from "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController";
  47120. export * from "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController";
  47121. }
  47122. declare module "babylonjs/Cameras/XR/index" {
  47123. export * from "babylonjs/Cameras/XR/webXRCamera";
  47124. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  47125. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47126. export * from "babylonjs/Cameras/XR/webXRInput";
  47127. export * from "babylonjs/Cameras/XR/webXRController";
  47128. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  47129. export * from "babylonjs/Cameras/XR/webXRTypes";
  47130. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  47131. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  47132. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  47133. export * from "babylonjs/Cameras/XR/features/index";
  47134. export * from "babylonjs/Cameras/XR/motionController/index";
  47135. }
  47136. declare module "babylonjs/Cameras/RigModes/index" {
  47137. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47138. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47139. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47140. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47141. }
  47142. declare module "babylonjs/Cameras/index" {
  47143. export * from "babylonjs/Cameras/Inputs/index";
  47144. export * from "babylonjs/Cameras/cameraInputsManager";
  47145. export * from "babylonjs/Cameras/camera";
  47146. export * from "babylonjs/Cameras/targetCamera";
  47147. export * from "babylonjs/Cameras/freeCamera";
  47148. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47149. export * from "babylonjs/Cameras/touchCamera";
  47150. export * from "babylonjs/Cameras/arcRotateCamera";
  47151. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47152. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47153. export * from "babylonjs/Cameras/flyCamera";
  47154. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47155. export * from "babylonjs/Cameras/followCamera";
  47156. export * from "babylonjs/Cameras/followCameraInputsManager";
  47157. export * from "babylonjs/Cameras/gamepadCamera";
  47158. export * from "babylonjs/Cameras/Stereoscopic/index";
  47159. export * from "babylonjs/Cameras/universalCamera";
  47160. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47161. export * from "babylonjs/Cameras/VR/index";
  47162. export * from "babylonjs/Cameras/XR/index";
  47163. export * from "babylonjs/Cameras/RigModes/index";
  47164. }
  47165. declare module "babylonjs/Collisions/index" {
  47166. export * from "babylonjs/Collisions/collider";
  47167. export * from "babylonjs/Collisions/collisionCoordinator";
  47168. export * from "babylonjs/Collisions/pickingInfo";
  47169. export * from "babylonjs/Collisions/intersectionInfo";
  47170. export * from "babylonjs/Collisions/meshCollisionData";
  47171. }
  47172. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47173. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47174. import { Vector3 } from "babylonjs/Maths/math.vector";
  47175. import { Ray } from "babylonjs/Culling/ray";
  47176. import { Plane } from "babylonjs/Maths/math.plane";
  47177. /**
  47178. * Contains an array of blocks representing the octree
  47179. */
  47180. export interface IOctreeContainer<T> {
  47181. /**
  47182. * Blocks within the octree
  47183. */
  47184. blocks: Array<OctreeBlock<T>>;
  47185. }
  47186. /**
  47187. * Class used to store a cell in an octree
  47188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47189. */
  47190. export class OctreeBlock<T> {
  47191. /**
  47192. * Gets the content of the current block
  47193. */
  47194. entries: T[];
  47195. /**
  47196. * Gets the list of block children
  47197. */
  47198. blocks: Array<OctreeBlock<T>>;
  47199. private _depth;
  47200. private _maxDepth;
  47201. private _capacity;
  47202. private _minPoint;
  47203. private _maxPoint;
  47204. private _boundingVectors;
  47205. private _creationFunc;
  47206. /**
  47207. * Creates a new block
  47208. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47209. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47210. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47211. * @param depth defines the current depth of this block in the octree
  47212. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47213. * @param creationFunc defines a callback to call when an element is added to the block
  47214. */
  47215. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47216. /**
  47217. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47218. */
  47219. get capacity(): number;
  47220. /**
  47221. * Gets the minimum vector (in world space) of the block's bounding box
  47222. */
  47223. get minPoint(): Vector3;
  47224. /**
  47225. * Gets the maximum vector (in world space) of the block's bounding box
  47226. */
  47227. get maxPoint(): Vector3;
  47228. /**
  47229. * Add a new element to this block
  47230. * @param entry defines the element to add
  47231. */
  47232. addEntry(entry: T): void;
  47233. /**
  47234. * Remove an element from this block
  47235. * @param entry defines the element to remove
  47236. */
  47237. removeEntry(entry: T): void;
  47238. /**
  47239. * Add an array of elements to this block
  47240. * @param entries defines the array of elements to add
  47241. */
  47242. addEntries(entries: T[]): void;
  47243. /**
  47244. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47245. * @param frustumPlanes defines the frustum planes to test
  47246. * @param selection defines the array to store current content if selection is positive
  47247. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47248. */
  47249. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47250. /**
  47251. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47252. * @param sphereCenter defines the bounding sphere center
  47253. * @param sphereRadius defines the bounding sphere radius
  47254. * @param selection defines the array to store current content if selection is positive
  47255. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47256. */
  47257. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47258. /**
  47259. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47260. * @param ray defines the ray to test with
  47261. * @param selection defines the array to store current content if selection is positive
  47262. */
  47263. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47264. /**
  47265. * Subdivide the content into child blocks (this block will then be empty)
  47266. */
  47267. createInnerBlocks(): void;
  47268. /**
  47269. * @hidden
  47270. */
  47271. 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;
  47272. }
  47273. }
  47274. declare module "babylonjs/Culling/Octrees/octree" {
  47275. import { SmartArray } from "babylonjs/Misc/smartArray";
  47276. import { Vector3 } from "babylonjs/Maths/math.vector";
  47277. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47279. import { Ray } from "babylonjs/Culling/ray";
  47280. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47281. import { Plane } from "babylonjs/Maths/math.plane";
  47282. /**
  47283. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47284. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47285. */
  47286. export class Octree<T> {
  47287. /** 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.) */
  47288. maxDepth: number;
  47289. /**
  47290. * Blocks within the octree containing objects
  47291. */
  47292. blocks: Array<OctreeBlock<T>>;
  47293. /**
  47294. * Content stored in the octree
  47295. */
  47296. dynamicContent: T[];
  47297. private _maxBlockCapacity;
  47298. private _selectionContent;
  47299. private _creationFunc;
  47300. /**
  47301. * Creates a octree
  47302. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47303. * @param creationFunc function to be used to instatiate the octree
  47304. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47305. * @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.)
  47306. */
  47307. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47308. /** 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.) */
  47309. maxDepth?: number);
  47310. /**
  47311. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47312. * @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);
  47313. * @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);
  47314. * @param entries meshes to be added to the octree blocks
  47315. */
  47316. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47317. /**
  47318. * Adds a mesh to the octree
  47319. * @param entry Mesh to add to the octree
  47320. */
  47321. addMesh(entry: T): void;
  47322. /**
  47323. * Remove an element from the octree
  47324. * @param entry defines the element to remove
  47325. */
  47326. removeMesh(entry: T): void;
  47327. /**
  47328. * Selects an array of meshes within the frustum
  47329. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47330. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47331. * @returns array of meshes within the frustum
  47332. */
  47333. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47334. /**
  47335. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47336. * @param sphereCenter defines the bounding sphere center
  47337. * @param sphereRadius defines the bounding sphere radius
  47338. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47339. * @returns an array of objects that intersect the sphere
  47340. */
  47341. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47342. /**
  47343. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47344. * @param ray defines the ray to test with
  47345. * @returns array of intersected objects
  47346. */
  47347. intersectsRay(ray: Ray): SmartArray<T>;
  47348. /**
  47349. * Adds a mesh into the octree block if it intersects the block
  47350. */
  47351. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47352. /**
  47353. * Adds a submesh into the octree block if it intersects the block
  47354. */
  47355. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47356. }
  47357. }
  47358. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47359. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47360. import { Scene } from "babylonjs/scene";
  47361. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47363. import { Ray } from "babylonjs/Culling/ray";
  47364. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47365. import { Collider } from "babylonjs/Collisions/collider";
  47366. module "babylonjs/scene" {
  47367. interface Scene {
  47368. /**
  47369. * @hidden
  47370. * Backing Filed
  47371. */
  47372. _selectionOctree: Octree<AbstractMesh>;
  47373. /**
  47374. * Gets the octree used to boost mesh selection (picking)
  47375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47376. */
  47377. selectionOctree: Octree<AbstractMesh>;
  47378. /**
  47379. * Creates or updates the octree used to boost selection (picking)
  47380. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47381. * @param maxCapacity defines the maximum capacity per leaf
  47382. * @param maxDepth defines the maximum depth of the octree
  47383. * @returns an octree of AbstractMesh
  47384. */
  47385. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47386. }
  47387. }
  47388. module "babylonjs/Meshes/abstractMesh" {
  47389. interface AbstractMesh {
  47390. /**
  47391. * @hidden
  47392. * Backing Field
  47393. */
  47394. _submeshesOctree: Octree<SubMesh>;
  47395. /**
  47396. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47397. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47398. * @param maxCapacity defines the maximum size of each block (64 by default)
  47399. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47400. * @returns the new octree
  47401. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47403. */
  47404. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47405. }
  47406. }
  47407. /**
  47408. * Defines the octree scene component responsible to manage any octrees
  47409. * in a given scene.
  47410. */
  47411. export class OctreeSceneComponent {
  47412. /**
  47413. * The component name help to identify the component in the list of scene components.
  47414. */
  47415. readonly name: string;
  47416. /**
  47417. * The scene the component belongs to.
  47418. */
  47419. scene: Scene;
  47420. /**
  47421. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47422. */
  47423. readonly checksIsEnabled: boolean;
  47424. /**
  47425. * Creates a new instance of the component for the given scene
  47426. * @param scene Defines the scene to register the component in
  47427. */
  47428. constructor(scene: Scene);
  47429. /**
  47430. * Registers the component in a given scene
  47431. */
  47432. register(): void;
  47433. /**
  47434. * Return the list of active meshes
  47435. * @returns the list of active meshes
  47436. */
  47437. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47438. /**
  47439. * Return the list of active sub meshes
  47440. * @param mesh The mesh to get the candidates sub meshes from
  47441. * @returns the list of active sub meshes
  47442. */
  47443. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47444. private _tempRay;
  47445. /**
  47446. * Return the list of sub meshes intersecting with a given local ray
  47447. * @param mesh defines the mesh to find the submesh for
  47448. * @param localRay defines the ray in local space
  47449. * @returns the list of intersecting sub meshes
  47450. */
  47451. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47452. /**
  47453. * Return the list of sub meshes colliding with a collider
  47454. * @param mesh defines the mesh to find the submesh for
  47455. * @param collider defines the collider to evaluate the collision against
  47456. * @returns the list of colliding sub meshes
  47457. */
  47458. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47459. /**
  47460. * Rebuilds the elements related to this component in case of
  47461. * context lost for instance.
  47462. */
  47463. rebuild(): void;
  47464. /**
  47465. * Disposes the component and the associated ressources.
  47466. */
  47467. dispose(): void;
  47468. }
  47469. }
  47470. declare module "babylonjs/Culling/Octrees/index" {
  47471. export * from "babylonjs/Culling/Octrees/octree";
  47472. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47473. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47474. }
  47475. declare module "babylonjs/Culling/index" {
  47476. export * from "babylonjs/Culling/boundingBox";
  47477. export * from "babylonjs/Culling/boundingInfo";
  47478. export * from "babylonjs/Culling/boundingSphere";
  47479. export * from "babylonjs/Culling/Octrees/index";
  47480. export * from "babylonjs/Culling/ray";
  47481. }
  47482. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  47483. import { IDisposable, Scene } from "babylonjs/scene";
  47484. import { Nullable } from "babylonjs/types";
  47485. import { Observable } from "babylonjs/Misc/observable";
  47486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47487. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  47488. import { Camera } from "babylonjs/Cameras/camera";
  47489. /**
  47490. * Renders a layer on top of an existing scene
  47491. */
  47492. export class UtilityLayerRenderer implements IDisposable {
  47493. /** the original scene that will be rendered on top of */
  47494. originalScene: Scene;
  47495. private _pointerCaptures;
  47496. private _lastPointerEvents;
  47497. private static _DefaultUtilityLayer;
  47498. private static _DefaultKeepDepthUtilityLayer;
  47499. private _sharedGizmoLight;
  47500. private _renderCamera;
  47501. /**
  47502. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47503. * @returns the camera that is used when rendering the utility layer
  47504. */
  47505. getRenderCamera(): Nullable<Camera>;
  47506. /**
  47507. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47508. * @param cam the camera that should be used when rendering the utility layer
  47509. */
  47510. setRenderCamera(cam: Nullable<Camera>): void;
  47511. /**
  47512. * @hidden
  47513. * Light which used by gizmos to get light shading
  47514. */
  47515. _getSharedGizmoLight(): HemisphericLight;
  47516. /**
  47517. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47518. */
  47519. pickUtilitySceneFirst: boolean;
  47520. /**
  47521. * 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)
  47522. */
  47523. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47524. /**
  47525. * 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)
  47526. */
  47527. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47528. /**
  47529. * The scene that is rendered on top of the original scene
  47530. */
  47531. utilityLayerScene: Scene;
  47532. /**
  47533. * If the utility layer should automatically be rendered on top of existing scene
  47534. */
  47535. shouldRender: boolean;
  47536. /**
  47537. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47538. */
  47539. onlyCheckPointerDownEvents: boolean;
  47540. /**
  47541. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47542. */
  47543. processAllEvents: boolean;
  47544. /**
  47545. * Observable raised when the pointer move from the utility layer scene to the main scene
  47546. */
  47547. onPointerOutObservable: Observable<number>;
  47548. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47549. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47550. private _afterRenderObserver;
  47551. private _sceneDisposeObserver;
  47552. private _originalPointerObserver;
  47553. /**
  47554. * Instantiates a UtilityLayerRenderer
  47555. * @param originalScene the original scene that will be rendered on top of
  47556. * @param handleEvents boolean indicating if the utility layer should handle events
  47557. */
  47558. constructor(
  47559. /** the original scene that will be rendered on top of */
  47560. originalScene: Scene, handleEvents?: boolean);
  47561. private _notifyObservers;
  47562. /**
  47563. * Renders the utility layers scene on top of the original scene
  47564. */
  47565. render(): void;
  47566. /**
  47567. * Disposes of the renderer
  47568. */
  47569. dispose(): void;
  47570. private _updateCamera;
  47571. }
  47572. }
  47573. declare module "babylonjs/Gizmos/gizmo" {
  47574. import { Nullable } from "babylonjs/types";
  47575. import { IDisposable } from "babylonjs/scene";
  47576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47577. import { Mesh } from "babylonjs/Meshes/mesh";
  47578. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47579. /**
  47580. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47581. */
  47582. export class Gizmo implements IDisposable {
  47583. /** The utility layer the gizmo will be added to */
  47584. gizmoLayer: UtilityLayerRenderer;
  47585. /**
  47586. * The root mesh of the gizmo
  47587. */
  47588. _rootMesh: Mesh;
  47589. private _attachedMesh;
  47590. /**
  47591. * Ratio for the scale of the gizmo (Default: 1)
  47592. */
  47593. scaleRatio: number;
  47594. /**
  47595. * If a custom mesh has been set (Default: false)
  47596. */
  47597. protected _customMeshSet: boolean;
  47598. /**
  47599. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47600. * * When set, interactions will be enabled
  47601. */
  47602. get attachedMesh(): Nullable<AbstractMesh>;
  47603. set attachedMesh(value: Nullable<AbstractMesh>);
  47604. /**
  47605. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47606. * @param mesh The mesh to replace the default mesh of the gizmo
  47607. */
  47608. setCustomMesh(mesh: Mesh): void;
  47609. /**
  47610. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47611. */
  47612. updateGizmoRotationToMatchAttachedMesh: boolean;
  47613. /**
  47614. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47615. */
  47616. updateGizmoPositionToMatchAttachedMesh: boolean;
  47617. /**
  47618. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47619. */
  47620. updateScale: boolean;
  47621. protected _interactionsEnabled: boolean;
  47622. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47623. private _beforeRenderObserver;
  47624. private _tempVector;
  47625. /**
  47626. * Creates a gizmo
  47627. * @param gizmoLayer The utility layer the gizmo will be added to
  47628. */
  47629. constructor(
  47630. /** The utility layer the gizmo will be added to */
  47631. gizmoLayer?: UtilityLayerRenderer);
  47632. /**
  47633. * Updates the gizmo to match the attached mesh's position/rotation
  47634. */
  47635. protected _update(): void;
  47636. /**
  47637. * Disposes of the gizmo
  47638. */
  47639. dispose(): void;
  47640. }
  47641. }
  47642. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47643. import { Observable } from "babylonjs/Misc/observable";
  47644. import { Nullable } from "babylonjs/types";
  47645. import { Vector3 } from "babylonjs/Maths/math.vector";
  47646. import { Color3 } from "babylonjs/Maths/math.color";
  47647. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47649. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47650. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47651. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47652. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47653. import { Scene } from "babylonjs/scene";
  47654. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47655. /**
  47656. * Single plane drag gizmo
  47657. */
  47658. export class PlaneDragGizmo extends Gizmo {
  47659. /**
  47660. * Drag behavior responsible for the gizmos dragging interactions
  47661. */
  47662. dragBehavior: PointerDragBehavior;
  47663. private _pointerObserver;
  47664. /**
  47665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47666. */
  47667. snapDistance: number;
  47668. /**
  47669. * Event that fires each time the gizmo snaps to a new location.
  47670. * * snapDistance is the the change in distance
  47671. */
  47672. onSnapObservable: Observable<{
  47673. snapDistance: number;
  47674. }>;
  47675. private _plane;
  47676. private _coloredMaterial;
  47677. private _hoverMaterial;
  47678. private _isEnabled;
  47679. private _parent;
  47680. /** @hidden */
  47681. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47682. /** @hidden */
  47683. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47684. /**
  47685. * Creates a PlaneDragGizmo
  47686. * @param gizmoLayer The utility layer the gizmo will be added to
  47687. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47688. * @param color The color of the gizmo
  47689. */
  47690. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47691. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47692. /**
  47693. * If the gizmo is enabled
  47694. */
  47695. set isEnabled(value: boolean);
  47696. get isEnabled(): boolean;
  47697. /**
  47698. * Disposes of the gizmo
  47699. */
  47700. dispose(): void;
  47701. }
  47702. }
  47703. declare module "babylonjs/Gizmos/positionGizmo" {
  47704. import { Observable } from "babylonjs/Misc/observable";
  47705. import { Nullable } from "babylonjs/types";
  47706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47707. import { Mesh } from "babylonjs/Meshes/mesh";
  47708. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47709. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47710. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47711. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47712. /**
  47713. * Gizmo that enables dragging a mesh along 3 axis
  47714. */
  47715. export class PositionGizmo extends Gizmo {
  47716. /**
  47717. * Internal gizmo used for interactions on the x axis
  47718. */
  47719. xGizmo: AxisDragGizmo;
  47720. /**
  47721. * Internal gizmo used for interactions on the y axis
  47722. */
  47723. yGizmo: AxisDragGizmo;
  47724. /**
  47725. * Internal gizmo used for interactions on the z axis
  47726. */
  47727. zGizmo: AxisDragGizmo;
  47728. /**
  47729. * Internal gizmo used for interactions on the yz plane
  47730. */
  47731. xPlaneGizmo: PlaneDragGizmo;
  47732. /**
  47733. * Internal gizmo used for interactions on the xz plane
  47734. */
  47735. yPlaneGizmo: PlaneDragGizmo;
  47736. /**
  47737. * Internal gizmo used for interactions on the xy plane
  47738. */
  47739. zPlaneGizmo: PlaneDragGizmo;
  47740. /**
  47741. * private variables
  47742. */
  47743. private _meshAttached;
  47744. private _updateGizmoRotationToMatchAttachedMesh;
  47745. private _snapDistance;
  47746. private _scaleRatio;
  47747. /** Fires an event when any of it's sub gizmos are dragged */
  47748. onDragStartObservable: Observable<unknown>;
  47749. /** Fires an event when any of it's sub gizmos are released from dragging */
  47750. onDragEndObservable: Observable<unknown>;
  47751. /**
  47752. * If set to true, planar drag is enabled
  47753. */
  47754. private _planarGizmoEnabled;
  47755. get attachedMesh(): Nullable<AbstractMesh>;
  47756. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47757. /**
  47758. * Creates a PositionGizmo
  47759. * @param gizmoLayer The utility layer the gizmo will be added to
  47760. */
  47761. constructor(gizmoLayer?: UtilityLayerRenderer);
  47762. /**
  47763. * If the planar drag gizmo is enabled
  47764. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47765. */
  47766. set planarGizmoEnabled(value: boolean);
  47767. get planarGizmoEnabled(): boolean;
  47768. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47769. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47770. /**
  47771. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47772. */
  47773. set snapDistance(value: number);
  47774. get snapDistance(): number;
  47775. /**
  47776. * Ratio for the scale of the gizmo (Default: 1)
  47777. */
  47778. set scaleRatio(value: number);
  47779. get scaleRatio(): number;
  47780. /**
  47781. * Disposes of the gizmo
  47782. */
  47783. dispose(): void;
  47784. /**
  47785. * CustomMeshes are not supported by this gizmo
  47786. * @param mesh The mesh to replace the default mesh of the gizmo
  47787. */
  47788. setCustomMesh(mesh: Mesh): void;
  47789. }
  47790. }
  47791. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47792. import { Observable } from "babylonjs/Misc/observable";
  47793. import { Nullable } from "babylonjs/types";
  47794. import { Vector3 } from "babylonjs/Maths/math.vector";
  47795. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47797. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47798. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47799. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47800. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47801. import { Scene } from "babylonjs/scene";
  47802. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47803. import { Color3 } from "babylonjs/Maths/math.color";
  47804. /**
  47805. * Single axis drag gizmo
  47806. */
  47807. export class AxisDragGizmo extends Gizmo {
  47808. /**
  47809. * Drag behavior responsible for the gizmos dragging interactions
  47810. */
  47811. dragBehavior: PointerDragBehavior;
  47812. private _pointerObserver;
  47813. /**
  47814. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47815. */
  47816. snapDistance: number;
  47817. /**
  47818. * Event that fires each time the gizmo snaps to a new location.
  47819. * * snapDistance is the the change in distance
  47820. */
  47821. onSnapObservable: Observable<{
  47822. snapDistance: number;
  47823. }>;
  47824. private _isEnabled;
  47825. private _parent;
  47826. private _arrow;
  47827. private _coloredMaterial;
  47828. private _hoverMaterial;
  47829. /** @hidden */
  47830. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47831. /** @hidden */
  47832. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47833. /**
  47834. * Creates an AxisDragGizmo
  47835. * @param gizmoLayer The utility layer the gizmo will be added to
  47836. * @param dragAxis The axis which the gizmo will be able to drag on
  47837. * @param color The color of the gizmo
  47838. */
  47839. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47840. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47841. /**
  47842. * If the gizmo is enabled
  47843. */
  47844. set isEnabled(value: boolean);
  47845. get isEnabled(): boolean;
  47846. /**
  47847. * Disposes of the gizmo
  47848. */
  47849. dispose(): void;
  47850. }
  47851. }
  47852. declare module "babylonjs/Debug/axesViewer" {
  47853. import { Vector3 } from "babylonjs/Maths/math.vector";
  47854. import { Nullable } from "babylonjs/types";
  47855. import { Scene } from "babylonjs/scene";
  47856. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47857. /**
  47858. * The Axes viewer will show 3 axes in a specific point in space
  47859. */
  47860. export class AxesViewer {
  47861. private _xAxis;
  47862. private _yAxis;
  47863. private _zAxis;
  47864. private _scaleLinesFactor;
  47865. private _instanced;
  47866. /**
  47867. * Gets the hosting scene
  47868. */
  47869. scene: Scene;
  47870. /**
  47871. * Gets or sets a number used to scale line length
  47872. */
  47873. scaleLines: number;
  47874. /** Gets the node hierarchy used to render x-axis */
  47875. get xAxis(): TransformNode;
  47876. /** Gets the node hierarchy used to render y-axis */
  47877. get yAxis(): TransformNode;
  47878. /** Gets the node hierarchy used to render z-axis */
  47879. get zAxis(): TransformNode;
  47880. /**
  47881. * Creates a new AxesViewer
  47882. * @param scene defines the hosting scene
  47883. * @param scaleLines defines a number used to scale line length (1 by default)
  47884. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47885. * @param xAxis defines the node hierarchy used to render the x-axis
  47886. * @param yAxis defines the node hierarchy used to render the y-axis
  47887. * @param zAxis defines the node hierarchy used to render the z-axis
  47888. */
  47889. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47890. /**
  47891. * Force the viewer to update
  47892. * @param position defines the position of the viewer
  47893. * @param xaxis defines the x axis of the viewer
  47894. * @param yaxis defines the y axis of the viewer
  47895. * @param zaxis defines the z axis of the viewer
  47896. */
  47897. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47898. /**
  47899. * Creates an instance of this axes viewer.
  47900. * @returns a new axes viewer with instanced meshes
  47901. */
  47902. createInstance(): AxesViewer;
  47903. /** Releases resources */
  47904. dispose(): void;
  47905. private static _SetRenderingGroupId;
  47906. }
  47907. }
  47908. declare module "babylonjs/Debug/boneAxesViewer" {
  47909. import { Nullable } from "babylonjs/types";
  47910. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47911. import { Vector3 } from "babylonjs/Maths/math.vector";
  47912. import { Mesh } from "babylonjs/Meshes/mesh";
  47913. import { Bone } from "babylonjs/Bones/bone";
  47914. import { Scene } from "babylonjs/scene";
  47915. /**
  47916. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47917. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47918. */
  47919. export class BoneAxesViewer extends AxesViewer {
  47920. /**
  47921. * Gets or sets the target mesh where to display the axes viewer
  47922. */
  47923. mesh: Nullable<Mesh>;
  47924. /**
  47925. * Gets or sets the target bone where to display the axes viewer
  47926. */
  47927. bone: Nullable<Bone>;
  47928. /** Gets current position */
  47929. pos: Vector3;
  47930. /** Gets direction of X axis */
  47931. xaxis: Vector3;
  47932. /** Gets direction of Y axis */
  47933. yaxis: Vector3;
  47934. /** Gets direction of Z axis */
  47935. zaxis: Vector3;
  47936. /**
  47937. * Creates a new BoneAxesViewer
  47938. * @param scene defines the hosting scene
  47939. * @param bone defines the target bone
  47940. * @param mesh defines the target mesh
  47941. * @param scaleLines defines a scaling factor for line length (1 by default)
  47942. */
  47943. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47944. /**
  47945. * Force the viewer to update
  47946. */
  47947. update(): void;
  47948. /** Releases resources */
  47949. dispose(): void;
  47950. }
  47951. }
  47952. declare module "babylonjs/Debug/debugLayer" {
  47953. import { Scene } from "babylonjs/scene";
  47954. /**
  47955. * Interface used to define scene explorer extensibility option
  47956. */
  47957. export interface IExplorerExtensibilityOption {
  47958. /**
  47959. * Define the option label
  47960. */
  47961. label: string;
  47962. /**
  47963. * Defines the action to execute on click
  47964. */
  47965. action: (entity: any) => void;
  47966. }
  47967. /**
  47968. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47969. */
  47970. export interface IExplorerExtensibilityGroup {
  47971. /**
  47972. * Defines a predicate to test if a given type mut be extended
  47973. */
  47974. predicate: (entity: any) => boolean;
  47975. /**
  47976. * Gets the list of options added to a type
  47977. */
  47978. entries: IExplorerExtensibilityOption[];
  47979. }
  47980. /**
  47981. * Interface used to define the options to use to create the Inspector
  47982. */
  47983. export interface IInspectorOptions {
  47984. /**
  47985. * Display in overlay mode (default: false)
  47986. */
  47987. overlay?: boolean;
  47988. /**
  47989. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47990. */
  47991. globalRoot?: HTMLElement;
  47992. /**
  47993. * Display the Scene explorer
  47994. */
  47995. showExplorer?: boolean;
  47996. /**
  47997. * Display the property inspector
  47998. */
  47999. showInspector?: boolean;
  48000. /**
  48001. * Display in embed mode (both panes on the right)
  48002. */
  48003. embedMode?: boolean;
  48004. /**
  48005. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48006. */
  48007. handleResize?: boolean;
  48008. /**
  48009. * Allow the panes to popup (default: true)
  48010. */
  48011. enablePopup?: boolean;
  48012. /**
  48013. * Allow the panes to be closed by users (default: true)
  48014. */
  48015. enableClose?: boolean;
  48016. /**
  48017. * Optional list of extensibility entries
  48018. */
  48019. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48020. /**
  48021. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48022. */
  48023. inspectorURL?: string;
  48024. /**
  48025. * Optional initial tab (default to DebugLayerTab.Properties)
  48026. */
  48027. initialTab?: DebugLayerTab;
  48028. }
  48029. module "babylonjs/scene" {
  48030. interface Scene {
  48031. /**
  48032. * @hidden
  48033. * Backing field
  48034. */
  48035. _debugLayer: DebugLayer;
  48036. /**
  48037. * Gets the debug layer (aka Inspector) associated with the scene
  48038. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48039. */
  48040. debugLayer: DebugLayer;
  48041. }
  48042. }
  48043. /**
  48044. * Enum of inspector action tab
  48045. */
  48046. export enum DebugLayerTab {
  48047. /**
  48048. * Properties tag (default)
  48049. */
  48050. Properties = 0,
  48051. /**
  48052. * Debug tab
  48053. */
  48054. Debug = 1,
  48055. /**
  48056. * Statistics tab
  48057. */
  48058. Statistics = 2,
  48059. /**
  48060. * Tools tab
  48061. */
  48062. Tools = 3,
  48063. /**
  48064. * Settings tab
  48065. */
  48066. Settings = 4
  48067. }
  48068. /**
  48069. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48070. * what is happening in your scene
  48071. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48072. */
  48073. export class DebugLayer {
  48074. /**
  48075. * Define the url to get the inspector script from.
  48076. * By default it uses the babylonjs CDN.
  48077. * @ignoreNaming
  48078. */
  48079. static InspectorURL: string;
  48080. private _scene;
  48081. private BJSINSPECTOR;
  48082. private _onPropertyChangedObservable?;
  48083. /**
  48084. * Observable triggered when a property is changed through the inspector.
  48085. */
  48086. get onPropertyChangedObservable(): any;
  48087. /**
  48088. * Instantiates a new debug layer.
  48089. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48090. * what is happening in your scene
  48091. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48092. * @param scene Defines the scene to inspect
  48093. */
  48094. constructor(scene: Scene);
  48095. /** Creates the inspector window. */
  48096. private _createInspector;
  48097. /**
  48098. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48099. * @param entity defines the entity to select
  48100. * @param lineContainerTitle defines the specific block to highlight
  48101. */
  48102. select(entity: any, lineContainerTitle?: string): void;
  48103. /** Get the inspector from bundle or global */
  48104. private _getGlobalInspector;
  48105. /**
  48106. * Get if the inspector is visible or not.
  48107. * @returns true if visible otherwise, false
  48108. */
  48109. isVisible(): boolean;
  48110. /**
  48111. * Hide the inspector and close its window.
  48112. */
  48113. hide(): void;
  48114. /**
  48115. * Launch the debugLayer.
  48116. * @param config Define the configuration of the inspector
  48117. * @return a promise fulfilled when the debug layer is visible
  48118. */
  48119. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48120. }
  48121. }
  48122. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48123. import { Nullable } from "babylonjs/types";
  48124. import { Scene } from "babylonjs/scene";
  48125. import { Vector4 } from "babylonjs/Maths/math.vector";
  48126. import { Color4 } from "babylonjs/Maths/math.color";
  48127. import { Mesh } from "babylonjs/Meshes/mesh";
  48128. /**
  48129. * Class containing static functions to help procedurally build meshes
  48130. */
  48131. export class BoxBuilder {
  48132. /**
  48133. * Creates a box mesh
  48134. * * The parameter `size` sets the size (float) of each box side (default 1)
  48135. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48136. * * 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)
  48137. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48141. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48142. * @param name defines the name of the mesh
  48143. * @param options defines the options used to create the mesh
  48144. * @param scene defines the hosting scene
  48145. * @returns the box mesh
  48146. */
  48147. static CreateBox(name: string, options: {
  48148. size?: number;
  48149. width?: number;
  48150. height?: number;
  48151. depth?: number;
  48152. faceUV?: Vector4[];
  48153. faceColors?: Color4[];
  48154. sideOrientation?: number;
  48155. frontUVs?: Vector4;
  48156. backUVs?: Vector4;
  48157. wrap?: boolean;
  48158. topBaseAt?: number;
  48159. bottomBaseAt?: number;
  48160. updatable?: boolean;
  48161. }, scene?: Nullable<Scene>): Mesh;
  48162. }
  48163. }
  48164. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48165. import { Vector4 } from "babylonjs/Maths/math.vector";
  48166. import { Mesh } from "babylonjs/Meshes/mesh";
  48167. import { Scene } from "babylonjs/scene";
  48168. import { Nullable } from "babylonjs/types";
  48169. /**
  48170. * Class containing static functions to help procedurally build meshes
  48171. */
  48172. export class SphereBuilder {
  48173. /**
  48174. * Creates a sphere mesh
  48175. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48176. * * 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`)
  48177. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48178. * * 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
  48179. * * 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)
  48180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48183. * @param name defines the name of the mesh
  48184. * @param options defines the options used to create the mesh
  48185. * @param scene defines the hosting scene
  48186. * @returns the sphere mesh
  48187. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48188. */
  48189. static CreateSphere(name: string, options: {
  48190. segments?: number;
  48191. diameter?: number;
  48192. diameterX?: number;
  48193. diameterY?: number;
  48194. diameterZ?: number;
  48195. arc?: number;
  48196. slice?: number;
  48197. sideOrientation?: number;
  48198. frontUVs?: Vector4;
  48199. backUVs?: Vector4;
  48200. updatable?: boolean;
  48201. }, scene?: Nullable<Scene>): Mesh;
  48202. }
  48203. }
  48204. declare module "babylonjs/Debug/physicsViewer" {
  48205. import { Nullable } from "babylonjs/types";
  48206. import { Scene } from "babylonjs/scene";
  48207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48208. import { Mesh } from "babylonjs/Meshes/mesh";
  48209. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48210. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48211. /**
  48212. * Used to show the physics impostor around the specific mesh
  48213. */
  48214. export class PhysicsViewer {
  48215. /** @hidden */
  48216. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48217. /** @hidden */
  48218. protected _meshes: Array<Nullable<AbstractMesh>>;
  48219. /** @hidden */
  48220. protected _scene: Nullable<Scene>;
  48221. /** @hidden */
  48222. protected _numMeshes: number;
  48223. /** @hidden */
  48224. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48225. private _renderFunction;
  48226. private _utilityLayer;
  48227. private _debugBoxMesh;
  48228. private _debugSphereMesh;
  48229. private _debugCylinderMesh;
  48230. private _debugMaterial;
  48231. private _debugMeshMeshes;
  48232. /**
  48233. * Creates a new PhysicsViewer
  48234. * @param scene defines the hosting scene
  48235. */
  48236. constructor(scene: Scene);
  48237. /** @hidden */
  48238. protected _updateDebugMeshes(): void;
  48239. /**
  48240. * Renders a specified physic impostor
  48241. * @param impostor defines the impostor to render
  48242. * @param targetMesh defines the mesh represented by the impostor
  48243. * @returns the new debug mesh used to render the impostor
  48244. */
  48245. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48246. /**
  48247. * Hides a specified physic impostor
  48248. * @param impostor defines the impostor to hide
  48249. */
  48250. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48251. private _getDebugMaterial;
  48252. private _getDebugBoxMesh;
  48253. private _getDebugSphereMesh;
  48254. private _getDebugCylinderMesh;
  48255. private _getDebugMeshMesh;
  48256. private _getDebugMesh;
  48257. /** Releases all resources */
  48258. dispose(): void;
  48259. }
  48260. }
  48261. declare module "babylonjs/Debug/rayHelper" {
  48262. import { Nullable } from "babylonjs/types";
  48263. import { Ray } from "babylonjs/Culling/ray";
  48264. import { Vector3 } from "babylonjs/Maths/math.vector";
  48265. import { Color3 } from "babylonjs/Maths/math.color";
  48266. import { Scene } from "babylonjs/scene";
  48267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48268. import "babylonjs/Meshes/Builders/linesBuilder";
  48269. /**
  48270. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48271. * in order to better appreciate the issue one might have.
  48272. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48273. */
  48274. export class RayHelper {
  48275. /**
  48276. * Defines the ray we are currently tryin to visualize.
  48277. */
  48278. ray: Nullable<Ray>;
  48279. private _renderPoints;
  48280. private _renderLine;
  48281. private _renderFunction;
  48282. private _scene;
  48283. private _updateToMeshFunction;
  48284. private _attachedToMesh;
  48285. private _meshSpaceDirection;
  48286. private _meshSpaceOrigin;
  48287. /**
  48288. * Helper function to create a colored helper in a scene in one line.
  48289. * @param ray Defines the ray we are currently tryin to visualize
  48290. * @param scene Defines the scene the ray is used in
  48291. * @param color Defines the color we want to see the ray in
  48292. * @returns The newly created ray helper.
  48293. */
  48294. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48295. /**
  48296. * Instantiate a new ray helper.
  48297. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48298. * in order to better appreciate the issue one might have.
  48299. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48300. * @param ray Defines the ray we are currently tryin to visualize
  48301. */
  48302. constructor(ray: Ray);
  48303. /**
  48304. * Shows the ray we are willing to debug.
  48305. * @param scene Defines the scene the ray needs to be rendered in
  48306. * @param color Defines the color the ray needs to be rendered in
  48307. */
  48308. show(scene: Scene, color?: Color3): void;
  48309. /**
  48310. * Hides the ray we are debugging.
  48311. */
  48312. hide(): void;
  48313. private _render;
  48314. /**
  48315. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48316. * @param mesh Defines the mesh we want the helper attached to
  48317. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48318. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48319. * @param length Defines the length of the ray
  48320. */
  48321. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48322. /**
  48323. * Detach the ray helper from the mesh it has previously been attached to.
  48324. */
  48325. detachFromMesh(): void;
  48326. private _updateToMesh;
  48327. /**
  48328. * Dispose the helper and release its associated resources.
  48329. */
  48330. dispose(): void;
  48331. }
  48332. }
  48333. declare module "babylonjs/Debug/skeletonViewer" {
  48334. import { Color3 } from "babylonjs/Maths/math.color";
  48335. import { Scene } from "babylonjs/scene";
  48336. import { Nullable } from "babylonjs/types";
  48337. import { Skeleton } from "babylonjs/Bones/skeleton";
  48338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48339. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48340. /**
  48341. * Class used to render a debug view of a given skeleton
  48342. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48343. */
  48344. export class SkeletonViewer {
  48345. /** defines the skeleton to render */
  48346. skeleton: Skeleton;
  48347. /** defines the mesh attached to the skeleton */
  48348. mesh: AbstractMesh;
  48349. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48350. autoUpdateBonesMatrices: boolean;
  48351. /** defines the rendering group id to use with the viewer */
  48352. renderingGroupId: number;
  48353. /** Gets or sets the color used to render the skeleton */
  48354. color: Color3;
  48355. private _scene;
  48356. private _debugLines;
  48357. private _debugMesh;
  48358. private _isEnabled;
  48359. private _renderFunction;
  48360. private _utilityLayer;
  48361. /**
  48362. * Returns the mesh used to render the bones
  48363. */
  48364. get debugMesh(): Nullable<LinesMesh>;
  48365. /**
  48366. * Creates a new SkeletonViewer
  48367. * @param skeleton defines the skeleton to render
  48368. * @param mesh defines the mesh attached to the skeleton
  48369. * @param scene defines the hosting scene
  48370. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48371. * @param renderingGroupId defines the rendering group id to use with the viewer
  48372. */
  48373. constructor(
  48374. /** defines the skeleton to render */
  48375. skeleton: Skeleton,
  48376. /** defines the mesh attached to the skeleton */
  48377. mesh: AbstractMesh, scene: Scene,
  48378. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48379. autoUpdateBonesMatrices?: boolean,
  48380. /** defines the rendering group id to use with the viewer */
  48381. renderingGroupId?: number);
  48382. /** Gets or sets a boolean indicating if the viewer is enabled */
  48383. set isEnabled(value: boolean);
  48384. get isEnabled(): boolean;
  48385. private _getBonePosition;
  48386. private _getLinesForBonesWithLength;
  48387. private _getLinesForBonesNoLength;
  48388. /** Update the viewer to sync with current skeleton state */
  48389. update(): void;
  48390. /** Release associated resources */
  48391. dispose(): void;
  48392. }
  48393. }
  48394. declare module "babylonjs/Debug/index" {
  48395. export * from "babylonjs/Debug/axesViewer";
  48396. export * from "babylonjs/Debug/boneAxesViewer";
  48397. export * from "babylonjs/Debug/debugLayer";
  48398. export * from "babylonjs/Debug/physicsViewer";
  48399. export * from "babylonjs/Debug/rayHelper";
  48400. export * from "babylonjs/Debug/skeletonViewer";
  48401. }
  48402. declare module "babylonjs/Engines/nullEngine" {
  48403. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48404. import { Scene } from "babylonjs/scene";
  48405. import { Engine } from "babylonjs/Engines/engine";
  48406. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48407. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48409. import { Effect } from "babylonjs/Materials/effect";
  48410. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48411. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48412. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48413. /**
  48414. * Options to create the null engine
  48415. */
  48416. export class NullEngineOptions {
  48417. /**
  48418. * Render width (Default: 512)
  48419. */
  48420. renderWidth: number;
  48421. /**
  48422. * Render height (Default: 256)
  48423. */
  48424. renderHeight: number;
  48425. /**
  48426. * Texture size (Default: 512)
  48427. */
  48428. textureSize: number;
  48429. /**
  48430. * If delta time between frames should be constant
  48431. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48432. */
  48433. deterministicLockstep: boolean;
  48434. /**
  48435. * Maximum about of steps between frames (Default: 4)
  48436. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48437. */
  48438. lockstepMaxSteps: number;
  48439. }
  48440. /**
  48441. * The null engine class provides support for headless version of babylon.js.
  48442. * This can be used in server side scenario or for testing purposes
  48443. */
  48444. export class NullEngine extends Engine {
  48445. private _options;
  48446. /**
  48447. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48448. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48449. * @returns true if engine is in deterministic lock step mode
  48450. */
  48451. isDeterministicLockStep(): boolean;
  48452. /**
  48453. * Gets the max steps when engine is running in deterministic lock step
  48454. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48455. * @returns the max steps
  48456. */
  48457. getLockstepMaxSteps(): number;
  48458. /**
  48459. * Gets the current hardware scaling level.
  48460. * By default the hardware scaling level is computed from the window device ratio.
  48461. * 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.
  48462. * @returns a number indicating the current hardware scaling level
  48463. */
  48464. getHardwareScalingLevel(): number;
  48465. constructor(options?: NullEngineOptions);
  48466. /**
  48467. * Creates a vertex buffer
  48468. * @param vertices the data for the vertex buffer
  48469. * @returns the new WebGL static buffer
  48470. */
  48471. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48472. /**
  48473. * Creates a new index buffer
  48474. * @param indices defines the content of the index buffer
  48475. * @param updatable defines if the index buffer must be updatable
  48476. * @returns a new webGL buffer
  48477. */
  48478. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48479. /**
  48480. * Clear the current render buffer or the current render target (if any is set up)
  48481. * @param color defines the color to use
  48482. * @param backBuffer defines if the back buffer must be cleared
  48483. * @param depth defines if the depth buffer must be cleared
  48484. * @param stencil defines if the stencil buffer must be cleared
  48485. */
  48486. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48487. /**
  48488. * Gets the current render width
  48489. * @param useScreen defines if screen size must be used (or the current render target if any)
  48490. * @returns a number defining the current render width
  48491. */
  48492. getRenderWidth(useScreen?: boolean): number;
  48493. /**
  48494. * Gets the current render height
  48495. * @param useScreen defines if screen size must be used (or the current render target if any)
  48496. * @returns a number defining the current render height
  48497. */
  48498. getRenderHeight(useScreen?: boolean): number;
  48499. /**
  48500. * Set the WebGL's viewport
  48501. * @param viewport defines the viewport element to be used
  48502. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48503. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48504. */
  48505. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48506. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48507. /**
  48508. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48509. * @param pipelineContext defines the pipeline context to use
  48510. * @param uniformsNames defines the list of uniform names
  48511. * @returns an array of webGL uniform locations
  48512. */
  48513. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48514. /**
  48515. * Gets the lsit of active attributes for a given webGL program
  48516. * @param pipelineContext defines the pipeline context to use
  48517. * @param attributesNames defines the list of attribute names to get
  48518. * @returns an array of indices indicating the offset of each attribute
  48519. */
  48520. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48521. /**
  48522. * Binds an effect to the webGL context
  48523. * @param effect defines the effect to bind
  48524. */
  48525. bindSamplers(effect: Effect): void;
  48526. /**
  48527. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48528. * @param effect defines the effect to activate
  48529. */
  48530. enableEffect(effect: Effect): void;
  48531. /**
  48532. * Set various states to the webGL context
  48533. * @param culling defines backface culling state
  48534. * @param zOffset defines the value to apply to zOffset (0 by default)
  48535. * @param force defines if states must be applied even if cache is up to date
  48536. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48537. */
  48538. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48539. /**
  48540. * Set the value of an uniform to an array of int32
  48541. * @param uniform defines the webGL uniform location where to store the value
  48542. * @param array defines the array of int32 to store
  48543. */
  48544. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48545. /**
  48546. * Set the value of an uniform to an array of int32 (stored as vec2)
  48547. * @param uniform defines the webGL uniform location where to store the value
  48548. * @param array defines the array of int32 to store
  48549. */
  48550. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48551. /**
  48552. * Set the value of an uniform to an array of int32 (stored as vec3)
  48553. * @param uniform defines the webGL uniform location where to store the value
  48554. * @param array defines the array of int32 to store
  48555. */
  48556. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48557. /**
  48558. * Set the value of an uniform to an array of int32 (stored as vec4)
  48559. * @param uniform defines the webGL uniform location where to store the value
  48560. * @param array defines the array of int32 to store
  48561. */
  48562. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48563. /**
  48564. * Set the value of an uniform to an array of float32
  48565. * @param uniform defines the webGL uniform location where to store the value
  48566. * @param array defines the array of float32 to store
  48567. */
  48568. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48569. /**
  48570. * Set the value of an uniform to an array of float32 (stored as vec2)
  48571. * @param uniform defines the webGL uniform location where to store the value
  48572. * @param array defines the array of float32 to store
  48573. */
  48574. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48575. /**
  48576. * Set the value of an uniform to an array of float32 (stored as vec3)
  48577. * @param uniform defines the webGL uniform location where to store the value
  48578. * @param array defines the array of float32 to store
  48579. */
  48580. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48581. /**
  48582. * Set the value of an uniform to an array of float32 (stored as vec4)
  48583. * @param uniform defines the webGL uniform location where to store the value
  48584. * @param array defines the array of float32 to store
  48585. */
  48586. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48587. /**
  48588. * Set the value of an uniform to an array of number
  48589. * @param uniform defines the webGL uniform location where to store the value
  48590. * @param array defines the array of number to store
  48591. */
  48592. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48593. /**
  48594. * Set the value of an uniform to an array of number (stored as vec2)
  48595. * @param uniform defines the webGL uniform location where to store the value
  48596. * @param array defines the array of number to store
  48597. */
  48598. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48599. /**
  48600. * Set the value of an uniform to an array of number (stored as vec3)
  48601. * @param uniform defines the webGL uniform location where to store the value
  48602. * @param array defines the array of number to store
  48603. */
  48604. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48605. /**
  48606. * Set the value of an uniform to an array of number (stored as vec4)
  48607. * @param uniform defines the webGL uniform location where to store the value
  48608. * @param array defines the array of number to store
  48609. */
  48610. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48611. /**
  48612. * Set the value of an uniform to an array of float32 (stored as matrices)
  48613. * @param uniform defines the webGL uniform location where to store the value
  48614. * @param matrices defines the array of float32 to store
  48615. */
  48616. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48617. /**
  48618. * Set the value of an uniform to a matrix (3x3)
  48619. * @param uniform defines the webGL uniform location where to store the value
  48620. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48621. */
  48622. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48623. /**
  48624. * Set the value of an uniform to a matrix (2x2)
  48625. * @param uniform defines the webGL uniform location where to store the value
  48626. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48627. */
  48628. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48629. /**
  48630. * Set the value of an uniform to a number (float)
  48631. * @param uniform defines the webGL uniform location where to store the value
  48632. * @param value defines the float number to store
  48633. */
  48634. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48635. /**
  48636. * Set the value of an uniform to a vec2
  48637. * @param uniform defines the webGL uniform location where to store the value
  48638. * @param x defines the 1st component of the value
  48639. * @param y defines the 2nd component of the value
  48640. */
  48641. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48642. /**
  48643. * Set the value of an uniform to a vec3
  48644. * @param uniform defines the webGL uniform location where to store the value
  48645. * @param x defines the 1st component of the value
  48646. * @param y defines the 2nd component of the value
  48647. * @param z defines the 3rd component of the value
  48648. */
  48649. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48650. /**
  48651. * Set the value of an uniform to a boolean
  48652. * @param uniform defines the webGL uniform location where to store the value
  48653. * @param bool defines the boolean to store
  48654. */
  48655. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48656. /**
  48657. * Set the value of an uniform to a vec4
  48658. * @param uniform defines the webGL uniform location where to store the value
  48659. * @param x defines the 1st component of the value
  48660. * @param y defines the 2nd component of the value
  48661. * @param z defines the 3rd component of the value
  48662. * @param w defines the 4th component of the value
  48663. */
  48664. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48665. /**
  48666. * Sets the current alpha mode
  48667. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48668. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48669. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48670. */
  48671. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48672. /**
  48673. * Bind webGl buffers directly to the webGL context
  48674. * @param vertexBuffers defines the vertex buffer to bind
  48675. * @param indexBuffer defines the index buffer to bind
  48676. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48677. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48678. * @param effect defines the effect associated with the vertex buffer
  48679. */
  48680. bindBuffers(vertexBuffers: {
  48681. [key: string]: VertexBuffer;
  48682. }, indexBuffer: DataBuffer, effect: Effect): void;
  48683. /**
  48684. * Force the entire cache to be cleared
  48685. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48686. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48687. */
  48688. wipeCaches(bruteForce?: boolean): void;
  48689. /**
  48690. * Send a draw order
  48691. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48692. * @param indexStart defines the starting index
  48693. * @param indexCount defines the number of index to draw
  48694. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48695. */
  48696. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48697. /**
  48698. * Draw a list of indexed primitives
  48699. * @param fillMode defines the primitive to use
  48700. * @param indexStart defines the starting index
  48701. * @param indexCount defines the number of index to draw
  48702. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48703. */
  48704. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48705. /**
  48706. * Draw a list of unindexed primitives
  48707. * @param fillMode defines the primitive to use
  48708. * @param verticesStart defines the index of first vertex to draw
  48709. * @param verticesCount defines the count of vertices to draw
  48710. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48711. */
  48712. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48713. /** @hidden */
  48714. _createTexture(): WebGLTexture;
  48715. /** @hidden */
  48716. _releaseTexture(texture: InternalTexture): void;
  48717. /**
  48718. * Usually called from Texture.ts.
  48719. * Passed information to create a WebGLTexture
  48720. * @param urlArg defines a value which contains one of the following:
  48721. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48722. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48723. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48724. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48725. * @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)
  48726. * @param scene needed for loading to the correct scene
  48727. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48728. * @param onLoad optional callback to be called upon successful completion
  48729. * @param onError optional callback to be called upon failure
  48730. * @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
  48731. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48732. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48733. * @param forcedExtension defines the extension to use to pick the right loader
  48734. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48735. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48736. */
  48737. 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;
  48738. /**
  48739. * Creates a new render target texture
  48740. * @param size defines the size of the texture
  48741. * @param options defines the options used to create the texture
  48742. * @returns a new render target texture stored in an InternalTexture
  48743. */
  48744. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48745. /**
  48746. * Update the sampling mode of a given texture
  48747. * @param samplingMode defines the required sampling mode
  48748. * @param texture defines the texture to update
  48749. */
  48750. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48751. /**
  48752. * Binds the frame buffer to the specified texture.
  48753. * @param texture The texture to render to or null for the default canvas
  48754. * @param faceIndex The face of the texture to render to in case of cube texture
  48755. * @param requiredWidth The width of the target to render to
  48756. * @param requiredHeight The height of the target to render to
  48757. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48758. * @param lodLevel defines le lod level to bind to the frame buffer
  48759. */
  48760. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48761. /**
  48762. * Unbind the current render target texture from the webGL context
  48763. * @param texture defines the render target texture to unbind
  48764. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48765. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48766. */
  48767. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48768. /**
  48769. * Creates a dynamic vertex buffer
  48770. * @param vertices the data for the dynamic vertex buffer
  48771. * @returns the new WebGL dynamic buffer
  48772. */
  48773. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48774. /**
  48775. * Update the content of a dynamic texture
  48776. * @param texture defines the texture to update
  48777. * @param canvas defines the canvas containing the source
  48778. * @param invertY defines if data must be stored with Y axis inverted
  48779. * @param premulAlpha defines if alpha is stored as premultiplied
  48780. * @param format defines the format of the data
  48781. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48782. */
  48783. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48784. /**
  48785. * Gets a boolean indicating if all created effects are ready
  48786. * @returns true if all effects are ready
  48787. */
  48788. areAllEffectsReady(): boolean;
  48789. /**
  48790. * @hidden
  48791. * Get the current error code of the webGL context
  48792. * @returns the error code
  48793. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48794. */
  48795. getError(): number;
  48796. /** @hidden */
  48797. _getUnpackAlignement(): number;
  48798. /** @hidden */
  48799. _unpackFlipY(value: boolean): void;
  48800. /**
  48801. * Update a dynamic index buffer
  48802. * @param indexBuffer defines the target index buffer
  48803. * @param indices defines the data to update
  48804. * @param offset defines the offset in the target index buffer where update should start
  48805. */
  48806. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48807. /**
  48808. * Updates a dynamic vertex buffer.
  48809. * @param vertexBuffer the vertex buffer to update
  48810. * @param vertices the data used to update the vertex buffer
  48811. * @param byteOffset the byte offset of the data (optional)
  48812. * @param byteLength the byte length of the data (optional)
  48813. */
  48814. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48815. /** @hidden */
  48816. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48817. /** @hidden */
  48818. _bindTexture(channel: number, texture: InternalTexture): void;
  48819. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48820. /**
  48821. * 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
  48822. */
  48823. releaseEffects(): void;
  48824. displayLoadingUI(): void;
  48825. hideLoadingUI(): void;
  48826. /** @hidden */
  48827. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48828. /** @hidden */
  48829. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48830. /** @hidden */
  48831. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48832. /** @hidden */
  48833. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48834. }
  48835. }
  48836. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48837. import { Nullable, int } from "babylonjs/types";
  48838. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48839. /** @hidden */
  48840. export class _OcclusionDataStorage {
  48841. /** @hidden */
  48842. occlusionInternalRetryCounter: number;
  48843. /** @hidden */
  48844. isOcclusionQueryInProgress: boolean;
  48845. /** @hidden */
  48846. isOccluded: boolean;
  48847. /** @hidden */
  48848. occlusionRetryCount: number;
  48849. /** @hidden */
  48850. occlusionType: number;
  48851. /** @hidden */
  48852. occlusionQueryAlgorithmType: number;
  48853. }
  48854. module "babylonjs/Engines/engine" {
  48855. interface Engine {
  48856. /**
  48857. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48858. * @return the new query
  48859. */
  48860. createQuery(): WebGLQuery;
  48861. /**
  48862. * Delete and release a webGL query
  48863. * @param query defines the query to delete
  48864. * @return the current engine
  48865. */
  48866. deleteQuery(query: WebGLQuery): Engine;
  48867. /**
  48868. * Check if a given query has resolved and got its value
  48869. * @param query defines the query to check
  48870. * @returns true if the query got its value
  48871. */
  48872. isQueryResultAvailable(query: WebGLQuery): boolean;
  48873. /**
  48874. * Gets the value of a given query
  48875. * @param query defines the query to check
  48876. * @returns the value of the query
  48877. */
  48878. getQueryResult(query: WebGLQuery): number;
  48879. /**
  48880. * Initiates an occlusion query
  48881. * @param algorithmType defines the algorithm to use
  48882. * @param query defines the query to use
  48883. * @returns the current engine
  48884. * @see http://doc.babylonjs.com/features/occlusionquery
  48885. */
  48886. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48887. /**
  48888. * Ends an occlusion query
  48889. * @see http://doc.babylonjs.com/features/occlusionquery
  48890. * @param algorithmType defines the algorithm to use
  48891. * @returns the current engine
  48892. */
  48893. endOcclusionQuery(algorithmType: number): Engine;
  48894. /**
  48895. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48896. * Please note that only one query can be issued at a time
  48897. * @returns a time token used to track the time span
  48898. */
  48899. startTimeQuery(): Nullable<_TimeToken>;
  48900. /**
  48901. * Ends a time query
  48902. * @param token defines the token used to measure the time span
  48903. * @returns the time spent (in ns)
  48904. */
  48905. endTimeQuery(token: _TimeToken): int;
  48906. /** @hidden */
  48907. _currentNonTimestampToken: Nullable<_TimeToken>;
  48908. /** @hidden */
  48909. _createTimeQuery(): WebGLQuery;
  48910. /** @hidden */
  48911. _deleteTimeQuery(query: WebGLQuery): void;
  48912. /** @hidden */
  48913. _getGlAlgorithmType(algorithmType: number): number;
  48914. /** @hidden */
  48915. _getTimeQueryResult(query: WebGLQuery): any;
  48916. /** @hidden */
  48917. _getTimeQueryAvailability(query: WebGLQuery): any;
  48918. }
  48919. }
  48920. module "babylonjs/Meshes/abstractMesh" {
  48921. interface AbstractMesh {
  48922. /**
  48923. * Backing filed
  48924. * @hidden
  48925. */
  48926. __occlusionDataStorage: _OcclusionDataStorage;
  48927. /**
  48928. * Access property
  48929. * @hidden
  48930. */
  48931. _occlusionDataStorage: _OcclusionDataStorage;
  48932. /**
  48933. * 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.
  48934. * The default value is -1 which means don't break the query and wait till the result
  48935. * @see http://doc.babylonjs.com/features/occlusionquery
  48936. */
  48937. occlusionRetryCount: number;
  48938. /**
  48939. * 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:
  48940. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48941. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48942. * * 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.
  48943. * @see http://doc.babylonjs.com/features/occlusionquery
  48944. */
  48945. occlusionType: number;
  48946. /**
  48947. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48948. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48949. * * 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.
  48950. * @see http://doc.babylonjs.com/features/occlusionquery
  48951. */
  48952. occlusionQueryAlgorithmType: number;
  48953. /**
  48954. * 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
  48955. * @see http://doc.babylonjs.com/features/occlusionquery
  48956. */
  48957. isOccluded: boolean;
  48958. /**
  48959. * Flag to check the progress status of the query
  48960. * @see http://doc.babylonjs.com/features/occlusionquery
  48961. */
  48962. isOcclusionQueryInProgress: boolean;
  48963. }
  48964. }
  48965. }
  48966. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48967. import { Nullable } from "babylonjs/types";
  48968. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48969. /** @hidden */
  48970. export var _forceTransformFeedbackToBundle: boolean;
  48971. module "babylonjs/Engines/engine" {
  48972. interface Engine {
  48973. /**
  48974. * Creates a webGL transform feedback object
  48975. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48976. * @returns the webGL transform feedback object
  48977. */
  48978. createTransformFeedback(): WebGLTransformFeedback;
  48979. /**
  48980. * Delete a webGL transform feedback object
  48981. * @param value defines the webGL transform feedback object to delete
  48982. */
  48983. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48984. /**
  48985. * Bind a webGL transform feedback object to the webgl context
  48986. * @param value defines the webGL transform feedback object to bind
  48987. */
  48988. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48989. /**
  48990. * Begins a transform feedback operation
  48991. * @param usePoints defines if points or triangles must be used
  48992. */
  48993. beginTransformFeedback(usePoints: boolean): void;
  48994. /**
  48995. * Ends a transform feedback operation
  48996. */
  48997. endTransformFeedback(): void;
  48998. /**
  48999. * Specify the varyings to use with transform feedback
  49000. * @param program defines the associated webGL program
  49001. * @param value defines the list of strings representing the varying names
  49002. */
  49003. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49004. /**
  49005. * Bind a webGL buffer for a transform feedback operation
  49006. * @param value defines the webGL buffer to bind
  49007. */
  49008. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49009. }
  49010. }
  49011. }
  49012. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49013. import { Scene } from "babylonjs/scene";
  49014. import { Engine } from "babylonjs/Engines/engine";
  49015. import { Texture } from "babylonjs/Materials/Textures/texture";
  49016. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49017. import "babylonjs/Engines/Extensions/engine.multiRender";
  49018. /**
  49019. * Creation options of the multi render target texture.
  49020. */
  49021. export interface IMultiRenderTargetOptions {
  49022. /**
  49023. * Define if the texture needs to create mip maps after render.
  49024. */
  49025. generateMipMaps?: boolean;
  49026. /**
  49027. * Define the types of all the draw buffers we want to create
  49028. */
  49029. types?: number[];
  49030. /**
  49031. * Define the sampling modes of all the draw buffers we want to create
  49032. */
  49033. samplingModes?: number[];
  49034. /**
  49035. * Define if a depth buffer is required
  49036. */
  49037. generateDepthBuffer?: boolean;
  49038. /**
  49039. * Define if a stencil buffer is required
  49040. */
  49041. generateStencilBuffer?: boolean;
  49042. /**
  49043. * Define if a depth texture is required instead of a depth buffer
  49044. */
  49045. generateDepthTexture?: boolean;
  49046. /**
  49047. * Define the number of desired draw buffers
  49048. */
  49049. textureCount?: number;
  49050. /**
  49051. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49052. */
  49053. doNotChangeAspectRatio?: boolean;
  49054. /**
  49055. * Define the default type of the buffers we are creating
  49056. */
  49057. defaultType?: number;
  49058. }
  49059. /**
  49060. * A multi render target, like a render target provides the ability to render to a texture.
  49061. * Unlike the render target, it can render to several draw buffers in one draw.
  49062. * This is specially interesting in deferred rendering or for any effects requiring more than
  49063. * just one color from a single pass.
  49064. */
  49065. export class MultiRenderTarget extends RenderTargetTexture {
  49066. private _internalTextures;
  49067. private _textures;
  49068. private _multiRenderTargetOptions;
  49069. /**
  49070. * Get if draw buffers are currently supported by the used hardware and browser.
  49071. */
  49072. get isSupported(): boolean;
  49073. /**
  49074. * Get the list of textures generated by the multi render target.
  49075. */
  49076. get textures(): Texture[];
  49077. /**
  49078. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49079. */
  49080. get depthTexture(): Texture;
  49081. /**
  49082. * Set the wrapping mode on U of all the textures we are rendering to.
  49083. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49084. */
  49085. set wrapU(wrap: number);
  49086. /**
  49087. * Set the wrapping mode on V of all the textures we are rendering to.
  49088. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49089. */
  49090. set wrapV(wrap: number);
  49091. /**
  49092. * Instantiate a new multi render target texture.
  49093. * A multi render target, like a render target provides the ability to render to a texture.
  49094. * Unlike the render target, it can render to several draw buffers in one draw.
  49095. * This is specially interesting in deferred rendering or for any effects requiring more than
  49096. * just one color from a single pass.
  49097. * @param name Define the name of the texture
  49098. * @param size Define the size of the buffers to render to
  49099. * @param count Define the number of target we are rendering into
  49100. * @param scene Define the scene the texture belongs to
  49101. * @param options Define the options used to create the multi render target
  49102. */
  49103. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49104. /** @hidden */
  49105. _rebuild(): void;
  49106. private _createInternalTextures;
  49107. private _createTextures;
  49108. /**
  49109. * Define the number of samples used if MSAA is enabled.
  49110. */
  49111. get samples(): number;
  49112. set samples(value: number);
  49113. /**
  49114. * Resize all the textures in the multi render target.
  49115. * Be carrefull as it will recreate all the data in the new texture.
  49116. * @param size Define the new size
  49117. */
  49118. resize(size: any): void;
  49119. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49120. /**
  49121. * Dispose the render targets and their associated resources
  49122. */
  49123. dispose(): void;
  49124. /**
  49125. * Release all the underlying texture used as draw buffers.
  49126. */
  49127. releaseInternalTextures(): void;
  49128. }
  49129. }
  49130. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49131. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49132. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49133. import { Nullable } from "babylonjs/types";
  49134. module "babylonjs/Engines/thinEngine" {
  49135. interface ThinEngine {
  49136. /**
  49137. * Unbind a list of render target textures from the webGL context
  49138. * This is used only when drawBuffer extension or webGL2 are active
  49139. * @param textures defines the render target textures to unbind
  49140. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49141. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49142. */
  49143. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49144. /**
  49145. * Create a multi render target texture
  49146. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49147. * @param size defines the size of the texture
  49148. * @param options defines the creation options
  49149. * @returns the cube texture as an InternalTexture
  49150. */
  49151. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49152. /**
  49153. * Update the sample count for a given multiple render target texture
  49154. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49155. * @param textures defines the textures to update
  49156. * @param samples defines the sample count to set
  49157. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49158. */
  49159. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49160. }
  49161. }
  49162. }
  49163. declare module "babylonjs/Engines/Extensions/engine.views" {
  49164. import { Camera } from "babylonjs/Cameras/camera";
  49165. import { Nullable } from "babylonjs/types";
  49166. /**
  49167. * Class used to define an additional view for the engine
  49168. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49169. */
  49170. export class EngineView {
  49171. /** Defines the canvas where to render the view */
  49172. target: HTMLCanvasElement;
  49173. /** Defines an optional camera used to render the view (will use active camera else) */
  49174. camera?: Camera;
  49175. }
  49176. module "babylonjs/Engines/engine" {
  49177. interface Engine {
  49178. /**
  49179. * Gets or sets the HTML element to use for attaching events
  49180. */
  49181. inputElement: Nullable<HTMLElement>;
  49182. /**
  49183. * Gets the current engine view
  49184. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49185. */
  49186. activeView: Nullable<EngineView>;
  49187. /** Gets or sets the list of views */
  49188. views: EngineView[];
  49189. /**
  49190. * Register a new child canvas
  49191. * @param canvas defines the canvas to register
  49192. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49193. * @returns the associated view
  49194. */
  49195. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49196. /**
  49197. * Remove a registered child canvas
  49198. * @param canvas defines the canvas to remove
  49199. * @returns the current engine
  49200. */
  49201. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49202. }
  49203. }
  49204. }
  49205. declare module "babylonjs/Engines/Extensions/index" {
  49206. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49207. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49208. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49209. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49210. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49211. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49212. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49213. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49214. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49215. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49216. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49217. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49218. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49219. export * from "babylonjs/Engines/Extensions/engine.views";
  49220. }
  49221. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49222. import { Nullable } from "babylonjs/types";
  49223. /**
  49224. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49225. */
  49226. export interface CubeMapInfo {
  49227. /**
  49228. * The pixel array for the front face.
  49229. * This is stored in format, left to right, up to down format.
  49230. */
  49231. front: Nullable<ArrayBufferView>;
  49232. /**
  49233. * The pixel array for the back face.
  49234. * This is stored in format, left to right, up to down format.
  49235. */
  49236. back: Nullable<ArrayBufferView>;
  49237. /**
  49238. * The pixel array for the left face.
  49239. * This is stored in format, left to right, up to down format.
  49240. */
  49241. left: Nullable<ArrayBufferView>;
  49242. /**
  49243. * The pixel array for the right face.
  49244. * This is stored in format, left to right, up to down format.
  49245. */
  49246. right: Nullable<ArrayBufferView>;
  49247. /**
  49248. * The pixel array for the up face.
  49249. * This is stored in format, left to right, up to down format.
  49250. */
  49251. up: Nullable<ArrayBufferView>;
  49252. /**
  49253. * The pixel array for the down face.
  49254. * This is stored in format, left to right, up to down format.
  49255. */
  49256. down: Nullable<ArrayBufferView>;
  49257. /**
  49258. * The size of the cubemap stored.
  49259. *
  49260. * Each faces will be size * size pixels.
  49261. */
  49262. size: number;
  49263. /**
  49264. * The format of the texture.
  49265. *
  49266. * RGBA, RGB.
  49267. */
  49268. format: number;
  49269. /**
  49270. * The type of the texture data.
  49271. *
  49272. * UNSIGNED_INT, FLOAT.
  49273. */
  49274. type: number;
  49275. /**
  49276. * Specifies whether the texture is in gamma space.
  49277. */
  49278. gammaSpace: boolean;
  49279. }
  49280. /**
  49281. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49282. */
  49283. export class PanoramaToCubeMapTools {
  49284. private static FACE_FRONT;
  49285. private static FACE_BACK;
  49286. private static FACE_RIGHT;
  49287. private static FACE_LEFT;
  49288. private static FACE_DOWN;
  49289. private static FACE_UP;
  49290. /**
  49291. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49292. *
  49293. * @param float32Array The source data.
  49294. * @param inputWidth The width of the input panorama.
  49295. * @param inputHeight The height of the input panorama.
  49296. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49297. * @return The cubemap data
  49298. */
  49299. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49300. private static CreateCubemapTexture;
  49301. private static CalcProjectionSpherical;
  49302. }
  49303. }
  49304. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49305. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49306. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49307. import { Nullable } from "babylonjs/types";
  49308. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49309. /**
  49310. * Helper class dealing with the extraction of spherical polynomial dataArray
  49311. * from a cube map.
  49312. */
  49313. export class CubeMapToSphericalPolynomialTools {
  49314. private static FileFaces;
  49315. /**
  49316. * Converts a texture to the according Spherical Polynomial data.
  49317. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49318. *
  49319. * @param texture The texture to extract the information from.
  49320. * @return The Spherical Polynomial data.
  49321. */
  49322. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49323. /**
  49324. * Converts a cubemap to the according Spherical Polynomial data.
  49325. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49326. *
  49327. * @param cubeInfo The Cube map to extract the information from.
  49328. * @return The Spherical Polynomial data.
  49329. */
  49330. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49331. }
  49332. }
  49333. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49334. import { Nullable } from "babylonjs/types";
  49335. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49336. module "babylonjs/Materials/Textures/baseTexture" {
  49337. interface BaseTexture {
  49338. /**
  49339. * Get the polynomial representation of the texture data.
  49340. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49341. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49342. */
  49343. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49344. }
  49345. }
  49346. }
  49347. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49348. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49349. /** @hidden */
  49350. export var rgbdEncodePixelShader: {
  49351. name: string;
  49352. shader: string;
  49353. };
  49354. }
  49355. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49356. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49357. /** @hidden */
  49358. export var rgbdDecodePixelShader: {
  49359. name: string;
  49360. shader: string;
  49361. };
  49362. }
  49363. declare module "babylonjs/Misc/environmentTextureTools" {
  49364. import { Nullable } from "babylonjs/types";
  49365. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49366. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49367. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49368. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49369. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49370. import "babylonjs/Shaders/rgbdEncode.fragment";
  49371. import "babylonjs/Shaders/rgbdDecode.fragment";
  49372. /**
  49373. * Raw texture data and descriptor sufficient for WebGL texture upload
  49374. */
  49375. export interface EnvironmentTextureInfo {
  49376. /**
  49377. * Version of the environment map
  49378. */
  49379. version: number;
  49380. /**
  49381. * Width of image
  49382. */
  49383. width: number;
  49384. /**
  49385. * Irradiance information stored in the file.
  49386. */
  49387. irradiance: any;
  49388. /**
  49389. * Specular information stored in the file.
  49390. */
  49391. specular: any;
  49392. }
  49393. /**
  49394. * Defines One Image in the file. It requires only the position in the file
  49395. * as well as the length.
  49396. */
  49397. interface BufferImageData {
  49398. /**
  49399. * Length of the image data.
  49400. */
  49401. length: number;
  49402. /**
  49403. * Position of the data from the null terminator delimiting the end of the JSON.
  49404. */
  49405. position: number;
  49406. }
  49407. /**
  49408. * Defines the specular data enclosed in the file.
  49409. * This corresponds to the version 1 of the data.
  49410. */
  49411. export interface EnvironmentTextureSpecularInfoV1 {
  49412. /**
  49413. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49414. */
  49415. specularDataPosition?: number;
  49416. /**
  49417. * This contains all the images data needed to reconstruct the cubemap.
  49418. */
  49419. mipmaps: Array<BufferImageData>;
  49420. /**
  49421. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49422. */
  49423. lodGenerationScale: number;
  49424. }
  49425. /**
  49426. * Sets of helpers addressing the serialization and deserialization of environment texture
  49427. * stored in a BabylonJS env file.
  49428. * Those files are usually stored as .env files.
  49429. */
  49430. export class EnvironmentTextureTools {
  49431. /**
  49432. * Magic number identifying the env file.
  49433. */
  49434. private static _MagicBytes;
  49435. /**
  49436. * Gets the environment info from an env file.
  49437. * @param data The array buffer containing the .env bytes.
  49438. * @returns the environment file info (the json header) if successfully parsed.
  49439. */
  49440. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49441. /**
  49442. * Creates an environment texture from a loaded cube texture.
  49443. * @param texture defines the cube texture to convert in env file
  49444. * @return a promise containing the environment data if succesfull.
  49445. */
  49446. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49447. /**
  49448. * Creates a JSON representation of the spherical data.
  49449. * @param texture defines the texture containing the polynomials
  49450. * @return the JSON representation of the spherical info
  49451. */
  49452. private static _CreateEnvTextureIrradiance;
  49453. /**
  49454. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49455. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  49456. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49457. * @return the views described by info providing access to the underlying buffer
  49458. */
  49459. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49460. /**
  49461. * Uploads the texture info contained in the env file to the GPU.
  49462. * @param texture defines the internal texture to upload to
  49463. * @param arrayBuffer defines the buffer cotaining the data to load
  49464. * @param info defines the texture info retrieved through the GetEnvInfo method
  49465. * @returns a promise
  49466. */
  49467. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49468. private static _OnImageReadyAsync;
  49469. /**
  49470. * Uploads the levels of image data to the GPU.
  49471. * @param texture defines the internal texture to upload to
  49472. * @param imageData defines the array buffer views of image data [mipmap][face]
  49473. * @returns a promise
  49474. */
  49475. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49476. /**
  49477. * Uploads spherical polynomials information to the texture.
  49478. * @param texture defines the texture we are trying to upload the information to
  49479. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49480. */
  49481. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49482. /** @hidden */
  49483. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49484. }
  49485. }
  49486. declare module "babylonjs/Maths/math.vertexFormat" {
  49487. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49488. /**
  49489. * Contains position and normal vectors for a vertex
  49490. */
  49491. export class PositionNormalVertex {
  49492. /** the position of the vertex (defaut: 0,0,0) */
  49493. position: Vector3;
  49494. /** the normal of the vertex (defaut: 0,1,0) */
  49495. normal: Vector3;
  49496. /**
  49497. * Creates a PositionNormalVertex
  49498. * @param position the position of the vertex (defaut: 0,0,0)
  49499. * @param normal the normal of the vertex (defaut: 0,1,0)
  49500. */
  49501. constructor(
  49502. /** the position of the vertex (defaut: 0,0,0) */
  49503. position?: Vector3,
  49504. /** the normal of the vertex (defaut: 0,1,0) */
  49505. normal?: Vector3);
  49506. /**
  49507. * Clones the PositionNormalVertex
  49508. * @returns the cloned PositionNormalVertex
  49509. */
  49510. clone(): PositionNormalVertex;
  49511. }
  49512. /**
  49513. * Contains position, normal and uv vectors for a vertex
  49514. */
  49515. export class PositionNormalTextureVertex {
  49516. /** the position of the vertex (defaut: 0,0,0) */
  49517. position: Vector3;
  49518. /** the normal of the vertex (defaut: 0,1,0) */
  49519. normal: Vector3;
  49520. /** the uv of the vertex (default: 0,0) */
  49521. uv: Vector2;
  49522. /**
  49523. * Creates a PositionNormalTextureVertex
  49524. * @param position the position of the vertex (defaut: 0,0,0)
  49525. * @param normal the normal of the vertex (defaut: 0,1,0)
  49526. * @param uv the uv of the vertex (default: 0,0)
  49527. */
  49528. constructor(
  49529. /** the position of the vertex (defaut: 0,0,0) */
  49530. position?: Vector3,
  49531. /** the normal of the vertex (defaut: 0,1,0) */
  49532. normal?: Vector3,
  49533. /** the uv of the vertex (default: 0,0) */
  49534. uv?: Vector2);
  49535. /**
  49536. * Clones the PositionNormalTextureVertex
  49537. * @returns the cloned PositionNormalTextureVertex
  49538. */
  49539. clone(): PositionNormalTextureVertex;
  49540. }
  49541. }
  49542. declare module "babylonjs/Maths/math" {
  49543. export * from "babylonjs/Maths/math.axis";
  49544. export * from "babylonjs/Maths/math.color";
  49545. export * from "babylonjs/Maths/math.constants";
  49546. export * from "babylonjs/Maths/math.frustum";
  49547. export * from "babylonjs/Maths/math.path";
  49548. export * from "babylonjs/Maths/math.plane";
  49549. export * from "babylonjs/Maths/math.size";
  49550. export * from "babylonjs/Maths/math.vector";
  49551. export * from "babylonjs/Maths/math.vertexFormat";
  49552. export * from "babylonjs/Maths/math.viewport";
  49553. }
  49554. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49555. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49556. /** @hidden */
  49557. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49558. private _genericAttributeLocation;
  49559. private _varyingLocationCount;
  49560. private _varyingLocationMap;
  49561. private _replacements;
  49562. private _textureCount;
  49563. private _uniforms;
  49564. lineProcessor(line: string): string;
  49565. attributeProcessor(attribute: string): string;
  49566. varyingProcessor(varying: string, isFragment: boolean): string;
  49567. uniformProcessor(uniform: string): string;
  49568. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49569. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49570. }
  49571. }
  49572. declare module "babylonjs/Engines/nativeEngine" {
  49573. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49574. import { Engine } from "babylonjs/Engines/engine";
  49575. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49578. import { Effect } from "babylonjs/Materials/effect";
  49579. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49580. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49581. import { IColor4Like } from "babylonjs/Maths/math.like";
  49582. import { Scene } from "babylonjs/scene";
  49583. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49584. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49585. /**
  49586. * Container for accessors for natively-stored mesh data buffers.
  49587. */
  49588. class NativeDataBuffer extends DataBuffer {
  49589. /**
  49590. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49591. */
  49592. nativeIndexBuffer?: any;
  49593. /**
  49594. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49595. */
  49596. nativeVertexBuffer?: any;
  49597. }
  49598. /** @hidden */
  49599. class NativeTexture extends InternalTexture {
  49600. getInternalTexture(): InternalTexture;
  49601. getViewCount(): number;
  49602. }
  49603. /** @hidden */
  49604. export class NativeEngine extends Engine {
  49605. private readonly _native;
  49606. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49607. private readonly INVALID_HANDLE;
  49608. getHardwareScalingLevel(): number;
  49609. constructor();
  49610. /**
  49611. * Can be used to override the current requestAnimationFrame requester.
  49612. * @hidden
  49613. */
  49614. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49615. /**
  49616. * Override default engine behavior.
  49617. * @param color
  49618. * @param backBuffer
  49619. * @param depth
  49620. * @param stencil
  49621. */
  49622. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49623. /**
  49624. * Gets host document
  49625. * @returns the host document object
  49626. */
  49627. getHostDocument(): Nullable<Document>;
  49628. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49629. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49630. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49631. recordVertexArrayObject(vertexBuffers: {
  49632. [key: string]: VertexBuffer;
  49633. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49634. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49635. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49636. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49637. /**
  49638. * Draw a list of indexed primitives
  49639. * @param fillMode defines the primitive to use
  49640. * @param indexStart defines the starting index
  49641. * @param indexCount defines the number of index to draw
  49642. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49643. */
  49644. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49645. /**
  49646. * Draw a list of unindexed primitives
  49647. * @param fillMode defines the primitive to use
  49648. * @param verticesStart defines the index of first vertex to draw
  49649. * @param verticesCount defines the count of vertices to draw
  49650. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49651. */
  49652. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49653. createPipelineContext(): IPipelineContext;
  49654. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49655. /** @hidden */
  49656. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49657. /** @hidden */
  49658. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49659. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49660. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49661. protected _setProgram(program: WebGLProgram): void;
  49662. _releaseEffect(effect: Effect): void;
  49663. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49664. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49665. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49666. bindSamplers(effect: Effect): void;
  49667. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49668. getRenderWidth(useScreen?: boolean): number;
  49669. getRenderHeight(useScreen?: boolean): number;
  49670. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49671. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49672. /**
  49673. * Set the z offset to apply to current rendering
  49674. * @param value defines the offset to apply
  49675. */
  49676. setZOffset(value: number): void;
  49677. /**
  49678. * Gets the current value of the zOffset
  49679. * @returns the current zOffset state
  49680. */
  49681. getZOffset(): number;
  49682. /**
  49683. * Enable or disable depth buffering
  49684. * @param enable defines the state to set
  49685. */
  49686. setDepthBuffer(enable: boolean): void;
  49687. /**
  49688. * Gets a boolean indicating if depth writing is enabled
  49689. * @returns the current depth writing state
  49690. */
  49691. getDepthWrite(): boolean;
  49692. /**
  49693. * Enable or disable depth writing
  49694. * @param enable defines the state to set
  49695. */
  49696. setDepthWrite(enable: boolean): void;
  49697. /**
  49698. * Enable or disable color writing
  49699. * @param enable defines the state to set
  49700. */
  49701. setColorWrite(enable: boolean): void;
  49702. /**
  49703. * Gets a boolean indicating if color writing is enabled
  49704. * @returns the current color writing state
  49705. */
  49706. getColorWrite(): boolean;
  49707. /**
  49708. * Sets alpha constants used by some alpha blending modes
  49709. * @param r defines the red component
  49710. * @param g defines the green component
  49711. * @param b defines the blue component
  49712. * @param a defines the alpha component
  49713. */
  49714. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49715. /**
  49716. * Sets the current alpha mode
  49717. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49718. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49720. */
  49721. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49722. /**
  49723. * Gets the current alpha mode
  49724. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49725. * @returns the current alpha mode
  49726. */
  49727. getAlphaMode(): number;
  49728. setInt(uniform: WebGLUniformLocation, int: number): void;
  49729. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49730. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49731. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49732. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49733. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49734. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49735. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49736. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49737. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49738. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49739. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49740. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49741. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49742. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49743. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49744. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49745. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49746. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49747. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49748. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49749. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49750. wipeCaches(bruteForce?: boolean): void;
  49751. _createTexture(): WebGLTexture;
  49752. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49753. /**
  49754. * Usually called from BABYLON.Texture.ts.
  49755. * Passed information to create a WebGLTexture
  49756. * @param urlArg defines a value which contains one of the following:
  49757. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49758. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49759. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49760. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49761. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49762. * @param scene needed for loading to the correct scene
  49763. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49764. * @param onLoad optional callback to be called upon successful completion
  49765. * @param onError optional callback to be called upon failure
  49766. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49767. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49768. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49769. * @param forcedExtension defines the extension to use to pick the right loader
  49770. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49771. */
  49772. 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;
  49773. /**
  49774. * Creates a cube texture
  49775. * @param rootUrl defines the url where the files to load is located
  49776. * @param scene defines the current scene
  49777. * @param files defines the list of files to load (1 per face)
  49778. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49779. * @param onLoad defines an optional callback raised when the texture is loaded
  49780. * @param onError defines an optional callback raised if there is an issue to load the texture
  49781. * @param format defines the format of the data
  49782. * @param forcedExtension defines the extension to use to pick the right loader
  49783. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49784. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49785. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49786. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49787. * @returns the cube texture as an InternalTexture
  49788. */
  49789. 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;
  49790. private _getSamplingFilter;
  49791. private static _GetNativeTextureFormat;
  49792. createRenderTargetTexture(size: number | {
  49793. width: number;
  49794. height: number;
  49795. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49796. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49797. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49798. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49799. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49800. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49801. /**
  49802. * Updates a dynamic vertex buffer.
  49803. * @param vertexBuffer the vertex buffer to update
  49804. * @param data the data used to update the vertex buffer
  49805. * @param byteOffset the byte offset of the data (optional)
  49806. * @param byteLength the byte length of the data (optional)
  49807. */
  49808. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49809. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49810. private _updateAnisotropicLevel;
  49811. private _getAddressMode;
  49812. /** @hidden */
  49813. _bindTexture(channel: number, texture: InternalTexture): void;
  49814. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49815. releaseEffects(): void;
  49816. /** @hidden */
  49817. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49818. /** @hidden */
  49819. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49820. /** @hidden */
  49821. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49822. /** @hidden */
  49823. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49824. }
  49825. }
  49826. declare module "babylonjs/Engines/index" {
  49827. export * from "babylonjs/Engines/constants";
  49828. export * from "babylonjs/Engines/engineCapabilities";
  49829. export * from "babylonjs/Engines/instancingAttributeInfo";
  49830. export * from "babylonjs/Engines/thinEngine";
  49831. export * from "babylonjs/Engines/engine";
  49832. export * from "babylonjs/Engines/engineStore";
  49833. export * from "babylonjs/Engines/nullEngine";
  49834. export * from "babylonjs/Engines/Extensions/index";
  49835. export * from "babylonjs/Engines/IPipelineContext";
  49836. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49837. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49838. export * from "babylonjs/Engines/nativeEngine";
  49839. }
  49840. declare module "babylonjs/Events/clipboardEvents" {
  49841. /**
  49842. * Gather the list of clipboard event types as constants.
  49843. */
  49844. export class ClipboardEventTypes {
  49845. /**
  49846. * The clipboard event is fired when a copy command is active (pressed).
  49847. */
  49848. static readonly COPY: number;
  49849. /**
  49850. * The clipboard event is fired when a cut command is active (pressed).
  49851. */
  49852. static readonly CUT: number;
  49853. /**
  49854. * The clipboard event is fired when a paste command is active (pressed).
  49855. */
  49856. static readonly PASTE: number;
  49857. }
  49858. /**
  49859. * This class is used to store clipboard related info for the onClipboardObservable event.
  49860. */
  49861. export class ClipboardInfo {
  49862. /**
  49863. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49864. */
  49865. type: number;
  49866. /**
  49867. * Defines the related dom event
  49868. */
  49869. event: ClipboardEvent;
  49870. /**
  49871. *Creates an instance of ClipboardInfo.
  49872. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49873. * @param event Defines the related dom event
  49874. */
  49875. constructor(
  49876. /**
  49877. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49878. */
  49879. type: number,
  49880. /**
  49881. * Defines the related dom event
  49882. */
  49883. event: ClipboardEvent);
  49884. /**
  49885. * Get the clipboard event's type from the keycode.
  49886. * @param keyCode Defines the keyCode for the current keyboard event.
  49887. * @return {number}
  49888. */
  49889. static GetTypeFromCharacter(keyCode: number): number;
  49890. }
  49891. }
  49892. declare module "babylonjs/Events/index" {
  49893. export * from "babylonjs/Events/keyboardEvents";
  49894. export * from "babylonjs/Events/pointerEvents";
  49895. export * from "babylonjs/Events/clipboardEvents";
  49896. }
  49897. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49898. import { Scene } from "babylonjs/scene";
  49899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49900. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49901. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49902. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49903. /**
  49904. * Google Daydream controller
  49905. */
  49906. export class DaydreamController extends WebVRController {
  49907. /**
  49908. * Base Url for the controller model.
  49909. */
  49910. static MODEL_BASE_URL: string;
  49911. /**
  49912. * File name for the controller model.
  49913. */
  49914. static MODEL_FILENAME: string;
  49915. /**
  49916. * Gamepad Id prefix used to identify Daydream Controller.
  49917. */
  49918. static readonly GAMEPAD_ID_PREFIX: string;
  49919. /**
  49920. * Creates a new DaydreamController from a gamepad
  49921. * @param vrGamepad the gamepad that the controller should be created from
  49922. */
  49923. constructor(vrGamepad: any);
  49924. /**
  49925. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49926. * @param scene scene in which to add meshes
  49927. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49928. */
  49929. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49930. /**
  49931. * Called once for each button that changed state since the last frame
  49932. * @param buttonIdx Which button index changed
  49933. * @param state New state of the button
  49934. * @param changes Which properties on the state changed since last frame
  49935. */
  49936. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49937. }
  49938. }
  49939. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49940. import { Scene } from "babylonjs/scene";
  49941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49942. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49943. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49944. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49945. /**
  49946. * Gear VR Controller
  49947. */
  49948. export class GearVRController extends WebVRController {
  49949. /**
  49950. * Base Url for the controller model.
  49951. */
  49952. static MODEL_BASE_URL: string;
  49953. /**
  49954. * File name for the controller model.
  49955. */
  49956. static MODEL_FILENAME: string;
  49957. /**
  49958. * Gamepad Id prefix used to identify this controller.
  49959. */
  49960. static readonly GAMEPAD_ID_PREFIX: string;
  49961. private readonly _buttonIndexToObservableNameMap;
  49962. /**
  49963. * Creates a new GearVRController from a gamepad
  49964. * @param vrGamepad the gamepad that the controller should be created from
  49965. */
  49966. constructor(vrGamepad: any);
  49967. /**
  49968. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49969. * @param scene scene in which to add meshes
  49970. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49971. */
  49972. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49973. /**
  49974. * Called once for each button that changed state since the last frame
  49975. * @param buttonIdx Which button index changed
  49976. * @param state New state of the button
  49977. * @param changes Which properties on the state changed since last frame
  49978. */
  49979. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49980. }
  49981. }
  49982. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49983. import { Scene } from "babylonjs/scene";
  49984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49985. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49986. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49987. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49988. /**
  49989. * Generic Controller
  49990. */
  49991. export class GenericController extends WebVRController {
  49992. /**
  49993. * Base Url for the controller model.
  49994. */
  49995. static readonly MODEL_BASE_URL: string;
  49996. /**
  49997. * File name for the controller model.
  49998. */
  49999. static readonly MODEL_FILENAME: string;
  50000. /**
  50001. * Creates a new GenericController from a gamepad
  50002. * @param vrGamepad the gamepad that the controller should be created from
  50003. */
  50004. constructor(vrGamepad: any);
  50005. /**
  50006. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50007. * @param scene scene in which to add meshes
  50008. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50009. */
  50010. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50011. /**
  50012. * Called once for each button that changed state since the last frame
  50013. * @param buttonIdx Which button index changed
  50014. * @param state New state of the button
  50015. * @param changes Which properties on the state changed since last frame
  50016. */
  50017. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50018. }
  50019. }
  50020. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50021. import { Observable } from "babylonjs/Misc/observable";
  50022. import { Scene } from "babylonjs/scene";
  50023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50024. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50025. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50026. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50027. /**
  50028. * Oculus Touch Controller
  50029. */
  50030. export class OculusTouchController extends WebVRController {
  50031. /**
  50032. * Base Url for the controller model.
  50033. */
  50034. static MODEL_BASE_URL: string;
  50035. /**
  50036. * File name for the left controller model.
  50037. */
  50038. static MODEL_LEFT_FILENAME: string;
  50039. /**
  50040. * File name for the right controller model.
  50041. */
  50042. static MODEL_RIGHT_FILENAME: string;
  50043. /**
  50044. * Base Url for the Quest controller model.
  50045. */
  50046. static QUEST_MODEL_BASE_URL: string;
  50047. /**
  50048. * @hidden
  50049. * If the controllers are running on a device that needs the updated Quest controller models
  50050. */
  50051. static _IsQuest: boolean;
  50052. /**
  50053. * Fired when the secondary trigger on this controller is modified
  50054. */
  50055. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50056. /**
  50057. * Fired when the thumb rest on this controller is modified
  50058. */
  50059. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50060. /**
  50061. * Creates a new OculusTouchController from a gamepad
  50062. * @param vrGamepad the gamepad that the controller should be created from
  50063. */
  50064. constructor(vrGamepad: any);
  50065. /**
  50066. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50067. * @param scene scene in which to add meshes
  50068. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50069. */
  50070. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50071. /**
  50072. * Fired when the A button on this controller is modified
  50073. */
  50074. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50075. /**
  50076. * Fired when the B button on this controller is modified
  50077. */
  50078. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50079. /**
  50080. * Fired when the X button on this controller is modified
  50081. */
  50082. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50083. /**
  50084. * Fired when the Y button on this controller is modified
  50085. */
  50086. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50087. /**
  50088. * Called once for each button that changed state since the last frame
  50089. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50090. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50091. * 2) secondary trigger (same)
  50092. * 3) A (right) X (left), touch, pressed = value
  50093. * 4) B / Y
  50094. * 5) thumb rest
  50095. * @param buttonIdx Which button index changed
  50096. * @param state New state of the button
  50097. * @param changes Which properties on the state changed since last frame
  50098. */
  50099. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50100. }
  50101. }
  50102. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50103. import { Scene } from "babylonjs/scene";
  50104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50105. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50106. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50107. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50108. import { Observable } from "babylonjs/Misc/observable";
  50109. /**
  50110. * Vive Controller
  50111. */
  50112. export class ViveController extends WebVRController {
  50113. /**
  50114. * Base Url for the controller model.
  50115. */
  50116. static MODEL_BASE_URL: string;
  50117. /**
  50118. * File name for the controller model.
  50119. */
  50120. static MODEL_FILENAME: string;
  50121. /**
  50122. * Creates a new ViveController from a gamepad
  50123. * @param vrGamepad the gamepad that the controller should be created from
  50124. */
  50125. constructor(vrGamepad: any);
  50126. /**
  50127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50128. * @param scene scene in which to add meshes
  50129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50130. */
  50131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50132. /**
  50133. * Fired when the left button on this controller is modified
  50134. */
  50135. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50136. /**
  50137. * Fired when the right button on this controller is modified
  50138. */
  50139. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50140. /**
  50141. * Fired when the menu button on this controller is modified
  50142. */
  50143. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50144. /**
  50145. * Called once for each button that changed state since the last frame
  50146. * Vive mapping:
  50147. * 0: touchpad
  50148. * 1: trigger
  50149. * 2: left AND right buttons
  50150. * 3: menu button
  50151. * @param buttonIdx Which button index changed
  50152. * @param state New state of the button
  50153. * @param changes Which properties on the state changed since last frame
  50154. */
  50155. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50156. }
  50157. }
  50158. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50159. import { Observable } from "babylonjs/Misc/observable";
  50160. import { Scene } from "babylonjs/scene";
  50161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50162. import { Ray } from "babylonjs/Culling/ray";
  50163. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50164. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50165. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50166. /**
  50167. * Defines the WindowsMotionController object that the state of the windows motion controller
  50168. */
  50169. export class WindowsMotionController extends WebVRController {
  50170. /**
  50171. * The base url used to load the left and right controller models
  50172. */
  50173. static MODEL_BASE_URL: string;
  50174. /**
  50175. * The name of the left controller model file
  50176. */
  50177. static MODEL_LEFT_FILENAME: string;
  50178. /**
  50179. * The name of the right controller model file
  50180. */
  50181. static MODEL_RIGHT_FILENAME: string;
  50182. /**
  50183. * The controller name prefix for this controller type
  50184. */
  50185. static readonly GAMEPAD_ID_PREFIX: string;
  50186. /**
  50187. * The controller id pattern for this controller type
  50188. */
  50189. private static readonly GAMEPAD_ID_PATTERN;
  50190. private _loadedMeshInfo;
  50191. protected readonly _mapping: {
  50192. buttons: string[];
  50193. buttonMeshNames: {
  50194. 'trigger': string;
  50195. 'menu': string;
  50196. 'grip': string;
  50197. 'thumbstick': string;
  50198. 'trackpad': string;
  50199. };
  50200. buttonObservableNames: {
  50201. 'trigger': string;
  50202. 'menu': string;
  50203. 'grip': string;
  50204. 'thumbstick': string;
  50205. 'trackpad': string;
  50206. };
  50207. axisMeshNames: string[];
  50208. pointingPoseMeshName: string;
  50209. };
  50210. /**
  50211. * Fired when the trackpad on this controller is clicked
  50212. */
  50213. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50214. /**
  50215. * Fired when the trackpad on this controller is modified
  50216. */
  50217. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50218. /**
  50219. * The current x and y values of this controller's trackpad
  50220. */
  50221. trackpad: StickValues;
  50222. /**
  50223. * Creates a new WindowsMotionController from a gamepad
  50224. * @param vrGamepad the gamepad that the controller should be created from
  50225. */
  50226. constructor(vrGamepad: any);
  50227. /**
  50228. * Fired when the trigger on this controller is modified
  50229. */
  50230. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50231. /**
  50232. * Fired when the menu button on this controller is modified
  50233. */
  50234. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50235. /**
  50236. * Fired when the grip button on this controller is modified
  50237. */
  50238. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50239. /**
  50240. * Fired when the thumbstick button on this controller is modified
  50241. */
  50242. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50243. /**
  50244. * Fired when the touchpad button on this controller is modified
  50245. */
  50246. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50247. /**
  50248. * Fired when the touchpad values on this controller are modified
  50249. */
  50250. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50251. protected _updateTrackpad(): void;
  50252. /**
  50253. * Called once per frame by the engine.
  50254. */
  50255. update(): void;
  50256. /**
  50257. * Called once for each button that changed state since the last frame
  50258. * @param buttonIdx Which button index changed
  50259. * @param state New state of the button
  50260. * @param changes Which properties on the state changed since last frame
  50261. */
  50262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50263. /**
  50264. * Moves the buttons on the controller mesh based on their current state
  50265. * @param buttonName the name of the button to move
  50266. * @param buttonValue the value of the button which determines the buttons new position
  50267. */
  50268. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50269. /**
  50270. * Moves the axis on the controller mesh based on its current state
  50271. * @param axis the index of the axis
  50272. * @param axisValue the value of the axis which determines the meshes new position
  50273. * @hidden
  50274. */
  50275. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50276. /**
  50277. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50278. * @param scene scene in which to add meshes
  50279. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50280. */
  50281. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50282. /**
  50283. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50284. * can be transformed by button presses and axes values, based on this._mapping.
  50285. *
  50286. * @param scene scene in which the meshes exist
  50287. * @param meshes list of meshes that make up the controller model to process
  50288. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50289. */
  50290. private processModel;
  50291. private createMeshInfo;
  50292. /**
  50293. * Gets the ray of the controller in the direction the controller is pointing
  50294. * @param length the length the resulting ray should be
  50295. * @returns a ray in the direction the controller is pointing
  50296. */
  50297. getForwardRay(length?: number): Ray;
  50298. /**
  50299. * Disposes of the controller
  50300. */
  50301. dispose(): void;
  50302. }
  50303. /**
  50304. * This class represents a new windows motion controller in XR.
  50305. */
  50306. export class XRWindowsMotionController extends WindowsMotionController {
  50307. /**
  50308. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50309. */
  50310. protected readonly _mapping: {
  50311. buttons: string[];
  50312. buttonMeshNames: {
  50313. 'trigger': string;
  50314. 'menu': string;
  50315. 'grip': string;
  50316. 'thumbstick': string;
  50317. 'trackpad': string;
  50318. };
  50319. buttonObservableNames: {
  50320. 'trigger': string;
  50321. 'menu': string;
  50322. 'grip': string;
  50323. 'thumbstick': string;
  50324. 'trackpad': string;
  50325. };
  50326. axisMeshNames: string[];
  50327. pointingPoseMeshName: string;
  50328. };
  50329. /**
  50330. * Construct a new XR-Based windows motion controller
  50331. *
  50332. * @param gamepadInfo the gamepad object from the browser
  50333. */
  50334. constructor(gamepadInfo: any);
  50335. /**
  50336. * holds the thumbstick values (X,Y)
  50337. */
  50338. thumbstickValues: StickValues;
  50339. /**
  50340. * Fired when the thumbstick on this controller is clicked
  50341. */
  50342. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50343. /**
  50344. * Fired when the thumbstick on this controller is modified
  50345. */
  50346. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50347. /**
  50348. * Fired when the touchpad button on this controller is modified
  50349. */
  50350. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50351. /**
  50352. * Fired when the touchpad values on this controller are modified
  50353. */
  50354. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50355. /**
  50356. * Fired when the thumbstick button on this controller is modified
  50357. * here to prevent breaking changes
  50358. */
  50359. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50360. /**
  50361. * updating the thumbstick(!) and not the trackpad.
  50362. * This is named this way due to the difference between WebVR and XR and to avoid
  50363. * changing the parent class.
  50364. */
  50365. protected _updateTrackpad(): void;
  50366. /**
  50367. * Disposes the class with joy
  50368. */
  50369. dispose(): void;
  50370. }
  50371. }
  50372. declare module "babylonjs/Gamepads/Controllers/index" {
  50373. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50374. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50375. export * from "babylonjs/Gamepads/Controllers/genericController";
  50376. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50377. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50378. export * from "babylonjs/Gamepads/Controllers/viveController";
  50379. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50380. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50381. }
  50382. declare module "babylonjs/Gamepads/index" {
  50383. export * from "babylonjs/Gamepads/Controllers/index";
  50384. export * from "babylonjs/Gamepads/gamepad";
  50385. export * from "babylonjs/Gamepads/gamepadManager";
  50386. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50387. export * from "babylonjs/Gamepads/xboxGamepad";
  50388. export * from "babylonjs/Gamepads/dualShockGamepad";
  50389. }
  50390. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50391. import { Scene } from "babylonjs/scene";
  50392. import { Vector4 } from "babylonjs/Maths/math.vector";
  50393. import { Color4 } from "babylonjs/Maths/math.color";
  50394. import { Mesh } from "babylonjs/Meshes/mesh";
  50395. import { Nullable } from "babylonjs/types";
  50396. /**
  50397. * Class containing static functions to help procedurally build meshes
  50398. */
  50399. export class PolyhedronBuilder {
  50400. /**
  50401. * Creates a polyhedron mesh
  50402. * * 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
  50403. * * The parameter `size` (positive float, default 1) sets the polygon size
  50404. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50405. * * 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`
  50406. * * 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
  50407. * * 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)`)
  50408. * * 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
  50409. * * 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
  50410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50413. * @param name defines the name of the mesh
  50414. * @param options defines the options used to create the mesh
  50415. * @param scene defines the hosting scene
  50416. * @returns the polyhedron mesh
  50417. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50418. */
  50419. static CreatePolyhedron(name: string, options: {
  50420. type?: number;
  50421. size?: number;
  50422. sizeX?: number;
  50423. sizeY?: number;
  50424. sizeZ?: number;
  50425. custom?: any;
  50426. faceUV?: Vector4[];
  50427. faceColors?: Color4[];
  50428. flat?: boolean;
  50429. updatable?: boolean;
  50430. sideOrientation?: number;
  50431. frontUVs?: Vector4;
  50432. backUVs?: Vector4;
  50433. }, scene?: Nullable<Scene>): Mesh;
  50434. }
  50435. }
  50436. declare module "babylonjs/Gizmos/scaleGizmo" {
  50437. import { Observable } from "babylonjs/Misc/observable";
  50438. import { Nullable } from "babylonjs/types";
  50439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50440. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50441. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50442. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50443. /**
  50444. * Gizmo that enables scaling a mesh along 3 axis
  50445. */
  50446. export class ScaleGizmo extends Gizmo {
  50447. /**
  50448. * Internal gizmo used for interactions on the x axis
  50449. */
  50450. xGizmo: AxisScaleGizmo;
  50451. /**
  50452. * Internal gizmo used for interactions on the y axis
  50453. */
  50454. yGizmo: AxisScaleGizmo;
  50455. /**
  50456. * Internal gizmo used for interactions on the z axis
  50457. */
  50458. zGizmo: AxisScaleGizmo;
  50459. /**
  50460. * Internal gizmo used to scale all axis equally
  50461. */
  50462. uniformScaleGizmo: AxisScaleGizmo;
  50463. private _meshAttached;
  50464. private _updateGizmoRotationToMatchAttachedMesh;
  50465. private _snapDistance;
  50466. private _scaleRatio;
  50467. private _uniformScalingMesh;
  50468. private _octahedron;
  50469. private _sensitivity;
  50470. /** Fires an event when any of it's sub gizmos are dragged */
  50471. onDragStartObservable: Observable<unknown>;
  50472. /** Fires an event when any of it's sub gizmos are released from dragging */
  50473. onDragEndObservable: Observable<unknown>;
  50474. get attachedMesh(): Nullable<AbstractMesh>;
  50475. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50476. /**
  50477. * Creates a ScaleGizmo
  50478. * @param gizmoLayer The utility layer the gizmo will be added to
  50479. */
  50480. constructor(gizmoLayer?: UtilityLayerRenderer);
  50481. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50482. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50483. /**
  50484. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50485. */
  50486. set snapDistance(value: number);
  50487. get snapDistance(): number;
  50488. /**
  50489. * Ratio for the scale of the gizmo (Default: 1)
  50490. */
  50491. set scaleRatio(value: number);
  50492. get scaleRatio(): number;
  50493. /**
  50494. * Sensitivity factor for dragging (Default: 1)
  50495. */
  50496. set sensitivity(value: number);
  50497. get sensitivity(): number;
  50498. /**
  50499. * Disposes of the gizmo
  50500. */
  50501. dispose(): void;
  50502. }
  50503. }
  50504. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50505. import { Observable } from "babylonjs/Misc/observable";
  50506. import { Nullable } from "babylonjs/types";
  50507. import { Vector3 } from "babylonjs/Maths/math.vector";
  50508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50509. import { Mesh } from "babylonjs/Meshes/mesh";
  50510. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50511. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50512. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50513. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50514. import { Color3 } from "babylonjs/Maths/math.color";
  50515. /**
  50516. * Single axis scale gizmo
  50517. */
  50518. export class AxisScaleGizmo extends Gizmo {
  50519. /**
  50520. * Drag behavior responsible for the gizmos dragging interactions
  50521. */
  50522. dragBehavior: PointerDragBehavior;
  50523. private _pointerObserver;
  50524. /**
  50525. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50526. */
  50527. snapDistance: number;
  50528. /**
  50529. * Event that fires each time the gizmo snaps to a new location.
  50530. * * snapDistance is the the change in distance
  50531. */
  50532. onSnapObservable: Observable<{
  50533. snapDistance: number;
  50534. }>;
  50535. /**
  50536. * If the scaling operation should be done on all axis (default: false)
  50537. */
  50538. uniformScaling: boolean;
  50539. /**
  50540. * Custom sensitivity value for the drag strength
  50541. */
  50542. sensitivity: number;
  50543. private _isEnabled;
  50544. private _parent;
  50545. private _arrow;
  50546. private _coloredMaterial;
  50547. private _hoverMaterial;
  50548. /**
  50549. * Creates an AxisScaleGizmo
  50550. * @param gizmoLayer The utility layer the gizmo will be added to
  50551. * @param dragAxis The axis which the gizmo will be able to scale on
  50552. * @param color The color of the gizmo
  50553. */
  50554. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50555. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50556. /**
  50557. * If the gizmo is enabled
  50558. */
  50559. set isEnabled(value: boolean);
  50560. get isEnabled(): boolean;
  50561. /**
  50562. * Disposes of the gizmo
  50563. */
  50564. dispose(): void;
  50565. /**
  50566. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50567. * @param mesh The mesh to replace the default mesh of the gizmo
  50568. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50569. */
  50570. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50571. }
  50572. }
  50573. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50574. import { Observable } from "babylonjs/Misc/observable";
  50575. import { Nullable } from "babylonjs/types";
  50576. import { Vector3 } from "babylonjs/Maths/math.vector";
  50577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50578. import { Mesh } from "babylonjs/Meshes/mesh";
  50579. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50580. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50581. import { Color3 } from "babylonjs/Maths/math.color";
  50582. import "babylonjs/Meshes/Builders/boxBuilder";
  50583. /**
  50584. * Bounding box gizmo
  50585. */
  50586. export class BoundingBoxGizmo extends Gizmo {
  50587. private _lineBoundingBox;
  50588. private _rotateSpheresParent;
  50589. private _scaleBoxesParent;
  50590. private _boundingDimensions;
  50591. private _renderObserver;
  50592. private _pointerObserver;
  50593. private _scaleDragSpeed;
  50594. private _tmpQuaternion;
  50595. private _tmpVector;
  50596. private _tmpRotationMatrix;
  50597. /**
  50598. * 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)
  50599. */
  50600. ignoreChildren: boolean;
  50601. /**
  50602. * 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)
  50603. */
  50604. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50605. /**
  50606. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50607. */
  50608. rotationSphereSize: number;
  50609. /**
  50610. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50611. */
  50612. scaleBoxSize: number;
  50613. /**
  50614. * 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)
  50615. */
  50616. fixedDragMeshScreenSize: boolean;
  50617. /**
  50618. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50619. */
  50620. fixedDragMeshScreenSizeDistanceFactor: number;
  50621. /**
  50622. * Fired when a rotation sphere or scale box is dragged
  50623. */
  50624. onDragStartObservable: Observable<{}>;
  50625. /**
  50626. * Fired when a scale box is dragged
  50627. */
  50628. onScaleBoxDragObservable: Observable<{}>;
  50629. /**
  50630. * Fired when a scale box drag is ended
  50631. */
  50632. onScaleBoxDragEndObservable: Observable<{}>;
  50633. /**
  50634. * Fired when a rotation sphere is dragged
  50635. */
  50636. onRotationSphereDragObservable: Observable<{}>;
  50637. /**
  50638. * Fired when a rotation sphere drag is ended
  50639. */
  50640. onRotationSphereDragEndObservable: Observable<{}>;
  50641. /**
  50642. * 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)
  50643. */
  50644. scalePivot: Nullable<Vector3>;
  50645. /**
  50646. * Mesh used as a pivot to rotate the attached mesh
  50647. */
  50648. private _anchorMesh;
  50649. private _existingMeshScale;
  50650. private _dragMesh;
  50651. private pointerDragBehavior;
  50652. private coloredMaterial;
  50653. private hoverColoredMaterial;
  50654. /**
  50655. * Sets the color of the bounding box gizmo
  50656. * @param color the color to set
  50657. */
  50658. setColor(color: Color3): void;
  50659. /**
  50660. * Creates an BoundingBoxGizmo
  50661. * @param gizmoLayer The utility layer the gizmo will be added to
  50662. * @param color The color of the gizmo
  50663. */
  50664. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50665. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50666. private _selectNode;
  50667. /**
  50668. * Updates the bounding box information for the Gizmo
  50669. */
  50670. updateBoundingBox(): void;
  50671. private _updateRotationSpheres;
  50672. private _updateScaleBoxes;
  50673. /**
  50674. * Enables rotation on the specified axis and disables rotation on the others
  50675. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50676. */
  50677. setEnabledRotationAxis(axis: string): void;
  50678. /**
  50679. * Enables/disables scaling
  50680. * @param enable if scaling should be enabled
  50681. */
  50682. setEnabledScaling(enable: boolean): void;
  50683. private _updateDummy;
  50684. /**
  50685. * Enables a pointer drag behavior on the bounding box of the gizmo
  50686. */
  50687. enableDragBehavior(): void;
  50688. /**
  50689. * Disposes of the gizmo
  50690. */
  50691. dispose(): void;
  50692. /**
  50693. * 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)
  50694. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50695. * @returns the bounding box mesh with the passed in mesh as a child
  50696. */
  50697. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50698. /**
  50699. * CustomMeshes are not supported by this gizmo
  50700. * @param mesh The mesh to replace the default mesh of the gizmo
  50701. */
  50702. setCustomMesh(mesh: Mesh): void;
  50703. }
  50704. }
  50705. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50706. import { Observable } from "babylonjs/Misc/observable";
  50707. import { Nullable } from "babylonjs/types";
  50708. import { Vector3 } from "babylonjs/Maths/math.vector";
  50709. import { Color3 } from "babylonjs/Maths/math.color";
  50710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50711. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50712. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50713. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50714. import "babylonjs/Meshes/Builders/linesBuilder";
  50715. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50716. /**
  50717. * Single plane rotation gizmo
  50718. */
  50719. export class PlaneRotationGizmo extends Gizmo {
  50720. /**
  50721. * Drag behavior responsible for the gizmos dragging interactions
  50722. */
  50723. dragBehavior: PointerDragBehavior;
  50724. private _pointerObserver;
  50725. /**
  50726. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50727. */
  50728. snapDistance: number;
  50729. /**
  50730. * Event that fires each time the gizmo snaps to a new location.
  50731. * * snapDistance is the the change in distance
  50732. */
  50733. onSnapObservable: Observable<{
  50734. snapDistance: number;
  50735. }>;
  50736. private _isEnabled;
  50737. private _parent;
  50738. /**
  50739. * Creates a PlaneRotationGizmo
  50740. * @param gizmoLayer The utility layer the gizmo will be added to
  50741. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50742. * @param color The color of the gizmo
  50743. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50744. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50745. */
  50746. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50747. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50748. /**
  50749. * If the gizmo is enabled
  50750. */
  50751. set isEnabled(value: boolean);
  50752. get isEnabled(): boolean;
  50753. /**
  50754. * Disposes of the gizmo
  50755. */
  50756. dispose(): void;
  50757. }
  50758. }
  50759. declare module "babylonjs/Gizmos/rotationGizmo" {
  50760. import { Observable } from "babylonjs/Misc/observable";
  50761. import { Nullable } from "babylonjs/types";
  50762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50763. import { Mesh } from "babylonjs/Meshes/mesh";
  50764. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50765. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50766. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50767. /**
  50768. * Gizmo that enables rotating a mesh along 3 axis
  50769. */
  50770. export class RotationGizmo extends Gizmo {
  50771. /**
  50772. * Internal gizmo used for interactions on the x axis
  50773. */
  50774. xGizmo: PlaneRotationGizmo;
  50775. /**
  50776. * Internal gizmo used for interactions on the y axis
  50777. */
  50778. yGizmo: PlaneRotationGizmo;
  50779. /**
  50780. * Internal gizmo used for interactions on the z axis
  50781. */
  50782. zGizmo: PlaneRotationGizmo;
  50783. /** Fires an event when any of it's sub gizmos are dragged */
  50784. onDragStartObservable: Observable<unknown>;
  50785. /** Fires an event when any of it's sub gizmos are released from dragging */
  50786. onDragEndObservable: Observable<unknown>;
  50787. private _meshAttached;
  50788. get attachedMesh(): Nullable<AbstractMesh>;
  50789. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50790. /**
  50791. * Creates a RotationGizmo
  50792. * @param gizmoLayer The utility layer the gizmo will be added to
  50793. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50794. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50795. */
  50796. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50797. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50798. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50799. /**
  50800. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50801. */
  50802. set snapDistance(value: number);
  50803. get snapDistance(): number;
  50804. /**
  50805. * Ratio for the scale of the gizmo (Default: 1)
  50806. */
  50807. set scaleRatio(value: number);
  50808. get scaleRatio(): number;
  50809. /**
  50810. * Disposes of the gizmo
  50811. */
  50812. dispose(): void;
  50813. /**
  50814. * CustomMeshes are not supported by this gizmo
  50815. * @param mesh The mesh to replace the default mesh of the gizmo
  50816. */
  50817. setCustomMesh(mesh: Mesh): void;
  50818. }
  50819. }
  50820. declare module "babylonjs/Gizmos/gizmoManager" {
  50821. import { Observable } from "babylonjs/Misc/observable";
  50822. import { Nullable } from "babylonjs/types";
  50823. import { Scene, IDisposable } from "babylonjs/scene";
  50824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50825. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50826. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50827. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50828. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50829. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50830. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50831. /**
  50832. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50833. */
  50834. export class GizmoManager implements IDisposable {
  50835. private scene;
  50836. /**
  50837. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50838. */
  50839. gizmos: {
  50840. positionGizmo: Nullable<PositionGizmo>;
  50841. rotationGizmo: Nullable<RotationGizmo>;
  50842. scaleGizmo: Nullable<ScaleGizmo>;
  50843. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50844. };
  50845. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50846. clearGizmoOnEmptyPointerEvent: boolean;
  50847. /** Fires an event when the manager is attached to a mesh */
  50848. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50849. private _gizmosEnabled;
  50850. private _pointerObserver;
  50851. private _attachedMesh;
  50852. private _boundingBoxColor;
  50853. private _defaultUtilityLayer;
  50854. private _defaultKeepDepthUtilityLayer;
  50855. /**
  50856. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50857. */
  50858. boundingBoxDragBehavior: SixDofDragBehavior;
  50859. /**
  50860. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50861. */
  50862. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50863. /**
  50864. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50865. */
  50866. usePointerToAttachGizmos: boolean;
  50867. /**
  50868. * Utility layer that the bounding box gizmo belongs to
  50869. */
  50870. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50871. /**
  50872. * Utility layer that all gizmos besides bounding box belong to
  50873. */
  50874. get utilityLayer(): UtilityLayerRenderer;
  50875. /**
  50876. * Instatiates a gizmo manager
  50877. * @param scene the scene to overlay the gizmos on top of
  50878. */
  50879. constructor(scene: Scene);
  50880. /**
  50881. * Attaches a set of gizmos to the specified mesh
  50882. * @param mesh The mesh the gizmo's should be attached to
  50883. */
  50884. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50885. /**
  50886. * If the position gizmo is enabled
  50887. */
  50888. set positionGizmoEnabled(value: boolean);
  50889. get positionGizmoEnabled(): boolean;
  50890. /**
  50891. * If the rotation gizmo is enabled
  50892. */
  50893. set rotationGizmoEnabled(value: boolean);
  50894. get rotationGizmoEnabled(): boolean;
  50895. /**
  50896. * If the scale gizmo is enabled
  50897. */
  50898. set scaleGizmoEnabled(value: boolean);
  50899. get scaleGizmoEnabled(): boolean;
  50900. /**
  50901. * If the boundingBox gizmo is enabled
  50902. */
  50903. set boundingBoxGizmoEnabled(value: boolean);
  50904. get boundingBoxGizmoEnabled(): boolean;
  50905. /**
  50906. * Disposes of the gizmo manager
  50907. */
  50908. dispose(): void;
  50909. }
  50910. }
  50911. declare module "babylonjs/Lights/directionalLight" {
  50912. import { Camera } from "babylonjs/Cameras/camera";
  50913. import { Scene } from "babylonjs/scene";
  50914. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50916. import { Light } from "babylonjs/Lights/light";
  50917. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50918. import { Effect } from "babylonjs/Materials/effect";
  50919. /**
  50920. * A directional light is defined by a direction (what a surprise!).
  50921. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50922. * 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.
  50923. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50924. */
  50925. export class DirectionalLight extends ShadowLight {
  50926. private _shadowFrustumSize;
  50927. /**
  50928. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50929. */
  50930. get shadowFrustumSize(): number;
  50931. /**
  50932. * Specifies a fix frustum size for the shadow generation.
  50933. */
  50934. set shadowFrustumSize(value: number);
  50935. private _shadowOrthoScale;
  50936. /**
  50937. * Gets the shadow projection scale against the optimal computed one.
  50938. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50939. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50940. */
  50941. get shadowOrthoScale(): number;
  50942. /**
  50943. * Sets the shadow projection scale against the optimal computed one.
  50944. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50945. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50946. */
  50947. set shadowOrthoScale(value: number);
  50948. /**
  50949. * Automatically compute the projection matrix to best fit (including all the casters)
  50950. * on each frame.
  50951. */
  50952. autoUpdateExtends: boolean;
  50953. /**
  50954. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50955. * on each frame. autoUpdateExtends must be set to true for this to work
  50956. */
  50957. autoCalcShadowZBounds: boolean;
  50958. private _orthoLeft;
  50959. private _orthoRight;
  50960. private _orthoTop;
  50961. private _orthoBottom;
  50962. /**
  50963. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50964. * The directional light is emitted from everywhere in the given direction.
  50965. * It can cast shadows.
  50966. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50967. * @param name The friendly name of the light
  50968. * @param direction The direction of the light
  50969. * @param scene The scene the light belongs to
  50970. */
  50971. constructor(name: string, direction: Vector3, scene: Scene);
  50972. /**
  50973. * Returns the string "DirectionalLight".
  50974. * @return The class name
  50975. */
  50976. getClassName(): string;
  50977. /**
  50978. * Returns the integer 1.
  50979. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50980. */
  50981. getTypeID(): number;
  50982. /**
  50983. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50984. * Returns the DirectionalLight Shadow projection matrix.
  50985. */
  50986. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50987. /**
  50988. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50989. * Returns the DirectionalLight Shadow projection matrix.
  50990. */
  50991. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50992. /**
  50993. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50994. * Returns the DirectionalLight Shadow projection matrix.
  50995. */
  50996. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50997. protected _buildUniformLayout(): void;
  50998. /**
  50999. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51000. * @param effect The effect to update
  51001. * @param lightIndex The index of the light in the effect to update
  51002. * @returns The directional light
  51003. */
  51004. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51005. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51006. /**
  51007. * Gets the minZ used for shadow according to both the scene and the light.
  51008. *
  51009. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51010. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51011. * @param activeCamera The camera we are returning the min for
  51012. * @returns the depth min z
  51013. */
  51014. getDepthMinZ(activeCamera: Camera): number;
  51015. /**
  51016. * Gets the maxZ used for shadow according to both the scene and the light.
  51017. *
  51018. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51019. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51020. * @param activeCamera The camera we are returning the max for
  51021. * @returns the depth max z
  51022. */
  51023. getDepthMaxZ(activeCamera: Camera): number;
  51024. /**
  51025. * Prepares the list of defines specific to the light type.
  51026. * @param defines the list of defines
  51027. * @param lightIndex defines the index of the light for the effect
  51028. */
  51029. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51030. }
  51031. }
  51032. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51033. import { Mesh } from "babylonjs/Meshes/mesh";
  51034. /**
  51035. * Class containing static functions to help procedurally build meshes
  51036. */
  51037. export class HemisphereBuilder {
  51038. /**
  51039. * Creates a hemisphere mesh
  51040. * @param name defines the name of the mesh
  51041. * @param options defines the options used to create the mesh
  51042. * @param scene defines the hosting scene
  51043. * @returns the hemisphere mesh
  51044. */
  51045. static CreateHemisphere(name: string, options: {
  51046. segments?: number;
  51047. diameter?: number;
  51048. sideOrientation?: number;
  51049. }, scene: any): Mesh;
  51050. }
  51051. }
  51052. declare module "babylonjs/Lights/spotLight" {
  51053. import { Nullable } from "babylonjs/types";
  51054. import { Scene } from "babylonjs/scene";
  51055. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51057. import { Effect } from "babylonjs/Materials/effect";
  51058. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51059. import { Light } from "babylonjs/Lights/light";
  51060. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51061. /**
  51062. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51063. * These values define a cone of light starting from the position, emitting toward the direction.
  51064. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51065. * and the exponent defines the speed of the decay of the light with distance (reach).
  51066. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51067. */
  51068. export class SpotLight extends ShadowLight {
  51069. private _angle;
  51070. private _innerAngle;
  51071. private _cosHalfAngle;
  51072. private _lightAngleScale;
  51073. private _lightAngleOffset;
  51074. /**
  51075. * Gets the cone angle of the spot light in Radians.
  51076. */
  51077. get angle(): number;
  51078. /**
  51079. * Sets the cone angle of the spot light in Radians.
  51080. */
  51081. set angle(value: number);
  51082. /**
  51083. * Only used in gltf falloff mode, this defines the angle where
  51084. * the directional falloff will start before cutting at angle which could be seen
  51085. * as outer angle.
  51086. */
  51087. get innerAngle(): number;
  51088. /**
  51089. * Only used in gltf falloff mode, this defines the angle where
  51090. * the directional falloff will start before cutting at angle which could be seen
  51091. * as outer angle.
  51092. */
  51093. set innerAngle(value: number);
  51094. private _shadowAngleScale;
  51095. /**
  51096. * Allows scaling the angle of the light for shadow generation only.
  51097. */
  51098. get shadowAngleScale(): number;
  51099. /**
  51100. * Allows scaling the angle of the light for shadow generation only.
  51101. */
  51102. set shadowAngleScale(value: number);
  51103. /**
  51104. * The light decay speed with the distance from the emission spot.
  51105. */
  51106. exponent: number;
  51107. private _projectionTextureMatrix;
  51108. /**
  51109. * Allows reading the projecton texture
  51110. */
  51111. get projectionTextureMatrix(): Matrix;
  51112. protected _projectionTextureLightNear: number;
  51113. /**
  51114. * Gets the near clip of the Spotlight for texture projection.
  51115. */
  51116. get projectionTextureLightNear(): number;
  51117. /**
  51118. * Sets the near clip of the Spotlight for texture projection.
  51119. */
  51120. set projectionTextureLightNear(value: number);
  51121. protected _projectionTextureLightFar: number;
  51122. /**
  51123. * Gets the far clip of the Spotlight for texture projection.
  51124. */
  51125. get projectionTextureLightFar(): number;
  51126. /**
  51127. * Sets the far clip of the Spotlight for texture projection.
  51128. */
  51129. set projectionTextureLightFar(value: number);
  51130. protected _projectionTextureUpDirection: Vector3;
  51131. /**
  51132. * Gets the Up vector of the Spotlight for texture projection.
  51133. */
  51134. get projectionTextureUpDirection(): Vector3;
  51135. /**
  51136. * Sets the Up vector of the Spotlight for texture projection.
  51137. */
  51138. set projectionTextureUpDirection(value: Vector3);
  51139. private _projectionTexture;
  51140. /**
  51141. * Gets the projection texture of the light.
  51142. */
  51143. get projectionTexture(): Nullable<BaseTexture>;
  51144. /**
  51145. * Sets the projection texture of the light.
  51146. */
  51147. set projectionTexture(value: Nullable<BaseTexture>);
  51148. private _projectionTextureViewLightDirty;
  51149. private _projectionTextureProjectionLightDirty;
  51150. private _projectionTextureDirty;
  51151. private _projectionTextureViewTargetVector;
  51152. private _projectionTextureViewLightMatrix;
  51153. private _projectionTextureProjectionLightMatrix;
  51154. private _projectionTextureScalingMatrix;
  51155. /**
  51156. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51157. * It can cast shadows.
  51158. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51159. * @param name The light friendly name
  51160. * @param position The position of the spot light in the scene
  51161. * @param direction The direction of the light in the scene
  51162. * @param angle The cone angle of the light in Radians
  51163. * @param exponent The light decay speed with the distance from the emission spot
  51164. * @param scene The scene the lights belongs to
  51165. */
  51166. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51167. /**
  51168. * Returns the string "SpotLight".
  51169. * @returns the class name
  51170. */
  51171. getClassName(): string;
  51172. /**
  51173. * Returns the integer 2.
  51174. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51175. */
  51176. getTypeID(): number;
  51177. /**
  51178. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51179. */
  51180. protected _setDirection(value: Vector3): void;
  51181. /**
  51182. * Overrides the position setter to recompute the projection texture view light Matrix.
  51183. */
  51184. protected _setPosition(value: Vector3): void;
  51185. /**
  51186. * 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.
  51187. * Returns the SpotLight.
  51188. */
  51189. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51190. protected _computeProjectionTextureViewLightMatrix(): void;
  51191. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51192. /**
  51193. * Main function for light texture projection matrix computing.
  51194. */
  51195. protected _computeProjectionTextureMatrix(): void;
  51196. protected _buildUniformLayout(): void;
  51197. private _computeAngleValues;
  51198. /**
  51199. * Sets the passed Effect "effect" with the Light textures.
  51200. * @param effect The effect to update
  51201. * @param lightIndex The index of the light in the effect to update
  51202. * @returns The light
  51203. */
  51204. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51205. /**
  51206. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51207. * @param effect The effect to update
  51208. * @param lightIndex The index of the light in the effect to update
  51209. * @returns The spot light
  51210. */
  51211. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51212. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51213. /**
  51214. * Disposes the light and the associated resources.
  51215. */
  51216. dispose(): void;
  51217. /**
  51218. * Prepares the list of defines specific to the light type.
  51219. * @param defines the list of defines
  51220. * @param lightIndex defines the index of the light for the effect
  51221. */
  51222. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51223. }
  51224. }
  51225. declare module "babylonjs/Gizmos/lightGizmo" {
  51226. import { Nullable } from "babylonjs/types";
  51227. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51228. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51229. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51230. import { Light } from "babylonjs/Lights/light";
  51231. /**
  51232. * Gizmo that enables viewing a light
  51233. */
  51234. export class LightGizmo extends Gizmo {
  51235. private _lightMesh;
  51236. private _material;
  51237. private _cachedPosition;
  51238. private _cachedForward;
  51239. private _attachedMeshParent;
  51240. /**
  51241. * Creates a LightGizmo
  51242. * @param gizmoLayer The utility layer the gizmo will be added to
  51243. */
  51244. constructor(gizmoLayer?: UtilityLayerRenderer);
  51245. private _light;
  51246. /**
  51247. * The light that the gizmo is attached to
  51248. */
  51249. set light(light: Nullable<Light>);
  51250. get light(): Nullable<Light>;
  51251. /**
  51252. * Gets the material used to render the light gizmo
  51253. */
  51254. get material(): StandardMaterial;
  51255. /**
  51256. * @hidden
  51257. * Updates the gizmo to match the attached mesh's position/rotation
  51258. */
  51259. protected _update(): void;
  51260. private static _Scale;
  51261. /**
  51262. * Creates the lines for a light mesh
  51263. */
  51264. private static _CreateLightLines;
  51265. /**
  51266. * Disposes of the light gizmo
  51267. */
  51268. dispose(): void;
  51269. private static _CreateHemisphericLightMesh;
  51270. private static _CreatePointLightMesh;
  51271. private static _CreateSpotLightMesh;
  51272. private static _CreateDirectionalLightMesh;
  51273. }
  51274. }
  51275. declare module "babylonjs/Gizmos/index" {
  51276. export * from "babylonjs/Gizmos/axisDragGizmo";
  51277. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51278. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51279. export * from "babylonjs/Gizmos/gizmo";
  51280. export * from "babylonjs/Gizmos/gizmoManager";
  51281. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51282. export * from "babylonjs/Gizmos/positionGizmo";
  51283. export * from "babylonjs/Gizmos/rotationGizmo";
  51284. export * from "babylonjs/Gizmos/scaleGizmo";
  51285. export * from "babylonjs/Gizmos/lightGizmo";
  51286. export * from "babylonjs/Gizmos/planeDragGizmo";
  51287. }
  51288. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51289. /** @hidden */
  51290. export var backgroundFragmentDeclaration: {
  51291. name: string;
  51292. shader: string;
  51293. };
  51294. }
  51295. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51296. /** @hidden */
  51297. export var backgroundUboDeclaration: {
  51298. name: string;
  51299. shader: string;
  51300. };
  51301. }
  51302. declare module "babylonjs/Shaders/background.fragment" {
  51303. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51304. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51305. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51306. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51307. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51308. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51309. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51310. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51311. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51312. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51313. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51314. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51315. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51316. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51317. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51318. /** @hidden */
  51319. export var backgroundPixelShader: {
  51320. name: string;
  51321. shader: string;
  51322. };
  51323. }
  51324. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51325. /** @hidden */
  51326. export var backgroundVertexDeclaration: {
  51327. name: string;
  51328. shader: string;
  51329. };
  51330. }
  51331. declare module "babylonjs/Shaders/background.vertex" {
  51332. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51333. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51334. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51335. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51336. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51337. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51338. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51339. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51340. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51341. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51342. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51343. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51344. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51345. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51346. /** @hidden */
  51347. export var backgroundVertexShader: {
  51348. name: string;
  51349. shader: string;
  51350. };
  51351. }
  51352. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51353. import { Nullable, int, float } from "babylonjs/types";
  51354. import { Scene } from "babylonjs/scene";
  51355. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51356. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51358. import { Mesh } from "babylonjs/Meshes/mesh";
  51359. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51360. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51361. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51363. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51364. import { Color3 } from "babylonjs/Maths/math.color";
  51365. import "babylonjs/Shaders/background.fragment";
  51366. import "babylonjs/Shaders/background.vertex";
  51367. /**
  51368. * Background material used to create an efficient environement around your scene.
  51369. */
  51370. export class BackgroundMaterial extends PushMaterial {
  51371. /**
  51372. * Standard reflectance value at parallel view angle.
  51373. */
  51374. static StandardReflectance0: number;
  51375. /**
  51376. * Standard reflectance value at grazing angle.
  51377. */
  51378. static StandardReflectance90: number;
  51379. protected _primaryColor: Color3;
  51380. /**
  51381. * Key light Color (multiply against the environement texture)
  51382. */
  51383. primaryColor: Color3;
  51384. protected __perceptualColor: Nullable<Color3>;
  51385. /**
  51386. * Experimental Internal Use Only.
  51387. *
  51388. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51389. * This acts as a helper to set the primary color to a more "human friendly" value.
  51390. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51391. * output color as close as possible from the chosen value.
  51392. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51393. * part of lighting setup.)
  51394. */
  51395. get _perceptualColor(): Nullable<Color3>;
  51396. set _perceptualColor(value: Nullable<Color3>);
  51397. protected _primaryColorShadowLevel: float;
  51398. /**
  51399. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51400. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51401. */
  51402. get primaryColorShadowLevel(): float;
  51403. set primaryColorShadowLevel(value: float);
  51404. protected _primaryColorHighlightLevel: float;
  51405. /**
  51406. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51407. * The primary color is used at the level chosen to define what the white area would look.
  51408. */
  51409. get primaryColorHighlightLevel(): float;
  51410. set primaryColorHighlightLevel(value: float);
  51411. protected _reflectionTexture: Nullable<BaseTexture>;
  51412. /**
  51413. * Reflection Texture used in the material.
  51414. * Should be author in a specific way for the best result (refer to the documentation).
  51415. */
  51416. reflectionTexture: Nullable<BaseTexture>;
  51417. protected _reflectionBlur: float;
  51418. /**
  51419. * Reflection Texture level of blur.
  51420. *
  51421. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51422. * texture twice.
  51423. */
  51424. reflectionBlur: float;
  51425. protected _diffuseTexture: Nullable<BaseTexture>;
  51426. /**
  51427. * Diffuse Texture used in the material.
  51428. * Should be author in a specific way for the best result (refer to the documentation).
  51429. */
  51430. diffuseTexture: Nullable<BaseTexture>;
  51431. protected _shadowLights: Nullable<IShadowLight[]>;
  51432. /**
  51433. * Specify the list of lights casting shadow on the material.
  51434. * All scene shadow lights will be included if null.
  51435. */
  51436. shadowLights: Nullable<IShadowLight[]>;
  51437. protected _shadowLevel: float;
  51438. /**
  51439. * Helps adjusting the shadow to a softer level if required.
  51440. * 0 means black shadows and 1 means no shadows.
  51441. */
  51442. shadowLevel: float;
  51443. protected _sceneCenter: Vector3;
  51444. /**
  51445. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51446. * It is usually zero but might be interesting to modify according to your setup.
  51447. */
  51448. sceneCenter: Vector3;
  51449. protected _opacityFresnel: boolean;
  51450. /**
  51451. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51452. * This helps ensuring a nice transition when the camera goes under the ground.
  51453. */
  51454. opacityFresnel: boolean;
  51455. protected _reflectionFresnel: boolean;
  51456. /**
  51457. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51458. * This helps adding a mirror texture on the ground.
  51459. */
  51460. reflectionFresnel: boolean;
  51461. protected _reflectionFalloffDistance: number;
  51462. /**
  51463. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51464. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51465. */
  51466. reflectionFalloffDistance: number;
  51467. protected _reflectionAmount: number;
  51468. /**
  51469. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51470. */
  51471. reflectionAmount: number;
  51472. protected _reflectionReflectance0: number;
  51473. /**
  51474. * This specifies the weight of the reflection at grazing angle.
  51475. */
  51476. reflectionReflectance0: number;
  51477. protected _reflectionReflectance90: number;
  51478. /**
  51479. * This specifies the weight of the reflection at a perpendicular point of view.
  51480. */
  51481. reflectionReflectance90: number;
  51482. /**
  51483. * Sets the reflection reflectance fresnel values according to the default standard
  51484. * empirically know to work well :-)
  51485. */
  51486. set reflectionStandardFresnelWeight(value: number);
  51487. protected _useRGBColor: boolean;
  51488. /**
  51489. * Helps to directly use the maps channels instead of their level.
  51490. */
  51491. useRGBColor: boolean;
  51492. protected _enableNoise: boolean;
  51493. /**
  51494. * This helps reducing the banding effect that could occur on the background.
  51495. */
  51496. enableNoise: boolean;
  51497. /**
  51498. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51499. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51500. * Recommended to be keep at 1.0 except for special cases.
  51501. */
  51502. get fovMultiplier(): number;
  51503. set fovMultiplier(value: number);
  51504. private _fovMultiplier;
  51505. /**
  51506. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51507. */
  51508. useEquirectangularFOV: boolean;
  51509. private _maxSimultaneousLights;
  51510. /**
  51511. * Number of Simultaneous lights allowed on the material.
  51512. */
  51513. maxSimultaneousLights: int;
  51514. /**
  51515. * Default configuration related to image processing available in the Background Material.
  51516. */
  51517. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51518. /**
  51519. * Keep track of the image processing observer to allow dispose and replace.
  51520. */
  51521. private _imageProcessingObserver;
  51522. /**
  51523. * Attaches a new image processing configuration to the PBR Material.
  51524. * @param configuration (if null the scene configuration will be use)
  51525. */
  51526. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51527. /**
  51528. * Gets the image processing configuration used either in this material.
  51529. */
  51530. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51531. /**
  51532. * Sets the Default image processing configuration used either in the this material.
  51533. *
  51534. * If sets to null, the scene one is in use.
  51535. */
  51536. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51537. /**
  51538. * Gets wether the color curves effect is enabled.
  51539. */
  51540. get cameraColorCurvesEnabled(): boolean;
  51541. /**
  51542. * Sets wether the color curves effect is enabled.
  51543. */
  51544. set cameraColorCurvesEnabled(value: boolean);
  51545. /**
  51546. * Gets wether the color grading effect is enabled.
  51547. */
  51548. get cameraColorGradingEnabled(): boolean;
  51549. /**
  51550. * Gets wether the color grading effect is enabled.
  51551. */
  51552. set cameraColorGradingEnabled(value: boolean);
  51553. /**
  51554. * Gets wether tonemapping is enabled or not.
  51555. */
  51556. get cameraToneMappingEnabled(): boolean;
  51557. /**
  51558. * Sets wether tonemapping is enabled or not
  51559. */
  51560. set cameraToneMappingEnabled(value: boolean);
  51561. /**
  51562. * The camera exposure used on this material.
  51563. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51564. * This corresponds to a photographic exposure.
  51565. */
  51566. get cameraExposure(): float;
  51567. /**
  51568. * The camera exposure used on this material.
  51569. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51570. * This corresponds to a photographic exposure.
  51571. */
  51572. set cameraExposure(value: float);
  51573. /**
  51574. * Gets The camera contrast used on this material.
  51575. */
  51576. get cameraContrast(): float;
  51577. /**
  51578. * Sets The camera contrast used on this material.
  51579. */
  51580. set cameraContrast(value: float);
  51581. /**
  51582. * Gets the Color Grading 2D Lookup Texture.
  51583. */
  51584. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51585. /**
  51586. * Sets the Color Grading 2D Lookup Texture.
  51587. */
  51588. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51589. /**
  51590. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51591. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51592. * 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;
  51593. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51594. */
  51595. get cameraColorCurves(): Nullable<ColorCurves>;
  51596. /**
  51597. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51598. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51599. * 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;
  51600. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51601. */
  51602. set cameraColorCurves(value: Nullable<ColorCurves>);
  51603. /**
  51604. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51605. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51606. */
  51607. switchToBGR: boolean;
  51608. private _renderTargets;
  51609. private _reflectionControls;
  51610. private _white;
  51611. private _primaryShadowColor;
  51612. private _primaryHighlightColor;
  51613. /**
  51614. * Instantiates a Background Material in the given scene
  51615. * @param name The friendly name of the material
  51616. * @param scene The scene to add the material to
  51617. */
  51618. constructor(name: string, scene: Scene);
  51619. /**
  51620. * Gets a boolean indicating that current material needs to register RTT
  51621. */
  51622. get hasRenderTargetTextures(): boolean;
  51623. /**
  51624. * The entire material has been created in order to prevent overdraw.
  51625. * @returns false
  51626. */
  51627. needAlphaTesting(): boolean;
  51628. /**
  51629. * The entire material has been created in order to prevent overdraw.
  51630. * @returns true if blending is enable
  51631. */
  51632. needAlphaBlending(): boolean;
  51633. /**
  51634. * Checks wether the material is ready to be rendered for a given mesh.
  51635. * @param mesh The mesh to render
  51636. * @param subMesh The submesh to check against
  51637. * @param useInstances Specify wether or not the material is used with instances
  51638. * @returns true if all the dependencies are ready (Textures, Effects...)
  51639. */
  51640. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51641. /**
  51642. * Compute the primary color according to the chosen perceptual color.
  51643. */
  51644. private _computePrimaryColorFromPerceptualColor;
  51645. /**
  51646. * Compute the highlights and shadow colors according to their chosen levels.
  51647. */
  51648. private _computePrimaryColors;
  51649. /**
  51650. * Build the uniform buffer used in the material.
  51651. */
  51652. buildUniformLayout(): void;
  51653. /**
  51654. * Unbind the material.
  51655. */
  51656. unbind(): void;
  51657. /**
  51658. * Bind only the world matrix to the material.
  51659. * @param world The world matrix to bind.
  51660. */
  51661. bindOnlyWorldMatrix(world: Matrix): void;
  51662. /**
  51663. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51664. * @param world The world matrix to bind.
  51665. * @param subMesh The submesh to bind for.
  51666. */
  51667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51668. /**
  51669. * Checks to see if a texture is used in the material.
  51670. * @param texture - Base texture to use.
  51671. * @returns - Boolean specifying if a texture is used in the material.
  51672. */
  51673. hasTexture(texture: BaseTexture): boolean;
  51674. /**
  51675. * Dispose the material.
  51676. * @param forceDisposeEffect Force disposal of the associated effect.
  51677. * @param forceDisposeTextures Force disposal of the associated textures.
  51678. */
  51679. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51680. /**
  51681. * Clones the material.
  51682. * @param name The cloned name.
  51683. * @returns The cloned material.
  51684. */
  51685. clone(name: string): BackgroundMaterial;
  51686. /**
  51687. * Serializes the current material to its JSON representation.
  51688. * @returns The JSON representation.
  51689. */
  51690. serialize(): any;
  51691. /**
  51692. * Gets the class name of the material
  51693. * @returns "BackgroundMaterial"
  51694. */
  51695. getClassName(): string;
  51696. /**
  51697. * Parse a JSON input to create back a background material.
  51698. * @param source The JSON data to parse
  51699. * @param scene The scene to create the parsed material in
  51700. * @param rootUrl The root url of the assets the material depends upon
  51701. * @returns the instantiated BackgroundMaterial.
  51702. */
  51703. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51704. }
  51705. }
  51706. declare module "babylonjs/Helpers/environmentHelper" {
  51707. import { Observable } from "babylonjs/Misc/observable";
  51708. import { Nullable } from "babylonjs/types";
  51709. import { Scene } from "babylonjs/scene";
  51710. import { Vector3 } from "babylonjs/Maths/math.vector";
  51711. import { Color3 } from "babylonjs/Maths/math.color";
  51712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51713. import { Mesh } from "babylonjs/Meshes/mesh";
  51714. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51715. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51716. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51717. import "babylonjs/Meshes/Builders/planeBuilder";
  51718. import "babylonjs/Meshes/Builders/boxBuilder";
  51719. /**
  51720. * Represents the different options available during the creation of
  51721. * a Environment helper.
  51722. *
  51723. * This can control the default ground, skybox and image processing setup of your scene.
  51724. */
  51725. export interface IEnvironmentHelperOptions {
  51726. /**
  51727. * Specifies wether or not to create a ground.
  51728. * True by default.
  51729. */
  51730. createGround: boolean;
  51731. /**
  51732. * Specifies the ground size.
  51733. * 15 by default.
  51734. */
  51735. groundSize: number;
  51736. /**
  51737. * The texture used on the ground for the main color.
  51738. * Comes from the BabylonJS CDN by default.
  51739. *
  51740. * Remarks: Can be either a texture or a url.
  51741. */
  51742. groundTexture: string | BaseTexture;
  51743. /**
  51744. * The color mixed in the ground texture by default.
  51745. * BabylonJS clearColor by default.
  51746. */
  51747. groundColor: Color3;
  51748. /**
  51749. * Specifies the ground opacity.
  51750. * 1 by default.
  51751. */
  51752. groundOpacity: number;
  51753. /**
  51754. * Enables the ground to receive shadows.
  51755. * True by default.
  51756. */
  51757. enableGroundShadow: boolean;
  51758. /**
  51759. * Helps preventing the shadow to be fully black on the ground.
  51760. * 0.5 by default.
  51761. */
  51762. groundShadowLevel: number;
  51763. /**
  51764. * Creates a mirror texture attach to the ground.
  51765. * false by default.
  51766. */
  51767. enableGroundMirror: boolean;
  51768. /**
  51769. * Specifies the ground mirror size ratio.
  51770. * 0.3 by default as the default kernel is 64.
  51771. */
  51772. groundMirrorSizeRatio: number;
  51773. /**
  51774. * Specifies the ground mirror blur kernel size.
  51775. * 64 by default.
  51776. */
  51777. groundMirrorBlurKernel: number;
  51778. /**
  51779. * Specifies the ground mirror visibility amount.
  51780. * 1 by default
  51781. */
  51782. groundMirrorAmount: number;
  51783. /**
  51784. * Specifies the ground mirror reflectance weight.
  51785. * This uses the standard weight of the background material to setup the fresnel effect
  51786. * of the mirror.
  51787. * 1 by default.
  51788. */
  51789. groundMirrorFresnelWeight: number;
  51790. /**
  51791. * Specifies the ground mirror Falloff distance.
  51792. * This can helps reducing the size of the reflection.
  51793. * 0 by Default.
  51794. */
  51795. groundMirrorFallOffDistance: number;
  51796. /**
  51797. * Specifies the ground mirror texture type.
  51798. * Unsigned Int by Default.
  51799. */
  51800. groundMirrorTextureType: number;
  51801. /**
  51802. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51803. * the shown objects.
  51804. */
  51805. groundYBias: number;
  51806. /**
  51807. * Specifies wether or not to create a skybox.
  51808. * True by default.
  51809. */
  51810. createSkybox: boolean;
  51811. /**
  51812. * Specifies the skybox size.
  51813. * 20 by default.
  51814. */
  51815. skyboxSize: number;
  51816. /**
  51817. * The texture used on the skybox for the main color.
  51818. * Comes from the BabylonJS CDN by default.
  51819. *
  51820. * Remarks: Can be either a texture or a url.
  51821. */
  51822. skyboxTexture: string | BaseTexture;
  51823. /**
  51824. * The color mixed in the skybox texture by default.
  51825. * BabylonJS clearColor by default.
  51826. */
  51827. skyboxColor: Color3;
  51828. /**
  51829. * The background rotation around the Y axis of the scene.
  51830. * This helps aligning the key lights of your scene with the background.
  51831. * 0 by default.
  51832. */
  51833. backgroundYRotation: number;
  51834. /**
  51835. * Compute automatically the size of the elements to best fit with the scene.
  51836. */
  51837. sizeAuto: boolean;
  51838. /**
  51839. * Default position of the rootMesh if autoSize is not true.
  51840. */
  51841. rootPosition: Vector3;
  51842. /**
  51843. * Sets up the image processing in the scene.
  51844. * true by default.
  51845. */
  51846. setupImageProcessing: boolean;
  51847. /**
  51848. * The texture used as your environment texture in the scene.
  51849. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51850. *
  51851. * Remarks: Can be either a texture or a url.
  51852. */
  51853. environmentTexture: string | BaseTexture;
  51854. /**
  51855. * The value of the exposure to apply to the scene.
  51856. * 0.6 by default if setupImageProcessing is true.
  51857. */
  51858. cameraExposure: number;
  51859. /**
  51860. * The value of the contrast to apply to the scene.
  51861. * 1.6 by default if setupImageProcessing is true.
  51862. */
  51863. cameraContrast: number;
  51864. /**
  51865. * Specifies wether or not tonemapping should be enabled in the scene.
  51866. * true by default if setupImageProcessing is true.
  51867. */
  51868. toneMappingEnabled: boolean;
  51869. }
  51870. /**
  51871. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51872. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51873. * It also helps with the default setup of your imageProcessing configuration.
  51874. */
  51875. export class EnvironmentHelper {
  51876. /**
  51877. * Default ground texture URL.
  51878. */
  51879. private static _groundTextureCDNUrl;
  51880. /**
  51881. * Default skybox texture URL.
  51882. */
  51883. private static _skyboxTextureCDNUrl;
  51884. /**
  51885. * Default environment texture URL.
  51886. */
  51887. private static _environmentTextureCDNUrl;
  51888. /**
  51889. * Creates the default options for the helper.
  51890. */
  51891. private static _getDefaultOptions;
  51892. private _rootMesh;
  51893. /**
  51894. * Gets the root mesh created by the helper.
  51895. */
  51896. get rootMesh(): Mesh;
  51897. private _skybox;
  51898. /**
  51899. * Gets the skybox created by the helper.
  51900. */
  51901. get skybox(): Nullable<Mesh>;
  51902. private _skyboxTexture;
  51903. /**
  51904. * Gets the skybox texture created by the helper.
  51905. */
  51906. get skyboxTexture(): Nullable<BaseTexture>;
  51907. private _skyboxMaterial;
  51908. /**
  51909. * Gets the skybox material created by the helper.
  51910. */
  51911. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51912. private _ground;
  51913. /**
  51914. * Gets the ground mesh created by the helper.
  51915. */
  51916. get ground(): Nullable<Mesh>;
  51917. private _groundTexture;
  51918. /**
  51919. * Gets the ground texture created by the helper.
  51920. */
  51921. get groundTexture(): Nullable<BaseTexture>;
  51922. private _groundMirror;
  51923. /**
  51924. * Gets the ground mirror created by the helper.
  51925. */
  51926. get groundMirror(): Nullable<MirrorTexture>;
  51927. /**
  51928. * Gets the ground mirror render list to helps pushing the meshes
  51929. * you wish in the ground reflection.
  51930. */
  51931. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51932. private _groundMaterial;
  51933. /**
  51934. * Gets the ground material created by the helper.
  51935. */
  51936. get groundMaterial(): Nullable<BackgroundMaterial>;
  51937. /**
  51938. * Stores the creation options.
  51939. */
  51940. private readonly _scene;
  51941. private _options;
  51942. /**
  51943. * This observable will be notified with any error during the creation of the environment,
  51944. * mainly texture creation errors.
  51945. */
  51946. onErrorObservable: Observable<{
  51947. message?: string;
  51948. exception?: any;
  51949. }>;
  51950. /**
  51951. * constructor
  51952. * @param options Defines the options we want to customize the helper
  51953. * @param scene The scene to add the material to
  51954. */
  51955. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51956. /**
  51957. * Updates the background according to the new options
  51958. * @param options
  51959. */
  51960. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51961. /**
  51962. * Sets the primary color of all the available elements.
  51963. * @param color the main color to affect to the ground and the background
  51964. */
  51965. setMainColor(color: Color3): void;
  51966. /**
  51967. * Setup the image processing according to the specified options.
  51968. */
  51969. private _setupImageProcessing;
  51970. /**
  51971. * Setup the environment texture according to the specified options.
  51972. */
  51973. private _setupEnvironmentTexture;
  51974. /**
  51975. * Setup the background according to the specified options.
  51976. */
  51977. private _setupBackground;
  51978. /**
  51979. * Get the scene sizes according to the setup.
  51980. */
  51981. private _getSceneSize;
  51982. /**
  51983. * Setup the ground according to the specified options.
  51984. */
  51985. private _setupGround;
  51986. /**
  51987. * Setup the ground material according to the specified options.
  51988. */
  51989. private _setupGroundMaterial;
  51990. /**
  51991. * Setup the ground diffuse texture according to the specified options.
  51992. */
  51993. private _setupGroundDiffuseTexture;
  51994. /**
  51995. * Setup the ground mirror texture according to the specified options.
  51996. */
  51997. private _setupGroundMirrorTexture;
  51998. /**
  51999. * Setup the ground to receive the mirror texture.
  52000. */
  52001. private _setupMirrorInGroundMaterial;
  52002. /**
  52003. * Setup the skybox according to the specified options.
  52004. */
  52005. private _setupSkybox;
  52006. /**
  52007. * Setup the skybox material according to the specified options.
  52008. */
  52009. private _setupSkyboxMaterial;
  52010. /**
  52011. * Setup the skybox reflection texture according to the specified options.
  52012. */
  52013. private _setupSkyboxReflectionTexture;
  52014. private _errorHandler;
  52015. /**
  52016. * Dispose all the elements created by the Helper.
  52017. */
  52018. dispose(): void;
  52019. }
  52020. }
  52021. declare module "babylonjs/Helpers/photoDome" {
  52022. import { Observable } from "babylonjs/Misc/observable";
  52023. import { Nullable } from "babylonjs/types";
  52024. import { Scene } from "babylonjs/scene";
  52025. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52026. import { Mesh } from "babylonjs/Meshes/mesh";
  52027. import { Texture } from "babylonjs/Materials/Textures/texture";
  52028. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52029. import "babylonjs/Meshes/Builders/sphereBuilder";
  52030. /**
  52031. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52032. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52033. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52034. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52035. */
  52036. export class PhotoDome extends TransformNode {
  52037. /**
  52038. * Define the image as a Monoscopic panoramic 360 image.
  52039. */
  52040. static readonly MODE_MONOSCOPIC: number;
  52041. /**
  52042. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52043. */
  52044. static readonly MODE_TOPBOTTOM: number;
  52045. /**
  52046. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52047. */
  52048. static readonly MODE_SIDEBYSIDE: number;
  52049. private _useDirectMapping;
  52050. /**
  52051. * The texture being displayed on the sphere
  52052. */
  52053. protected _photoTexture: Texture;
  52054. /**
  52055. * Gets or sets the texture being displayed on the sphere
  52056. */
  52057. get photoTexture(): Texture;
  52058. set photoTexture(value: Texture);
  52059. /**
  52060. * Observable raised when an error occured while loading the 360 image
  52061. */
  52062. onLoadErrorObservable: Observable<string>;
  52063. /**
  52064. * The skybox material
  52065. */
  52066. protected _material: BackgroundMaterial;
  52067. /**
  52068. * The surface used for the skybox
  52069. */
  52070. protected _mesh: Mesh;
  52071. /**
  52072. * Gets the mesh used for the skybox.
  52073. */
  52074. get mesh(): Mesh;
  52075. /**
  52076. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52077. * Also see the options.resolution property.
  52078. */
  52079. get fovMultiplier(): number;
  52080. set fovMultiplier(value: number);
  52081. private _imageMode;
  52082. /**
  52083. * Gets or set the current video mode for the video. It can be:
  52084. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52085. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52086. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52087. */
  52088. get imageMode(): number;
  52089. set imageMode(value: number);
  52090. /**
  52091. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52092. * @param name Element's name, child elements will append suffixes for their own names.
  52093. * @param urlsOfPhoto defines the url of the photo to display
  52094. * @param options defines an object containing optional or exposed sub element properties
  52095. * @param onError defines a callback called when an error occured while loading the texture
  52096. */
  52097. constructor(name: string, urlOfPhoto: string, options: {
  52098. resolution?: number;
  52099. size?: number;
  52100. useDirectMapping?: boolean;
  52101. faceForward?: boolean;
  52102. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52103. private _onBeforeCameraRenderObserver;
  52104. private _changeImageMode;
  52105. /**
  52106. * Releases resources associated with this node.
  52107. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52108. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52109. */
  52110. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52111. }
  52112. }
  52113. declare module "babylonjs/Misc/rgbdTextureTools" {
  52114. import "babylonjs/Shaders/rgbdDecode.fragment";
  52115. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52116. import { Texture } from "babylonjs/Materials/Textures/texture";
  52117. /**
  52118. * Class used to host RGBD texture specific utilities
  52119. */
  52120. export class RGBDTextureTools {
  52121. /**
  52122. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52123. * @param texture the texture to expand.
  52124. */
  52125. static ExpandRGBDTexture(texture: Texture): void;
  52126. }
  52127. }
  52128. declare module "babylonjs/Misc/brdfTextureTools" {
  52129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52130. import { Scene } from "babylonjs/scene";
  52131. /**
  52132. * Class used to host texture specific utilities
  52133. */
  52134. export class BRDFTextureTools {
  52135. /**
  52136. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52137. * @param scene defines the hosting scene
  52138. * @returns the environment BRDF texture
  52139. */
  52140. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52141. private static _environmentBRDFBase64Texture;
  52142. }
  52143. }
  52144. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52145. import { Nullable } from "babylonjs/types";
  52146. import { Color3 } from "babylonjs/Maths/math.color";
  52147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52148. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52149. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52150. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52151. import { Engine } from "babylonjs/Engines/engine";
  52152. import { Scene } from "babylonjs/scene";
  52153. /**
  52154. * @hidden
  52155. */
  52156. export interface IMaterialClearCoatDefines {
  52157. CLEARCOAT: boolean;
  52158. CLEARCOAT_DEFAULTIOR: boolean;
  52159. CLEARCOAT_TEXTURE: boolean;
  52160. CLEARCOAT_TEXTUREDIRECTUV: number;
  52161. CLEARCOAT_BUMP: boolean;
  52162. CLEARCOAT_BUMPDIRECTUV: number;
  52163. CLEARCOAT_TINT: boolean;
  52164. CLEARCOAT_TINT_TEXTURE: boolean;
  52165. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52166. /** @hidden */
  52167. _areTexturesDirty: boolean;
  52168. }
  52169. /**
  52170. * Define the code related to the clear coat parameters of the pbr material.
  52171. */
  52172. export class PBRClearCoatConfiguration {
  52173. /**
  52174. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52175. * The default fits with a polyurethane material.
  52176. */
  52177. private static readonly _DefaultIndexOfRefraction;
  52178. private _isEnabled;
  52179. /**
  52180. * Defines if the clear coat is enabled in the material.
  52181. */
  52182. isEnabled: boolean;
  52183. /**
  52184. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52185. */
  52186. intensity: number;
  52187. /**
  52188. * Defines the clear coat layer roughness.
  52189. */
  52190. roughness: number;
  52191. private _indexOfRefraction;
  52192. /**
  52193. * Defines the index of refraction of the clear coat.
  52194. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52195. * The default fits with a polyurethane material.
  52196. * Changing the default value is more performance intensive.
  52197. */
  52198. indexOfRefraction: number;
  52199. private _texture;
  52200. /**
  52201. * Stores the clear coat values in a texture.
  52202. */
  52203. texture: Nullable<BaseTexture>;
  52204. private _bumpTexture;
  52205. /**
  52206. * Define the clear coat specific bump texture.
  52207. */
  52208. bumpTexture: Nullable<BaseTexture>;
  52209. private _isTintEnabled;
  52210. /**
  52211. * Defines if the clear coat tint is enabled in the material.
  52212. */
  52213. isTintEnabled: boolean;
  52214. /**
  52215. * Defines the clear coat tint of the material.
  52216. * This is only use if tint is enabled
  52217. */
  52218. tintColor: Color3;
  52219. /**
  52220. * Defines the distance at which the tint color should be found in the
  52221. * clear coat media.
  52222. * This is only use if tint is enabled
  52223. */
  52224. tintColorAtDistance: number;
  52225. /**
  52226. * Defines the clear coat layer thickness.
  52227. * This is only use if tint is enabled
  52228. */
  52229. tintThickness: number;
  52230. private _tintTexture;
  52231. /**
  52232. * Stores the clear tint values in a texture.
  52233. * rgb is tint
  52234. * a is a thickness factor
  52235. */
  52236. tintTexture: Nullable<BaseTexture>;
  52237. /** @hidden */
  52238. private _internalMarkAllSubMeshesAsTexturesDirty;
  52239. /** @hidden */
  52240. _markAllSubMeshesAsTexturesDirty(): void;
  52241. /**
  52242. * Instantiate a new istance of clear coat configuration.
  52243. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52244. */
  52245. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52246. /**
  52247. * Gets wehter the submesh is ready to be used or not.
  52248. * @param defines the list of "defines" to update.
  52249. * @param scene defines the scene the material belongs to.
  52250. * @param engine defines the engine the material belongs to.
  52251. * @param disableBumpMap defines wether the material disables bump or not.
  52252. * @returns - boolean indicating that the submesh is ready or not.
  52253. */
  52254. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52255. /**
  52256. * Checks to see if a texture is used in the material.
  52257. * @param defines the list of "defines" to update.
  52258. * @param scene defines the scene to the material belongs to.
  52259. */
  52260. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52261. /**
  52262. * Binds the material data.
  52263. * @param uniformBuffer defines the Uniform buffer to fill in.
  52264. * @param scene defines the scene the material belongs to.
  52265. * @param engine defines the engine the material belongs to.
  52266. * @param disableBumpMap defines wether the material disables bump or not.
  52267. * @param isFrozen defines wether the material is frozen or not.
  52268. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52269. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52270. */
  52271. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52272. /**
  52273. * Checks to see if a texture is used in the material.
  52274. * @param texture - Base texture to use.
  52275. * @returns - Boolean specifying if a texture is used in the material.
  52276. */
  52277. hasTexture(texture: BaseTexture): boolean;
  52278. /**
  52279. * Returns an array of the actively used textures.
  52280. * @param activeTextures Array of BaseTextures
  52281. */
  52282. getActiveTextures(activeTextures: BaseTexture[]): void;
  52283. /**
  52284. * Returns the animatable textures.
  52285. * @param animatables Array of animatable textures.
  52286. */
  52287. getAnimatables(animatables: IAnimatable[]): void;
  52288. /**
  52289. * Disposes the resources of the material.
  52290. * @param forceDisposeTextures - Forces the disposal of all textures.
  52291. */
  52292. dispose(forceDisposeTextures?: boolean): void;
  52293. /**
  52294. * Get the current class name of the texture useful for serialization or dynamic coding.
  52295. * @returns "PBRClearCoatConfiguration"
  52296. */
  52297. getClassName(): string;
  52298. /**
  52299. * Add fallbacks to the effect fallbacks list.
  52300. * @param defines defines the Base texture to use.
  52301. * @param fallbacks defines the current fallback list.
  52302. * @param currentRank defines the current fallback rank.
  52303. * @returns the new fallback rank.
  52304. */
  52305. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52306. /**
  52307. * Add the required uniforms to the current list.
  52308. * @param uniforms defines the current uniform list.
  52309. */
  52310. static AddUniforms(uniforms: string[]): void;
  52311. /**
  52312. * Add the required samplers to the current list.
  52313. * @param samplers defines the current sampler list.
  52314. */
  52315. static AddSamplers(samplers: string[]): void;
  52316. /**
  52317. * Add the required uniforms to the current buffer.
  52318. * @param uniformBuffer defines the current uniform buffer.
  52319. */
  52320. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52321. /**
  52322. * Makes a duplicate of the current configuration into another one.
  52323. * @param clearCoatConfiguration define the config where to copy the info
  52324. */
  52325. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52326. /**
  52327. * Serializes this clear coat configuration.
  52328. * @returns - An object with the serialized config.
  52329. */
  52330. serialize(): any;
  52331. /**
  52332. * Parses a anisotropy Configuration from a serialized object.
  52333. * @param source - Serialized object.
  52334. * @param scene Defines the scene we are parsing for
  52335. * @param rootUrl Defines the rootUrl to load from
  52336. */
  52337. parse(source: any, scene: Scene, rootUrl: string): void;
  52338. }
  52339. }
  52340. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52341. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52343. import { Vector2 } from "babylonjs/Maths/math.vector";
  52344. import { Scene } from "babylonjs/scene";
  52345. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52346. import { Nullable } from "babylonjs/types";
  52347. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52348. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52349. /**
  52350. * @hidden
  52351. */
  52352. export interface IMaterialAnisotropicDefines {
  52353. ANISOTROPIC: boolean;
  52354. ANISOTROPIC_TEXTURE: boolean;
  52355. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52356. MAINUV1: boolean;
  52357. _areTexturesDirty: boolean;
  52358. _needUVs: boolean;
  52359. }
  52360. /**
  52361. * Define the code related to the anisotropic parameters of the pbr material.
  52362. */
  52363. export class PBRAnisotropicConfiguration {
  52364. private _isEnabled;
  52365. /**
  52366. * Defines if the anisotropy is enabled in the material.
  52367. */
  52368. isEnabled: boolean;
  52369. /**
  52370. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52371. */
  52372. intensity: number;
  52373. /**
  52374. * Defines if the effect is along the tangents, bitangents or in between.
  52375. * By default, the effect is "strectching" the highlights along the tangents.
  52376. */
  52377. direction: Vector2;
  52378. private _texture;
  52379. /**
  52380. * Stores the anisotropy values in a texture.
  52381. * rg is direction (like normal from -1 to 1)
  52382. * b is a intensity
  52383. */
  52384. texture: Nullable<BaseTexture>;
  52385. /** @hidden */
  52386. private _internalMarkAllSubMeshesAsTexturesDirty;
  52387. /** @hidden */
  52388. _markAllSubMeshesAsTexturesDirty(): void;
  52389. /**
  52390. * Instantiate a new istance of anisotropy configuration.
  52391. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52392. */
  52393. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52394. /**
  52395. * Specifies that the submesh is ready to be used.
  52396. * @param defines the list of "defines" to update.
  52397. * @param scene defines the scene the material belongs to.
  52398. * @returns - boolean indicating that the submesh is ready or not.
  52399. */
  52400. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52401. /**
  52402. * Checks to see if a texture is used in the material.
  52403. * @param defines the list of "defines" to update.
  52404. * @param mesh the mesh we are preparing the defines for.
  52405. * @param scene defines the scene the material belongs to.
  52406. */
  52407. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52408. /**
  52409. * Binds the material data.
  52410. * @param uniformBuffer defines the Uniform buffer to fill in.
  52411. * @param scene defines the scene the material belongs to.
  52412. * @param isFrozen defines wether the material is frozen or not.
  52413. */
  52414. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52415. /**
  52416. * Checks to see if a texture is used in the material.
  52417. * @param texture - Base texture to use.
  52418. * @returns - Boolean specifying if a texture is used in the material.
  52419. */
  52420. hasTexture(texture: BaseTexture): boolean;
  52421. /**
  52422. * Returns an array of the actively used textures.
  52423. * @param activeTextures Array of BaseTextures
  52424. */
  52425. getActiveTextures(activeTextures: BaseTexture[]): void;
  52426. /**
  52427. * Returns the animatable textures.
  52428. * @param animatables Array of animatable textures.
  52429. */
  52430. getAnimatables(animatables: IAnimatable[]): void;
  52431. /**
  52432. * Disposes the resources of the material.
  52433. * @param forceDisposeTextures - Forces the disposal of all textures.
  52434. */
  52435. dispose(forceDisposeTextures?: boolean): void;
  52436. /**
  52437. * Get the current class name of the texture useful for serialization or dynamic coding.
  52438. * @returns "PBRAnisotropicConfiguration"
  52439. */
  52440. getClassName(): string;
  52441. /**
  52442. * Add fallbacks to the effect fallbacks list.
  52443. * @param defines defines the Base texture to use.
  52444. * @param fallbacks defines the current fallback list.
  52445. * @param currentRank defines the current fallback rank.
  52446. * @returns the new fallback rank.
  52447. */
  52448. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52449. /**
  52450. * Add the required uniforms to the current list.
  52451. * @param uniforms defines the current uniform list.
  52452. */
  52453. static AddUniforms(uniforms: string[]): void;
  52454. /**
  52455. * Add the required uniforms to the current buffer.
  52456. * @param uniformBuffer defines the current uniform buffer.
  52457. */
  52458. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52459. /**
  52460. * Add the required samplers to the current list.
  52461. * @param samplers defines the current sampler list.
  52462. */
  52463. static AddSamplers(samplers: string[]): void;
  52464. /**
  52465. * Makes a duplicate of the current configuration into another one.
  52466. * @param anisotropicConfiguration define the config where to copy the info
  52467. */
  52468. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52469. /**
  52470. * Serializes this anisotropy configuration.
  52471. * @returns - An object with the serialized config.
  52472. */
  52473. serialize(): any;
  52474. /**
  52475. * Parses a anisotropy Configuration from a serialized object.
  52476. * @param source - Serialized object.
  52477. * @param scene Defines the scene we are parsing for
  52478. * @param rootUrl Defines the rootUrl to load from
  52479. */
  52480. parse(source: any, scene: Scene, rootUrl: string): void;
  52481. }
  52482. }
  52483. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52484. import { Scene } from "babylonjs/scene";
  52485. /**
  52486. * @hidden
  52487. */
  52488. export interface IMaterialBRDFDefines {
  52489. BRDF_V_HEIGHT_CORRELATED: boolean;
  52490. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52491. SPHERICAL_HARMONICS: boolean;
  52492. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52493. /** @hidden */
  52494. _areMiscDirty: boolean;
  52495. }
  52496. /**
  52497. * Define the code related to the BRDF parameters of the pbr material.
  52498. */
  52499. export class PBRBRDFConfiguration {
  52500. /**
  52501. * Default value used for the energy conservation.
  52502. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52503. */
  52504. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52505. /**
  52506. * Default value used for the Smith Visibility Height Correlated mode.
  52507. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52508. */
  52509. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52510. /**
  52511. * Default value used for the IBL diffuse part.
  52512. * This can help switching back to the polynomials mode globally which is a tiny bit
  52513. * less GPU intensive at the drawback of a lower quality.
  52514. */
  52515. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52516. /**
  52517. * Default value used for activating energy conservation for the specular workflow.
  52518. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52519. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52520. */
  52521. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52522. private _useEnergyConservation;
  52523. /**
  52524. * Defines if the material uses energy conservation.
  52525. */
  52526. useEnergyConservation: boolean;
  52527. private _useSmithVisibilityHeightCorrelated;
  52528. /**
  52529. * LEGACY Mode set to false
  52530. * Defines if the material uses height smith correlated visibility term.
  52531. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52532. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52533. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52534. * Not relying on height correlated will also disable energy conservation.
  52535. */
  52536. useSmithVisibilityHeightCorrelated: boolean;
  52537. private _useSphericalHarmonics;
  52538. /**
  52539. * LEGACY Mode set to false
  52540. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52541. * diffuse part of the IBL.
  52542. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52543. * to the ground truth.
  52544. */
  52545. useSphericalHarmonics: boolean;
  52546. private _useSpecularGlossinessInputEnergyConservation;
  52547. /**
  52548. * Defines if the material uses energy conservation, when the specular workflow is active.
  52549. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52550. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52551. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52552. */
  52553. useSpecularGlossinessInputEnergyConservation: boolean;
  52554. /** @hidden */
  52555. private _internalMarkAllSubMeshesAsMiscDirty;
  52556. /** @hidden */
  52557. _markAllSubMeshesAsMiscDirty(): void;
  52558. /**
  52559. * Instantiate a new istance of clear coat configuration.
  52560. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52561. */
  52562. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52563. /**
  52564. * Checks to see if a texture is used in the material.
  52565. * @param defines the list of "defines" to update.
  52566. */
  52567. prepareDefines(defines: IMaterialBRDFDefines): void;
  52568. /**
  52569. * Get the current class name of the texture useful for serialization or dynamic coding.
  52570. * @returns "PBRClearCoatConfiguration"
  52571. */
  52572. getClassName(): string;
  52573. /**
  52574. * Makes a duplicate of the current configuration into another one.
  52575. * @param brdfConfiguration define the config where to copy the info
  52576. */
  52577. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52578. /**
  52579. * Serializes this BRDF configuration.
  52580. * @returns - An object with the serialized config.
  52581. */
  52582. serialize(): any;
  52583. /**
  52584. * Parses a anisotropy Configuration from a serialized object.
  52585. * @param source - Serialized object.
  52586. * @param scene Defines the scene we are parsing for
  52587. * @param rootUrl Defines the rootUrl to load from
  52588. */
  52589. parse(source: any, scene: Scene, rootUrl: string): void;
  52590. }
  52591. }
  52592. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52593. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52594. import { Color3 } from "babylonjs/Maths/math.color";
  52595. import { Scene } from "babylonjs/scene";
  52596. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52597. import { Nullable } from "babylonjs/types";
  52598. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52599. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52600. /**
  52601. * @hidden
  52602. */
  52603. export interface IMaterialSheenDefines {
  52604. SHEEN: boolean;
  52605. SHEEN_TEXTURE: boolean;
  52606. SHEEN_TEXTUREDIRECTUV: number;
  52607. SHEEN_LINKWITHALBEDO: boolean;
  52608. /** @hidden */
  52609. _areTexturesDirty: boolean;
  52610. }
  52611. /**
  52612. * Define the code related to the Sheen parameters of the pbr material.
  52613. */
  52614. export class PBRSheenConfiguration {
  52615. private _isEnabled;
  52616. /**
  52617. * Defines if the material uses sheen.
  52618. */
  52619. isEnabled: boolean;
  52620. private _linkSheenWithAlbedo;
  52621. /**
  52622. * Defines if the sheen is linked to the sheen color.
  52623. */
  52624. linkSheenWithAlbedo: boolean;
  52625. /**
  52626. * Defines the sheen intensity.
  52627. */
  52628. intensity: number;
  52629. /**
  52630. * Defines the sheen color.
  52631. */
  52632. color: Color3;
  52633. private _texture;
  52634. /**
  52635. * Stores the sheen tint values in a texture.
  52636. * rgb is tint
  52637. * a is a intensity
  52638. */
  52639. texture: Nullable<BaseTexture>;
  52640. /** @hidden */
  52641. private _internalMarkAllSubMeshesAsTexturesDirty;
  52642. /** @hidden */
  52643. _markAllSubMeshesAsTexturesDirty(): void;
  52644. /**
  52645. * Instantiate a new istance of clear coat configuration.
  52646. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52647. */
  52648. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52649. /**
  52650. * Specifies that the submesh is ready to be used.
  52651. * @param defines the list of "defines" to update.
  52652. * @param scene defines the scene the material belongs to.
  52653. * @returns - boolean indicating that the submesh is ready or not.
  52654. */
  52655. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52656. /**
  52657. * Checks to see if a texture is used in the material.
  52658. * @param defines the list of "defines" to update.
  52659. * @param scene defines the scene the material belongs to.
  52660. */
  52661. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52662. /**
  52663. * Binds the material data.
  52664. * @param uniformBuffer defines the Uniform buffer to fill in.
  52665. * @param scene defines the scene the material belongs to.
  52666. * @param isFrozen defines wether the material is frozen or not.
  52667. */
  52668. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52669. /**
  52670. * Checks to see if a texture is used in the material.
  52671. * @param texture - Base texture to use.
  52672. * @returns - Boolean specifying if a texture is used in the material.
  52673. */
  52674. hasTexture(texture: BaseTexture): boolean;
  52675. /**
  52676. * Returns an array of the actively used textures.
  52677. * @param activeTextures Array of BaseTextures
  52678. */
  52679. getActiveTextures(activeTextures: BaseTexture[]): void;
  52680. /**
  52681. * Returns the animatable textures.
  52682. * @param animatables Array of animatable textures.
  52683. */
  52684. getAnimatables(animatables: IAnimatable[]): void;
  52685. /**
  52686. * Disposes the resources of the material.
  52687. * @param forceDisposeTextures - Forces the disposal of all textures.
  52688. */
  52689. dispose(forceDisposeTextures?: boolean): void;
  52690. /**
  52691. * Get the current class name of the texture useful for serialization or dynamic coding.
  52692. * @returns "PBRSheenConfiguration"
  52693. */
  52694. getClassName(): string;
  52695. /**
  52696. * Add fallbacks to the effect fallbacks list.
  52697. * @param defines defines the Base texture to use.
  52698. * @param fallbacks defines the current fallback list.
  52699. * @param currentRank defines the current fallback rank.
  52700. * @returns the new fallback rank.
  52701. */
  52702. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52703. /**
  52704. * Add the required uniforms to the current list.
  52705. * @param uniforms defines the current uniform list.
  52706. */
  52707. static AddUniforms(uniforms: string[]): void;
  52708. /**
  52709. * Add the required uniforms to the current buffer.
  52710. * @param uniformBuffer defines the current uniform buffer.
  52711. */
  52712. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52713. /**
  52714. * Add the required samplers to the current list.
  52715. * @param samplers defines the current sampler list.
  52716. */
  52717. static AddSamplers(samplers: string[]): void;
  52718. /**
  52719. * Makes a duplicate of the current configuration into another one.
  52720. * @param sheenConfiguration define the config where to copy the info
  52721. */
  52722. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52723. /**
  52724. * Serializes this BRDF configuration.
  52725. * @returns - An object with the serialized config.
  52726. */
  52727. serialize(): any;
  52728. /**
  52729. * Parses a anisotropy Configuration from a serialized object.
  52730. * @param source - Serialized object.
  52731. * @param scene Defines the scene we are parsing for
  52732. * @param rootUrl Defines the rootUrl to load from
  52733. */
  52734. parse(source: any, scene: Scene, rootUrl: string): void;
  52735. }
  52736. }
  52737. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52738. import { Nullable } from "babylonjs/types";
  52739. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52740. import { Color3 } from "babylonjs/Maths/math.color";
  52741. import { SmartArray } from "babylonjs/Misc/smartArray";
  52742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52744. import { Effect } from "babylonjs/Materials/effect";
  52745. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52746. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52747. import { Engine } from "babylonjs/Engines/engine";
  52748. import { Scene } from "babylonjs/scene";
  52749. /**
  52750. * @hidden
  52751. */
  52752. export interface IMaterialSubSurfaceDefines {
  52753. SUBSURFACE: boolean;
  52754. SS_REFRACTION: boolean;
  52755. SS_TRANSLUCENCY: boolean;
  52756. SS_SCATERRING: boolean;
  52757. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52758. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52759. SS_REFRACTIONMAP_3D: boolean;
  52760. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52761. SS_LODINREFRACTIONALPHA: boolean;
  52762. SS_GAMMAREFRACTION: boolean;
  52763. SS_RGBDREFRACTION: boolean;
  52764. SS_LINEARSPECULARREFRACTION: boolean;
  52765. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52766. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52767. /** @hidden */
  52768. _areTexturesDirty: boolean;
  52769. }
  52770. /**
  52771. * Define the code related to the sub surface parameters of the pbr material.
  52772. */
  52773. export class PBRSubSurfaceConfiguration {
  52774. private _isRefractionEnabled;
  52775. /**
  52776. * Defines if the refraction is enabled in the material.
  52777. */
  52778. isRefractionEnabled: boolean;
  52779. private _isTranslucencyEnabled;
  52780. /**
  52781. * Defines if the translucency is enabled in the material.
  52782. */
  52783. isTranslucencyEnabled: boolean;
  52784. private _isScatteringEnabled;
  52785. /**
  52786. * Defines the refraction intensity of the material.
  52787. * The refraction when enabled replaces the Diffuse part of the material.
  52788. * The intensity helps transitionning between diffuse and refraction.
  52789. */
  52790. refractionIntensity: number;
  52791. /**
  52792. * Defines the translucency intensity of the material.
  52793. * When translucency has been enabled, this defines how much of the "translucency"
  52794. * is addded to the diffuse part of the material.
  52795. */
  52796. translucencyIntensity: number;
  52797. /**
  52798. * Defines the scattering intensity of the material.
  52799. * When scattering has been enabled, this defines how much of the "scattered light"
  52800. * is addded to the diffuse part of the material.
  52801. */
  52802. scatteringIntensity: number;
  52803. private _thicknessTexture;
  52804. /**
  52805. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52806. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52807. * 0 would mean minimumThickness
  52808. * 1 would mean maximumThickness
  52809. * The other channels might be use as a mask to vary the different effects intensity.
  52810. */
  52811. thicknessTexture: Nullable<BaseTexture>;
  52812. private _refractionTexture;
  52813. /**
  52814. * Defines the texture to use for refraction.
  52815. */
  52816. refractionTexture: Nullable<BaseTexture>;
  52817. private _indexOfRefraction;
  52818. /**
  52819. * Defines the index of refraction used in the material.
  52820. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52821. */
  52822. indexOfRefraction: number;
  52823. private _invertRefractionY;
  52824. /**
  52825. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52826. */
  52827. invertRefractionY: boolean;
  52828. private _linkRefractionWithTransparency;
  52829. /**
  52830. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52831. * Materials half opaque for instance using refraction could benefit from this control.
  52832. */
  52833. linkRefractionWithTransparency: boolean;
  52834. /**
  52835. * Defines the minimum thickness stored in the thickness map.
  52836. * If no thickness map is defined, this value will be used to simulate thickness.
  52837. */
  52838. minimumThickness: number;
  52839. /**
  52840. * Defines the maximum thickness stored in the thickness map.
  52841. */
  52842. maximumThickness: number;
  52843. /**
  52844. * Defines the volume tint of the material.
  52845. * This is used for both translucency and scattering.
  52846. */
  52847. tintColor: Color3;
  52848. /**
  52849. * Defines the distance at which the tint color should be found in the media.
  52850. * This is used for refraction only.
  52851. */
  52852. tintColorAtDistance: number;
  52853. /**
  52854. * Defines how far each channel transmit through the media.
  52855. * It is defined as a color to simplify it selection.
  52856. */
  52857. diffusionDistance: Color3;
  52858. private _useMaskFromThicknessTexture;
  52859. /**
  52860. * Stores the intensity of the different subsurface effects in the thickness texture.
  52861. * * the green channel is the translucency intensity.
  52862. * * the blue channel is the scattering intensity.
  52863. * * the alpha channel is the refraction intensity.
  52864. */
  52865. useMaskFromThicknessTexture: boolean;
  52866. /** @hidden */
  52867. private _internalMarkAllSubMeshesAsTexturesDirty;
  52868. /** @hidden */
  52869. _markAllSubMeshesAsTexturesDirty(): void;
  52870. /**
  52871. * Instantiate a new istance of sub surface configuration.
  52872. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52873. */
  52874. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52875. /**
  52876. * Gets wehter the submesh is ready to be used or not.
  52877. * @param defines the list of "defines" to update.
  52878. * @param scene defines the scene the material belongs to.
  52879. * @returns - boolean indicating that the submesh is ready or not.
  52880. */
  52881. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52882. /**
  52883. * Checks to see if a texture is used in the material.
  52884. * @param defines the list of "defines" to update.
  52885. * @param scene defines the scene to the material belongs to.
  52886. */
  52887. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52888. /**
  52889. * Binds the material data.
  52890. * @param uniformBuffer defines the Uniform buffer to fill in.
  52891. * @param scene defines the scene the material belongs to.
  52892. * @param engine defines the engine the material belongs to.
  52893. * @param isFrozen defines wether the material is frozen or not.
  52894. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52895. */
  52896. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52897. /**
  52898. * Unbinds the material from the mesh.
  52899. * @param activeEffect defines the effect that should be unbound from.
  52900. * @returns true if unbound, otherwise false
  52901. */
  52902. unbind(activeEffect: Effect): boolean;
  52903. /**
  52904. * Returns the texture used for refraction or null if none is used.
  52905. * @param scene defines the scene the material belongs to.
  52906. * @returns - Refraction texture if present. If no refraction texture and refraction
  52907. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52908. */
  52909. private _getRefractionTexture;
  52910. /**
  52911. * Returns true if alpha blending should be disabled.
  52912. */
  52913. get disableAlphaBlending(): boolean;
  52914. /**
  52915. * Fills the list of render target textures.
  52916. * @param renderTargets the list of render targets to update
  52917. */
  52918. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52919. /**
  52920. * Checks to see if a texture is used in the material.
  52921. * @param texture - Base texture to use.
  52922. * @returns - Boolean specifying if a texture is used in the material.
  52923. */
  52924. hasTexture(texture: BaseTexture): boolean;
  52925. /**
  52926. * Gets a boolean indicating that current material needs to register RTT
  52927. * @returns true if this uses a render target otherwise false.
  52928. */
  52929. hasRenderTargetTextures(): boolean;
  52930. /**
  52931. * Returns an array of the actively used textures.
  52932. * @param activeTextures Array of BaseTextures
  52933. */
  52934. getActiveTextures(activeTextures: BaseTexture[]): void;
  52935. /**
  52936. * Returns the animatable textures.
  52937. * @param animatables Array of animatable textures.
  52938. */
  52939. getAnimatables(animatables: IAnimatable[]): void;
  52940. /**
  52941. * Disposes the resources of the material.
  52942. * @param forceDisposeTextures - Forces the disposal of all textures.
  52943. */
  52944. dispose(forceDisposeTextures?: boolean): void;
  52945. /**
  52946. * Get the current class name of the texture useful for serialization or dynamic coding.
  52947. * @returns "PBRSubSurfaceConfiguration"
  52948. */
  52949. getClassName(): string;
  52950. /**
  52951. * Add fallbacks to the effect fallbacks list.
  52952. * @param defines defines the Base texture to use.
  52953. * @param fallbacks defines the current fallback list.
  52954. * @param currentRank defines the current fallback rank.
  52955. * @returns the new fallback rank.
  52956. */
  52957. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52958. /**
  52959. * Add the required uniforms to the current list.
  52960. * @param uniforms defines the current uniform list.
  52961. */
  52962. static AddUniforms(uniforms: string[]): void;
  52963. /**
  52964. * Add the required samplers to the current list.
  52965. * @param samplers defines the current sampler list.
  52966. */
  52967. static AddSamplers(samplers: string[]): void;
  52968. /**
  52969. * Add the required uniforms to the current buffer.
  52970. * @param uniformBuffer defines the current uniform buffer.
  52971. */
  52972. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52973. /**
  52974. * Makes a duplicate of the current configuration into another one.
  52975. * @param configuration define the config where to copy the info
  52976. */
  52977. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52978. /**
  52979. * Serializes this Sub Surface configuration.
  52980. * @returns - An object with the serialized config.
  52981. */
  52982. serialize(): any;
  52983. /**
  52984. * Parses a anisotropy Configuration from a serialized object.
  52985. * @param source - Serialized object.
  52986. * @param scene Defines the scene we are parsing for
  52987. * @param rootUrl Defines the rootUrl to load from
  52988. */
  52989. parse(source: any, scene: Scene, rootUrl: string): void;
  52990. }
  52991. }
  52992. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52993. /** @hidden */
  52994. export var pbrFragmentDeclaration: {
  52995. name: string;
  52996. shader: string;
  52997. };
  52998. }
  52999. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53000. /** @hidden */
  53001. export var pbrUboDeclaration: {
  53002. name: string;
  53003. shader: string;
  53004. };
  53005. }
  53006. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53007. /** @hidden */
  53008. export var pbrFragmentExtraDeclaration: {
  53009. name: string;
  53010. shader: string;
  53011. };
  53012. }
  53013. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53014. /** @hidden */
  53015. export var pbrFragmentSamplersDeclaration: {
  53016. name: string;
  53017. shader: string;
  53018. };
  53019. }
  53020. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53021. /** @hidden */
  53022. export var pbrHelperFunctions: {
  53023. name: string;
  53024. shader: string;
  53025. };
  53026. }
  53027. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53028. /** @hidden */
  53029. export var harmonicsFunctions: {
  53030. name: string;
  53031. shader: string;
  53032. };
  53033. }
  53034. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53035. /** @hidden */
  53036. export var pbrDirectLightingSetupFunctions: {
  53037. name: string;
  53038. shader: string;
  53039. };
  53040. }
  53041. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53042. /** @hidden */
  53043. export var pbrDirectLightingFalloffFunctions: {
  53044. name: string;
  53045. shader: string;
  53046. };
  53047. }
  53048. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53049. /** @hidden */
  53050. export var pbrBRDFFunctions: {
  53051. name: string;
  53052. shader: string;
  53053. };
  53054. }
  53055. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53056. /** @hidden */
  53057. export var pbrDirectLightingFunctions: {
  53058. name: string;
  53059. shader: string;
  53060. };
  53061. }
  53062. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53063. /** @hidden */
  53064. export var pbrIBLFunctions: {
  53065. name: string;
  53066. shader: string;
  53067. };
  53068. }
  53069. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53070. /** @hidden */
  53071. export var pbrDebug: {
  53072. name: string;
  53073. shader: string;
  53074. };
  53075. }
  53076. declare module "babylonjs/Shaders/pbr.fragment" {
  53077. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53078. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53079. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53080. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53081. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53082. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53083. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53084. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53085. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53086. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53087. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53088. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53089. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53090. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53091. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53092. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53093. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53094. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53095. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53096. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53097. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53098. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53099. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53100. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53101. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53102. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53103. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53104. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53105. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53106. /** @hidden */
  53107. export var pbrPixelShader: {
  53108. name: string;
  53109. shader: string;
  53110. };
  53111. }
  53112. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53113. /** @hidden */
  53114. export var pbrVertexDeclaration: {
  53115. name: string;
  53116. shader: string;
  53117. };
  53118. }
  53119. declare module "babylonjs/Shaders/pbr.vertex" {
  53120. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53121. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53122. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53123. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53124. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53125. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53126. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53127. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53128. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53129. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53130. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53131. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53132. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53133. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53134. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53135. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53136. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53137. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53138. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53139. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53140. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53141. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53142. /** @hidden */
  53143. export var pbrVertexShader: {
  53144. name: string;
  53145. shader: string;
  53146. };
  53147. }
  53148. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53149. import { Nullable } from "babylonjs/types";
  53150. import { Scene } from "babylonjs/scene";
  53151. import { Matrix } from "babylonjs/Maths/math.vector";
  53152. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53154. import { Mesh } from "babylonjs/Meshes/mesh";
  53155. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53156. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53157. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53158. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53159. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53160. import { Color3 } from "babylonjs/Maths/math.color";
  53161. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53162. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53163. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53164. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53166. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53167. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53168. import "babylonjs/Shaders/pbr.fragment";
  53169. import "babylonjs/Shaders/pbr.vertex";
  53170. /**
  53171. * Manages the defines for the PBR Material.
  53172. * @hidden
  53173. */
  53174. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53175. PBR: boolean;
  53176. MAINUV1: boolean;
  53177. MAINUV2: boolean;
  53178. UV1: boolean;
  53179. UV2: boolean;
  53180. ALBEDO: boolean;
  53181. ALBEDODIRECTUV: number;
  53182. VERTEXCOLOR: boolean;
  53183. AMBIENT: boolean;
  53184. AMBIENTDIRECTUV: number;
  53185. AMBIENTINGRAYSCALE: boolean;
  53186. OPACITY: boolean;
  53187. VERTEXALPHA: boolean;
  53188. OPACITYDIRECTUV: number;
  53189. OPACITYRGB: boolean;
  53190. ALPHATEST: boolean;
  53191. DEPTHPREPASS: boolean;
  53192. ALPHABLEND: boolean;
  53193. ALPHAFROMALBEDO: boolean;
  53194. ALPHATESTVALUE: string;
  53195. SPECULAROVERALPHA: boolean;
  53196. RADIANCEOVERALPHA: boolean;
  53197. ALPHAFRESNEL: boolean;
  53198. LINEARALPHAFRESNEL: boolean;
  53199. PREMULTIPLYALPHA: boolean;
  53200. EMISSIVE: boolean;
  53201. EMISSIVEDIRECTUV: number;
  53202. REFLECTIVITY: boolean;
  53203. REFLECTIVITYDIRECTUV: number;
  53204. SPECULARTERM: boolean;
  53205. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53206. MICROSURFACEAUTOMATIC: boolean;
  53207. LODBASEDMICROSFURACE: boolean;
  53208. MICROSURFACEMAP: boolean;
  53209. MICROSURFACEMAPDIRECTUV: number;
  53210. METALLICWORKFLOW: boolean;
  53211. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53212. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53213. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53214. AOSTOREINMETALMAPRED: boolean;
  53215. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53216. ENVIRONMENTBRDF: boolean;
  53217. ENVIRONMENTBRDF_RGBD: boolean;
  53218. NORMAL: boolean;
  53219. TANGENT: boolean;
  53220. BUMP: boolean;
  53221. BUMPDIRECTUV: number;
  53222. OBJECTSPACE_NORMALMAP: boolean;
  53223. PARALLAX: boolean;
  53224. PARALLAXOCCLUSION: boolean;
  53225. NORMALXYSCALE: boolean;
  53226. LIGHTMAP: boolean;
  53227. LIGHTMAPDIRECTUV: number;
  53228. USELIGHTMAPASSHADOWMAP: boolean;
  53229. GAMMALIGHTMAP: boolean;
  53230. RGBDLIGHTMAP: boolean;
  53231. REFLECTION: boolean;
  53232. REFLECTIONMAP_3D: boolean;
  53233. REFLECTIONMAP_SPHERICAL: boolean;
  53234. REFLECTIONMAP_PLANAR: boolean;
  53235. REFLECTIONMAP_CUBIC: boolean;
  53236. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53237. REFLECTIONMAP_PROJECTION: boolean;
  53238. REFLECTIONMAP_SKYBOX: boolean;
  53239. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  53240. REFLECTIONMAP_EXPLICIT: boolean;
  53241. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53242. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53243. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53244. INVERTCUBICMAP: boolean;
  53245. USESPHERICALFROMREFLECTIONMAP: boolean;
  53246. USEIRRADIANCEMAP: boolean;
  53247. SPHERICAL_HARMONICS: boolean;
  53248. USESPHERICALINVERTEX: boolean;
  53249. REFLECTIONMAP_OPPOSITEZ: boolean;
  53250. LODINREFLECTIONALPHA: boolean;
  53251. GAMMAREFLECTION: boolean;
  53252. RGBDREFLECTION: boolean;
  53253. LINEARSPECULARREFLECTION: boolean;
  53254. RADIANCEOCCLUSION: boolean;
  53255. HORIZONOCCLUSION: boolean;
  53256. INSTANCES: boolean;
  53257. NUM_BONE_INFLUENCERS: number;
  53258. BonesPerMesh: number;
  53259. BONETEXTURE: boolean;
  53260. NONUNIFORMSCALING: boolean;
  53261. MORPHTARGETS: boolean;
  53262. MORPHTARGETS_NORMAL: boolean;
  53263. MORPHTARGETS_TANGENT: boolean;
  53264. MORPHTARGETS_UV: boolean;
  53265. NUM_MORPH_INFLUENCERS: number;
  53266. IMAGEPROCESSING: boolean;
  53267. VIGNETTE: boolean;
  53268. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53269. VIGNETTEBLENDMODEOPAQUE: boolean;
  53270. TONEMAPPING: boolean;
  53271. TONEMAPPING_ACES: boolean;
  53272. CONTRAST: boolean;
  53273. COLORCURVES: boolean;
  53274. COLORGRADING: boolean;
  53275. COLORGRADING3D: boolean;
  53276. SAMPLER3DGREENDEPTH: boolean;
  53277. SAMPLER3DBGRMAP: boolean;
  53278. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53279. EXPOSURE: boolean;
  53280. MULTIVIEW: boolean;
  53281. USEPHYSICALLIGHTFALLOFF: boolean;
  53282. USEGLTFLIGHTFALLOFF: boolean;
  53283. TWOSIDEDLIGHTING: boolean;
  53284. SHADOWFLOAT: boolean;
  53285. CLIPPLANE: boolean;
  53286. CLIPPLANE2: boolean;
  53287. CLIPPLANE3: boolean;
  53288. CLIPPLANE4: boolean;
  53289. CLIPPLANE5: boolean;
  53290. CLIPPLANE6: boolean;
  53291. POINTSIZE: boolean;
  53292. FOG: boolean;
  53293. LOGARITHMICDEPTH: boolean;
  53294. FORCENORMALFORWARD: boolean;
  53295. SPECULARAA: boolean;
  53296. CLEARCOAT: boolean;
  53297. CLEARCOAT_DEFAULTIOR: boolean;
  53298. CLEARCOAT_TEXTURE: boolean;
  53299. CLEARCOAT_TEXTUREDIRECTUV: number;
  53300. CLEARCOAT_BUMP: boolean;
  53301. CLEARCOAT_BUMPDIRECTUV: number;
  53302. CLEARCOAT_TINT: boolean;
  53303. CLEARCOAT_TINT_TEXTURE: boolean;
  53304. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53305. ANISOTROPIC: boolean;
  53306. ANISOTROPIC_TEXTURE: boolean;
  53307. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53308. BRDF_V_HEIGHT_CORRELATED: boolean;
  53309. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53310. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53311. SHEEN: boolean;
  53312. SHEEN_TEXTURE: boolean;
  53313. SHEEN_TEXTUREDIRECTUV: number;
  53314. SHEEN_LINKWITHALBEDO: boolean;
  53315. SUBSURFACE: boolean;
  53316. SS_REFRACTION: boolean;
  53317. SS_TRANSLUCENCY: boolean;
  53318. SS_SCATERRING: boolean;
  53319. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53320. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53321. SS_REFRACTIONMAP_3D: boolean;
  53322. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53323. SS_LODINREFRACTIONALPHA: boolean;
  53324. SS_GAMMAREFRACTION: boolean;
  53325. SS_RGBDREFRACTION: boolean;
  53326. SS_LINEARSPECULARREFRACTION: boolean;
  53327. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53328. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53329. UNLIT: boolean;
  53330. DEBUGMODE: number;
  53331. /**
  53332. * Initializes the PBR Material defines.
  53333. */
  53334. constructor();
  53335. /**
  53336. * Resets the PBR Material defines.
  53337. */
  53338. reset(): void;
  53339. }
  53340. /**
  53341. * The Physically based material base class of BJS.
  53342. *
  53343. * This offers the main features of a standard PBR material.
  53344. * For more information, please refer to the documentation :
  53345. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53346. */
  53347. export abstract class PBRBaseMaterial extends PushMaterial {
  53348. /**
  53349. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53350. */
  53351. static readonly PBRMATERIAL_OPAQUE: number;
  53352. /**
  53353. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53354. */
  53355. static readonly PBRMATERIAL_ALPHATEST: number;
  53356. /**
  53357. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53358. */
  53359. static readonly PBRMATERIAL_ALPHABLEND: number;
  53360. /**
  53361. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53362. * They are also discarded below the alpha cutoff threshold to improve performances.
  53363. */
  53364. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53365. /**
  53366. * Defines the default value of how much AO map is occluding the analytical lights
  53367. * (point spot...).
  53368. */
  53369. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53370. /**
  53371. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53372. */
  53373. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53374. /**
  53375. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53376. * to enhance interoperability with other engines.
  53377. */
  53378. static readonly LIGHTFALLOFF_GLTF: number;
  53379. /**
  53380. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53381. * to enhance interoperability with other materials.
  53382. */
  53383. static readonly LIGHTFALLOFF_STANDARD: number;
  53384. /**
  53385. * Intensity of the direct lights e.g. the four lights available in your scene.
  53386. * This impacts both the direct diffuse and specular highlights.
  53387. */
  53388. protected _directIntensity: number;
  53389. /**
  53390. * Intensity of the emissive part of the material.
  53391. * This helps controlling the emissive effect without modifying the emissive color.
  53392. */
  53393. protected _emissiveIntensity: number;
  53394. /**
  53395. * Intensity of the environment e.g. how much the environment will light the object
  53396. * either through harmonics for rough material or through the refelction for shiny ones.
  53397. */
  53398. protected _environmentIntensity: number;
  53399. /**
  53400. * This is a special control allowing the reduction of the specular highlights coming from the
  53401. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53402. */
  53403. protected _specularIntensity: number;
  53404. /**
  53405. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53406. */
  53407. private _lightingInfos;
  53408. /**
  53409. * Debug Control allowing disabling the bump map on this material.
  53410. */
  53411. protected _disableBumpMap: boolean;
  53412. /**
  53413. * AKA Diffuse Texture in standard nomenclature.
  53414. */
  53415. protected _albedoTexture: Nullable<BaseTexture>;
  53416. /**
  53417. * AKA Occlusion Texture in other nomenclature.
  53418. */
  53419. protected _ambientTexture: Nullable<BaseTexture>;
  53420. /**
  53421. * AKA Occlusion Texture Intensity in other nomenclature.
  53422. */
  53423. protected _ambientTextureStrength: number;
  53424. /**
  53425. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53426. * 1 means it completely occludes it
  53427. * 0 mean it has no impact
  53428. */
  53429. protected _ambientTextureImpactOnAnalyticalLights: number;
  53430. /**
  53431. * Stores the alpha values in a texture.
  53432. */
  53433. protected _opacityTexture: Nullable<BaseTexture>;
  53434. /**
  53435. * Stores the reflection values in a texture.
  53436. */
  53437. protected _reflectionTexture: Nullable<BaseTexture>;
  53438. /**
  53439. * Stores the emissive values in a texture.
  53440. */
  53441. protected _emissiveTexture: Nullable<BaseTexture>;
  53442. /**
  53443. * AKA Specular texture in other nomenclature.
  53444. */
  53445. protected _reflectivityTexture: Nullable<BaseTexture>;
  53446. /**
  53447. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53448. */
  53449. protected _metallicTexture: Nullable<BaseTexture>;
  53450. /**
  53451. * Specifies the metallic scalar of the metallic/roughness workflow.
  53452. * Can also be used to scale the metalness values of the metallic texture.
  53453. */
  53454. protected _metallic: Nullable<number>;
  53455. /**
  53456. * Specifies the roughness scalar of the metallic/roughness workflow.
  53457. * Can also be used to scale the roughness values of the metallic texture.
  53458. */
  53459. protected _roughness: Nullable<number>;
  53460. /**
  53461. * Specifies the an F0 factor to help configuring the material F0.
  53462. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53463. * to 0.5 the previously hard coded value stays the same.
  53464. * Can also be used to scale the F0 values of the metallic texture.
  53465. */
  53466. protected _metallicF0Factor: number;
  53467. /**
  53468. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53469. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53470. * your expectation as it multiplies with the texture data.
  53471. */
  53472. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53473. /**
  53474. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53475. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53476. */
  53477. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53478. /**
  53479. * Stores surface normal data used to displace a mesh in a texture.
  53480. */
  53481. protected _bumpTexture: Nullable<BaseTexture>;
  53482. /**
  53483. * Stores the pre-calculated light information of a mesh in a texture.
  53484. */
  53485. protected _lightmapTexture: Nullable<BaseTexture>;
  53486. /**
  53487. * The color of a material in ambient lighting.
  53488. */
  53489. protected _ambientColor: Color3;
  53490. /**
  53491. * AKA Diffuse Color in other nomenclature.
  53492. */
  53493. protected _albedoColor: Color3;
  53494. /**
  53495. * AKA Specular Color in other nomenclature.
  53496. */
  53497. protected _reflectivityColor: Color3;
  53498. /**
  53499. * The color applied when light is reflected from a material.
  53500. */
  53501. protected _reflectionColor: Color3;
  53502. /**
  53503. * The color applied when light is emitted from a material.
  53504. */
  53505. protected _emissiveColor: Color3;
  53506. /**
  53507. * AKA Glossiness in other nomenclature.
  53508. */
  53509. protected _microSurface: number;
  53510. /**
  53511. * Specifies that the material will use the light map as a show map.
  53512. */
  53513. protected _useLightmapAsShadowmap: boolean;
  53514. /**
  53515. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53516. * makes the reflect vector face the model (under horizon).
  53517. */
  53518. protected _useHorizonOcclusion: boolean;
  53519. /**
  53520. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53521. * too much the area relying on ambient texture to define their ambient occlusion.
  53522. */
  53523. protected _useRadianceOcclusion: boolean;
  53524. /**
  53525. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53526. */
  53527. protected _useAlphaFromAlbedoTexture: boolean;
  53528. /**
  53529. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53530. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53531. */
  53532. protected _useSpecularOverAlpha: boolean;
  53533. /**
  53534. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53535. */
  53536. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53537. /**
  53538. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53539. */
  53540. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53541. /**
  53542. * Specifies if the metallic texture contains the roughness information in its green channel.
  53543. */
  53544. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53545. /**
  53546. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53547. */
  53548. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53549. /**
  53550. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53551. */
  53552. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53553. /**
  53554. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53555. */
  53556. protected _useAmbientInGrayScale: boolean;
  53557. /**
  53558. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53559. * The material will try to infer what glossiness each pixel should be.
  53560. */
  53561. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53562. /**
  53563. * Defines the falloff type used in this material.
  53564. * It by default is Physical.
  53565. */
  53566. protected _lightFalloff: number;
  53567. /**
  53568. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53569. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53570. */
  53571. protected _useRadianceOverAlpha: boolean;
  53572. /**
  53573. * Allows using an object space normal map (instead of tangent space).
  53574. */
  53575. protected _useObjectSpaceNormalMap: boolean;
  53576. /**
  53577. * Allows using the bump map in parallax mode.
  53578. */
  53579. protected _useParallax: boolean;
  53580. /**
  53581. * Allows using the bump map in parallax occlusion mode.
  53582. */
  53583. protected _useParallaxOcclusion: boolean;
  53584. /**
  53585. * Controls the scale bias of the parallax mode.
  53586. */
  53587. protected _parallaxScaleBias: number;
  53588. /**
  53589. * If sets to true, disables all the lights affecting the material.
  53590. */
  53591. protected _disableLighting: boolean;
  53592. /**
  53593. * Number of Simultaneous lights allowed on the material.
  53594. */
  53595. protected _maxSimultaneousLights: number;
  53596. /**
  53597. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53598. */
  53599. protected _invertNormalMapX: boolean;
  53600. /**
  53601. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53602. */
  53603. protected _invertNormalMapY: boolean;
  53604. /**
  53605. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53606. */
  53607. protected _twoSidedLighting: boolean;
  53608. /**
  53609. * Defines the alpha limits in alpha test mode.
  53610. */
  53611. protected _alphaCutOff: number;
  53612. /**
  53613. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53614. */
  53615. protected _forceAlphaTest: boolean;
  53616. /**
  53617. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53618. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53619. */
  53620. protected _useAlphaFresnel: boolean;
  53621. /**
  53622. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53623. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53624. */
  53625. protected _useLinearAlphaFresnel: boolean;
  53626. /**
  53627. * The transparency mode of the material.
  53628. */
  53629. protected _transparencyMode: Nullable<number>;
  53630. /**
  53631. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53632. * from cos thetav and roughness:
  53633. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53634. */
  53635. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53636. /**
  53637. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53638. */
  53639. protected _forceIrradianceInFragment: boolean;
  53640. /**
  53641. * Force normal to face away from face.
  53642. */
  53643. protected _forceNormalForward: boolean;
  53644. /**
  53645. * Enables specular anti aliasing in the PBR shader.
  53646. * It will both interacts on the Geometry for analytical and IBL lighting.
  53647. * It also prefilter the roughness map based on the bump values.
  53648. */
  53649. protected _enableSpecularAntiAliasing: boolean;
  53650. /**
  53651. * Default configuration related to image processing available in the PBR Material.
  53652. */
  53653. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53654. /**
  53655. * Keep track of the image processing observer to allow dispose and replace.
  53656. */
  53657. private _imageProcessingObserver;
  53658. /**
  53659. * Attaches a new image processing configuration to the PBR Material.
  53660. * @param configuration
  53661. */
  53662. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53663. /**
  53664. * Stores the available render targets.
  53665. */
  53666. private _renderTargets;
  53667. /**
  53668. * Sets the global ambient color for the material used in lighting calculations.
  53669. */
  53670. private _globalAmbientColor;
  53671. /**
  53672. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53673. */
  53674. private _useLogarithmicDepth;
  53675. /**
  53676. * If set to true, no lighting calculations will be applied.
  53677. */
  53678. private _unlit;
  53679. private _debugMode;
  53680. /**
  53681. * @hidden
  53682. * This is reserved for the inspector.
  53683. * Defines the material debug mode.
  53684. * It helps seeing only some components of the material while troubleshooting.
  53685. */
  53686. debugMode: number;
  53687. /**
  53688. * @hidden
  53689. * This is reserved for the inspector.
  53690. * Specify from where on screen the debug mode should start.
  53691. * The value goes from -1 (full screen) to 1 (not visible)
  53692. * It helps with side by side comparison against the final render
  53693. * This defaults to -1
  53694. */
  53695. private debugLimit;
  53696. /**
  53697. * @hidden
  53698. * This is reserved for the inspector.
  53699. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53700. * You can use the factor to better multiply the final value.
  53701. */
  53702. private debugFactor;
  53703. /**
  53704. * Defines the clear coat layer parameters for the material.
  53705. */
  53706. readonly clearCoat: PBRClearCoatConfiguration;
  53707. /**
  53708. * Defines the anisotropic parameters for the material.
  53709. */
  53710. readonly anisotropy: PBRAnisotropicConfiguration;
  53711. /**
  53712. * Defines the BRDF parameters for the material.
  53713. */
  53714. readonly brdf: PBRBRDFConfiguration;
  53715. /**
  53716. * Defines the Sheen parameters for the material.
  53717. */
  53718. readonly sheen: PBRSheenConfiguration;
  53719. /**
  53720. * Defines the SubSurface parameters for the material.
  53721. */
  53722. readonly subSurface: PBRSubSurfaceConfiguration;
  53723. /**
  53724. * Custom callback helping to override the default shader used in the material.
  53725. */
  53726. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53727. protected _rebuildInParallel: boolean;
  53728. /**
  53729. * Instantiates a new PBRMaterial instance.
  53730. *
  53731. * @param name The material name
  53732. * @param scene The scene the material will be use in.
  53733. */
  53734. constructor(name: string, scene: Scene);
  53735. /**
  53736. * Gets a boolean indicating that current material needs to register RTT
  53737. */
  53738. get hasRenderTargetTextures(): boolean;
  53739. /**
  53740. * Gets the name of the material class.
  53741. */
  53742. getClassName(): string;
  53743. /**
  53744. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53745. */
  53746. get useLogarithmicDepth(): boolean;
  53747. /**
  53748. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53749. */
  53750. set useLogarithmicDepth(value: boolean);
  53751. /**
  53752. * Gets the current transparency mode.
  53753. */
  53754. get transparencyMode(): Nullable<number>;
  53755. /**
  53756. * Sets the transparency mode of the material.
  53757. *
  53758. * | Value | Type | Description |
  53759. * | ----- | ----------------------------------- | ----------- |
  53760. * | 0 | OPAQUE | |
  53761. * | 1 | ALPHATEST | |
  53762. * | 2 | ALPHABLEND | |
  53763. * | 3 | ALPHATESTANDBLEND | |
  53764. *
  53765. */
  53766. set transparencyMode(value: Nullable<number>);
  53767. /**
  53768. * Returns true if alpha blending should be disabled.
  53769. */
  53770. private get _disableAlphaBlending();
  53771. /**
  53772. * Specifies whether or not this material should be rendered in alpha blend mode.
  53773. */
  53774. needAlphaBlending(): boolean;
  53775. /**
  53776. * Specifies if the mesh will require alpha blending.
  53777. * @param mesh - BJS mesh.
  53778. */
  53779. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53780. /**
  53781. * Specifies whether or not this material should be rendered in alpha test mode.
  53782. */
  53783. needAlphaTesting(): boolean;
  53784. /**
  53785. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53786. */
  53787. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53788. /**
  53789. * Gets the texture used for the alpha test.
  53790. */
  53791. getAlphaTestTexture(): Nullable<BaseTexture>;
  53792. /**
  53793. * Specifies that the submesh is ready to be used.
  53794. * @param mesh - BJS mesh.
  53795. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53796. * @param useInstances - Specifies that instances should be used.
  53797. * @returns - boolean indicating that the submesh is ready or not.
  53798. */
  53799. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53800. /**
  53801. * Specifies if the material uses metallic roughness workflow.
  53802. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53803. */
  53804. isMetallicWorkflow(): boolean;
  53805. private _prepareEffect;
  53806. private _prepareDefines;
  53807. /**
  53808. * Force shader compilation
  53809. */
  53810. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53811. /**
  53812. * Initializes the uniform buffer layout for the shader.
  53813. */
  53814. buildUniformLayout(): void;
  53815. /**
  53816. * Unbinds the material from the mesh
  53817. */
  53818. unbind(): void;
  53819. /**
  53820. * Binds the submesh data.
  53821. * @param world - The world matrix.
  53822. * @param mesh - The BJS mesh.
  53823. * @param subMesh - A submesh of the BJS mesh.
  53824. */
  53825. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53826. /**
  53827. * Returns the animatable textures.
  53828. * @returns - Array of animatable textures.
  53829. */
  53830. getAnimatables(): IAnimatable[];
  53831. /**
  53832. * Returns the texture used for reflections.
  53833. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53834. */
  53835. private _getReflectionTexture;
  53836. /**
  53837. * Returns an array of the actively used textures.
  53838. * @returns - Array of BaseTextures
  53839. */
  53840. getActiveTextures(): BaseTexture[];
  53841. /**
  53842. * Checks to see if a texture is used in the material.
  53843. * @param texture - Base texture to use.
  53844. * @returns - Boolean specifying if a texture is used in the material.
  53845. */
  53846. hasTexture(texture: BaseTexture): boolean;
  53847. /**
  53848. * Disposes the resources of the material.
  53849. * @param forceDisposeEffect - Forces the disposal of effects.
  53850. * @param forceDisposeTextures - Forces the disposal of all textures.
  53851. */
  53852. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53853. }
  53854. }
  53855. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53856. import { Nullable } from "babylonjs/types";
  53857. import { Scene } from "babylonjs/scene";
  53858. import { Color3 } from "babylonjs/Maths/math.color";
  53859. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53860. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53862. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53863. /**
  53864. * The Physically based material of BJS.
  53865. *
  53866. * This offers the main features of a standard PBR material.
  53867. * For more information, please refer to the documentation :
  53868. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53869. */
  53870. export class PBRMaterial extends PBRBaseMaterial {
  53871. /**
  53872. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53873. */
  53874. static readonly PBRMATERIAL_OPAQUE: number;
  53875. /**
  53876. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53877. */
  53878. static readonly PBRMATERIAL_ALPHATEST: number;
  53879. /**
  53880. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53881. */
  53882. static readonly PBRMATERIAL_ALPHABLEND: number;
  53883. /**
  53884. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53885. * They are also discarded below the alpha cutoff threshold to improve performances.
  53886. */
  53887. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53888. /**
  53889. * Defines the default value of how much AO map is occluding the analytical lights
  53890. * (point spot...).
  53891. */
  53892. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53893. /**
  53894. * Intensity of the direct lights e.g. the four lights available in your scene.
  53895. * This impacts both the direct diffuse and specular highlights.
  53896. */
  53897. directIntensity: number;
  53898. /**
  53899. * Intensity of the emissive part of the material.
  53900. * This helps controlling the emissive effect without modifying the emissive color.
  53901. */
  53902. emissiveIntensity: number;
  53903. /**
  53904. * Intensity of the environment e.g. how much the environment will light the object
  53905. * either through harmonics for rough material or through the refelction for shiny ones.
  53906. */
  53907. environmentIntensity: number;
  53908. /**
  53909. * This is a special control allowing the reduction of the specular highlights coming from the
  53910. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53911. */
  53912. specularIntensity: number;
  53913. /**
  53914. * Debug Control allowing disabling the bump map on this material.
  53915. */
  53916. disableBumpMap: boolean;
  53917. /**
  53918. * AKA Diffuse Texture in standard nomenclature.
  53919. */
  53920. albedoTexture: BaseTexture;
  53921. /**
  53922. * AKA Occlusion Texture in other nomenclature.
  53923. */
  53924. ambientTexture: BaseTexture;
  53925. /**
  53926. * AKA Occlusion Texture Intensity in other nomenclature.
  53927. */
  53928. ambientTextureStrength: number;
  53929. /**
  53930. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53931. * 1 means it completely occludes it
  53932. * 0 mean it has no impact
  53933. */
  53934. ambientTextureImpactOnAnalyticalLights: number;
  53935. /**
  53936. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53937. */
  53938. opacityTexture: BaseTexture;
  53939. /**
  53940. * Stores the reflection values in a texture.
  53941. */
  53942. reflectionTexture: Nullable<BaseTexture>;
  53943. /**
  53944. * Stores the emissive values in a texture.
  53945. */
  53946. emissiveTexture: BaseTexture;
  53947. /**
  53948. * AKA Specular texture in other nomenclature.
  53949. */
  53950. reflectivityTexture: BaseTexture;
  53951. /**
  53952. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53953. */
  53954. metallicTexture: BaseTexture;
  53955. /**
  53956. * Specifies the metallic scalar of the metallic/roughness workflow.
  53957. * Can also be used to scale the metalness values of the metallic texture.
  53958. */
  53959. metallic: Nullable<number>;
  53960. /**
  53961. * Specifies the roughness scalar of the metallic/roughness workflow.
  53962. * Can also be used to scale the roughness values of the metallic texture.
  53963. */
  53964. roughness: Nullable<number>;
  53965. /**
  53966. * Specifies the an F0 factor to help configuring the material F0.
  53967. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53968. * to 0.5 the previously hard coded value stays the same.
  53969. * Can also be used to scale the F0 values of the metallic texture.
  53970. */
  53971. metallicF0Factor: number;
  53972. /**
  53973. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53974. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53975. * your expectation as it multiplies with the texture data.
  53976. */
  53977. useMetallicF0FactorFromMetallicTexture: boolean;
  53978. /**
  53979. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53980. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53981. */
  53982. microSurfaceTexture: BaseTexture;
  53983. /**
  53984. * Stores surface normal data used to displace a mesh in a texture.
  53985. */
  53986. bumpTexture: BaseTexture;
  53987. /**
  53988. * Stores the pre-calculated light information of a mesh in a texture.
  53989. */
  53990. lightmapTexture: BaseTexture;
  53991. /**
  53992. * Stores the refracted light information in a texture.
  53993. */
  53994. get refractionTexture(): Nullable<BaseTexture>;
  53995. set refractionTexture(value: Nullable<BaseTexture>);
  53996. /**
  53997. * The color of a material in ambient lighting.
  53998. */
  53999. ambientColor: Color3;
  54000. /**
  54001. * AKA Diffuse Color in other nomenclature.
  54002. */
  54003. albedoColor: Color3;
  54004. /**
  54005. * AKA Specular Color in other nomenclature.
  54006. */
  54007. reflectivityColor: Color3;
  54008. /**
  54009. * The color reflected from the material.
  54010. */
  54011. reflectionColor: Color3;
  54012. /**
  54013. * The color emitted from the material.
  54014. */
  54015. emissiveColor: Color3;
  54016. /**
  54017. * AKA Glossiness in other nomenclature.
  54018. */
  54019. microSurface: number;
  54020. /**
  54021. * source material index of refraction (IOR)' / 'destination material IOR.
  54022. */
  54023. get indexOfRefraction(): number;
  54024. set indexOfRefraction(value: number);
  54025. /**
  54026. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54027. */
  54028. get invertRefractionY(): boolean;
  54029. set invertRefractionY(value: boolean);
  54030. /**
  54031. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54032. * Materials half opaque for instance using refraction could benefit from this control.
  54033. */
  54034. get linkRefractionWithTransparency(): boolean;
  54035. set linkRefractionWithTransparency(value: boolean);
  54036. /**
  54037. * If true, the light map contains occlusion information instead of lighting info.
  54038. */
  54039. useLightmapAsShadowmap: boolean;
  54040. /**
  54041. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54042. */
  54043. useAlphaFromAlbedoTexture: boolean;
  54044. /**
  54045. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54046. */
  54047. forceAlphaTest: boolean;
  54048. /**
  54049. * Defines the alpha limits in alpha test mode.
  54050. */
  54051. alphaCutOff: number;
  54052. /**
  54053. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54054. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54055. */
  54056. useSpecularOverAlpha: boolean;
  54057. /**
  54058. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54059. */
  54060. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54061. /**
  54062. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54063. */
  54064. useRoughnessFromMetallicTextureAlpha: boolean;
  54065. /**
  54066. * Specifies if the metallic texture contains the roughness information in its green channel.
  54067. */
  54068. useRoughnessFromMetallicTextureGreen: boolean;
  54069. /**
  54070. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54071. */
  54072. useMetallnessFromMetallicTextureBlue: boolean;
  54073. /**
  54074. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54075. */
  54076. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54077. /**
  54078. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54079. */
  54080. useAmbientInGrayScale: boolean;
  54081. /**
  54082. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54083. * The material will try to infer what glossiness each pixel should be.
  54084. */
  54085. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54086. /**
  54087. * BJS is using an harcoded light falloff based on a manually sets up range.
  54088. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54089. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54090. */
  54091. get usePhysicalLightFalloff(): boolean;
  54092. /**
  54093. * BJS is using an harcoded light falloff based on a manually sets up range.
  54094. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54095. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54096. */
  54097. set usePhysicalLightFalloff(value: boolean);
  54098. /**
  54099. * In order to support the falloff compatibility with gltf, a special mode has been added
  54100. * to reproduce the gltf light falloff.
  54101. */
  54102. get useGLTFLightFalloff(): boolean;
  54103. /**
  54104. * In order to support the falloff compatibility with gltf, a special mode has been added
  54105. * to reproduce the gltf light falloff.
  54106. */
  54107. set useGLTFLightFalloff(value: boolean);
  54108. /**
  54109. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54110. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54111. */
  54112. useRadianceOverAlpha: boolean;
  54113. /**
  54114. * Allows using an object space normal map (instead of tangent space).
  54115. */
  54116. useObjectSpaceNormalMap: boolean;
  54117. /**
  54118. * Allows using the bump map in parallax mode.
  54119. */
  54120. useParallax: boolean;
  54121. /**
  54122. * Allows using the bump map in parallax occlusion mode.
  54123. */
  54124. useParallaxOcclusion: boolean;
  54125. /**
  54126. * Controls the scale bias of the parallax mode.
  54127. */
  54128. parallaxScaleBias: number;
  54129. /**
  54130. * If sets to true, disables all the lights affecting the material.
  54131. */
  54132. disableLighting: boolean;
  54133. /**
  54134. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54135. */
  54136. forceIrradianceInFragment: boolean;
  54137. /**
  54138. * Number of Simultaneous lights allowed on the material.
  54139. */
  54140. maxSimultaneousLights: number;
  54141. /**
  54142. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54143. */
  54144. invertNormalMapX: boolean;
  54145. /**
  54146. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54147. */
  54148. invertNormalMapY: boolean;
  54149. /**
  54150. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54151. */
  54152. twoSidedLighting: boolean;
  54153. /**
  54154. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54155. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54156. */
  54157. useAlphaFresnel: boolean;
  54158. /**
  54159. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54160. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54161. */
  54162. useLinearAlphaFresnel: boolean;
  54163. /**
  54164. * Let user defines the brdf lookup texture used for IBL.
  54165. * A default 8bit version is embedded but you could point at :
  54166. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54167. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54168. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54169. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54170. */
  54171. environmentBRDFTexture: Nullable<BaseTexture>;
  54172. /**
  54173. * Force normal to face away from face.
  54174. */
  54175. forceNormalForward: boolean;
  54176. /**
  54177. * Enables specular anti aliasing in the PBR shader.
  54178. * It will both interacts on the Geometry for analytical and IBL lighting.
  54179. * It also prefilter the roughness map based on the bump values.
  54180. */
  54181. enableSpecularAntiAliasing: boolean;
  54182. /**
  54183. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54184. * makes the reflect vector face the model (under horizon).
  54185. */
  54186. useHorizonOcclusion: boolean;
  54187. /**
  54188. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54189. * too much the area relying on ambient texture to define their ambient occlusion.
  54190. */
  54191. useRadianceOcclusion: boolean;
  54192. /**
  54193. * If set to true, no lighting calculations will be applied.
  54194. */
  54195. unlit: boolean;
  54196. /**
  54197. * Gets the image processing configuration used either in this material.
  54198. */
  54199. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54200. /**
  54201. * Sets the Default image processing configuration used either in the this material.
  54202. *
  54203. * If sets to null, the scene one is in use.
  54204. */
  54205. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54206. /**
  54207. * Gets wether the color curves effect is enabled.
  54208. */
  54209. get cameraColorCurvesEnabled(): boolean;
  54210. /**
  54211. * Sets wether the color curves effect is enabled.
  54212. */
  54213. set cameraColorCurvesEnabled(value: boolean);
  54214. /**
  54215. * Gets wether the color grading effect is enabled.
  54216. */
  54217. get cameraColorGradingEnabled(): boolean;
  54218. /**
  54219. * Gets wether the color grading effect is enabled.
  54220. */
  54221. set cameraColorGradingEnabled(value: boolean);
  54222. /**
  54223. * Gets wether tonemapping is enabled or not.
  54224. */
  54225. get cameraToneMappingEnabled(): boolean;
  54226. /**
  54227. * Sets wether tonemapping is enabled or not
  54228. */
  54229. set cameraToneMappingEnabled(value: boolean);
  54230. /**
  54231. * The camera exposure used on this material.
  54232. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54233. * This corresponds to a photographic exposure.
  54234. */
  54235. get cameraExposure(): number;
  54236. /**
  54237. * The camera exposure used on this material.
  54238. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54239. * This corresponds to a photographic exposure.
  54240. */
  54241. set cameraExposure(value: number);
  54242. /**
  54243. * Gets The camera contrast used on this material.
  54244. */
  54245. get cameraContrast(): number;
  54246. /**
  54247. * Sets The camera contrast used on this material.
  54248. */
  54249. set cameraContrast(value: number);
  54250. /**
  54251. * Gets the Color Grading 2D Lookup Texture.
  54252. */
  54253. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54254. /**
  54255. * Sets the Color Grading 2D Lookup Texture.
  54256. */
  54257. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54258. /**
  54259. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54260. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54261. * 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;
  54262. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54263. */
  54264. get cameraColorCurves(): Nullable<ColorCurves>;
  54265. /**
  54266. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54267. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54268. * 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;
  54269. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54270. */
  54271. set cameraColorCurves(value: Nullable<ColorCurves>);
  54272. /**
  54273. * Instantiates a new PBRMaterial instance.
  54274. *
  54275. * @param name The material name
  54276. * @param scene The scene the material will be use in.
  54277. */
  54278. constructor(name: string, scene: Scene);
  54279. /**
  54280. * Returns the name of this material class.
  54281. */
  54282. getClassName(): string;
  54283. /**
  54284. * Makes a duplicate of the current material.
  54285. * @param name - name to use for the new material.
  54286. */
  54287. clone(name: string): PBRMaterial;
  54288. /**
  54289. * Serializes this PBR Material.
  54290. * @returns - An object with the serialized material.
  54291. */
  54292. serialize(): any;
  54293. /**
  54294. * Parses a PBR Material from a serialized object.
  54295. * @param source - Serialized object.
  54296. * @param scene - BJS scene instance.
  54297. * @param rootUrl - url for the scene object
  54298. * @returns - PBRMaterial
  54299. */
  54300. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54301. }
  54302. }
  54303. declare module "babylonjs/Misc/dds" {
  54304. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54305. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54306. import { Nullable } from "babylonjs/types";
  54307. import { Scene } from "babylonjs/scene";
  54308. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54309. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54310. /**
  54311. * Direct draw surface info
  54312. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54313. */
  54314. export interface DDSInfo {
  54315. /**
  54316. * Width of the texture
  54317. */
  54318. width: number;
  54319. /**
  54320. * Width of the texture
  54321. */
  54322. height: number;
  54323. /**
  54324. * Number of Mipmaps for the texture
  54325. * @see https://en.wikipedia.org/wiki/Mipmap
  54326. */
  54327. mipmapCount: number;
  54328. /**
  54329. * If the textures format is a known fourCC format
  54330. * @see https://www.fourcc.org/
  54331. */
  54332. isFourCC: boolean;
  54333. /**
  54334. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54335. */
  54336. isRGB: boolean;
  54337. /**
  54338. * If the texture is a lumincance format
  54339. */
  54340. isLuminance: boolean;
  54341. /**
  54342. * If this is a cube texture
  54343. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54344. */
  54345. isCube: boolean;
  54346. /**
  54347. * If the texture is a compressed format eg. FOURCC_DXT1
  54348. */
  54349. isCompressed: boolean;
  54350. /**
  54351. * The dxgiFormat of the texture
  54352. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54353. */
  54354. dxgiFormat: number;
  54355. /**
  54356. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54357. */
  54358. textureType: number;
  54359. /**
  54360. * Sphericle polynomial created for the dds texture
  54361. */
  54362. sphericalPolynomial?: SphericalPolynomial;
  54363. }
  54364. /**
  54365. * Class used to provide DDS decompression tools
  54366. */
  54367. export class DDSTools {
  54368. /**
  54369. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54370. */
  54371. static StoreLODInAlphaChannel: boolean;
  54372. /**
  54373. * Gets DDS information from an array buffer
  54374. * @param arrayBuffer defines the array buffer to read data from
  54375. * @returns the DDS information
  54376. */
  54377. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  54378. private static _FloatView;
  54379. private static _Int32View;
  54380. private static _ToHalfFloat;
  54381. private static _FromHalfFloat;
  54382. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54383. private static _GetHalfFloatRGBAArrayBuffer;
  54384. private static _GetFloatRGBAArrayBuffer;
  54385. private static _GetFloatAsUIntRGBAArrayBuffer;
  54386. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54387. private static _GetRGBAArrayBuffer;
  54388. private static _ExtractLongWordOrder;
  54389. private static _GetRGBArrayBuffer;
  54390. private static _GetLuminanceArrayBuffer;
  54391. /**
  54392. * Uploads DDS Levels to a Babylon Texture
  54393. * @hidden
  54394. */
  54395. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54396. }
  54397. module "babylonjs/Engines/thinEngine" {
  54398. interface ThinEngine {
  54399. /**
  54400. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54401. * @param rootUrl defines the url where the file to load is located
  54402. * @param scene defines the current scene
  54403. * @param lodScale defines scale to apply to the mip map selection
  54404. * @param lodOffset defines offset to apply to the mip map selection
  54405. * @param onLoad defines an optional callback raised when the texture is loaded
  54406. * @param onError defines an optional callback raised if there is an issue to load the texture
  54407. * @param format defines the format of the data
  54408. * @param forcedExtension defines the extension to use to pick the right loader
  54409. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54410. * @returns the cube texture as an InternalTexture
  54411. */
  54412. 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;
  54413. }
  54414. }
  54415. }
  54416. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54417. import { Nullable } from "babylonjs/types";
  54418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54419. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54420. /**
  54421. * Implementation of the DDS Texture Loader.
  54422. * @hidden
  54423. */
  54424. export class _DDSTextureLoader implements IInternalTextureLoader {
  54425. /**
  54426. * Defines wether the loader supports cascade loading the different faces.
  54427. */
  54428. readonly supportCascades: boolean;
  54429. /**
  54430. * This returns if the loader support the current file information.
  54431. * @param extension defines the file extension of the file being loaded
  54432. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54433. * @param fallback defines the fallback internal texture if any
  54434. * @param isBase64 defines whether the texture is encoded as a base64
  54435. * @param isBuffer defines whether the texture data are stored as a buffer
  54436. * @returns true if the loader can load the specified file
  54437. */
  54438. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54439. /**
  54440. * Transform the url before loading if required.
  54441. * @param rootUrl the url of the texture
  54442. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54443. * @returns the transformed texture
  54444. */
  54445. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54446. /**
  54447. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54448. * @param rootUrl the url of the texture
  54449. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54450. * @returns the fallback texture
  54451. */
  54452. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54453. /**
  54454. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54455. * @param data contains the texture data
  54456. * @param texture defines the BabylonJS internal texture
  54457. * @param createPolynomials will be true if polynomials have been requested
  54458. * @param onLoad defines the callback to trigger once the texture is ready
  54459. * @param onError defines the callback to trigger in case of error
  54460. */
  54461. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54462. /**
  54463. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54464. * @param data contains the texture data
  54465. * @param texture defines the BabylonJS internal texture
  54466. * @param callback defines the method to call once ready to upload
  54467. */
  54468. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54469. }
  54470. }
  54471. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54472. import { Nullable } from "babylonjs/types";
  54473. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54475. /**
  54476. * Implementation of the ENV Texture Loader.
  54477. * @hidden
  54478. */
  54479. export class _ENVTextureLoader implements IInternalTextureLoader {
  54480. /**
  54481. * Defines wether the loader supports cascade loading the different faces.
  54482. */
  54483. readonly supportCascades: boolean;
  54484. /**
  54485. * This returns if the loader support the current file information.
  54486. * @param extension defines the file extension of the file being loaded
  54487. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54488. * @param fallback defines the fallback internal texture if any
  54489. * @param isBase64 defines whether the texture is encoded as a base64
  54490. * @param isBuffer defines whether the texture data are stored as a buffer
  54491. * @returns true if the loader can load the specified file
  54492. */
  54493. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54494. /**
  54495. * Transform the url before loading if required.
  54496. * @param rootUrl the url of the texture
  54497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54498. * @returns the transformed texture
  54499. */
  54500. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54501. /**
  54502. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54503. * @param rootUrl the url of the texture
  54504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54505. * @returns the fallback texture
  54506. */
  54507. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54508. /**
  54509. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54510. * @param data contains the texture data
  54511. * @param texture defines the BabylonJS internal texture
  54512. * @param createPolynomials will be true if polynomials have been requested
  54513. * @param onLoad defines the callback to trigger once the texture is ready
  54514. * @param onError defines the callback to trigger in case of error
  54515. */
  54516. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54517. /**
  54518. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54519. * @param data contains the texture data
  54520. * @param texture defines the BabylonJS internal texture
  54521. * @param callback defines the method to call once ready to upload
  54522. */
  54523. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54524. }
  54525. }
  54526. declare module "babylonjs/Misc/khronosTextureContainer" {
  54527. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54528. /**
  54529. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54530. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54531. */
  54532. export class KhronosTextureContainer {
  54533. /** contents of the KTX container file */
  54534. arrayBuffer: any;
  54535. private static HEADER_LEN;
  54536. private static COMPRESSED_2D;
  54537. private static COMPRESSED_3D;
  54538. private static TEX_2D;
  54539. private static TEX_3D;
  54540. /**
  54541. * Gets the openGL type
  54542. */
  54543. glType: number;
  54544. /**
  54545. * Gets the openGL type size
  54546. */
  54547. glTypeSize: number;
  54548. /**
  54549. * Gets the openGL format
  54550. */
  54551. glFormat: number;
  54552. /**
  54553. * Gets the openGL internal format
  54554. */
  54555. glInternalFormat: number;
  54556. /**
  54557. * Gets the base internal format
  54558. */
  54559. glBaseInternalFormat: number;
  54560. /**
  54561. * Gets image width in pixel
  54562. */
  54563. pixelWidth: number;
  54564. /**
  54565. * Gets image height in pixel
  54566. */
  54567. pixelHeight: number;
  54568. /**
  54569. * Gets image depth in pixels
  54570. */
  54571. pixelDepth: number;
  54572. /**
  54573. * Gets the number of array elements
  54574. */
  54575. numberOfArrayElements: number;
  54576. /**
  54577. * Gets the number of faces
  54578. */
  54579. numberOfFaces: number;
  54580. /**
  54581. * Gets the number of mipmap levels
  54582. */
  54583. numberOfMipmapLevels: number;
  54584. /**
  54585. * Gets the bytes of key value data
  54586. */
  54587. bytesOfKeyValueData: number;
  54588. /**
  54589. * Gets the load type
  54590. */
  54591. loadType: number;
  54592. /**
  54593. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54594. */
  54595. isInvalid: boolean;
  54596. /**
  54597. * Creates a new KhronosTextureContainer
  54598. * @param arrayBuffer contents of the KTX container file
  54599. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54600. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54601. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54602. */
  54603. constructor(
  54604. /** contents of the KTX container file */
  54605. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54606. /**
  54607. * Uploads KTX content to a Babylon Texture.
  54608. * It is assumed that the texture has already been created & is currently bound
  54609. * @hidden
  54610. */
  54611. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54612. private _upload2DCompressedLevels;
  54613. }
  54614. }
  54615. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54616. import { Nullable } from "babylonjs/types";
  54617. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54618. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54619. /**
  54620. * Implementation of the KTX Texture Loader.
  54621. * @hidden
  54622. */
  54623. export class _KTXTextureLoader implements IInternalTextureLoader {
  54624. /**
  54625. * Defines wether the loader supports cascade loading the different faces.
  54626. */
  54627. readonly supportCascades: boolean;
  54628. /**
  54629. * This returns if the loader support the current file information.
  54630. * @param extension defines the file extension of the file being loaded
  54631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54632. * @param fallback defines the fallback internal texture if any
  54633. * @param isBase64 defines whether the texture is encoded as a base64
  54634. * @param isBuffer defines whether the texture data are stored as a buffer
  54635. * @returns true if the loader can load the specified file
  54636. */
  54637. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54638. /**
  54639. * Transform the url before loading if required.
  54640. * @param rootUrl the url of the texture
  54641. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54642. * @returns the transformed texture
  54643. */
  54644. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54645. /**
  54646. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54647. * @param rootUrl the url of the texture
  54648. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54649. * @returns the fallback texture
  54650. */
  54651. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54652. /**
  54653. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54654. * @param data contains the texture data
  54655. * @param texture defines the BabylonJS internal texture
  54656. * @param createPolynomials will be true if polynomials have been requested
  54657. * @param onLoad defines the callback to trigger once the texture is ready
  54658. * @param onError defines the callback to trigger in case of error
  54659. */
  54660. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54661. /**
  54662. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54663. * @param data contains the texture data
  54664. * @param texture defines the BabylonJS internal texture
  54665. * @param callback defines the method to call once ready to upload
  54666. */
  54667. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54668. }
  54669. }
  54670. declare module "babylonjs/Helpers/sceneHelpers" {
  54671. import { Nullable } from "babylonjs/types";
  54672. import { Mesh } from "babylonjs/Meshes/mesh";
  54673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54674. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54675. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54676. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54677. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54678. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54679. import "babylonjs/Meshes/Builders/boxBuilder";
  54680. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  54681. /** @hidden */
  54682. export var _forceSceneHelpersToBundle: boolean;
  54683. module "babylonjs/scene" {
  54684. interface Scene {
  54685. /**
  54686. * Creates a default light for the scene.
  54687. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54688. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54689. */
  54690. createDefaultLight(replace?: boolean): void;
  54691. /**
  54692. * Creates a default camera for the scene.
  54693. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54694. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54695. * @param replace has default false, when true replaces the active camera in the scene
  54696. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54697. */
  54698. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54699. /**
  54700. * Creates a default camera and a default light.
  54701. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54702. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54703. * @param replace has the default false, when true replaces the active camera/light in the scene
  54704. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54705. */
  54706. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54707. /**
  54708. * Creates a new sky box
  54709. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54710. * @param environmentTexture defines the texture to use as environment texture
  54711. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54712. * @param scale defines the overall scale of the skybox
  54713. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54714. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54715. * @returns a new mesh holding the sky box
  54716. */
  54717. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54718. /**
  54719. * Creates a new environment
  54720. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54721. * @param options defines the options you can use to configure the environment
  54722. * @returns the new EnvironmentHelper
  54723. */
  54724. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54725. /**
  54726. * Creates a new VREXperienceHelper
  54727. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54728. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54729. * @returns a new VREXperienceHelper
  54730. */
  54731. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54732. /**
  54733. * Creates a new WebXRDefaultExperience
  54734. * @see http://doc.babylonjs.com/how_to/webxr
  54735. * @param options experience options
  54736. * @returns a promise for a new WebXRDefaultExperience
  54737. */
  54738. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54739. }
  54740. }
  54741. }
  54742. declare module "babylonjs/Helpers/videoDome" {
  54743. import { Scene } from "babylonjs/scene";
  54744. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54745. import { Mesh } from "babylonjs/Meshes/mesh";
  54746. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54747. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54748. import "babylonjs/Meshes/Builders/sphereBuilder";
  54749. /**
  54750. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54751. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54752. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54753. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54754. */
  54755. export class VideoDome extends TransformNode {
  54756. /**
  54757. * Define the video source as a Monoscopic panoramic 360 video.
  54758. */
  54759. static readonly MODE_MONOSCOPIC: number;
  54760. /**
  54761. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54762. */
  54763. static readonly MODE_TOPBOTTOM: number;
  54764. /**
  54765. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54766. */
  54767. static readonly MODE_SIDEBYSIDE: number;
  54768. private _halfDome;
  54769. private _useDirectMapping;
  54770. /**
  54771. * The video texture being displayed on the sphere
  54772. */
  54773. protected _videoTexture: VideoTexture;
  54774. /**
  54775. * Gets the video texture being displayed on the sphere
  54776. */
  54777. get videoTexture(): VideoTexture;
  54778. /**
  54779. * The skybox material
  54780. */
  54781. protected _material: BackgroundMaterial;
  54782. /**
  54783. * The surface used for the skybox
  54784. */
  54785. protected _mesh: Mesh;
  54786. /**
  54787. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54788. */
  54789. private _halfDomeMask;
  54790. /**
  54791. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54792. * Also see the options.resolution property.
  54793. */
  54794. get fovMultiplier(): number;
  54795. set fovMultiplier(value: number);
  54796. private _videoMode;
  54797. /**
  54798. * Gets or set the current video mode for the video. It can be:
  54799. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54800. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54801. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54802. */
  54803. get videoMode(): number;
  54804. set videoMode(value: number);
  54805. /**
  54806. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54807. *
  54808. */
  54809. get halfDome(): boolean;
  54810. /**
  54811. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54812. */
  54813. set halfDome(enabled: boolean);
  54814. /**
  54815. * Oberserver used in Stereoscopic VR Mode.
  54816. */
  54817. private _onBeforeCameraRenderObserver;
  54818. /**
  54819. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54820. * @param name Element's name, child elements will append suffixes for their own names.
  54821. * @param urlsOrVideo defines the url(s) or the video element to use
  54822. * @param options An object containing optional or exposed sub element properties
  54823. */
  54824. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54825. resolution?: number;
  54826. clickToPlay?: boolean;
  54827. autoPlay?: boolean;
  54828. loop?: boolean;
  54829. size?: number;
  54830. poster?: string;
  54831. faceForward?: boolean;
  54832. useDirectMapping?: boolean;
  54833. halfDomeMode?: boolean;
  54834. }, scene: Scene);
  54835. private _changeVideoMode;
  54836. /**
  54837. * Releases resources associated with this node.
  54838. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54839. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54840. */
  54841. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54842. }
  54843. }
  54844. declare module "babylonjs/Helpers/index" {
  54845. export * from "babylonjs/Helpers/environmentHelper";
  54846. export * from "babylonjs/Helpers/photoDome";
  54847. export * from "babylonjs/Helpers/sceneHelpers";
  54848. export * from "babylonjs/Helpers/videoDome";
  54849. }
  54850. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54851. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54852. import { IDisposable } from "babylonjs/scene";
  54853. import { Engine } from "babylonjs/Engines/engine";
  54854. /**
  54855. * This class can be used to get instrumentation data from a Babylon engine
  54856. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54857. */
  54858. export class EngineInstrumentation implements IDisposable {
  54859. /**
  54860. * Define the instrumented engine.
  54861. */
  54862. engine: Engine;
  54863. private _captureGPUFrameTime;
  54864. private _gpuFrameTimeToken;
  54865. private _gpuFrameTime;
  54866. private _captureShaderCompilationTime;
  54867. private _shaderCompilationTime;
  54868. private _onBeginFrameObserver;
  54869. private _onEndFrameObserver;
  54870. private _onBeforeShaderCompilationObserver;
  54871. private _onAfterShaderCompilationObserver;
  54872. /**
  54873. * Gets the perf counter used for GPU frame time
  54874. */
  54875. get gpuFrameTimeCounter(): PerfCounter;
  54876. /**
  54877. * Gets the GPU frame time capture status
  54878. */
  54879. get captureGPUFrameTime(): boolean;
  54880. /**
  54881. * Enable or disable the GPU frame time capture
  54882. */
  54883. set captureGPUFrameTime(value: boolean);
  54884. /**
  54885. * Gets the perf counter used for shader compilation time
  54886. */
  54887. get shaderCompilationTimeCounter(): PerfCounter;
  54888. /**
  54889. * Gets the shader compilation time capture status
  54890. */
  54891. get captureShaderCompilationTime(): boolean;
  54892. /**
  54893. * Enable or disable the shader compilation time capture
  54894. */
  54895. set captureShaderCompilationTime(value: boolean);
  54896. /**
  54897. * Instantiates a new engine instrumentation.
  54898. * This class can be used to get instrumentation data from a Babylon engine
  54899. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54900. * @param engine Defines the engine to instrument
  54901. */
  54902. constructor(
  54903. /**
  54904. * Define the instrumented engine.
  54905. */
  54906. engine: Engine);
  54907. /**
  54908. * Dispose and release associated resources.
  54909. */
  54910. dispose(): void;
  54911. }
  54912. }
  54913. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54914. import { Scene, IDisposable } from "babylonjs/scene";
  54915. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54916. /**
  54917. * This class can be used to get instrumentation data from a Babylon engine
  54918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54919. */
  54920. export class SceneInstrumentation implements IDisposable {
  54921. /**
  54922. * Defines the scene to instrument
  54923. */
  54924. scene: Scene;
  54925. private _captureActiveMeshesEvaluationTime;
  54926. private _activeMeshesEvaluationTime;
  54927. private _captureRenderTargetsRenderTime;
  54928. private _renderTargetsRenderTime;
  54929. private _captureFrameTime;
  54930. private _frameTime;
  54931. private _captureRenderTime;
  54932. private _renderTime;
  54933. private _captureInterFrameTime;
  54934. private _interFrameTime;
  54935. private _captureParticlesRenderTime;
  54936. private _particlesRenderTime;
  54937. private _captureSpritesRenderTime;
  54938. private _spritesRenderTime;
  54939. private _capturePhysicsTime;
  54940. private _physicsTime;
  54941. private _captureAnimationsTime;
  54942. private _animationsTime;
  54943. private _captureCameraRenderTime;
  54944. private _cameraRenderTime;
  54945. private _onBeforeActiveMeshesEvaluationObserver;
  54946. private _onAfterActiveMeshesEvaluationObserver;
  54947. private _onBeforeRenderTargetsRenderObserver;
  54948. private _onAfterRenderTargetsRenderObserver;
  54949. private _onAfterRenderObserver;
  54950. private _onBeforeDrawPhaseObserver;
  54951. private _onAfterDrawPhaseObserver;
  54952. private _onBeforeAnimationsObserver;
  54953. private _onBeforeParticlesRenderingObserver;
  54954. private _onAfterParticlesRenderingObserver;
  54955. private _onBeforeSpritesRenderingObserver;
  54956. private _onAfterSpritesRenderingObserver;
  54957. private _onBeforePhysicsObserver;
  54958. private _onAfterPhysicsObserver;
  54959. private _onAfterAnimationsObserver;
  54960. private _onBeforeCameraRenderObserver;
  54961. private _onAfterCameraRenderObserver;
  54962. /**
  54963. * Gets the perf counter used for active meshes evaluation time
  54964. */
  54965. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54966. /**
  54967. * Gets the active meshes evaluation time capture status
  54968. */
  54969. get captureActiveMeshesEvaluationTime(): boolean;
  54970. /**
  54971. * Enable or disable the active meshes evaluation time capture
  54972. */
  54973. set captureActiveMeshesEvaluationTime(value: boolean);
  54974. /**
  54975. * Gets the perf counter used for render targets render time
  54976. */
  54977. get renderTargetsRenderTimeCounter(): PerfCounter;
  54978. /**
  54979. * Gets the render targets render time capture status
  54980. */
  54981. get captureRenderTargetsRenderTime(): boolean;
  54982. /**
  54983. * Enable or disable the render targets render time capture
  54984. */
  54985. set captureRenderTargetsRenderTime(value: boolean);
  54986. /**
  54987. * Gets the perf counter used for particles render time
  54988. */
  54989. get particlesRenderTimeCounter(): PerfCounter;
  54990. /**
  54991. * Gets the particles render time capture status
  54992. */
  54993. get captureParticlesRenderTime(): boolean;
  54994. /**
  54995. * Enable or disable the particles render time capture
  54996. */
  54997. set captureParticlesRenderTime(value: boolean);
  54998. /**
  54999. * Gets the perf counter used for sprites render time
  55000. */
  55001. get spritesRenderTimeCounter(): PerfCounter;
  55002. /**
  55003. * Gets the sprites render time capture status
  55004. */
  55005. get captureSpritesRenderTime(): boolean;
  55006. /**
  55007. * Enable or disable the sprites render time capture
  55008. */
  55009. set captureSpritesRenderTime(value: boolean);
  55010. /**
  55011. * Gets the perf counter used for physics time
  55012. */
  55013. get physicsTimeCounter(): PerfCounter;
  55014. /**
  55015. * Gets the physics time capture status
  55016. */
  55017. get capturePhysicsTime(): boolean;
  55018. /**
  55019. * Enable or disable the physics time capture
  55020. */
  55021. set capturePhysicsTime(value: boolean);
  55022. /**
  55023. * Gets the perf counter used for animations time
  55024. */
  55025. get animationsTimeCounter(): PerfCounter;
  55026. /**
  55027. * Gets the animations time capture status
  55028. */
  55029. get captureAnimationsTime(): boolean;
  55030. /**
  55031. * Enable or disable the animations time capture
  55032. */
  55033. set captureAnimationsTime(value: boolean);
  55034. /**
  55035. * Gets the perf counter used for frame time capture
  55036. */
  55037. get frameTimeCounter(): PerfCounter;
  55038. /**
  55039. * Gets the frame time capture status
  55040. */
  55041. get captureFrameTime(): boolean;
  55042. /**
  55043. * Enable or disable the frame time capture
  55044. */
  55045. set captureFrameTime(value: boolean);
  55046. /**
  55047. * Gets the perf counter used for inter-frames time capture
  55048. */
  55049. get interFrameTimeCounter(): PerfCounter;
  55050. /**
  55051. * Gets the inter-frames time capture status
  55052. */
  55053. get captureInterFrameTime(): boolean;
  55054. /**
  55055. * Enable or disable the inter-frames time capture
  55056. */
  55057. set captureInterFrameTime(value: boolean);
  55058. /**
  55059. * Gets the perf counter used for render time capture
  55060. */
  55061. get renderTimeCounter(): PerfCounter;
  55062. /**
  55063. * Gets the render time capture status
  55064. */
  55065. get captureRenderTime(): boolean;
  55066. /**
  55067. * Enable or disable the render time capture
  55068. */
  55069. set captureRenderTime(value: boolean);
  55070. /**
  55071. * Gets the perf counter used for camera render time capture
  55072. */
  55073. get cameraRenderTimeCounter(): PerfCounter;
  55074. /**
  55075. * Gets the camera render time capture status
  55076. */
  55077. get captureCameraRenderTime(): boolean;
  55078. /**
  55079. * Enable or disable the camera render time capture
  55080. */
  55081. set captureCameraRenderTime(value: boolean);
  55082. /**
  55083. * Gets the perf counter used for draw calls
  55084. */
  55085. get drawCallsCounter(): PerfCounter;
  55086. /**
  55087. * Instantiates a new scene instrumentation.
  55088. * This class can be used to get instrumentation data from a Babylon engine
  55089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55090. * @param scene Defines the scene to instrument
  55091. */
  55092. constructor(
  55093. /**
  55094. * Defines the scene to instrument
  55095. */
  55096. scene: Scene);
  55097. /**
  55098. * Dispose and release associated resources.
  55099. */
  55100. dispose(): void;
  55101. }
  55102. }
  55103. declare module "babylonjs/Instrumentation/index" {
  55104. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55105. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55106. export * from "babylonjs/Instrumentation/timeToken";
  55107. }
  55108. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55109. /** @hidden */
  55110. export var glowMapGenerationPixelShader: {
  55111. name: string;
  55112. shader: string;
  55113. };
  55114. }
  55115. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55116. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55117. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55118. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55119. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55121. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55122. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55123. /** @hidden */
  55124. export var glowMapGenerationVertexShader: {
  55125. name: string;
  55126. shader: string;
  55127. };
  55128. }
  55129. declare module "babylonjs/Layers/effectLayer" {
  55130. import { Observable } from "babylonjs/Misc/observable";
  55131. import { Nullable } from "babylonjs/types";
  55132. import { Camera } from "babylonjs/Cameras/camera";
  55133. import { Scene } from "babylonjs/scene";
  55134. import { ISize } from "babylonjs/Maths/math.size";
  55135. import { Color4 } from "babylonjs/Maths/math.color";
  55136. import { Engine } from "babylonjs/Engines/engine";
  55137. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55139. import { Mesh } from "babylonjs/Meshes/mesh";
  55140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55142. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55143. import { Effect } from "babylonjs/Materials/effect";
  55144. import { Material } from "babylonjs/Materials/material";
  55145. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55146. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55147. /**
  55148. * Effect layer options. This helps customizing the behaviour
  55149. * of the effect layer.
  55150. */
  55151. export interface IEffectLayerOptions {
  55152. /**
  55153. * Multiplication factor apply to the canvas size to compute the render target size
  55154. * used to generated the objects (the smaller the faster).
  55155. */
  55156. mainTextureRatio: number;
  55157. /**
  55158. * Enforces a fixed size texture to ensure effect stability across devices.
  55159. */
  55160. mainTextureFixedSize?: number;
  55161. /**
  55162. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55163. */
  55164. alphaBlendingMode: number;
  55165. /**
  55166. * The camera attached to the layer.
  55167. */
  55168. camera: Nullable<Camera>;
  55169. /**
  55170. * The rendering group to draw the layer in.
  55171. */
  55172. renderingGroupId: number;
  55173. }
  55174. /**
  55175. * The effect layer Helps adding post process effect blended with the main pass.
  55176. *
  55177. * This can be for instance use to generate glow or higlight effects on the scene.
  55178. *
  55179. * The effect layer class can not be used directly and is intented to inherited from to be
  55180. * customized per effects.
  55181. */
  55182. export abstract class EffectLayer {
  55183. private _vertexBuffers;
  55184. private _indexBuffer;
  55185. private _cachedDefines;
  55186. private _effectLayerMapGenerationEffect;
  55187. private _effectLayerOptions;
  55188. private _mergeEffect;
  55189. protected _scene: Scene;
  55190. protected _engine: Engine;
  55191. protected _maxSize: number;
  55192. protected _mainTextureDesiredSize: ISize;
  55193. protected _mainTexture: RenderTargetTexture;
  55194. protected _shouldRender: boolean;
  55195. protected _postProcesses: PostProcess[];
  55196. protected _textures: BaseTexture[];
  55197. protected _emissiveTextureAndColor: {
  55198. texture: Nullable<BaseTexture>;
  55199. color: Color4;
  55200. };
  55201. /**
  55202. * The name of the layer
  55203. */
  55204. name: string;
  55205. /**
  55206. * The clear color of the texture used to generate the glow map.
  55207. */
  55208. neutralColor: Color4;
  55209. /**
  55210. * Specifies wether the highlight layer is enabled or not.
  55211. */
  55212. isEnabled: boolean;
  55213. /**
  55214. * Gets the camera attached to the layer.
  55215. */
  55216. get camera(): Nullable<Camera>;
  55217. /**
  55218. * Gets the rendering group id the layer should render in.
  55219. */
  55220. get renderingGroupId(): number;
  55221. set renderingGroupId(renderingGroupId: number);
  55222. /**
  55223. * An event triggered when the effect layer has been disposed.
  55224. */
  55225. onDisposeObservable: Observable<EffectLayer>;
  55226. /**
  55227. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55228. */
  55229. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55230. /**
  55231. * An event triggered when the generated texture is being merged in the scene.
  55232. */
  55233. onBeforeComposeObservable: Observable<EffectLayer>;
  55234. /**
  55235. * An event triggered when the mesh is rendered into the effect render target.
  55236. */
  55237. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55238. /**
  55239. * An event triggered after the mesh has been rendered into the effect render target.
  55240. */
  55241. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55242. /**
  55243. * An event triggered when the generated texture has been merged in the scene.
  55244. */
  55245. onAfterComposeObservable: Observable<EffectLayer>;
  55246. /**
  55247. * An event triggered when the efffect layer changes its size.
  55248. */
  55249. onSizeChangedObservable: Observable<EffectLayer>;
  55250. /** @hidden */
  55251. static _SceneComponentInitialization: (scene: Scene) => void;
  55252. /**
  55253. * Instantiates a new effect Layer and references it in the scene.
  55254. * @param name The name of the layer
  55255. * @param scene The scene to use the layer in
  55256. */
  55257. constructor(
  55258. /** The Friendly of the effect in the scene */
  55259. name: string, scene: Scene);
  55260. /**
  55261. * Get the effect name of the layer.
  55262. * @return The effect name
  55263. */
  55264. abstract getEffectName(): string;
  55265. /**
  55266. * Checks for the readiness of the element composing the layer.
  55267. * @param subMesh the mesh to check for
  55268. * @param useInstances specify wether or not to use instances to render the mesh
  55269. * @return true if ready otherwise, false
  55270. */
  55271. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55272. /**
  55273. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55274. * @returns true if the effect requires stencil during the main canvas render pass.
  55275. */
  55276. abstract needStencil(): boolean;
  55277. /**
  55278. * Create the merge effect. This is the shader use to blit the information back
  55279. * to the main canvas at the end of the scene rendering.
  55280. * @returns The effect containing the shader used to merge the effect on the main canvas
  55281. */
  55282. protected abstract _createMergeEffect(): Effect;
  55283. /**
  55284. * Creates the render target textures and post processes used in the effect layer.
  55285. */
  55286. protected abstract _createTextureAndPostProcesses(): void;
  55287. /**
  55288. * Implementation specific of rendering the generating effect on the main canvas.
  55289. * @param effect The effect used to render through
  55290. */
  55291. protected abstract _internalRender(effect: Effect): void;
  55292. /**
  55293. * Sets the required values for both the emissive texture and and the main color.
  55294. */
  55295. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55296. /**
  55297. * Free any resources and references associated to a mesh.
  55298. * Internal use
  55299. * @param mesh The mesh to free.
  55300. */
  55301. abstract _disposeMesh(mesh: Mesh): void;
  55302. /**
  55303. * Serializes this layer (Glow or Highlight for example)
  55304. * @returns a serialized layer object
  55305. */
  55306. abstract serialize?(): any;
  55307. /**
  55308. * Initializes the effect layer with the required options.
  55309. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55310. */
  55311. protected _init(options: Partial<IEffectLayerOptions>): void;
  55312. /**
  55313. * Generates the index buffer of the full screen quad blending to the main canvas.
  55314. */
  55315. private _generateIndexBuffer;
  55316. /**
  55317. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55318. */
  55319. private _generateVertexBuffer;
  55320. /**
  55321. * Sets the main texture desired size which is the closest power of two
  55322. * of the engine canvas size.
  55323. */
  55324. private _setMainTextureSize;
  55325. /**
  55326. * Creates the main texture for the effect layer.
  55327. */
  55328. protected _createMainTexture(): void;
  55329. /**
  55330. * Adds specific effects defines.
  55331. * @param defines The defines to add specifics to.
  55332. */
  55333. protected _addCustomEffectDefines(defines: string[]): void;
  55334. /**
  55335. * Checks for the readiness of the element composing the layer.
  55336. * @param subMesh the mesh to check for
  55337. * @param useInstances specify wether or not to use instances to render the mesh
  55338. * @param emissiveTexture the associated emissive texture used to generate the glow
  55339. * @return true if ready otherwise, false
  55340. */
  55341. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55342. /**
  55343. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55344. */
  55345. render(): void;
  55346. /**
  55347. * Determine if a given mesh will be used in the current effect.
  55348. * @param mesh mesh to test
  55349. * @returns true if the mesh will be used
  55350. */
  55351. hasMesh(mesh: AbstractMesh): boolean;
  55352. /**
  55353. * Returns true if the layer contains information to display, otherwise false.
  55354. * @returns true if the glow layer should be rendered
  55355. */
  55356. shouldRender(): boolean;
  55357. /**
  55358. * Returns true if the mesh should render, otherwise false.
  55359. * @param mesh The mesh to render
  55360. * @returns true if it should render otherwise false
  55361. */
  55362. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55363. /**
  55364. * Returns true if the mesh can be rendered, otherwise false.
  55365. * @param mesh The mesh to render
  55366. * @param material The material used on the mesh
  55367. * @returns true if it can be rendered otherwise false
  55368. */
  55369. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55370. /**
  55371. * Returns true if the mesh should render, otherwise false.
  55372. * @param mesh The mesh to render
  55373. * @returns true if it should render otherwise false
  55374. */
  55375. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55376. /**
  55377. * Renders the submesh passed in parameter to the generation map.
  55378. */
  55379. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55380. /**
  55381. * Defines wether the current material of the mesh should be use to render the effect.
  55382. * @param mesh defines the current mesh to render
  55383. */
  55384. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55385. /**
  55386. * Rebuild the required buffers.
  55387. * @hidden Internal use only.
  55388. */
  55389. _rebuild(): void;
  55390. /**
  55391. * Dispose only the render target textures and post process.
  55392. */
  55393. private _disposeTextureAndPostProcesses;
  55394. /**
  55395. * Dispose the highlight layer and free resources.
  55396. */
  55397. dispose(): void;
  55398. /**
  55399. * Gets the class name of the effect layer
  55400. * @returns the string with the class name of the effect layer
  55401. */
  55402. getClassName(): string;
  55403. /**
  55404. * Creates an effect layer from parsed effect layer data
  55405. * @param parsedEffectLayer defines effect layer data
  55406. * @param scene defines the current scene
  55407. * @param rootUrl defines the root URL containing the effect layer information
  55408. * @returns a parsed effect Layer
  55409. */
  55410. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55411. }
  55412. }
  55413. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55414. import { Scene } from "babylonjs/scene";
  55415. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55416. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55417. import { AbstractScene } from "babylonjs/abstractScene";
  55418. module "babylonjs/abstractScene" {
  55419. interface AbstractScene {
  55420. /**
  55421. * The list of effect layers (highlights/glow) added to the scene
  55422. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55423. * @see http://doc.babylonjs.com/how_to/glow_layer
  55424. */
  55425. effectLayers: Array<EffectLayer>;
  55426. /**
  55427. * Removes the given effect layer from this scene.
  55428. * @param toRemove defines the effect layer to remove
  55429. * @returns the index of the removed effect layer
  55430. */
  55431. removeEffectLayer(toRemove: EffectLayer): number;
  55432. /**
  55433. * Adds the given effect layer to this scene
  55434. * @param newEffectLayer defines the effect layer to add
  55435. */
  55436. addEffectLayer(newEffectLayer: EffectLayer): void;
  55437. }
  55438. }
  55439. /**
  55440. * Defines the layer scene component responsible to manage any effect layers
  55441. * in a given scene.
  55442. */
  55443. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55444. /**
  55445. * The component name helpfull to identify the component in the list of scene components.
  55446. */
  55447. readonly name: string;
  55448. /**
  55449. * The scene the component belongs to.
  55450. */
  55451. scene: Scene;
  55452. private _engine;
  55453. private _renderEffects;
  55454. private _needStencil;
  55455. private _previousStencilState;
  55456. /**
  55457. * Creates a new instance of the component for the given scene
  55458. * @param scene Defines the scene to register the component in
  55459. */
  55460. constructor(scene: Scene);
  55461. /**
  55462. * Registers the component in a given scene
  55463. */
  55464. register(): void;
  55465. /**
  55466. * Rebuilds the elements related to this component in case of
  55467. * context lost for instance.
  55468. */
  55469. rebuild(): void;
  55470. /**
  55471. * Serializes the component data to the specified json object
  55472. * @param serializationObject The object to serialize to
  55473. */
  55474. serialize(serializationObject: any): void;
  55475. /**
  55476. * Adds all the elements from the container to the scene
  55477. * @param container the container holding the elements
  55478. */
  55479. addFromContainer(container: AbstractScene): void;
  55480. /**
  55481. * Removes all the elements in the container from the scene
  55482. * @param container contains the elements to remove
  55483. * @param dispose if the removed element should be disposed (default: false)
  55484. */
  55485. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55486. /**
  55487. * Disposes the component and the associated ressources.
  55488. */
  55489. dispose(): void;
  55490. private _isReadyForMesh;
  55491. private _renderMainTexture;
  55492. private _setStencil;
  55493. private _setStencilBack;
  55494. private _draw;
  55495. private _drawCamera;
  55496. private _drawRenderingGroup;
  55497. }
  55498. }
  55499. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55500. /** @hidden */
  55501. export var glowMapMergePixelShader: {
  55502. name: string;
  55503. shader: string;
  55504. };
  55505. }
  55506. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55507. /** @hidden */
  55508. export var glowMapMergeVertexShader: {
  55509. name: string;
  55510. shader: string;
  55511. };
  55512. }
  55513. declare module "babylonjs/Layers/glowLayer" {
  55514. import { Nullable } from "babylonjs/types";
  55515. import { Camera } from "babylonjs/Cameras/camera";
  55516. import { Scene } from "babylonjs/scene";
  55517. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55519. import { Mesh } from "babylonjs/Meshes/mesh";
  55520. import { Texture } from "babylonjs/Materials/Textures/texture";
  55521. import { Effect } from "babylonjs/Materials/effect";
  55522. import { Material } from "babylonjs/Materials/material";
  55523. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55524. import { Color4 } from "babylonjs/Maths/math.color";
  55525. import "babylonjs/Shaders/glowMapMerge.fragment";
  55526. import "babylonjs/Shaders/glowMapMerge.vertex";
  55527. import "babylonjs/Layers/effectLayerSceneComponent";
  55528. module "babylonjs/abstractScene" {
  55529. interface AbstractScene {
  55530. /**
  55531. * Return a the first highlight layer of the scene with a given name.
  55532. * @param name The name of the highlight layer to look for.
  55533. * @return The highlight layer if found otherwise null.
  55534. */
  55535. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55536. }
  55537. }
  55538. /**
  55539. * Glow layer options. This helps customizing the behaviour
  55540. * of the glow layer.
  55541. */
  55542. export interface IGlowLayerOptions {
  55543. /**
  55544. * Multiplication factor apply to the canvas size to compute the render target size
  55545. * used to generated the glowing objects (the smaller the faster).
  55546. */
  55547. mainTextureRatio: number;
  55548. /**
  55549. * Enforces a fixed size texture to ensure resize independant blur.
  55550. */
  55551. mainTextureFixedSize?: number;
  55552. /**
  55553. * How big is the kernel of the blur texture.
  55554. */
  55555. blurKernelSize: number;
  55556. /**
  55557. * The camera attached to the layer.
  55558. */
  55559. camera: Nullable<Camera>;
  55560. /**
  55561. * Enable MSAA by chosing the number of samples.
  55562. */
  55563. mainTextureSamples?: number;
  55564. /**
  55565. * The rendering group to draw the layer in.
  55566. */
  55567. renderingGroupId: number;
  55568. }
  55569. /**
  55570. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55571. *
  55572. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55573. *
  55574. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55575. */
  55576. export class GlowLayer extends EffectLayer {
  55577. /**
  55578. * Effect Name of the layer.
  55579. */
  55580. static readonly EffectName: string;
  55581. /**
  55582. * The default blur kernel size used for the glow.
  55583. */
  55584. static DefaultBlurKernelSize: number;
  55585. /**
  55586. * The default texture size ratio used for the glow.
  55587. */
  55588. static DefaultTextureRatio: number;
  55589. /**
  55590. * Sets the kernel size of the blur.
  55591. */
  55592. set blurKernelSize(value: number);
  55593. /**
  55594. * Gets the kernel size of the blur.
  55595. */
  55596. get blurKernelSize(): number;
  55597. /**
  55598. * Sets the glow intensity.
  55599. */
  55600. set intensity(value: number);
  55601. /**
  55602. * Gets the glow intensity.
  55603. */
  55604. get intensity(): number;
  55605. private _options;
  55606. private _intensity;
  55607. private _horizontalBlurPostprocess1;
  55608. private _verticalBlurPostprocess1;
  55609. private _horizontalBlurPostprocess2;
  55610. private _verticalBlurPostprocess2;
  55611. private _blurTexture1;
  55612. private _blurTexture2;
  55613. private _postProcesses1;
  55614. private _postProcesses2;
  55615. private _includedOnlyMeshes;
  55616. private _excludedMeshes;
  55617. private _meshesUsingTheirOwnMaterials;
  55618. /**
  55619. * Callback used to let the user override the color selection on a per mesh basis
  55620. */
  55621. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55622. /**
  55623. * Callback used to let the user override the texture selection on a per mesh basis
  55624. */
  55625. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55626. /**
  55627. * Instantiates a new glow Layer and references it to the scene.
  55628. * @param name The name of the layer
  55629. * @param scene The scene to use the layer in
  55630. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55631. */
  55632. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55633. /**
  55634. * Get the effect name of the layer.
  55635. * @return The effect name
  55636. */
  55637. getEffectName(): string;
  55638. /**
  55639. * Create the merge effect. This is the shader use to blit the information back
  55640. * to the main canvas at the end of the scene rendering.
  55641. */
  55642. protected _createMergeEffect(): Effect;
  55643. /**
  55644. * Creates the render target textures and post processes used in the glow layer.
  55645. */
  55646. protected _createTextureAndPostProcesses(): void;
  55647. /**
  55648. * Checks for the readiness of the element composing the layer.
  55649. * @param subMesh the mesh to check for
  55650. * @param useInstances specify wether or not to use instances to render the mesh
  55651. * @param emissiveTexture the associated emissive texture used to generate the glow
  55652. * @return true if ready otherwise, false
  55653. */
  55654. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55655. /**
  55656. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55657. */
  55658. needStencil(): boolean;
  55659. /**
  55660. * Returns true if the mesh can be rendered, otherwise false.
  55661. * @param mesh The mesh to render
  55662. * @param material The material used on the mesh
  55663. * @returns true if it can be rendered otherwise false
  55664. */
  55665. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55666. /**
  55667. * Implementation specific of rendering the generating effect on the main canvas.
  55668. * @param effect The effect used to render through
  55669. */
  55670. protected _internalRender(effect: Effect): void;
  55671. /**
  55672. * Sets the required values for both the emissive texture and and the main color.
  55673. */
  55674. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55675. /**
  55676. * Returns true if the mesh should render, otherwise false.
  55677. * @param mesh The mesh to render
  55678. * @returns true if it should render otherwise false
  55679. */
  55680. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55681. /**
  55682. * Adds specific effects defines.
  55683. * @param defines The defines to add specifics to.
  55684. */
  55685. protected _addCustomEffectDefines(defines: string[]): void;
  55686. /**
  55687. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55688. * @param mesh The mesh to exclude from the glow layer
  55689. */
  55690. addExcludedMesh(mesh: Mesh): void;
  55691. /**
  55692. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55693. * @param mesh The mesh to remove
  55694. */
  55695. removeExcludedMesh(mesh: Mesh): void;
  55696. /**
  55697. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55698. * @param mesh The mesh to include in the glow layer
  55699. */
  55700. addIncludedOnlyMesh(mesh: Mesh): void;
  55701. /**
  55702. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55703. * @param mesh The mesh to remove
  55704. */
  55705. removeIncludedOnlyMesh(mesh: Mesh): void;
  55706. /**
  55707. * Determine if a given mesh will be used in the glow layer
  55708. * @param mesh The mesh to test
  55709. * @returns true if the mesh will be highlighted by the current glow layer
  55710. */
  55711. hasMesh(mesh: AbstractMesh): boolean;
  55712. /**
  55713. * Defines wether the current material of the mesh should be use to render the effect.
  55714. * @param mesh defines the current mesh to render
  55715. */
  55716. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55717. /**
  55718. * Add a mesh to be rendered through its own material and not with emissive only.
  55719. * @param mesh The mesh for which we need to use its material
  55720. */
  55721. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55722. /**
  55723. * Remove a mesh from being rendered through its own material and not with emissive only.
  55724. * @param mesh The mesh for which we need to not use its material
  55725. */
  55726. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55727. /**
  55728. * Free any resources and references associated to a mesh.
  55729. * Internal use
  55730. * @param mesh The mesh to free.
  55731. * @hidden
  55732. */
  55733. _disposeMesh(mesh: Mesh): void;
  55734. /**
  55735. * Gets the class name of the effect layer
  55736. * @returns the string with the class name of the effect layer
  55737. */
  55738. getClassName(): string;
  55739. /**
  55740. * Serializes this glow layer
  55741. * @returns a serialized glow layer object
  55742. */
  55743. serialize(): any;
  55744. /**
  55745. * Creates a Glow Layer from parsed glow layer data
  55746. * @param parsedGlowLayer defines glow layer data
  55747. * @param scene defines the current scene
  55748. * @param rootUrl defines the root URL containing the glow layer information
  55749. * @returns a parsed Glow Layer
  55750. */
  55751. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55752. }
  55753. }
  55754. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55755. /** @hidden */
  55756. export var glowBlurPostProcessPixelShader: {
  55757. name: string;
  55758. shader: string;
  55759. };
  55760. }
  55761. declare module "babylonjs/Layers/highlightLayer" {
  55762. import { Observable } from "babylonjs/Misc/observable";
  55763. import { Nullable } from "babylonjs/types";
  55764. import { Camera } from "babylonjs/Cameras/camera";
  55765. import { Scene } from "babylonjs/scene";
  55766. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55768. import { Mesh } from "babylonjs/Meshes/mesh";
  55769. import { Effect } from "babylonjs/Materials/effect";
  55770. import { Material } from "babylonjs/Materials/material";
  55771. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55772. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55773. import "babylonjs/Shaders/glowMapMerge.fragment";
  55774. import "babylonjs/Shaders/glowMapMerge.vertex";
  55775. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55776. module "babylonjs/abstractScene" {
  55777. interface AbstractScene {
  55778. /**
  55779. * Return a the first highlight layer of the scene with a given name.
  55780. * @param name The name of the highlight layer to look for.
  55781. * @return The highlight layer if found otherwise null.
  55782. */
  55783. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55784. }
  55785. }
  55786. /**
  55787. * Highlight layer options. This helps customizing the behaviour
  55788. * of the highlight layer.
  55789. */
  55790. export interface IHighlightLayerOptions {
  55791. /**
  55792. * Multiplication factor apply to the canvas size to compute the render target size
  55793. * used to generated the glowing objects (the smaller the faster).
  55794. */
  55795. mainTextureRatio: number;
  55796. /**
  55797. * Enforces a fixed size texture to ensure resize independant blur.
  55798. */
  55799. mainTextureFixedSize?: number;
  55800. /**
  55801. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55802. * of the picture to blur (the smaller the faster).
  55803. */
  55804. blurTextureSizeRatio: number;
  55805. /**
  55806. * How big in texel of the blur texture is the vertical blur.
  55807. */
  55808. blurVerticalSize: number;
  55809. /**
  55810. * How big in texel of the blur texture is the horizontal blur.
  55811. */
  55812. blurHorizontalSize: number;
  55813. /**
  55814. * Alpha blending mode used to apply the blur. Default is combine.
  55815. */
  55816. alphaBlendingMode: number;
  55817. /**
  55818. * The camera attached to the layer.
  55819. */
  55820. camera: Nullable<Camera>;
  55821. /**
  55822. * Should we display highlight as a solid stroke?
  55823. */
  55824. isStroke?: boolean;
  55825. /**
  55826. * The rendering group to draw the layer in.
  55827. */
  55828. renderingGroupId: number;
  55829. }
  55830. /**
  55831. * The highlight layer Helps adding a glow effect around a mesh.
  55832. *
  55833. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55834. * glowy meshes to your scene.
  55835. *
  55836. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55837. */
  55838. export class HighlightLayer extends EffectLayer {
  55839. name: string;
  55840. /**
  55841. * Effect Name of the highlight layer.
  55842. */
  55843. static readonly EffectName: string;
  55844. /**
  55845. * The neutral color used during the preparation of the glow effect.
  55846. * This is black by default as the blend operation is a blend operation.
  55847. */
  55848. static NeutralColor: Color4;
  55849. /**
  55850. * Stencil value used for glowing meshes.
  55851. */
  55852. static GlowingMeshStencilReference: number;
  55853. /**
  55854. * Stencil value used for the other meshes in the scene.
  55855. */
  55856. static NormalMeshStencilReference: number;
  55857. /**
  55858. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55859. */
  55860. innerGlow: boolean;
  55861. /**
  55862. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55863. */
  55864. outerGlow: boolean;
  55865. /**
  55866. * Specifies the horizontal size of the blur.
  55867. */
  55868. set blurHorizontalSize(value: number);
  55869. /**
  55870. * Specifies the vertical size of the blur.
  55871. */
  55872. set blurVerticalSize(value: number);
  55873. /**
  55874. * Gets the horizontal size of the blur.
  55875. */
  55876. get blurHorizontalSize(): number;
  55877. /**
  55878. * Gets the vertical size of the blur.
  55879. */
  55880. get blurVerticalSize(): number;
  55881. /**
  55882. * An event triggered when the highlight layer is being blurred.
  55883. */
  55884. onBeforeBlurObservable: Observable<HighlightLayer>;
  55885. /**
  55886. * An event triggered when the highlight layer has been blurred.
  55887. */
  55888. onAfterBlurObservable: Observable<HighlightLayer>;
  55889. private _instanceGlowingMeshStencilReference;
  55890. private _options;
  55891. private _downSamplePostprocess;
  55892. private _horizontalBlurPostprocess;
  55893. private _verticalBlurPostprocess;
  55894. private _blurTexture;
  55895. private _meshes;
  55896. private _excludedMeshes;
  55897. /**
  55898. * Instantiates a new highlight Layer and references it to the scene..
  55899. * @param name The name of the layer
  55900. * @param scene The scene to use the layer in
  55901. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55902. */
  55903. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55904. /**
  55905. * Get the effect name of the layer.
  55906. * @return The effect name
  55907. */
  55908. getEffectName(): string;
  55909. /**
  55910. * Create the merge effect. This is the shader use to blit the information back
  55911. * to the main canvas at the end of the scene rendering.
  55912. */
  55913. protected _createMergeEffect(): Effect;
  55914. /**
  55915. * Creates the render target textures and post processes used in the highlight layer.
  55916. */
  55917. protected _createTextureAndPostProcesses(): void;
  55918. /**
  55919. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55920. */
  55921. needStencil(): boolean;
  55922. /**
  55923. * Checks for the readiness of the element composing the layer.
  55924. * @param subMesh the mesh to check for
  55925. * @param useInstances specify wether or not to use instances to render the mesh
  55926. * @param emissiveTexture the associated emissive texture used to generate the glow
  55927. * @return true if ready otherwise, false
  55928. */
  55929. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55930. /**
  55931. * Implementation specific of rendering the generating effect on the main canvas.
  55932. * @param effect The effect used to render through
  55933. */
  55934. protected _internalRender(effect: Effect): void;
  55935. /**
  55936. * Returns true if the layer contains information to display, otherwise false.
  55937. */
  55938. shouldRender(): boolean;
  55939. /**
  55940. * Returns true if the mesh should render, otherwise false.
  55941. * @param mesh The mesh to render
  55942. * @returns true if it should render otherwise false
  55943. */
  55944. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55945. /**
  55946. * Sets the required values for both the emissive texture and and the main color.
  55947. */
  55948. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55949. /**
  55950. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55951. * @param mesh The mesh to exclude from the highlight layer
  55952. */
  55953. addExcludedMesh(mesh: Mesh): void;
  55954. /**
  55955. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55956. * @param mesh The mesh to highlight
  55957. */
  55958. removeExcludedMesh(mesh: Mesh): void;
  55959. /**
  55960. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55961. * @param mesh mesh to test
  55962. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55963. */
  55964. hasMesh(mesh: AbstractMesh): boolean;
  55965. /**
  55966. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55967. * @param mesh The mesh to highlight
  55968. * @param color The color of the highlight
  55969. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55970. */
  55971. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55972. /**
  55973. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55974. * @param mesh The mesh to highlight
  55975. */
  55976. removeMesh(mesh: Mesh): void;
  55977. /**
  55978. * Force the stencil to the normal expected value for none glowing parts
  55979. */
  55980. private _defaultStencilReference;
  55981. /**
  55982. * Free any resources and references associated to a mesh.
  55983. * Internal use
  55984. * @param mesh The mesh to free.
  55985. * @hidden
  55986. */
  55987. _disposeMesh(mesh: Mesh): void;
  55988. /**
  55989. * Dispose the highlight layer and free resources.
  55990. */
  55991. dispose(): void;
  55992. /**
  55993. * Gets the class name of the effect layer
  55994. * @returns the string with the class name of the effect layer
  55995. */
  55996. getClassName(): string;
  55997. /**
  55998. * Serializes this Highlight layer
  55999. * @returns a serialized Highlight layer object
  56000. */
  56001. serialize(): any;
  56002. /**
  56003. * Creates a Highlight layer from parsed Highlight layer data
  56004. * @param parsedHightlightLayer defines the Highlight layer data
  56005. * @param scene defines the current scene
  56006. * @param rootUrl defines the root URL containing the Highlight layer information
  56007. * @returns a parsed Highlight layer
  56008. */
  56009. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56010. }
  56011. }
  56012. declare module "babylonjs/Layers/layerSceneComponent" {
  56013. import { Scene } from "babylonjs/scene";
  56014. import { ISceneComponent } from "babylonjs/sceneComponent";
  56015. import { Layer } from "babylonjs/Layers/layer";
  56016. import { AbstractScene } from "babylonjs/abstractScene";
  56017. module "babylonjs/abstractScene" {
  56018. interface AbstractScene {
  56019. /**
  56020. * The list of layers (background and foreground) of the scene
  56021. */
  56022. layers: Array<Layer>;
  56023. }
  56024. }
  56025. /**
  56026. * Defines the layer scene component responsible to manage any layers
  56027. * in a given scene.
  56028. */
  56029. export class LayerSceneComponent implements ISceneComponent {
  56030. /**
  56031. * The component name helpfull to identify the component in the list of scene components.
  56032. */
  56033. readonly name: string;
  56034. /**
  56035. * The scene the component belongs to.
  56036. */
  56037. scene: Scene;
  56038. private _engine;
  56039. /**
  56040. * Creates a new instance of the component for the given scene
  56041. * @param scene Defines the scene to register the component in
  56042. */
  56043. constructor(scene: Scene);
  56044. /**
  56045. * Registers the component in a given scene
  56046. */
  56047. register(): void;
  56048. /**
  56049. * Rebuilds the elements related to this component in case of
  56050. * context lost for instance.
  56051. */
  56052. rebuild(): void;
  56053. /**
  56054. * Disposes the component and the associated ressources.
  56055. */
  56056. dispose(): void;
  56057. private _draw;
  56058. private _drawCameraPredicate;
  56059. private _drawCameraBackground;
  56060. private _drawCameraForeground;
  56061. private _drawRenderTargetPredicate;
  56062. private _drawRenderTargetBackground;
  56063. private _drawRenderTargetForeground;
  56064. /**
  56065. * Adds all the elements from the container to the scene
  56066. * @param container the container holding the elements
  56067. */
  56068. addFromContainer(container: AbstractScene): void;
  56069. /**
  56070. * Removes all the elements in the container from the scene
  56071. * @param container contains the elements to remove
  56072. * @param dispose if the removed element should be disposed (default: false)
  56073. */
  56074. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56075. }
  56076. }
  56077. declare module "babylonjs/Shaders/layer.fragment" {
  56078. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56079. /** @hidden */
  56080. export var layerPixelShader: {
  56081. name: string;
  56082. shader: string;
  56083. };
  56084. }
  56085. declare module "babylonjs/Shaders/layer.vertex" {
  56086. /** @hidden */
  56087. export var layerVertexShader: {
  56088. name: string;
  56089. shader: string;
  56090. };
  56091. }
  56092. declare module "babylonjs/Layers/layer" {
  56093. import { Observable } from "babylonjs/Misc/observable";
  56094. import { Nullable } from "babylonjs/types";
  56095. import { Scene } from "babylonjs/scene";
  56096. import { Vector2 } from "babylonjs/Maths/math.vector";
  56097. import { Color4 } from "babylonjs/Maths/math.color";
  56098. import { Texture } from "babylonjs/Materials/Textures/texture";
  56099. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56100. import "babylonjs/Shaders/layer.fragment";
  56101. import "babylonjs/Shaders/layer.vertex";
  56102. /**
  56103. * This represents a full screen 2d layer.
  56104. * This can be useful to display a picture in the background of your scene for instance.
  56105. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56106. */
  56107. export class Layer {
  56108. /**
  56109. * Define the name of the layer.
  56110. */
  56111. name: string;
  56112. /**
  56113. * Define the texture the layer should display.
  56114. */
  56115. texture: Nullable<Texture>;
  56116. /**
  56117. * Is the layer in background or foreground.
  56118. */
  56119. isBackground: boolean;
  56120. /**
  56121. * Define the color of the layer (instead of texture).
  56122. */
  56123. color: Color4;
  56124. /**
  56125. * Define the scale of the layer in order to zoom in out of the texture.
  56126. */
  56127. scale: Vector2;
  56128. /**
  56129. * Define an offset for the layer in order to shift the texture.
  56130. */
  56131. offset: Vector2;
  56132. /**
  56133. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56134. */
  56135. alphaBlendingMode: number;
  56136. /**
  56137. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56138. * Alpha test will not mix with the background color in case of transparency.
  56139. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56140. */
  56141. alphaTest: boolean;
  56142. /**
  56143. * Define a mask to restrict the layer to only some of the scene cameras.
  56144. */
  56145. layerMask: number;
  56146. /**
  56147. * Define the list of render target the layer is visible into.
  56148. */
  56149. renderTargetTextures: RenderTargetTexture[];
  56150. /**
  56151. * Define if the layer is only used in renderTarget or if it also
  56152. * renders in the main frame buffer of the canvas.
  56153. */
  56154. renderOnlyInRenderTargetTextures: boolean;
  56155. private _scene;
  56156. private _vertexBuffers;
  56157. private _indexBuffer;
  56158. private _effect;
  56159. private _previousDefines;
  56160. /**
  56161. * An event triggered when the layer is disposed.
  56162. */
  56163. onDisposeObservable: Observable<Layer>;
  56164. private _onDisposeObserver;
  56165. /**
  56166. * Back compatibility with callback before the onDisposeObservable existed.
  56167. * The set callback will be triggered when the layer has been disposed.
  56168. */
  56169. set onDispose(callback: () => void);
  56170. /**
  56171. * An event triggered before rendering the scene
  56172. */
  56173. onBeforeRenderObservable: Observable<Layer>;
  56174. private _onBeforeRenderObserver;
  56175. /**
  56176. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56177. * The set callback will be triggered just before rendering the layer.
  56178. */
  56179. set onBeforeRender(callback: () => void);
  56180. /**
  56181. * An event triggered after rendering the scene
  56182. */
  56183. onAfterRenderObservable: Observable<Layer>;
  56184. private _onAfterRenderObserver;
  56185. /**
  56186. * Back compatibility with callback before the onAfterRenderObservable existed.
  56187. * The set callback will be triggered just after rendering the layer.
  56188. */
  56189. set onAfterRender(callback: () => void);
  56190. /**
  56191. * Instantiates a new layer.
  56192. * This represents a full screen 2d layer.
  56193. * This can be useful to display a picture in the background of your scene for instance.
  56194. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56195. * @param name Define the name of the layer in the scene
  56196. * @param imgUrl Define the url of the texture to display in the layer
  56197. * @param scene Define the scene the layer belongs to
  56198. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56199. * @param color Defines a color for the layer
  56200. */
  56201. constructor(
  56202. /**
  56203. * Define the name of the layer.
  56204. */
  56205. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56206. private _createIndexBuffer;
  56207. /** @hidden */
  56208. _rebuild(): void;
  56209. /**
  56210. * Renders the layer in the scene.
  56211. */
  56212. render(): void;
  56213. /**
  56214. * Disposes and releases the associated ressources.
  56215. */
  56216. dispose(): void;
  56217. }
  56218. }
  56219. declare module "babylonjs/Layers/index" {
  56220. export * from "babylonjs/Layers/effectLayer";
  56221. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56222. export * from "babylonjs/Layers/glowLayer";
  56223. export * from "babylonjs/Layers/highlightLayer";
  56224. export * from "babylonjs/Layers/layer";
  56225. export * from "babylonjs/Layers/layerSceneComponent";
  56226. }
  56227. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56228. /** @hidden */
  56229. export var lensFlarePixelShader: {
  56230. name: string;
  56231. shader: string;
  56232. };
  56233. }
  56234. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56235. /** @hidden */
  56236. export var lensFlareVertexShader: {
  56237. name: string;
  56238. shader: string;
  56239. };
  56240. }
  56241. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56242. import { Scene } from "babylonjs/scene";
  56243. import { Vector3 } from "babylonjs/Maths/math.vector";
  56244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56245. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56246. import "babylonjs/Shaders/lensFlare.fragment";
  56247. import "babylonjs/Shaders/lensFlare.vertex";
  56248. import { Viewport } from "babylonjs/Maths/math.viewport";
  56249. /**
  56250. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56251. * It is usually composed of several `lensFlare`.
  56252. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56253. */
  56254. export class LensFlareSystem {
  56255. /**
  56256. * Define the name of the lens flare system
  56257. */
  56258. name: string;
  56259. /**
  56260. * List of lens flares used in this system.
  56261. */
  56262. lensFlares: LensFlare[];
  56263. /**
  56264. * Define a limit from the border the lens flare can be visible.
  56265. */
  56266. borderLimit: number;
  56267. /**
  56268. * Define a viewport border we do not want to see the lens flare in.
  56269. */
  56270. viewportBorder: number;
  56271. /**
  56272. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56273. */
  56274. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56275. /**
  56276. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56277. */
  56278. layerMask: number;
  56279. /**
  56280. * Define the id of the lens flare system in the scene.
  56281. * (equal to name by default)
  56282. */
  56283. id: string;
  56284. private _scene;
  56285. private _emitter;
  56286. private _vertexBuffers;
  56287. private _indexBuffer;
  56288. private _effect;
  56289. private _positionX;
  56290. private _positionY;
  56291. private _isEnabled;
  56292. /** @hidden */
  56293. static _SceneComponentInitialization: (scene: Scene) => void;
  56294. /**
  56295. * Instantiates a lens flare system.
  56296. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56297. * It is usually composed of several `lensFlare`.
  56298. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56299. * @param name Define the name of the lens flare system in the scene
  56300. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56301. * @param scene Define the scene the lens flare system belongs to
  56302. */
  56303. constructor(
  56304. /**
  56305. * Define the name of the lens flare system
  56306. */
  56307. name: string, emitter: any, scene: Scene);
  56308. /**
  56309. * Define if the lens flare system is enabled.
  56310. */
  56311. get isEnabled(): boolean;
  56312. set isEnabled(value: boolean);
  56313. /**
  56314. * Get the scene the effects belongs to.
  56315. * @returns the scene holding the lens flare system
  56316. */
  56317. getScene(): Scene;
  56318. /**
  56319. * Get the emitter of the lens flare system.
  56320. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56321. * @returns the emitter of the lens flare system
  56322. */
  56323. getEmitter(): any;
  56324. /**
  56325. * Set the emitter of the lens flare system.
  56326. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56327. * @param newEmitter Define the new emitter of the system
  56328. */
  56329. setEmitter(newEmitter: any): void;
  56330. /**
  56331. * Get the lens flare system emitter position.
  56332. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56333. * @returns the position
  56334. */
  56335. getEmitterPosition(): Vector3;
  56336. /**
  56337. * @hidden
  56338. */
  56339. computeEffectivePosition(globalViewport: Viewport): boolean;
  56340. /** @hidden */
  56341. _isVisible(): boolean;
  56342. /**
  56343. * @hidden
  56344. */
  56345. render(): boolean;
  56346. /**
  56347. * Dispose and release the lens flare with its associated resources.
  56348. */
  56349. dispose(): void;
  56350. /**
  56351. * Parse a lens flare system from a JSON repressentation
  56352. * @param parsedLensFlareSystem Define the JSON to parse
  56353. * @param scene Define the scene the parsed system should be instantiated in
  56354. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56355. * @returns the parsed system
  56356. */
  56357. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56358. /**
  56359. * Serialize the current Lens Flare System into a JSON representation.
  56360. * @returns the serialized JSON
  56361. */
  56362. serialize(): any;
  56363. }
  56364. }
  56365. declare module "babylonjs/LensFlares/lensFlare" {
  56366. import { Nullable } from "babylonjs/types";
  56367. import { Color3 } from "babylonjs/Maths/math.color";
  56368. import { Texture } from "babylonjs/Materials/Textures/texture";
  56369. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56370. /**
  56371. * This represents one of the lens effect in a `lensFlareSystem`.
  56372. * It controls one of the indiviual texture used in the effect.
  56373. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56374. */
  56375. export class LensFlare {
  56376. /**
  56377. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56378. */
  56379. size: number;
  56380. /**
  56381. * 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.
  56382. */
  56383. position: number;
  56384. /**
  56385. * Define the lens color.
  56386. */
  56387. color: Color3;
  56388. /**
  56389. * Define the lens texture.
  56390. */
  56391. texture: Nullable<Texture>;
  56392. /**
  56393. * Define the alpha mode to render this particular lens.
  56394. */
  56395. alphaMode: number;
  56396. private _system;
  56397. /**
  56398. * Creates a new Lens Flare.
  56399. * This represents one of the lens effect in a `lensFlareSystem`.
  56400. * It controls one of the indiviual texture used in the effect.
  56401. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56402. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56403. * @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.
  56404. * @param color Define the lens color
  56405. * @param imgUrl Define the lens texture url
  56406. * @param system Define the `lensFlareSystem` this flare is part of
  56407. * @returns The newly created Lens Flare
  56408. */
  56409. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56410. /**
  56411. * Instantiates a new Lens Flare.
  56412. * This represents one of the lens effect in a `lensFlareSystem`.
  56413. * It controls one of the indiviual texture used in the effect.
  56414. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56415. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56416. * @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.
  56417. * @param color Define the lens color
  56418. * @param imgUrl Define the lens texture url
  56419. * @param system Define the `lensFlareSystem` this flare is part of
  56420. */
  56421. constructor(
  56422. /**
  56423. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56424. */
  56425. size: number,
  56426. /**
  56427. * 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.
  56428. */
  56429. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56430. /**
  56431. * Dispose and release the lens flare with its associated resources.
  56432. */
  56433. dispose(): void;
  56434. }
  56435. }
  56436. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56437. import { Nullable } from "babylonjs/types";
  56438. import { Scene } from "babylonjs/scene";
  56439. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56440. import { AbstractScene } from "babylonjs/abstractScene";
  56441. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56442. module "babylonjs/abstractScene" {
  56443. interface AbstractScene {
  56444. /**
  56445. * The list of lens flare system added to the scene
  56446. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56447. */
  56448. lensFlareSystems: Array<LensFlareSystem>;
  56449. /**
  56450. * Removes the given lens flare system from this scene.
  56451. * @param toRemove The lens flare system to remove
  56452. * @returns The index of the removed lens flare system
  56453. */
  56454. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56455. /**
  56456. * Adds the given lens flare system to this scene
  56457. * @param newLensFlareSystem The lens flare system to add
  56458. */
  56459. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56460. /**
  56461. * Gets a lens flare system using its name
  56462. * @param name defines the name to look for
  56463. * @returns the lens flare system or null if not found
  56464. */
  56465. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56466. /**
  56467. * Gets a lens flare system using its id
  56468. * @param id defines the id to look for
  56469. * @returns the lens flare system or null if not found
  56470. */
  56471. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56472. }
  56473. }
  56474. /**
  56475. * Defines the lens flare scene component responsible to manage any lens flares
  56476. * in a given scene.
  56477. */
  56478. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56479. /**
  56480. * The component name helpfull to identify the component in the list of scene components.
  56481. */
  56482. readonly name: string;
  56483. /**
  56484. * The scene the component belongs to.
  56485. */
  56486. scene: Scene;
  56487. /**
  56488. * Creates a new instance of the component for the given scene
  56489. * @param scene Defines the scene to register the component in
  56490. */
  56491. constructor(scene: Scene);
  56492. /**
  56493. * Registers the component in a given scene
  56494. */
  56495. register(): void;
  56496. /**
  56497. * Rebuilds the elements related to this component in case of
  56498. * context lost for instance.
  56499. */
  56500. rebuild(): void;
  56501. /**
  56502. * Adds all the elements from the container to the scene
  56503. * @param container the container holding the elements
  56504. */
  56505. addFromContainer(container: AbstractScene): void;
  56506. /**
  56507. * Removes all the elements in the container from the scene
  56508. * @param container contains the elements to remove
  56509. * @param dispose if the removed element should be disposed (default: false)
  56510. */
  56511. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56512. /**
  56513. * Serializes the component data to the specified json object
  56514. * @param serializationObject The object to serialize to
  56515. */
  56516. serialize(serializationObject: any): void;
  56517. /**
  56518. * Disposes the component and the associated ressources.
  56519. */
  56520. dispose(): void;
  56521. private _draw;
  56522. }
  56523. }
  56524. declare module "babylonjs/LensFlares/index" {
  56525. export * from "babylonjs/LensFlares/lensFlare";
  56526. export * from "babylonjs/LensFlares/lensFlareSystem";
  56527. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56528. }
  56529. declare module "babylonjs/Shaders/depth.fragment" {
  56530. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56531. /** @hidden */
  56532. export var depthPixelShader: {
  56533. name: string;
  56534. shader: string;
  56535. };
  56536. }
  56537. declare module "babylonjs/Shaders/depth.vertex" {
  56538. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56539. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56540. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56541. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56543. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56544. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56545. /** @hidden */
  56546. export var depthVertexShader: {
  56547. name: string;
  56548. shader: string;
  56549. };
  56550. }
  56551. declare module "babylonjs/Rendering/depthRenderer" {
  56552. import { Nullable } from "babylonjs/types";
  56553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56554. import { Scene } from "babylonjs/scene";
  56555. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56556. import { Camera } from "babylonjs/Cameras/camera";
  56557. import "babylonjs/Shaders/depth.fragment";
  56558. import "babylonjs/Shaders/depth.vertex";
  56559. /**
  56560. * This represents a depth renderer in Babylon.
  56561. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56562. */
  56563. export class DepthRenderer {
  56564. private _scene;
  56565. private _depthMap;
  56566. private _effect;
  56567. private readonly _storeNonLinearDepth;
  56568. private readonly _clearColor;
  56569. /** Get if the depth renderer is using packed depth or not */
  56570. readonly isPacked: boolean;
  56571. private _cachedDefines;
  56572. private _camera;
  56573. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56574. enabled: boolean;
  56575. /**
  56576. * Specifiess that the depth renderer will only be used within
  56577. * the camera it is created for.
  56578. * This can help forcing its rendering during the camera processing.
  56579. */
  56580. useOnlyInActiveCamera: boolean;
  56581. /** @hidden */
  56582. static _SceneComponentInitialization: (scene: Scene) => void;
  56583. /**
  56584. * Instantiates a depth renderer
  56585. * @param scene The scene the renderer belongs to
  56586. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56587. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56588. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56589. */
  56590. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56591. /**
  56592. * Creates the depth rendering effect and checks if the effect is ready.
  56593. * @param subMesh The submesh to be used to render the depth map of
  56594. * @param useInstances If multiple world instances should be used
  56595. * @returns if the depth renderer is ready to render the depth map
  56596. */
  56597. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56598. /**
  56599. * Gets the texture which the depth map will be written to.
  56600. * @returns The depth map texture
  56601. */
  56602. getDepthMap(): RenderTargetTexture;
  56603. /**
  56604. * Disposes of the depth renderer.
  56605. */
  56606. dispose(): void;
  56607. }
  56608. }
  56609. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56610. /** @hidden */
  56611. export var minmaxReduxPixelShader: {
  56612. name: string;
  56613. shader: string;
  56614. };
  56615. }
  56616. declare module "babylonjs/Misc/minMaxReducer" {
  56617. import { Nullable } from "babylonjs/types";
  56618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56619. import { Camera } from "babylonjs/Cameras/camera";
  56620. import { Observer } from "babylonjs/Misc/observable";
  56621. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56622. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56623. import { Observable } from "babylonjs/Misc/observable";
  56624. import "babylonjs/Shaders/minmaxRedux.fragment";
  56625. /**
  56626. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56627. * and maximum values from all values of the texture.
  56628. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56629. * The source values are read from the red channel of the texture.
  56630. */
  56631. export class MinMaxReducer {
  56632. /**
  56633. * Observable triggered when the computation has been performed
  56634. */
  56635. onAfterReductionPerformed: Observable<{
  56636. min: number;
  56637. max: number;
  56638. }>;
  56639. protected _camera: Camera;
  56640. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56641. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56642. protected _postProcessManager: PostProcessManager;
  56643. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56644. protected _forceFullscreenViewport: boolean;
  56645. /**
  56646. * Creates a min/max reducer
  56647. * @param camera The camera to use for the post processes
  56648. */
  56649. constructor(camera: Camera);
  56650. /**
  56651. * Gets the texture used to read the values from.
  56652. */
  56653. get sourceTexture(): Nullable<RenderTargetTexture>;
  56654. /**
  56655. * Sets the source texture to read the values from.
  56656. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56657. * because in such textures '1' value must not be taken into account to compute the maximum
  56658. * as this value is used to clear the texture.
  56659. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56660. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56661. * @param depthRedux Indicates if the texture is a depth texture or not
  56662. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56663. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56664. */
  56665. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56666. /**
  56667. * Defines the refresh rate of the computation.
  56668. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56669. */
  56670. get refreshRate(): number;
  56671. set refreshRate(value: number);
  56672. protected _activated: boolean;
  56673. /**
  56674. * Gets the activation status of the reducer
  56675. */
  56676. get activated(): boolean;
  56677. /**
  56678. * Activates the reduction computation.
  56679. * When activated, the observers registered in onAfterReductionPerformed are
  56680. * called after the compuation is performed
  56681. */
  56682. activate(): void;
  56683. /**
  56684. * Deactivates the reduction computation.
  56685. */
  56686. deactivate(): void;
  56687. /**
  56688. * Disposes the min/max reducer
  56689. * @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.
  56690. */
  56691. dispose(disposeAll?: boolean): void;
  56692. }
  56693. }
  56694. declare module "babylonjs/Misc/depthReducer" {
  56695. import { Nullable } from "babylonjs/types";
  56696. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56697. import { Camera } from "babylonjs/Cameras/camera";
  56698. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56699. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56700. /**
  56701. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56702. */
  56703. export class DepthReducer extends MinMaxReducer {
  56704. private _depthRenderer;
  56705. private _depthRendererId;
  56706. /**
  56707. * Gets the depth renderer used for the computation.
  56708. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56709. */
  56710. get depthRenderer(): Nullable<DepthRenderer>;
  56711. /**
  56712. * Creates a depth reducer
  56713. * @param camera The camera used to render the depth texture
  56714. */
  56715. constructor(camera: Camera);
  56716. /**
  56717. * Sets the depth renderer to use to generate the depth map
  56718. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56719. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56720. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56721. */
  56722. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56723. /** @hidden */
  56724. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56725. /**
  56726. * Activates the reduction computation.
  56727. * When activated, the observers registered in onAfterReductionPerformed are
  56728. * called after the compuation is performed
  56729. */
  56730. activate(): void;
  56731. /**
  56732. * Deactivates the reduction computation.
  56733. */
  56734. deactivate(): void;
  56735. /**
  56736. * Disposes the depth reducer
  56737. * @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.
  56738. */
  56739. dispose(disposeAll?: boolean): void;
  56740. }
  56741. }
  56742. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56743. import { Nullable } from "babylonjs/types";
  56744. import { Scene } from "babylonjs/scene";
  56745. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56746. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56747. import { Effect } from "babylonjs/Materials/effect";
  56748. import "babylonjs/Shaders/shadowMap.fragment";
  56749. import "babylonjs/Shaders/shadowMap.vertex";
  56750. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56751. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56752. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56753. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56754. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56755. /**
  56756. * A CSM implementation allowing casting shadows on large scenes.
  56757. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56758. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56759. */
  56760. export class CascadedShadowGenerator extends ShadowGenerator {
  56761. private static readonly frustumCornersNDCSpace;
  56762. /**
  56763. * Name of the CSM class
  56764. */
  56765. static CLASSNAME: string;
  56766. /**
  56767. * Defines the default number of cascades used by the CSM.
  56768. */
  56769. static readonly DEFAULT_CASCADES_COUNT: number;
  56770. /**
  56771. * Defines the minimum number of cascades used by the CSM.
  56772. */
  56773. static readonly MIN_CASCADES_COUNT: number;
  56774. /**
  56775. * Defines the maximum number of cascades used by the CSM.
  56776. */
  56777. static readonly MAX_CASCADES_COUNT: number;
  56778. protected _validateFilter(filter: number): number;
  56779. /**
  56780. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56781. */
  56782. penumbraDarkness: number;
  56783. private _numCascades;
  56784. /**
  56785. * Gets or set the number of cascades used by the CSM.
  56786. */
  56787. get numCascades(): number;
  56788. set numCascades(value: number);
  56789. /**
  56790. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56791. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56792. */
  56793. stabilizeCascades: boolean;
  56794. private _freezeShadowCastersBoundingInfo;
  56795. private _freezeShadowCastersBoundingInfoObservable;
  56796. /**
  56797. * Enables or disables the shadow casters bounding info computation.
  56798. * If your shadow casters don't move, you can disable this feature.
  56799. * If it is enabled, the bounding box computation is done every frame.
  56800. */
  56801. get freezeShadowCastersBoundingInfo(): boolean;
  56802. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56803. private _scbiMin;
  56804. private _scbiMax;
  56805. protected _computeShadowCastersBoundingInfo(): void;
  56806. protected _shadowCastersBoundingInfo: BoundingInfo;
  56807. /**
  56808. * Gets or sets the shadow casters bounding info.
  56809. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56810. * so that the system won't overwrite the bounds you provide
  56811. */
  56812. get shadowCastersBoundingInfo(): BoundingInfo;
  56813. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56814. protected _breaksAreDirty: boolean;
  56815. protected _minDistance: number;
  56816. protected _maxDistance: number;
  56817. /**
  56818. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56819. *
  56820. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56821. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56822. * @param min minimal distance for the breaks (default to 0.)
  56823. * @param max maximal distance for the breaks (default to 1.)
  56824. */
  56825. setMinMaxDistance(min: number, max: number): void;
  56826. /** Gets the minimal distance used in the cascade break computation */
  56827. get minDistance(): number;
  56828. /** Gets the maximal distance used in the cascade break computation */
  56829. get maxDistance(): number;
  56830. /**
  56831. * Gets the class name of that object
  56832. * @returns "CascadedShadowGenerator"
  56833. */
  56834. getClassName(): string;
  56835. private _cascadeMinExtents;
  56836. private _cascadeMaxExtents;
  56837. /**
  56838. * Gets a cascade minimum extents
  56839. * @param cascadeIndex index of the cascade
  56840. * @returns the minimum cascade extents
  56841. */
  56842. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56843. /**
  56844. * Gets a cascade maximum extents
  56845. * @param cascadeIndex index of the cascade
  56846. * @returns the maximum cascade extents
  56847. */
  56848. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56849. private _cascades;
  56850. private _currentLayer;
  56851. private _viewSpaceFrustumsZ;
  56852. private _viewMatrices;
  56853. private _projectionMatrices;
  56854. private _transformMatrices;
  56855. private _transformMatricesAsArray;
  56856. private _frustumLengths;
  56857. private _lightSizeUVCorrection;
  56858. private _depthCorrection;
  56859. private _frustumCornersWorldSpace;
  56860. private _frustumCenter;
  56861. private _shadowCameraPos;
  56862. private _shadowMaxZ;
  56863. /**
  56864. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56865. * It defaults to camera.maxZ
  56866. */
  56867. get shadowMaxZ(): number;
  56868. /**
  56869. * Sets the shadow max z distance.
  56870. */
  56871. set shadowMaxZ(value: number);
  56872. protected _debug: boolean;
  56873. /**
  56874. * Gets or sets the debug flag.
  56875. * When enabled, the cascades are materialized by different colors on the screen.
  56876. */
  56877. get debug(): boolean;
  56878. set debug(dbg: boolean);
  56879. private _depthClamp;
  56880. /**
  56881. * Gets or sets the depth clamping value.
  56882. *
  56883. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56884. * to account for the shadow casters far away.
  56885. *
  56886. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56887. */
  56888. get depthClamp(): boolean;
  56889. set depthClamp(value: boolean);
  56890. private _cascadeBlendPercentage;
  56891. /**
  56892. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56893. * It defaults to 0.1 (10% blending).
  56894. */
  56895. get cascadeBlendPercentage(): number;
  56896. set cascadeBlendPercentage(value: number);
  56897. private _lambda;
  56898. /**
  56899. * Gets or set the lambda parameter.
  56900. * This parameter is used to split the camera frustum and create the cascades.
  56901. * 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.
  56902. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56903. */
  56904. get lambda(): number;
  56905. set lambda(value: number);
  56906. /**
  56907. * Gets the view matrix corresponding to a given cascade
  56908. * @param cascadeNum cascade to retrieve the view matrix from
  56909. * @returns the cascade view matrix
  56910. */
  56911. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56912. /**
  56913. * Gets the projection matrix corresponding to a given cascade
  56914. * @param cascadeNum cascade to retrieve the projection matrix from
  56915. * @returns the cascade projection matrix
  56916. */
  56917. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56918. /**
  56919. * Gets the transformation matrix corresponding to a given cascade
  56920. * @param cascadeNum cascade to retrieve the transformation matrix from
  56921. * @returns the cascade transformation matrix
  56922. */
  56923. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56924. private _depthRenderer;
  56925. /**
  56926. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56927. *
  56928. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56929. *
  56930. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56931. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56932. * @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
  56933. */
  56934. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56935. private _depthReducer;
  56936. private _autoCalcDepthBounds;
  56937. /**
  56938. * Gets or sets the autoCalcDepthBounds property.
  56939. *
  56940. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56941. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56942. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56943. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56944. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56945. */
  56946. get autoCalcDepthBounds(): boolean;
  56947. set autoCalcDepthBounds(value: boolean);
  56948. /**
  56949. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56950. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56951. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56952. * for setting the refresh rate on the renderer yourself!
  56953. */
  56954. get autoCalcDepthBoundsRefreshRate(): number;
  56955. set autoCalcDepthBoundsRefreshRate(value: number);
  56956. /**
  56957. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56958. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56959. * you change the camera near/far planes!
  56960. */
  56961. splitFrustum(): void;
  56962. private _splitFrustum;
  56963. private _computeMatrices;
  56964. private _computeFrustumInWorldSpace;
  56965. private _computeCascadeFrustum;
  56966. /** @hidden */
  56967. static _SceneComponentInitialization: (scene: Scene) => void;
  56968. /**
  56969. * Creates a Cascaded Shadow Generator object.
  56970. * A ShadowGenerator is the required tool to use the shadows.
  56971. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56972. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56973. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56974. * @param light The directional light object generating the shadows.
  56975. * @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.
  56976. */
  56977. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56978. protected _initializeGenerator(): void;
  56979. protected _createTargetRenderTexture(): void;
  56980. protected _initializeShadowMap(): void;
  56981. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56982. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56983. /**
  56984. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56985. * @param defines Defines of the material we want to update
  56986. * @param lightIndex Index of the light in the enabled light list of the material
  56987. */
  56988. prepareDefines(defines: any, lightIndex: number): void;
  56989. /**
  56990. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56991. * defined in the generator but impacting the effect).
  56992. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56993. * @param effect The effect we are binfing the information for
  56994. */
  56995. bindShadowLight(lightIndex: string, effect: Effect): void;
  56996. /**
  56997. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56998. * (eq to view projection * shadow projection matrices)
  56999. * @returns The transform matrix used to create the shadow map
  57000. */
  57001. getTransformMatrix(): Matrix;
  57002. /**
  57003. * Disposes the ShadowGenerator.
  57004. * Returns nothing.
  57005. */
  57006. dispose(): void;
  57007. /**
  57008. * Serializes the shadow generator setup to a json object.
  57009. * @returns The serialized JSON object
  57010. */
  57011. serialize(): any;
  57012. /**
  57013. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57014. * @param parsedShadowGenerator The JSON object to parse
  57015. * @param scene The scene to create the shadow map for
  57016. * @returns The parsed shadow generator
  57017. */
  57018. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57019. }
  57020. }
  57021. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57022. import { Scene } from "babylonjs/scene";
  57023. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57024. import { AbstractScene } from "babylonjs/abstractScene";
  57025. /**
  57026. * Defines the shadow generator component responsible to manage any shadow generators
  57027. * in a given scene.
  57028. */
  57029. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57030. /**
  57031. * The component name helpfull to identify the component in the list of scene components.
  57032. */
  57033. readonly name: string;
  57034. /**
  57035. * The scene the component belongs to.
  57036. */
  57037. scene: Scene;
  57038. /**
  57039. * Creates a new instance of the component for the given scene
  57040. * @param scene Defines the scene to register the component in
  57041. */
  57042. constructor(scene: Scene);
  57043. /**
  57044. * Registers the component in a given scene
  57045. */
  57046. register(): void;
  57047. /**
  57048. * Rebuilds the elements related to this component in case of
  57049. * context lost for instance.
  57050. */
  57051. rebuild(): void;
  57052. /**
  57053. * Serializes the component data to the specified json object
  57054. * @param serializationObject The object to serialize to
  57055. */
  57056. serialize(serializationObject: any): void;
  57057. /**
  57058. * Adds all the elements from the container to the scene
  57059. * @param container the container holding the elements
  57060. */
  57061. addFromContainer(container: AbstractScene): void;
  57062. /**
  57063. * Removes all the elements in the container from the scene
  57064. * @param container contains the elements to remove
  57065. * @param dispose if the removed element should be disposed (default: false)
  57066. */
  57067. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57068. /**
  57069. * Rebuilds the elements related to this component in case of
  57070. * context lost for instance.
  57071. */
  57072. dispose(): void;
  57073. private _gatherRenderTargets;
  57074. }
  57075. }
  57076. declare module "babylonjs/Lights/Shadows/index" {
  57077. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57078. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57079. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57080. }
  57081. declare module "babylonjs/Lights/pointLight" {
  57082. import { Scene } from "babylonjs/scene";
  57083. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57085. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57086. import { Effect } from "babylonjs/Materials/effect";
  57087. /**
  57088. * A point light is a light defined by an unique point in world space.
  57089. * The light is emitted in every direction from this point.
  57090. * A good example of a point light is a standard light bulb.
  57091. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57092. */
  57093. export class PointLight extends ShadowLight {
  57094. private _shadowAngle;
  57095. /**
  57096. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57097. * This specifies what angle the shadow will use to be created.
  57098. *
  57099. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57100. */
  57101. get shadowAngle(): number;
  57102. /**
  57103. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57104. * This specifies what angle the shadow will use to be created.
  57105. *
  57106. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57107. */
  57108. set shadowAngle(value: number);
  57109. /**
  57110. * Gets the direction if it has been set.
  57111. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57112. */
  57113. get direction(): Vector3;
  57114. /**
  57115. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57116. */
  57117. set direction(value: Vector3);
  57118. /**
  57119. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57120. * A PointLight emits the light in every direction.
  57121. * It can cast shadows.
  57122. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57123. * ```javascript
  57124. * var pointLight = new PointLight("pl", camera.position, scene);
  57125. * ```
  57126. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57127. * @param name The light friendly name
  57128. * @param position The position of the point light in the scene
  57129. * @param scene The scene the lights belongs to
  57130. */
  57131. constructor(name: string, position: Vector3, scene: Scene);
  57132. /**
  57133. * Returns the string "PointLight"
  57134. * @returns the class name
  57135. */
  57136. getClassName(): string;
  57137. /**
  57138. * Returns the integer 0.
  57139. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57140. */
  57141. getTypeID(): number;
  57142. /**
  57143. * Specifies wether or not the shadowmap should be a cube texture.
  57144. * @returns true if the shadowmap needs to be a cube texture.
  57145. */
  57146. needCube(): boolean;
  57147. /**
  57148. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57149. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57150. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57151. */
  57152. getShadowDirection(faceIndex?: number): Vector3;
  57153. /**
  57154. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57155. * - fov = PI / 2
  57156. * - aspect ratio : 1.0
  57157. * - z-near and far equal to the active camera minZ and maxZ.
  57158. * Returns the PointLight.
  57159. */
  57160. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57161. protected _buildUniformLayout(): void;
  57162. /**
  57163. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57164. * @param effect The effect to update
  57165. * @param lightIndex The index of the light in the effect to update
  57166. * @returns The point light
  57167. */
  57168. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57169. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57170. /**
  57171. * Prepares the list of defines specific to the light type.
  57172. * @param defines the list of defines
  57173. * @param lightIndex defines the index of the light for the effect
  57174. */
  57175. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57176. }
  57177. }
  57178. declare module "babylonjs/Lights/index" {
  57179. export * from "babylonjs/Lights/light";
  57180. export * from "babylonjs/Lights/shadowLight";
  57181. export * from "babylonjs/Lights/Shadows/index";
  57182. export * from "babylonjs/Lights/directionalLight";
  57183. export * from "babylonjs/Lights/hemisphericLight";
  57184. export * from "babylonjs/Lights/pointLight";
  57185. export * from "babylonjs/Lights/spotLight";
  57186. }
  57187. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57188. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57189. /**
  57190. * Header information of HDR texture files.
  57191. */
  57192. export interface HDRInfo {
  57193. /**
  57194. * The height of the texture in pixels.
  57195. */
  57196. height: number;
  57197. /**
  57198. * The width of the texture in pixels.
  57199. */
  57200. width: number;
  57201. /**
  57202. * The index of the beginning of the data in the binary file.
  57203. */
  57204. dataPosition: number;
  57205. }
  57206. /**
  57207. * This groups tools to convert HDR texture to native colors array.
  57208. */
  57209. export class HDRTools {
  57210. private static Ldexp;
  57211. private static Rgbe2float;
  57212. private static readStringLine;
  57213. /**
  57214. * Reads header information from an RGBE texture stored in a native array.
  57215. * More information on this format are available here:
  57216. * https://en.wikipedia.org/wiki/RGBE_image_format
  57217. *
  57218. * @param uint8array The binary file stored in native array.
  57219. * @return The header information.
  57220. */
  57221. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57222. /**
  57223. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57224. * This RGBE texture needs to store the information as a panorama.
  57225. *
  57226. * More information on this format are available here:
  57227. * https://en.wikipedia.org/wiki/RGBE_image_format
  57228. *
  57229. * @param buffer The binary file stored in an array buffer.
  57230. * @param size The expected size of the extracted cubemap.
  57231. * @return The Cube Map information.
  57232. */
  57233. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57234. /**
  57235. * Returns the pixels data extracted from an RGBE texture.
  57236. * This pixels will be stored left to right up to down in the R G B order in one array.
  57237. *
  57238. * More information on this format are available here:
  57239. * https://en.wikipedia.org/wiki/RGBE_image_format
  57240. *
  57241. * @param uint8array The binary file stored in an array buffer.
  57242. * @param hdrInfo The header information of the file.
  57243. * @return The pixels data in RGB right to left up to down order.
  57244. */
  57245. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57246. private static RGBE_ReadPixels_RLE;
  57247. }
  57248. }
  57249. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57250. import { Nullable } from "babylonjs/types";
  57251. import { Scene } from "babylonjs/scene";
  57252. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57253. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57254. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57255. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57256. /**
  57257. * This represents a texture coming from an HDR input.
  57258. *
  57259. * The only supported format is currently panorama picture stored in RGBE format.
  57260. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57261. */
  57262. export class HDRCubeTexture extends BaseTexture {
  57263. private static _facesMapping;
  57264. private _generateHarmonics;
  57265. private _noMipmap;
  57266. private _textureMatrix;
  57267. private _size;
  57268. private _onLoad;
  57269. private _onError;
  57270. /**
  57271. * The texture URL.
  57272. */
  57273. url: string;
  57274. /**
  57275. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57276. */
  57277. coordinatesMode: number;
  57278. protected _isBlocking: boolean;
  57279. /**
  57280. * Sets wether or not the texture is blocking during loading.
  57281. */
  57282. set isBlocking(value: boolean);
  57283. /**
  57284. * Gets wether or not the texture is blocking during loading.
  57285. */
  57286. get isBlocking(): boolean;
  57287. protected _rotationY: number;
  57288. /**
  57289. * Sets texture matrix rotation angle around Y axis in radians.
  57290. */
  57291. set rotationY(value: number);
  57292. /**
  57293. * Gets texture matrix rotation angle around Y axis radians.
  57294. */
  57295. get rotationY(): number;
  57296. /**
  57297. * Gets or sets the center of the bounding box associated with the cube texture
  57298. * It must define where the camera used to render the texture was set
  57299. */
  57300. boundingBoxPosition: Vector3;
  57301. private _boundingBoxSize;
  57302. /**
  57303. * Gets or sets the size of the bounding box associated with the cube texture
  57304. * When defined, the cubemap will switch to local mode
  57305. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57306. * @example https://www.babylonjs-playground.com/#RNASML
  57307. */
  57308. set boundingBoxSize(value: Vector3);
  57309. get boundingBoxSize(): Vector3;
  57310. /**
  57311. * Instantiates an HDRTexture from the following parameters.
  57312. *
  57313. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57314. * @param scene The scene the texture will be used in
  57315. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57316. * @param noMipmap Forces to not generate the mipmap if true
  57317. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57318. * @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)
  57319. * @param reserved Reserved flag for internal use.
  57320. */
  57321. 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>);
  57322. /**
  57323. * Get the current class name of the texture useful for serialization or dynamic coding.
  57324. * @returns "HDRCubeTexture"
  57325. */
  57326. getClassName(): string;
  57327. /**
  57328. * Occurs when the file is raw .hdr file.
  57329. */
  57330. private loadTexture;
  57331. clone(): HDRCubeTexture;
  57332. delayLoad(): void;
  57333. /**
  57334. * Get the texture reflection matrix used to rotate/transform the reflection.
  57335. * @returns the reflection matrix
  57336. */
  57337. getReflectionTextureMatrix(): Matrix;
  57338. /**
  57339. * Set the texture reflection matrix used to rotate/transform the reflection.
  57340. * @param value Define the reflection matrix to set
  57341. */
  57342. setReflectionTextureMatrix(value: Matrix): void;
  57343. /**
  57344. * Parses a JSON representation of an HDR Texture in order to create the texture
  57345. * @param parsedTexture Define the JSON representation
  57346. * @param scene Define the scene the texture should be created in
  57347. * @param rootUrl Define the root url in case we need to load relative dependencies
  57348. * @returns the newly created texture after parsing
  57349. */
  57350. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57351. serialize(): any;
  57352. }
  57353. }
  57354. declare module "babylonjs/Physics/physicsEngine" {
  57355. import { Nullable } from "babylonjs/types";
  57356. import { Vector3 } from "babylonjs/Maths/math.vector";
  57357. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57358. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57359. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57360. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57361. /**
  57362. * Class used to control physics engine
  57363. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57364. */
  57365. export class PhysicsEngine implements IPhysicsEngine {
  57366. private _physicsPlugin;
  57367. /**
  57368. * Global value used to control the smallest number supported by the simulation
  57369. */
  57370. static Epsilon: number;
  57371. private _impostors;
  57372. private _joints;
  57373. private _subTimeStep;
  57374. /**
  57375. * Gets the gravity vector used by the simulation
  57376. */
  57377. gravity: Vector3;
  57378. /**
  57379. * Factory used to create the default physics plugin.
  57380. * @returns The default physics plugin
  57381. */
  57382. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57383. /**
  57384. * Creates a new Physics Engine
  57385. * @param gravity defines the gravity vector used by the simulation
  57386. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57387. */
  57388. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57389. /**
  57390. * Sets the gravity vector used by the simulation
  57391. * @param gravity defines the gravity vector to use
  57392. */
  57393. setGravity(gravity: Vector3): void;
  57394. /**
  57395. * Set the time step of the physics engine.
  57396. * Default is 1/60.
  57397. * To slow it down, enter 1/600 for example.
  57398. * To speed it up, 1/30
  57399. * @param newTimeStep defines the new timestep to apply to this world.
  57400. */
  57401. setTimeStep(newTimeStep?: number): void;
  57402. /**
  57403. * Get the time step of the physics engine.
  57404. * @returns the current time step
  57405. */
  57406. getTimeStep(): number;
  57407. /**
  57408. * Set the sub time step of the physics engine.
  57409. * Default is 0 meaning there is no sub steps
  57410. * To increase physics resolution precision, set a small value (like 1 ms)
  57411. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57412. */
  57413. setSubTimeStep(subTimeStep?: number): void;
  57414. /**
  57415. * Get the sub time step of the physics engine.
  57416. * @returns the current sub time step
  57417. */
  57418. getSubTimeStep(): number;
  57419. /**
  57420. * Release all resources
  57421. */
  57422. dispose(): void;
  57423. /**
  57424. * Gets the name of the current physics plugin
  57425. * @returns the name of the plugin
  57426. */
  57427. getPhysicsPluginName(): string;
  57428. /**
  57429. * Adding a new impostor for the impostor tracking.
  57430. * This will be done by the impostor itself.
  57431. * @param impostor the impostor to add
  57432. */
  57433. addImpostor(impostor: PhysicsImpostor): void;
  57434. /**
  57435. * Remove an impostor from the engine.
  57436. * This impostor and its mesh will not longer be updated by the physics engine.
  57437. * @param impostor the impostor to remove
  57438. */
  57439. removeImpostor(impostor: PhysicsImpostor): void;
  57440. /**
  57441. * Add a joint to the physics engine
  57442. * @param mainImpostor defines the main impostor to which the joint is added.
  57443. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57444. * @param joint defines the joint that will connect both impostors.
  57445. */
  57446. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57447. /**
  57448. * Removes a joint from the simulation
  57449. * @param mainImpostor defines the impostor used with the joint
  57450. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57451. * @param joint defines the joint to remove
  57452. */
  57453. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57454. /**
  57455. * Called by the scene. No need to call it.
  57456. * @param delta defines the timespam between frames
  57457. */
  57458. _step(delta: number): void;
  57459. /**
  57460. * Gets the current plugin used to run the simulation
  57461. * @returns current plugin
  57462. */
  57463. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57464. /**
  57465. * Gets the list of physic impostors
  57466. * @returns an array of PhysicsImpostor
  57467. */
  57468. getImpostors(): Array<PhysicsImpostor>;
  57469. /**
  57470. * Gets the impostor for a physics enabled object
  57471. * @param object defines the object impersonated by the impostor
  57472. * @returns the PhysicsImpostor or null if not found
  57473. */
  57474. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57475. /**
  57476. * Gets the impostor for a physics body object
  57477. * @param body defines physics body used by the impostor
  57478. * @returns the PhysicsImpostor or null if not found
  57479. */
  57480. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57481. /**
  57482. * Does a raycast in the physics world
  57483. * @param from when should the ray start?
  57484. * @param to when should the ray end?
  57485. * @returns PhysicsRaycastResult
  57486. */
  57487. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57488. }
  57489. }
  57490. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57491. import { Nullable } from "babylonjs/types";
  57492. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57494. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57495. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57496. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57497. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57498. /** @hidden */
  57499. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57500. private _useDeltaForWorldStep;
  57501. world: any;
  57502. name: string;
  57503. private _physicsMaterials;
  57504. private _fixedTimeStep;
  57505. private _cannonRaycastResult;
  57506. private _raycastResult;
  57507. private _physicsBodysToRemoveAfterStep;
  57508. BJSCANNON: any;
  57509. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57510. setGravity(gravity: Vector3): void;
  57511. setTimeStep(timeStep: number): void;
  57512. getTimeStep(): number;
  57513. executeStep(delta: number): void;
  57514. private _removeMarkedPhysicsBodiesFromWorld;
  57515. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57516. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57517. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57518. private _processChildMeshes;
  57519. removePhysicsBody(impostor: PhysicsImpostor): void;
  57520. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57521. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57522. private _addMaterial;
  57523. private _checkWithEpsilon;
  57524. private _createShape;
  57525. private _createHeightmap;
  57526. private _minus90X;
  57527. private _plus90X;
  57528. private _tmpPosition;
  57529. private _tmpDeltaPosition;
  57530. private _tmpUnityRotation;
  57531. private _updatePhysicsBodyTransformation;
  57532. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57533. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57534. isSupported(): boolean;
  57535. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57536. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57537. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57538. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57539. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57540. getBodyMass(impostor: PhysicsImpostor): number;
  57541. getBodyFriction(impostor: PhysicsImpostor): number;
  57542. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57543. getBodyRestitution(impostor: PhysicsImpostor): number;
  57544. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57545. sleepBody(impostor: PhysicsImpostor): void;
  57546. wakeUpBody(impostor: PhysicsImpostor): void;
  57547. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57548. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57549. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57550. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57551. getRadius(impostor: PhysicsImpostor): number;
  57552. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57553. dispose(): void;
  57554. private _extendNamespace;
  57555. /**
  57556. * Does a raycast in the physics world
  57557. * @param from when should the ray start?
  57558. * @param to when should the ray end?
  57559. * @returns PhysicsRaycastResult
  57560. */
  57561. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57562. }
  57563. }
  57564. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57565. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57566. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57567. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57569. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57570. import { Nullable } from "babylonjs/types";
  57571. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57572. /** @hidden */
  57573. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57574. world: any;
  57575. name: string;
  57576. BJSOIMO: any;
  57577. private _raycastResult;
  57578. constructor(iterations?: number, oimoInjection?: any);
  57579. setGravity(gravity: Vector3): void;
  57580. setTimeStep(timeStep: number): void;
  57581. getTimeStep(): number;
  57582. private _tmpImpostorsArray;
  57583. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57584. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57585. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57586. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57587. private _tmpPositionVector;
  57588. removePhysicsBody(impostor: PhysicsImpostor): void;
  57589. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57590. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57591. isSupported(): boolean;
  57592. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57593. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57594. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57595. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57596. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57597. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57598. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57599. getBodyMass(impostor: PhysicsImpostor): number;
  57600. getBodyFriction(impostor: PhysicsImpostor): number;
  57601. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57602. getBodyRestitution(impostor: PhysicsImpostor): number;
  57603. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57604. sleepBody(impostor: PhysicsImpostor): void;
  57605. wakeUpBody(impostor: PhysicsImpostor): void;
  57606. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57607. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57608. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57609. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57610. getRadius(impostor: PhysicsImpostor): number;
  57611. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57612. dispose(): void;
  57613. /**
  57614. * Does a raycast in the physics world
  57615. * @param from when should the ray start?
  57616. * @param to when should the ray end?
  57617. * @returns PhysicsRaycastResult
  57618. */
  57619. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57620. }
  57621. }
  57622. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57623. import { Nullable } from "babylonjs/types";
  57624. import { Scene } from "babylonjs/scene";
  57625. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57626. import { Color4 } from "babylonjs/Maths/math.color";
  57627. import { Mesh } from "babylonjs/Meshes/mesh";
  57628. /**
  57629. * Class containing static functions to help procedurally build meshes
  57630. */
  57631. export class RibbonBuilder {
  57632. /**
  57633. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57634. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57635. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57636. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57637. * * 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
  57638. * * 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
  57639. * * 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
  57640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57642. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57643. * * 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
  57644. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57645. * * 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
  57646. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57648. * @param name defines the name of the mesh
  57649. * @param options defines the options used to create the mesh
  57650. * @param scene defines the hosting scene
  57651. * @returns the ribbon mesh
  57652. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57653. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57654. */
  57655. static CreateRibbon(name: string, options: {
  57656. pathArray: Vector3[][];
  57657. closeArray?: boolean;
  57658. closePath?: boolean;
  57659. offset?: number;
  57660. updatable?: boolean;
  57661. sideOrientation?: number;
  57662. frontUVs?: Vector4;
  57663. backUVs?: Vector4;
  57664. instance?: Mesh;
  57665. invertUV?: boolean;
  57666. uvs?: Vector2[];
  57667. colors?: Color4[];
  57668. }, scene?: Nullable<Scene>): Mesh;
  57669. }
  57670. }
  57671. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57672. import { Nullable } from "babylonjs/types";
  57673. import { Scene } from "babylonjs/scene";
  57674. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57675. import { Mesh } from "babylonjs/Meshes/mesh";
  57676. /**
  57677. * Class containing static functions to help procedurally build meshes
  57678. */
  57679. export class ShapeBuilder {
  57680. /**
  57681. * 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.
  57682. * * 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.
  57683. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57684. * * 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.
  57685. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57686. * * 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
  57687. * * 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
  57688. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57693. * @param name defines the name of the mesh
  57694. * @param options defines the options used to create the mesh
  57695. * @param scene defines the hosting scene
  57696. * @returns the extruded shape mesh
  57697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57699. */
  57700. static ExtrudeShape(name: string, options: {
  57701. shape: Vector3[];
  57702. path: Vector3[];
  57703. scale?: number;
  57704. rotation?: number;
  57705. cap?: number;
  57706. updatable?: boolean;
  57707. sideOrientation?: number;
  57708. frontUVs?: Vector4;
  57709. backUVs?: Vector4;
  57710. instance?: Mesh;
  57711. invertUV?: boolean;
  57712. }, scene?: Nullable<Scene>): Mesh;
  57713. /**
  57714. * Creates an custom extruded shape mesh.
  57715. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57716. * * 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.
  57717. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57718. * * 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
  57719. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57720. * * 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
  57721. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57722. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57723. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57724. * * 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
  57725. * * 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
  57726. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57729. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57731. * @param name defines the name of the mesh
  57732. * @param options defines the options used to create the mesh
  57733. * @param scene defines the hosting scene
  57734. * @returns the custom extruded shape mesh
  57735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57738. */
  57739. static ExtrudeShapeCustom(name: string, options: {
  57740. shape: Vector3[];
  57741. path: Vector3[];
  57742. scaleFunction?: any;
  57743. rotationFunction?: any;
  57744. ribbonCloseArray?: boolean;
  57745. ribbonClosePath?: boolean;
  57746. cap?: number;
  57747. updatable?: boolean;
  57748. sideOrientation?: number;
  57749. frontUVs?: Vector4;
  57750. backUVs?: Vector4;
  57751. instance?: Mesh;
  57752. invertUV?: boolean;
  57753. }, scene?: Nullable<Scene>): Mesh;
  57754. private static _ExtrudeShapeGeneric;
  57755. }
  57756. }
  57757. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57758. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57759. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57760. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57761. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57762. import { Nullable } from "babylonjs/types";
  57763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57764. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57765. /**
  57766. * AmmoJS Physics plugin
  57767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57768. * @see https://github.com/kripken/ammo.js/
  57769. */
  57770. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57771. private _useDeltaForWorldStep;
  57772. /**
  57773. * Reference to the Ammo library
  57774. */
  57775. bjsAMMO: any;
  57776. /**
  57777. * Created ammoJS world which physics bodies are added to
  57778. */
  57779. world: any;
  57780. /**
  57781. * Name of the plugin
  57782. */
  57783. name: string;
  57784. private _timeStep;
  57785. private _fixedTimeStep;
  57786. private _maxSteps;
  57787. private _tmpQuaternion;
  57788. private _tmpAmmoTransform;
  57789. private _tmpAmmoQuaternion;
  57790. private _tmpAmmoConcreteContactResultCallback;
  57791. private _collisionConfiguration;
  57792. private _dispatcher;
  57793. private _overlappingPairCache;
  57794. private _solver;
  57795. private _softBodySolver;
  57796. private _tmpAmmoVectorA;
  57797. private _tmpAmmoVectorB;
  57798. private _tmpAmmoVectorC;
  57799. private _tmpAmmoVectorD;
  57800. private _tmpContactCallbackResult;
  57801. private _tmpAmmoVectorRCA;
  57802. private _tmpAmmoVectorRCB;
  57803. private _raycastResult;
  57804. private static readonly DISABLE_COLLISION_FLAG;
  57805. private static readonly KINEMATIC_FLAG;
  57806. private static readonly DISABLE_DEACTIVATION_FLAG;
  57807. /**
  57808. * Initializes the ammoJS plugin
  57809. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57810. * @param ammoInjection can be used to inject your own ammo reference
  57811. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57812. */
  57813. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57814. /**
  57815. * Sets the gravity of the physics world (m/(s^2))
  57816. * @param gravity Gravity to set
  57817. */
  57818. setGravity(gravity: Vector3): void;
  57819. /**
  57820. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57821. * @param timeStep timestep to use in seconds
  57822. */
  57823. setTimeStep(timeStep: number): void;
  57824. /**
  57825. * 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)
  57826. * @param fixedTimeStep fixedTimeStep to use in seconds
  57827. */
  57828. setFixedTimeStep(fixedTimeStep: number): void;
  57829. /**
  57830. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57831. * @param maxSteps the maximum number of steps by the physics engine per frame
  57832. */
  57833. setMaxSteps(maxSteps: number): void;
  57834. /**
  57835. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57836. * @returns the current timestep in seconds
  57837. */
  57838. getTimeStep(): number;
  57839. /**
  57840. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57841. */
  57842. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57843. private _isImpostorInContact;
  57844. private _isImpostorPairInContact;
  57845. private _stepSimulation;
  57846. /**
  57847. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57848. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57849. * After the step the babylon meshes are set to the position of the physics imposters
  57850. * @param delta amount of time to step forward
  57851. * @param impostors array of imposters to update before/after the step
  57852. */
  57853. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57854. /**
  57855. * Update babylon mesh to match physics world object
  57856. * @param impostor imposter to match
  57857. */
  57858. private _afterSoftStep;
  57859. /**
  57860. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57861. * @param impostor imposter to match
  57862. */
  57863. private _ropeStep;
  57864. /**
  57865. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57866. * @param impostor imposter to match
  57867. */
  57868. private _softbodyOrClothStep;
  57869. private _tmpVector;
  57870. private _tmpMatrix;
  57871. /**
  57872. * Applies an impulse on the imposter
  57873. * @param impostor imposter to apply impulse to
  57874. * @param force amount of force to be applied to the imposter
  57875. * @param contactPoint the location to apply the impulse on the imposter
  57876. */
  57877. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57878. /**
  57879. * Applies a force on the imposter
  57880. * @param impostor imposter to apply force
  57881. * @param force amount of force to be applied to the imposter
  57882. * @param contactPoint the location to apply the force on the imposter
  57883. */
  57884. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57885. /**
  57886. * Creates a physics body using the plugin
  57887. * @param impostor the imposter to create the physics body on
  57888. */
  57889. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57890. /**
  57891. * Removes the physics body from the imposter and disposes of the body's memory
  57892. * @param impostor imposter to remove the physics body from
  57893. */
  57894. removePhysicsBody(impostor: PhysicsImpostor): void;
  57895. /**
  57896. * Generates a joint
  57897. * @param impostorJoint the imposter joint to create the joint with
  57898. */
  57899. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57900. /**
  57901. * Removes a joint
  57902. * @param impostorJoint the imposter joint to remove the joint from
  57903. */
  57904. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57905. private _addMeshVerts;
  57906. /**
  57907. * Initialise the soft body vertices to match its object's (mesh) vertices
  57908. * Softbody vertices (nodes) are in world space and to match this
  57909. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57910. * @param impostor to create the softbody for
  57911. */
  57912. private _softVertexData;
  57913. /**
  57914. * Create an impostor's soft body
  57915. * @param impostor to create the softbody for
  57916. */
  57917. private _createSoftbody;
  57918. /**
  57919. * Create cloth for an impostor
  57920. * @param impostor to create the softbody for
  57921. */
  57922. private _createCloth;
  57923. /**
  57924. * Create rope for an impostor
  57925. * @param impostor to create the softbody for
  57926. */
  57927. private _createRope;
  57928. /**
  57929. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57930. * @param impostor to create the custom physics shape for
  57931. */
  57932. private _createCustom;
  57933. private _addHullVerts;
  57934. private _createShape;
  57935. /**
  57936. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57937. * @param impostor imposter containing the physics body and babylon object
  57938. */
  57939. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57940. /**
  57941. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57942. * @param impostor imposter containing the physics body and babylon object
  57943. * @param newPosition new position
  57944. * @param newRotation new rotation
  57945. */
  57946. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57947. /**
  57948. * If this plugin is supported
  57949. * @returns true if its supported
  57950. */
  57951. isSupported(): boolean;
  57952. /**
  57953. * Sets the linear velocity of the physics body
  57954. * @param impostor imposter to set the velocity on
  57955. * @param velocity velocity to set
  57956. */
  57957. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57958. /**
  57959. * Sets the angular velocity of the physics body
  57960. * @param impostor imposter to set the velocity on
  57961. * @param velocity velocity to set
  57962. */
  57963. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57964. /**
  57965. * gets the linear velocity
  57966. * @param impostor imposter to get linear velocity from
  57967. * @returns linear velocity
  57968. */
  57969. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57970. /**
  57971. * gets the angular velocity
  57972. * @param impostor imposter to get angular velocity from
  57973. * @returns angular velocity
  57974. */
  57975. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57976. /**
  57977. * Sets the mass of physics body
  57978. * @param impostor imposter to set the mass on
  57979. * @param mass mass to set
  57980. */
  57981. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57982. /**
  57983. * Gets the mass of the physics body
  57984. * @param impostor imposter to get the mass from
  57985. * @returns mass
  57986. */
  57987. getBodyMass(impostor: PhysicsImpostor): number;
  57988. /**
  57989. * Gets friction of the impostor
  57990. * @param impostor impostor to get friction from
  57991. * @returns friction value
  57992. */
  57993. getBodyFriction(impostor: PhysicsImpostor): number;
  57994. /**
  57995. * Sets friction of the impostor
  57996. * @param impostor impostor to set friction on
  57997. * @param friction friction value
  57998. */
  57999. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58000. /**
  58001. * Gets restitution of the impostor
  58002. * @param impostor impostor to get restitution from
  58003. * @returns restitution value
  58004. */
  58005. getBodyRestitution(impostor: PhysicsImpostor): number;
  58006. /**
  58007. * Sets resitution of the impostor
  58008. * @param impostor impostor to set resitution on
  58009. * @param restitution resitution value
  58010. */
  58011. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58012. /**
  58013. * Gets pressure inside the impostor
  58014. * @param impostor impostor to get pressure from
  58015. * @returns pressure value
  58016. */
  58017. getBodyPressure(impostor: PhysicsImpostor): number;
  58018. /**
  58019. * Sets pressure inside a soft body impostor
  58020. * Cloth and rope must remain 0 pressure
  58021. * @param impostor impostor to set pressure on
  58022. * @param pressure pressure value
  58023. */
  58024. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58025. /**
  58026. * Gets stiffness of the impostor
  58027. * @param impostor impostor to get stiffness from
  58028. * @returns pressure value
  58029. */
  58030. getBodyStiffness(impostor: PhysicsImpostor): number;
  58031. /**
  58032. * Sets stiffness of the impostor
  58033. * @param impostor impostor to set stiffness on
  58034. * @param stiffness stiffness value from 0 to 1
  58035. */
  58036. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58037. /**
  58038. * Gets velocityIterations of the impostor
  58039. * @param impostor impostor to get velocity iterations from
  58040. * @returns velocityIterations value
  58041. */
  58042. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58043. /**
  58044. * Sets velocityIterations of the impostor
  58045. * @param impostor impostor to set velocity iterations on
  58046. * @param velocityIterations velocityIterations value
  58047. */
  58048. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58049. /**
  58050. * Gets positionIterations of the impostor
  58051. * @param impostor impostor to get position iterations from
  58052. * @returns positionIterations value
  58053. */
  58054. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58055. /**
  58056. * Sets positionIterations of the impostor
  58057. * @param impostor impostor to set position on
  58058. * @param positionIterations positionIterations value
  58059. */
  58060. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58061. /**
  58062. * Append an anchor to a cloth object
  58063. * @param impostor is the cloth impostor to add anchor to
  58064. * @param otherImpostor is the rigid impostor to anchor to
  58065. * @param width ratio across width from 0 to 1
  58066. * @param height ratio up height from 0 to 1
  58067. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58068. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58069. */
  58070. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58071. /**
  58072. * Append an hook to a rope object
  58073. * @param impostor is the rope impostor to add hook to
  58074. * @param otherImpostor is the rigid impostor to hook to
  58075. * @param length ratio along the rope from 0 to 1
  58076. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58077. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58078. */
  58079. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58080. /**
  58081. * Sleeps the physics body and stops it from being active
  58082. * @param impostor impostor to sleep
  58083. */
  58084. sleepBody(impostor: PhysicsImpostor): void;
  58085. /**
  58086. * Activates the physics body
  58087. * @param impostor impostor to activate
  58088. */
  58089. wakeUpBody(impostor: PhysicsImpostor): void;
  58090. /**
  58091. * Updates the distance parameters of the joint
  58092. * @param joint joint to update
  58093. * @param maxDistance maximum distance of the joint
  58094. * @param minDistance minimum distance of the joint
  58095. */
  58096. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58097. /**
  58098. * Sets a motor on the joint
  58099. * @param joint joint to set motor on
  58100. * @param speed speed of the motor
  58101. * @param maxForce maximum force of the motor
  58102. * @param motorIndex index of the motor
  58103. */
  58104. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58105. /**
  58106. * Sets the motors limit
  58107. * @param joint joint to set limit on
  58108. * @param upperLimit upper limit
  58109. * @param lowerLimit lower limit
  58110. */
  58111. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58112. /**
  58113. * Syncs the position and rotation of a mesh with the impostor
  58114. * @param mesh mesh to sync
  58115. * @param impostor impostor to update the mesh with
  58116. */
  58117. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58118. /**
  58119. * Gets the radius of the impostor
  58120. * @param impostor impostor to get radius from
  58121. * @returns the radius
  58122. */
  58123. getRadius(impostor: PhysicsImpostor): number;
  58124. /**
  58125. * Gets the box size of the impostor
  58126. * @param impostor impostor to get box size from
  58127. * @param result the resulting box size
  58128. */
  58129. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58130. /**
  58131. * Disposes of the impostor
  58132. */
  58133. dispose(): void;
  58134. /**
  58135. * Does a raycast in the physics world
  58136. * @param from when should the ray start?
  58137. * @param to when should the ray end?
  58138. * @returns PhysicsRaycastResult
  58139. */
  58140. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58141. }
  58142. }
  58143. declare module "babylonjs/Probes/reflectionProbe" {
  58144. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58145. import { Vector3 } from "babylonjs/Maths/math.vector";
  58146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58147. import { Nullable } from "babylonjs/types";
  58148. import { Scene } from "babylonjs/scene";
  58149. module "babylonjs/abstractScene" {
  58150. interface AbstractScene {
  58151. /**
  58152. * The list of reflection probes added to the scene
  58153. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58154. */
  58155. reflectionProbes: Array<ReflectionProbe>;
  58156. /**
  58157. * Removes the given reflection probe from this scene.
  58158. * @param toRemove The reflection probe to remove
  58159. * @returns The index of the removed reflection probe
  58160. */
  58161. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58162. /**
  58163. * Adds the given reflection probe to this scene.
  58164. * @param newReflectionProbe The reflection probe to add
  58165. */
  58166. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58167. }
  58168. }
  58169. /**
  58170. * Class used to generate realtime reflection / refraction cube textures
  58171. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58172. */
  58173. export class ReflectionProbe {
  58174. /** defines the name of the probe */
  58175. name: string;
  58176. private _scene;
  58177. private _renderTargetTexture;
  58178. private _projectionMatrix;
  58179. private _viewMatrix;
  58180. private _target;
  58181. private _add;
  58182. private _attachedMesh;
  58183. private _invertYAxis;
  58184. /** Gets or sets probe position (center of the cube map) */
  58185. position: Vector3;
  58186. /**
  58187. * Creates a new reflection probe
  58188. * @param name defines the name of the probe
  58189. * @param size defines the texture resolution (for each face)
  58190. * @param scene defines the hosting scene
  58191. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58192. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58193. */
  58194. constructor(
  58195. /** defines the name of the probe */
  58196. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58197. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58198. get samples(): number;
  58199. set samples(value: number);
  58200. /** Gets or sets the refresh rate to use (on every frame by default) */
  58201. get refreshRate(): number;
  58202. set refreshRate(value: number);
  58203. /**
  58204. * Gets the hosting scene
  58205. * @returns a Scene
  58206. */
  58207. getScene(): Scene;
  58208. /** Gets the internal CubeTexture used to render to */
  58209. get cubeTexture(): RenderTargetTexture;
  58210. /** Gets the list of meshes to render */
  58211. get renderList(): Nullable<AbstractMesh[]>;
  58212. /**
  58213. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58214. * @param mesh defines the mesh to attach to
  58215. */
  58216. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58217. /**
  58218. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58219. * @param renderingGroupId The rendering group id corresponding to its index
  58220. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58221. */
  58222. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58223. /**
  58224. * Clean all associated resources
  58225. */
  58226. dispose(): void;
  58227. /**
  58228. * Converts the reflection probe information to a readable string for debug purpose.
  58229. * @param fullDetails Supports for multiple levels of logging within scene loading
  58230. * @returns the human readable reflection probe info
  58231. */
  58232. toString(fullDetails?: boolean): string;
  58233. /**
  58234. * Get the class name of the relfection probe.
  58235. * @returns "ReflectionProbe"
  58236. */
  58237. getClassName(): string;
  58238. /**
  58239. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58240. * @returns The JSON representation of the texture
  58241. */
  58242. serialize(): any;
  58243. /**
  58244. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58245. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58246. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58247. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58248. * @returns The parsed reflection probe if successful
  58249. */
  58250. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58251. }
  58252. }
  58253. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58254. /** @hidden */
  58255. export var _BabylonLoaderRegistered: boolean;
  58256. /**
  58257. * Helps setting up some configuration for the babylon file loader.
  58258. */
  58259. export class BabylonFileLoaderConfiguration {
  58260. /**
  58261. * The loader does not allow injecting custom physix engine into the plugins.
  58262. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58263. * So you could set this variable to your engine import to make it work.
  58264. */
  58265. static LoaderInjectedPhysicsEngine: any;
  58266. }
  58267. }
  58268. declare module "babylonjs/Loading/Plugins/index" {
  58269. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58270. }
  58271. declare module "babylonjs/Loading/index" {
  58272. export * from "babylonjs/Loading/loadingScreen";
  58273. export * from "babylonjs/Loading/Plugins/index";
  58274. export * from "babylonjs/Loading/sceneLoader";
  58275. export * from "babylonjs/Loading/sceneLoaderFlags";
  58276. }
  58277. declare module "babylonjs/Materials/Background/index" {
  58278. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58279. }
  58280. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58281. import { Scene } from "babylonjs/scene";
  58282. import { Color3 } from "babylonjs/Maths/math.color";
  58283. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58284. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58285. /**
  58286. * The Physically based simple base material of BJS.
  58287. *
  58288. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58289. * It is used as the base class for both the specGloss and metalRough conventions.
  58290. */
  58291. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58292. /**
  58293. * Number of Simultaneous lights allowed on the material.
  58294. */
  58295. maxSimultaneousLights: number;
  58296. /**
  58297. * If sets to true, disables all the lights affecting the material.
  58298. */
  58299. disableLighting: boolean;
  58300. /**
  58301. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58302. */
  58303. environmentTexture: BaseTexture;
  58304. /**
  58305. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58306. */
  58307. invertNormalMapX: boolean;
  58308. /**
  58309. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58310. */
  58311. invertNormalMapY: boolean;
  58312. /**
  58313. * Normal map used in the model.
  58314. */
  58315. normalTexture: BaseTexture;
  58316. /**
  58317. * Emissivie color used to self-illuminate the model.
  58318. */
  58319. emissiveColor: Color3;
  58320. /**
  58321. * Emissivie texture used to self-illuminate the model.
  58322. */
  58323. emissiveTexture: BaseTexture;
  58324. /**
  58325. * Occlusion Channel Strenght.
  58326. */
  58327. occlusionStrength: number;
  58328. /**
  58329. * Occlusion Texture of the material (adding extra occlusion effects).
  58330. */
  58331. occlusionTexture: BaseTexture;
  58332. /**
  58333. * Defines the alpha limits in alpha test mode.
  58334. */
  58335. alphaCutOff: number;
  58336. /**
  58337. * Gets the current double sided mode.
  58338. */
  58339. get doubleSided(): boolean;
  58340. /**
  58341. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58342. */
  58343. set doubleSided(value: boolean);
  58344. /**
  58345. * Stores the pre-calculated light information of a mesh in a texture.
  58346. */
  58347. lightmapTexture: BaseTexture;
  58348. /**
  58349. * If true, the light map contains occlusion information instead of lighting info.
  58350. */
  58351. useLightmapAsShadowmap: boolean;
  58352. /**
  58353. * Instantiates a new PBRMaterial instance.
  58354. *
  58355. * @param name The material name
  58356. * @param scene The scene the material will be use in.
  58357. */
  58358. constructor(name: string, scene: Scene);
  58359. getClassName(): string;
  58360. }
  58361. }
  58362. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58363. import { Scene } from "babylonjs/scene";
  58364. import { Color3 } from "babylonjs/Maths/math.color";
  58365. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58366. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58367. /**
  58368. * The PBR material of BJS following the metal roughness convention.
  58369. *
  58370. * This fits to the PBR convention in the GLTF definition:
  58371. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58372. */
  58373. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58374. /**
  58375. * The base color has two different interpretations depending on the value of metalness.
  58376. * When the material is a metal, the base color is the specific measured reflectance value
  58377. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58378. * of the material.
  58379. */
  58380. baseColor: Color3;
  58381. /**
  58382. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58383. * well as opacity information in the alpha channel.
  58384. */
  58385. baseTexture: BaseTexture;
  58386. /**
  58387. * Specifies the metallic scalar value of the material.
  58388. * Can also be used to scale the metalness values of the metallic texture.
  58389. */
  58390. metallic: number;
  58391. /**
  58392. * Specifies the roughness scalar value of the material.
  58393. * Can also be used to scale the roughness values of the metallic texture.
  58394. */
  58395. roughness: number;
  58396. /**
  58397. * Texture containing both the metallic value in the B channel and the
  58398. * roughness value in the G channel to keep better precision.
  58399. */
  58400. metallicRoughnessTexture: BaseTexture;
  58401. /**
  58402. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58403. *
  58404. * @param name The material name
  58405. * @param scene The scene the material will be use in.
  58406. */
  58407. constructor(name: string, scene: Scene);
  58408. /**
  58409. * Return the currrent class name of the material.
  58410. */
  58411. getClassName(): string;
  58412. /**
  58413. * Makes a duplicate of the current material.
  58414. * @param name - name to use for the new material.
  58415. */
  58416. clone(name: string): PBRMetallicRoughnessMaterial;
  58417. /**
  58418. * Serialize the material to a parsable JSON object.
  58419. */
  58420. serialize(): any;
  58421. /**
  58422. * Parses a JSON object correponding to the serialize function.
  58423. */
  58424. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58425. }
  58426. }
  58427. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58428. import { Scene } from "babylonjs/scene";
  58429. import { Color3 } from "babylonjs/Maths/math.color";
  58430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58431. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58432. /**
  58433. * The PBR material of BJS following the specular glossiness convention.
  58434. *
  58435. * This fits to the PBR convention in the GLTF definition:
  58436. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58437. */
  58438. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58439. /**
  58440. * Specifies the diffuse color of the material.
  58441. */
  58442. diffuseColor: Color3;
  58443. /**
  58444. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58445. * channel.
  58446. */
  58447. diffuseTexture: BaseTexture;
  58448. /**
  58449. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58450. */
  58451. specularColor: Color3;
  58452. /**
  58453. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58454. */
  58455. glossiness: number;
  58456. /**
  58457. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58458. */
  58459. specularGlossinessTexture: BaseTexture;
  58460. /**
  58461. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58462. *
  58463. * @param name The material name
  58464. * @param scene The scene the material will be use in.
  58465. */
  58466. constructor(name: string, scene: Scene);
  58467. /**
  58468. * Return the currrent class name of the material.
  58469. */
  58470. getClassName(): string;
  58471. /**
  58472. * Makes a duplicate of the current material.
  58473. * @param name - name to use for the new material.
  58474. */
  58475. clone(name: string): PBRSpecularGlossinessMaterial;
  58476. /**
  58477. * Serialize the material to a parsable JSON object.
  58478. */
  58479. serialize(): any;
  58480. /**
  58481. * Parses a JSON object correponding to the serialize function.
  58482. */
  58483. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58484. }
  58485. }
  58486. declare module "babylonjs/Materials/PBR/index" {
  58487. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58488. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58489. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58490. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58491. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58492. }
  58493. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58494. import { Nullable } from "babylonjs/types";
  58495. import { Scene } from "babylonjs/scene";
  58496. import { Matrix } from "babylonjs/Maths/math.vector";
  58497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58498. /**
  58499. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58500. * It can help converting any input color in a desired output one. This can then be used to create effects
  58501. * from sepia, black and white to sixties or futuristic rendering...
  58502. *
  58503. * The only supported format is currently 3dl.
  58504. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58505. */
  58506. export class ColorGradingTexture extends BaseTexture {
  58507. /**
  58508. * The current texture matrix. (will always be identity in color grading texture)
  58509. */
  58510. private _textureMatrix;
  58511. /**
  58512. * The texture URL.
  58513. */
  58514. url: string;
  58515. /**
  58516. * Empty line regex stored for GC.
  58517. */
  58518. private static _noneEmptyLineRegex;
  58519. private _engine;
  58520. /**
  58521. * Instantiates a ColorGradingTexture from the following parameters.
  58522. *
  58523. * @param url The location of the color gradind data (currently only supporting 3dl)
  58524. * @param scene The scene the texture will be used in
  58525. */
  58526. constructor(url: string, scene: Scene);
  58527. /**
  58528. * Returns the texture matrix used in most of the material.
  58529. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58530. */
  58531. getTextureMatrix(): Matrix;
  58532. /**
  58533. * Occurs when the file being loaded is a .3dl LUT file.
  58534. */
  58535. private load3dlTexture;
  58536. /**
  58537. * Starts the loading process of the texture.
  58538. */
  58539. private loadTexture;
  58540. /**
  58541. * Clones the color gradind texture.
  58542. */
  58543. clone(): ColorGradingTexture;
  58544. /**
  58545. * Called during delayed load for textures.
  58546. */
  58547. delayLoad(): void;
  58548. /**
  58549. * Parses a color grading texture serialized by Babylon.
  58550. * @param parsedTexture The texture information being parsedTexture
  58551. * @param scene The scene to load the texture in
  58552. * @param rootUrl The root url of the data assets to load
  58553. * @return A color gradind texture
  58554. */
  58555. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58556. /**
  58557. * Serializes the LUT texture to json format.
  58558. */
  58559. serialize(): any;
  58560. }
  58561. }
  58562. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58564. import { Scene } from "babylonjs/scene";
  58565. import { Nullable } from "babylonjs/types";
  58566. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58567. /**
  58568. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58569. */
  58570. export class EquiRectangularCubeTexture extends BaseTexture {
  58571. /** The six faces of the cube. */
  58572. private static _FacesMapping;
  58573. private _noMipmap;
  58574. private _onLoad;
  58575. private _onError;
  58576. /** The size of the cubemap. */
  58577. private _size;
  58578. /** The buffer of the image. */
  58579. private _buffer;
  58580. /** The width of the input image. */
  58581. private _width;
  58582. /** The height of the input image. */
  58583. private _height;
  58584. /** The URL to the image. */
  58585. url: string;
  58586. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58587. coordinatesMode: number;
  58588. /**
  58589. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58590. * @param url The location of the image
  58591. * @param scene The scene the texture will be used in
  58592. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58593. * @param noMipmap Forces to not generate the mipmap if true
  58594. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58595. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58596. * @param onLoad — defines a callback called when texture is loaded
  58597. * @param onError — defines a callback called if there is an error
  58598. */
  58599. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58600. /**
  58601. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58602. */
  58603. private loadImage;
  58604. /**
  58605. * Convert the image buffer into a cubemap and create a CubeTexture.
  58606. */
  58607. private loadTexture;
  58608. /**
  58609. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58610. * @param buffer The ArrayBuffer that should be converted.
  58611. * @returns The buffer as Float32Array.
  58612. */
  58613. private getFloat32ArrayFromArrayBuffer;
  58614. /**
  58615. * Get the current class name of the texture useful for serialization or dynamic coding.
  58616. * @returns "EquiRectangularCubeTexture"
  58617. */
  58618. getClassName(): string;
  58619. /**
  58620. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58621. * @returns A clone of the current EquiRectangularCubeTexture.
  58622. */
  58623. clone(): EquiRectangularCubeTexture;
  58624. }
  58625. }
  58626. declare module "babylonjs/Misc/tga" {
  58627. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58628. /**
  58629. * Based on jsTGALoader - Javascript loader for TGA file
  58630. * By Vincent Thibault
  58631. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58632. */
  58633. export class TGATools {
  58634. private static _TYPE_INDEXED;
  58635. private static _TYPE_RGB;
  58636. private static _TYPE_GREY;
  58637. private static _TYPE_RLE_INDEXED;
  58638. private static _TYPE_RLE_RGB;
  58639. private static _TYPE_RLE_GREY;
  58640. private static _ORIGIN_MASK;
  58641. private static _ORIGIN_SHIFT;
  58642. private static _ORIGIN_BL;
  58643. private static _ORIGIN_BR;
  58644. private static _ORIGIN_UL;
  58645. private static _ORIGIN_UR;
  58646. /**
  58647. * Gets the header of a TGA file
  58648. * @param data defines the TGA data
  58649. * @returns the header
  58650. */
  58651. static GetTGAHeader(data: Uint8Array): any;
  58652. /**
  58653. * Uploads TGA content to a Babylon Texture
  58654. * @hidden
  58655. */
  58656. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58657. /** @hidden */
  58658. 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;
  58659. /** @hidden */
  58660. 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;
  58661. /** @hidden */
  58662. 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;
  58663. /** @hidden */
  58664. 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;
  58665. /** @hidden */
  58666. 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;
  58667. /** @hidden */
  58668. 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;
  58669. }
  58670. }
  58671. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58672. import { Nullable } from "babylonjs/types";
  58673. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58674. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58675. /**
  58676. * Implementation of the TGA Texture Loader.
  58677. * @hidden
  58678. */
  58679. export class _TGATextureLoader implements IInternalTextureLoader {
  58680. /**
  58681. * Defines wether the loader supports cascade loading the different faces.
  58682. */
  58683. readonly supportCascades: boolean;
  58684. /**
  58685. * This returns if the loader support the current file information.
  58686. * @param extension defines the file extension of the file being loaded
  58687. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58688. * @param fallback defines the fallback internal texture if any
  58689. * @param isBase64 defines whether the texture is encoded as a base64
  58690. * @param isBuffer defines whether the texture data are stored as a buffer
  58691. * @returns true if the loader can load the specified file
  58692. */
  58693. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58694. /**
  58695. * Transform the url before loading if required.
  58696. * @param rootUrl the url of the texture
  58697. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58698. * @returns the transformed texture
  58699. */
  58700. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58701. /**
  58702. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58703. * @param rootUrl the url of the texture
  58704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58705. * @returns the fallback texture
  58706. */
  58707. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58708. /**
  58709. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58710. * @param data contains the texture data
  58711. * @param texture defines the BabylonJS internal texture
  58712. * @param createPolynomials will be true if polynomials have been requested
  58713. * @param onLoad defines the callback to trigger once the texture is ready
  58714. * @param onError defines the callback to trigger in case of error
  58715. */
  58716. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58717. /**
  58718. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58719. * @param data contains the texture data
  58720. * @param texture defines the BabylonJS internal texture
  58721. * @param callback defines the method to call once ready to upload
  58722. */
  58723. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58724. }
  58725. }
  58726. declare module "babylonjs/Misc/basis" {
  58727. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58728. /**
  58729. * Info about the .basis files
  58730. */
  58731. class BasisFileInfo {
  58732. /**
  58733. * If the file has alpha
  58734. */
  58735. hasAlpha: boolean;
  58736. /**
  58737. * Info about each image of the basis file
  58738. */
  58739. images: Array<{
  58740. levels: Array<{
  58741. width: number;
  58742. height: number;
  58743. transcodedPixels: ArrayBufferView;
  58744. }>;
  58745. }>;
  58746. }
  58747. /**
  58748. * Result of transcoding a basis file
  58749. */
  58750. class TranscodeResult {
  58751. /**
  58752. * Info about the .basis file
  58753. */
  58754. fileInfo: BasisFileInfo;
  58755. /**
  58756. * Format to use when loading the file
  58757. */
  58758. format: number;
  58759. }
  58760. /**
  58761. * Configuration options for the Basis transcoder
  58762. */
  58763. export class BasisTranscodeConfiguration {
  58764. /**
  58765. * Supported compression formats used to determine the supported output format of the transcoder
  58766. */
  58767. supportedCompressionFormats?: {
  58768. /**
  58769. * etc1 compression format
  58770. */
  58771. etc1?: boolean;
  58772. /**
  58773. * s3tc compression format
  58774. */
  58775. s3tc?: boolean;
  58776. /**
  58777. * pvrtc compression format
  58778. */
  58779. pvrtc?: boolean;
  58780. /**
  58781. * etc2 compression format
  58782. */
  58783. etc2?: boolean;
  58784. };
  58785. /**
  58786. * If mipmap levels should be loaded for transcoded images (Default: true)
  58787. */
  58788. loadMipmapLevels?: boolean;
  58789. /**
  58790. * Index of a single image to load (Default: all images)
  58791. */
  58792. loadSingleImage?: number;
  58793. }
  58794. /**
  58795. * Used to load .Basis files
  58796. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58797. */
  58798. export class BasisTools {
  58799. private static _IgnoreSupportedFormats;
  58800. /**
  58801. * URL to use when loading the basis transcoder
  58802. */
  58803. static JSModuleURL: string;
  58804. /**
  58805. * URL to use when loading the wasm module for the transcoder
  58806. */
  58807. static WasmModuleURL: string;
  58808. /**
  58809. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58810. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58811. * @returns internal format corresponding to the Basis format
  58812. */
  58813. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58814. private static _WorkerPromise;
  58815. private static _Worker;
  58816. private static _actionId;
  58817. private static _CreateWorkerAsync;
  58818. /**
  58819. * Transcodes a loaded image file to compressed pixel data
  58820. * @param imageData image data to transcode
  58821. * @param config configuration options for the transcoding
  58822. * @returns a promise resulting in the transcoded image
  58823. */
  58824. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58825. /**
  58826. * Loads a texture from the transcode result
  58827. * @param texture texture load to
  58828. * @param transcodeResult the result of transcoding the basis file to load from
  58829. */
  58830. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58831. }
  58832. }
  58833. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58834. import { Nullable } from "babylonjs/types";
  58835. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58836. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58837. /**
  58838. * Loader for .basis file format
  58839. */
  58840. export class _BasisTextureLoader implements IInternalTextureLoader {
  58841. /**
  58842. * Defines whether the loader supports cascade loading the different faces.
  58843. */
  58844. readonly supportCascades: boolean;
  58845. /**
  58846. * This returns if the loader support the current file information.
  58847. * @param extension defines the file extension of the file being loaded
  58848. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58849. * @param fallback defines the fallback internal texture if any
  58850. * @param isBase64 defines whether the texture is encoded as a base64
  58851. * @param isBuffer defines whether the texture data are stored as a buffer
  58852. * @returns true if the loader can load the specified file
  58853. */
  58854. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58855. /**
  58856. * Transform the url before loading if required.
  58857. * @param rootUrl the url of the texture
  58858. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58859. * @returns the transformed texture
  58860. */
  58861. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58862. /**
  58863. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58864. * @param rootUrl the url of the texture
  58865. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58866. * @returns the fallback texture
  58867. */
  58868. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58869. /**
  58870. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58871. * @param data contains the texture data
  58872. * @param texture defines the BabylonJS internal texture
  58873. * @param createPolynomials will be true if polynomials have been requested
  58874. * @param onLoad defines the callback to trigger once the texture is ready
  58875. * @param onError defines the callback to trigger in case of error
  58876. */
  58877. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58878. /**
  58879. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58880. * @param data contains the texture data
  58881. * @param texture defines the BabylonJS internal texture
  58882. * @param callback defines the method to call once ready to upload
  58883. */
  58884. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58885. }
  58886. }
  58887. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58888. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58889. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58890. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58891. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58892. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58893. }
  58894. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58895. import { Scene } from "babylonjs/scene";
  58896. import { Texture } from "babylonjs/Materials/Textures/texture";
  58897. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58898. /**
  58899. * 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.
  58900. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58901. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58902. */
  58903. export class CustomProceduralTexture extends ProceduralTexture {
  58904. private _animate;
  58905. private _time;
  58906. private _config;
  58907. private _texturePath;
  58908. /**
  58909. * Instantiates a new Custom Procedural Texture.
  58910. * 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.
  58911. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58912. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58913. * @param name Define the name of the texture
  58914. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58915. * @param size Define the size of the texture to create
  58916. * @param scene Define the scene the texture belongs to
  58917. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58918. * @param generateMipMaps Define if the texture should creates mip maps or not
  58919. */
  58920. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58921. private _loadJson;
  58922. /**
  58923. * Is the texture ready to be used ? (rendered at least once)
  58924. * @returns true if ready, otherwise, false.
  58925. */
  58926. isReady(): boolean;
  58927. /**
  58928. * Render the texture to its associated render target.
  58929. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58930. */
  58931. render(useCameraPostProcess?: boolean): void;
  58932. /**
  58933. * Update the list of dependant textures samplers in the shader.
  58934. */
  58935. updateTextures(): void;
  58936. /**
  58937. * Update the uniform values of the procedural texture in the shader.
  58938. */
  58939. updateShaderUniforms(): void;
  58940. /**
  58941. * Define if the texture animates or not.
  58942. */
  58943. get animate(): boolean;
  58944. set animate(value: boolean);
  58945. }
  58946. }
  58947. declare module "babylonjs/Shaders/noise.fragment" {
  58948. /** @hidden */
  58949. export var noisePixelShader: {
  58950. name: string;
  58951. shader: string;
  58952. };
  58953. }
  58954. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58955. import { Nullable } from "babylonjs/types";
  58956. import { Scene } from "babylonjs/scene";
  58957. import { Texture } from "babylonjs/Materials/Textures/texture";
  58958. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58959. import "babylonjs/Shaders/noise.fragment";
  58960. /**
  58961. * Class used to generate noise procedural textures
  58962. */
  58963. export class NoiseProceduralTexture extends ProceduralTexture {
  58964. private _time;
  58965. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58966. brightness: number;
  58967. /** Defines the number of octaves to process */
  58968. octaves: number;
  58969. /** Defines the level of persistence (0.8 by default) */
  58970. persistence: number;
  58971. /** Gets or sets animation speed factor (default is 1) */
  58972. animationSpeedFactor: number;
  58973. /**
  58974. * Creates a new NoiseProceduralTexture
  58975. * @param name defines the name fo the texture
  58976. * @param size defines the size of the texture (default is 256)
  58977. * @param scene defines the hosting scene
  58978. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58979. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58980. */
  58981. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58982. private _updateShaderUniforms;
  58983. protected _getDefines(): string;
  58984. /** Generate the current state of the procedural texture */
  58985. render(useCameraPostProcess?: boolean): void;
  58986. /**
  58987. * Serializes this noise procedural texture
  58988. * @returns a serialized noise procedural texture object
  58989. */
  58990. serialize(): any;
  58991. /**
  58992. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58993. * @param parsedTexture defines parsed texture data
  58994. * @param scene defines the current scene
  58995. * @param rootUrl defines the root URL containing noise procedural texture information
  58996. * @returns a parsed NoiseProceduralTexture
  58997. */
  58998. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58999. }
  59000. }
  59001. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59002. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59003. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59004. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59005. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59006. }
  59007. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59008. import { Nullable } from "babylonjs/types";
  59009. import { Scene } from "babylonjs/scene";
  59010. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59011. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59012. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59013. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59014. /**
  59015. * Raw cube texture where the raw buffers are passed in
  59016. */
  59017. export class RawCubeTexture extends CubeTexture {
  59018. /**
  59019. * Creates a cube texture where the raw buffers are passed in.
  59020. * @param scene defines the scene the texture is attached to
  59021. * @param data defines the array of data to use to create each face
  59022. * @param size defines the size of the textures
  59023. * @param format defines the format of the data
  59024. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59025. * @param generateMipMaps defines if the engine should generate the mip levels
  59026. * @param invertY defines if data must be stored with Y axis inverted
  59027. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59028. * @param compression defines the compression used (null by default)
  59029. */
  59030. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59031. /**
  59032. * Updates the raw cube texture.
  59033. * @param data defines the data to store
  59034. * @param format defines the data format
  59035. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59036. * @param invertY defines if data must be stored with Y axis inverted
  59037. * @param compression defines the compression used (null by default)
  59038. * @param level defines which level of the texture to update
  59039. */
  59040. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59041. /**
  59042. * Updates a raw cube texture with RGBD encoded data.
  59043. * @param data defines the array of data [mipmap][face] to use to create each face
  59044. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59045. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59046. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59047. * @returns a promsie that resolves when the operation is complete
  59048. */
  59049. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59050. /**
  59051. * Clones the raw cube texture.
  59052. * @return a new cube texture
  59053. */
  59054. clone(): CubeTexture;
  59055. /** @hidden */
  59056. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59057. }
  59058. }
  59059. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59060. import { Scene } from "babylonjs/scene";
  59061. import { Texture } from "babylonjs/Materials/Textures/texture";
  59062. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59063. /**
  59064. * Class used to store 3D textures containing user data
  59065. */
  59066. export class RawTexture3D extends Texture {
  59067. /** Gets or sets the texture format to use */
  59068. format: number;
  59069. private _engine;
  59070. /**
  59071. * Create a new RawTexture3D
  59072. * @param data defines the data of the texture
  59073. * @param width defines the width of the texture
  59074. * @param height defines the height of the texture
  59075. * @param depth defines the depth of the texture
  59076. * @param format defines the texture format to use
  59077. * @param scene defines the hosting scene
  59078. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59079. * @param invertY defines if texture must be stored with Y axis inverted
  59080. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59081. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59082. */
  59083. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59084. /** Gets or sets the texture format to use */
  59085. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59086. /**
  59087. * Update the texture with new data
  59088. * @param data defines the data to store in the texture
  59089. */
  59090. update(data: ArrayBufferView): void;
  59091. }
  59092. }
  59093. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59094. import { Scene } from "babylonjs/scene";
  59095. import { Texture } from "babylonjs/Materials/Textures/texture";
  59096. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59097. /**
  59098. * Class used to store 2D array textures containing user data
  59099. */
  59100. export class RawTexture2DArray extends Texture {
  59101. /** Gets or sets the texture format to use */
  59102. format: number;
  59103. private _engine;
  59104. /**
  59105. * Create a new RawTexture2DArray
  59106. * @param data defines the data of the texture
  59107. * @param width defines the width of the texture
  59108. * @param height defines the height of the texture
  59109. * @param depth defines the number of layers of the texture
  59110. * @param format defines the texture format to use
  59111. * @param scene defines the hosting scene
  59112. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59113. * @param invertY defines if texture must be stored with Y axis inverted
  59114. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59115. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59116. */
  59117. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59118. /** Gets or sets the texture format to use */
  59119. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59120. /**
  59121. * Update the texture with new data
  59122. * @param data defines the data to store in the texture
  59123. */
  59124. update(data: ArrayBufferView): void;
  59125. }
  59126. }
  59127. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59128. import { Scene } from "babylonjs/scene";
  59129. import { Plane } from "babylonjs/Maths/math.plane";
  59130. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59131. /**
  59132. * Creates a refraction texture used by refraction channel of the standard material.
  59133. * It is like a mirror but to see through a material.
  59134. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59135. */
  59136. export class RefractionTexture extends RenderTargetTexture {
  59137. /**
  59138. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59139. * 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.
  59140. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59141. */
  59142. refractionPlane: Plane;
  59143. /**
  59144. * Define how deep under the surface we should see.
  59145. */
  59146. depth: number;
  59147. /**
  59148. * Creates a refraction texture used by refraction channel of the standard material.
  59149. * It is like a mirror but to see through a material.
  59150. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59151. * @param name Define the texture name
  59152. * @param size Define the size of the underlying texture
  59153. * @param scene Define the scene the refraction belongs to
  59154. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59155. */
  59156. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59157. /**
  59158. * Clone the refraction texture.
  59159. * @returns the cloned texture
  59160. */
  59161. clone(): RefractionTexture;
  59162. /**
  59163. * Serialize the texture to a JSON representation you could use in Parse later on
  59164. * @returns the serialized JSON representation
  59165. */
  59166. serialize(): any;
  59167. }
  59168. }
  59169. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59170. import { Nullable } from "babylonjs/types";
  59171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59172. import { Matrix } from "babylonjs/Maths/math.vector";
  59173. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59174. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59175. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59176. import { Scene } from "babylonjs/scene";
  59177. /**
  59178. * Defines the options related to the creation of an HtmlElementTexture
  59179. */
  59180. export interface IHtmlElementTextureOptions {
  59181. /**
  59182. * Defines wether mip maps should be created or not.
  59183. */
  59184. generateMipMaps?: boolean;
  59185. /**
  59186. * Defines the sampling mode of the texture.
  59187. */
  59188. samplingMode?: number;
  59189. /**
  59190. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59191. */
  59192. engine: Nullable<ThinEngine>;
  59193. /**
  59194. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59195. */
  59196. scene: Nullable<Scene>;
  59197. }
  59198. /**
  59199. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59200. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59201. * is automatically managed.
  59202. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59203. * in your application.
  59204. *
  59205. * As the update is not automatic, you need to call them manually.
  59206. */
  59207. export class HtmlElementTexture extends BaseTexture {
  59208. /**
  59209. * The texture URL.
  59210. */
  59211. element: HTMLVideoElement | HTMLCanvasElement;
  59212. private static readonly DefaultOptions;
  59213. private _textureMatrix;
  59214. private _engine;
  59215. private _isVideo;
  59216. private _generateMipMaps;
  59217. private _samplingMode;
  59218. /**
  59219. * Instantiates a HtmlElementTexture from the following parameters.
  59220. *
  59221. * @param name Defines the name of the texture
  59222. * @param element Defines the video or canvas the texture is filled with
  59223. * @param options Defines the other none mandatory texture creation options
  59224. */
  59225. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59226. private _createInternalTexture;
  59227. /**
  59228. * Returns the texture matrix used in most of the material.
  59229. */
  59230. getTextureMatrix(): Matrix;
  59231. /**
  59232. * Updates the content of the texture.
  59233. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59234. */
  59235. update(invertY?: Nullable<boolean>): void;
  59236. }
  59237. }
  59238. declare module "babylonjs/Materials/Textures/index" {
  59239. export * from "babylonjs/Materials/Textures/baseTexture";
  59240. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59241. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59242. export * from "babylonjs/Materials/Textures/cubeTexture";
  59243. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59244. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59245. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59246. export * from "babylonjs/Materials/Textures/internalTexture";
  59247. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59248. export * from "babylonjs/Materials/Textures/Loaders/index";
  59249. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59250. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59251. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59252. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59253. export * from "babylonjs/Materials/Textures/rawTexture";
  59254. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59255. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59256. export * from "babylonjs/Materials/Textures/refractionTexture";
  59257. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59258. export * from "babylonjs/Materials/Textures/texture";
  59259. export * from "babylonjs/Materials/Textures/videoTexture";
  59260. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59261. }
  59262. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59263. /**
  59264. * Enum used to define the target of a block
  59265. */
  59266. export enum NodeMaterialBlockTargets {
  59267. /** Vertex shader */
  59268. Vertex = 1,
  59269. /** Fragment shader */
  59270. Fragment = 2,
  59271. /** Neutral */
  59272. Neutral = 4,
  59273. /** Vertex and Fragment */
  59274. VertexAndFragment = 3
  59275. }
  59276. }
  59277. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59278. /**
  59279. * Defines the kind of connection point for node based material
  59280. */
  59281. export enum NodeMaterialBlockConnectionPointTypes {
  59282. /** Float */
  59283. Float = 1,
  59284. /** Int */
  59285. Int = 2,
  59286. /** Vector2 */
  59287. Vector2 = 4,
  59288. /** Vector3 */
  59289. Vector3 = 8,
  59290. /** Vector4 */
  59291. Vector4 = 16,
  59292. /** Color3 */
  59293. Color3 = 32,
  59294. /** Color4 */
  59295. Color4 = 64,
  59296. /** Matrix */
  59297. Matrix = 128,
  59298. /** Detect type based on connection */
  59299. AutoDetect = 1024,
  59300. /** Output type that will be defined by input type */
  59301. BasedOnInput = 2048
  59302. }
  59303. }
  59304. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59305. /**
  59306. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59307. */
  59308. export enum NodeMaterialBlockConnectionPointMode {
  59309. /** Value is an uniform */
  59310. Uniform = 0,
  59311. /** Value is a mesh attribute */
  59312. Attribute = 1,
  59313. /** Value is a varying between vertex and fragment shaders */
  59314. Varying = 2,
  59315. /** Mode is undefined */
  59316. Undefined = 3
  59317. }
  59318. }
  59319. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59320. /**
  59321. * Enum used to define system values e.g. values automatically provided by the system
  59322. */
  59323. export enum NodeMaterialSystemValues {
  59324. /** World */
  59325. World = 1,
  59326. /** View */
  59327. View = 2,
  59328. /** Projection */
  59329. Projection = 3,
  59330. /** ViewProjection */
  59331. ViewProjection = 4,
  59332. /** WorldView */
  59333. WorldView = 5,
  59334. /** WorldViewProjection */
  59335. WorldViewProjection = 6,
  59336. /** CameraPosition */
  59337. CameraPosition = 7,
  59338. /** Fog Color */
  59339. FogColor = 8,
  59340. /** Delta time */
  59341. DeltaTime = 9
  59342. }
  59343. }
  59344. declare module "babylonjs/Materials/Node/Enums/index" {
  59345. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59346. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59347. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59348. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59349. }
  59350. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59352. /**
  59353. * Root class for all node material optimizers
  59354. */
  59355. export class NodeMaterialOptimizer {
  59356. /**
  59357. * Function used to optimize a NodeMaterial graph
  59358. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59359. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59360. */
  59361. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59362. }
  59363. }
  59364. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59365. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59366. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59367. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59368. import { Scene } from "babylonjs/scene";
  59369. /**
  59370. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59371. */
  59372. export class TransformBlock extends NodeMaterialBlock {
  59373. /**
  59374. * Defines the value to use to complement W value to transform it to a Vector4
  59375. */
  59376. complementW: number;
  59377. /**
  59378. * Defines the value to use to complement z value to transform it to a Vector4
  59379. */
  59380. complementZ: number;
  59381. /**
  59382. * Creates a new TransformBlock
  59383. * @param name defines the block name
  59384. */
  59385. constructor(name: string);
  59386. /**
  59387. * Gets the current class name
  59388. * @returns the class name
  59389. */
  59390. getClassName(): string;
  59391. /**
  59392. * Gets the vector input
  59393. */
  59394. get vector(): NodeMaterialConnectionPoint;
  59395. /**
  59396. * Gets the output component
  59397. */
  59398. get output(): NodeMaterialConnectionPoint;
  59399. /**
  59400. * Gets the matrix transform input
  59401. */
  59402. get transform(): NodeMaterialConnectionPoint;
  59403. protected _buildBlock(state: NodeMaterialBuildState): this;
  59404. serialize(): any;
  59405. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59406. protected _dumpPropertiesCode(): string;
  59407. }
  59408. }
  59409. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59413. /**
  59414. * Block used to output the vertex position
  59415. */
  59416. export class VertexOutputBlock extends NodeMaterialBlock {
  59417. /**
  59418. * Creates a new VertexOutputBlock
  59419. * @param name defines the block name
  59420. */
  59421. constructor(name: string);
  59422. /**
  59423. * Gets the current class name
  59424. * @returns the class name
  59425. */
  59426. getClassName(): string;
  59427. /**
  59428. * Gets the vector input component
  59429. */
  59430. get vector(): NodeMaterialConnectionPoint;
  59431. protected _buildBlock(state: NodeMaterialBuildState): this;
  59432. }
  59433. }
  59434. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59436. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59438. /**
  59439. * Block used to output the final color
  59440. */
  59441. export class FragmentOutputBlock extends NodeMaterialBlock {
  59442. /**
  59443. * Create a new FragmentOutputBlock
  59444. * @param name defines the block name
  59445. */
  59446. constructor(name: string);
  59447. /**
  59448. * Gets the current class name
  59449. * @returns the class name
  59450. */
  59451. getClassName(): string;
  59452. /**
  59453. * Gets the rgba input component
  59454. */
  59455. get rgba(): NodeMaterialConnectionPoint;
  59456. /**
  59457. * Gets the rgb input component
  59458. */
  59459. get rgb(): NodeMaterialConnectionPoint;
  59460. /**
  59461. * Gets the a input component
  59462. */
  59463. get a(): NodeMaterialConnectionPoint;
  59464. protected _buildBlock(state: NodeMaterialBuildState): this;
  59465. }
  59466. }
  59467. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59468. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59469. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59470. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59471. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59473. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59474. import { Effect } from "babylonjs/Materials/effect";
  59475. import { Mesh } from "babylonjs/Meshes/mesh";
  59476. import { Nullable } from "babylonjs/types";
  59477. import { Scene } from "babylonjs/scene";
  59478. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59479. /**
  59480. * Block used to read a reflection texture from a sampler
  59481. */
  59482. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59483. private _define3DName;
  59484. private _defineCubicName;
  59485. private _defineExplicitName;
  59486. private _defineProjectionName;
  59487. private _defineLocalCubicName;
  59488. private _defineSphericalName;
  59489. private _definePlanarName;
  59490. private _defineEquirectangularName;
  59491. private _defineMirroredEquirectangularFixedName;
  59492. private _defineEquirectangularFixedName;
  59493. private _defineSkyboxName;
  59494. private _cubeSamplerName;
  59495. private _2DSamplerName;
  59496. private _positionUVWName;
  59497. private _directionWName;
  59498. private _reflectionCoordsName;
  59499. private _reflection2DCoordsName;
  59500. private _reflectionColorName;
  59501. private _reflectionMatrixName;
  59502. /**
  59503. * Gets or sets the texture associated with the node
  59504. */
  59505. texture: Nullable<BaseTexture>;
  59506. /**
  59507. * Create a new TextureBlock
  59508. * @param name defines the block name
  59509. */
  59510. constructor(name: string);
  59511. /**
  59512. * Gets the current class name
  59513. * @returns the class name
  59514. */
  59515. getClassName(): string;
  59516. /**
  59517. * Gets the world position input component
  59518. */
  59519. get position(): NodeMaterialConnectionPoint;
  59520. /**
  59521. * Gets the world position input component
  59522. */
  59523. get worldPosition(): NodeMaterialConnectionPoint;
  59524. /**
  59525. * Gets the world normal input component
  59526. */
  59527. get worldNormal(): NodeMaterialConnectionPoint;
  59528. /**
  59529. * Gets the world input component
  59530. */
  59531. get world(): NodeMaterialConnectionPoint;
  59532. /**
  59533. * Gets the camera (or eye) position component
  59534. */
  59535. get cameraPosition(): NodeMaterialConnectionPoint;
  59536. /**
  59537. * Gets the view input component
  59538. */
  59539. get view(): NodeMaterialConnectionPoint;
  59540. /**
  59541. * Gets the rgb output component
  59542. */
  59543. get rgb(): NodeMaterialConnectionPoint;
  59544. /**
  59545. * Gets the r output component
  59546. */
  59547. get r(): NodeMaterialConnectionPoint;
  59548. /**
  59549. * Gets the g output component
  59550. */
  59551. get g(): NodeMaterialConnectionPoint;
  59552. /**
  59553. * Gets the b output component
  59554. */
  59555. get b(): NodeMaterialConnectionPoint;
  59556. autoConfigure(material: NodeMaterial): void;
  59557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59558. isReady(): boolean;
  59559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59560. private _injectVertexCode;
  59561. private _writeOutput;
  59562. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59563. protected _dumpPropertiesCode(): string;
  59564. serialize(): any;
  59565. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59566. }
  59567. }
  59568. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59570. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59571. import { Scene } from "babylonjs/scene";
  59572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59573. import { Matrix } from "babylonjs/Maths/math.vector";
  59574. import { Mesh } from "babylonjs/Meshes/mesh";
  59575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59576. import { Observable } from "babylonjs/Misc/observable";
  59577. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59578. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59579. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59580. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59581. import { Nullable } from "babylonjs/types";
  59582. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59583. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59584. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59585. /**
  59586. * Interface used to configure the node material editor
  59587. */
  59588. export interface INodeMaterialEditorOptions {
  59589. /** Define the URl to load node editor script */
  59590. editorURL?: string;
  59591. }
  59592. /** @hidden */
  59593. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59594. NORMAL: boolean;
  59595. TANGENT: boolean;
  59596. UV1: boolean;
  59597. /** BONES */
  59598. NUM_BONE_INFLUENCERS: number;
  59599. BonesPerMesh: number;
  59600. BONETEXTURE: boolean;
  59601. /** MORPH TARGETS */
  59602. MORPHTARGETS: boolean;
  59603. MORPHTARGETS_NORMAL: boolean;
  59604. MORPHTARGETS_TANGENT: boolean;
  59605. MORPHTARGETS_UV: boolean;
  59606. NUM_MORPH_INFLUENCERS: number;
  59607. /** IMAGE PROCESSING */
  59608. IMAGEPROCESSING: boolean;
  59609. VIGNETTE: boolean;
  59610. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59611. VIGNETTEBLENDMODEOPAQUE: boolean;
  59612. TONEMAPPING: boolean;
  59613. TONEMAPPING_ACES: boolean;
  59614. CONTRAST: boolean;
  59615. EXPOSURE: boolean;
  59616. COLORCURVES: boolean;
  59617. COLORGRADING: boolean;
  59618. COLORGRADING3D: boolean;
  59619. SAMPLER3DGREENDEPTH: boolean;
  59620. SAMPLER3DBGRMAP: boolean;
  59621. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59622. /** MISC. */
  59623. BUMPDIRECTUV: number;
  59624. constructor();
  59625. setValue(name: string, value: boolean): void;
  59626. }
  59627. /**
  59628. * Class used to configure NodeMaterial
  59629. */
  59630. export interface INodeMaterialOptions {
  59631. /**
  59632. * Defines if blocks should emit comments
  59633. */
  59634. emitComments: boolean;
  59635. }
  59636. /**
  59637. * Class used to create a node based material built by assembling shader blocks
  59638. */
  59639. export class NodeMaterial extends PushMaterial {
  59640. private static _BuildIdGenerator;
  59641. private _options;
  59642. private _vertexCompilationState;
  59643. private _fragmentCompilationState;
  59644. private _sharedData;
  59645. private _buildId;
  59646. private _buildWasSuccessful;
  59647. private _cachedWorldViewMatrix;
  59648. private _cachedWorldViewProjectionMatrix;
  59649. private _optimizers;
  59650. private _animationFrame;
  59651. /** Define the Url to load node editor script */
  59652. static EditorURL: string;
  59653. /** Define the Url to load snippets */
  59654. static SnippetUrl: string;
  59655. private BJSNODEMATERIALEDITOR;
  59656. /** Get the inspector from bundle or global */
  59657. private _getGlobalNodeMaterialEditor;
  59658. /**
  59659. * Gets or sets data used by visual editor
  59660. * @see https://nme.babylonjs.com
  59661. */
  59662. editorData: any;
  59663. /**
  59664. * 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)
  59665. */
  59666. ignoreAlpha: boolean;
  59667. /**
  59668. * Defines the maximum number of lights that can be used in the material
  59669. */
  59670. maxSimultaneousLights: number;
  59671. /**
  59672. * Observable raised when the material is built
  59673. */
  59674. onBuildObservable: Observable<NodeMaterial>;
  59675. /**
  59676. * Gets or sets the root nodes of the material vertex shader
  59677. */
  59678. _vertexOutputNodes: NodeMaterialBlock[];
  59679. /**
  59680. * Gets or sets the root nodes of the material fragment (pixel) shader
  59681. */
  59682. _fragmentOutputNodes: NodeMaterialBlock[];
  59683. /** Gets or sets options to control the node material overall behavior */
  59684. get options(): INodeMaterialOptions;
  59685. set options(options: INodeMaterialOptions);
  59686. /**
  59687. * Default configuration related to image processing available in the standard Material.
  59688. */
  59689. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59690. /**
  59691. * Gets the image processing configuration used either in this material.
  59692. */
  59693. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59694. /**
  59695. * Sets the Default image processing configuration used either in the this material.
  59696. *
  59697. * If sets to null, the scene one is in use.
  59698. */
  59699. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59700. /**
  59701. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59702. */
  59703. attachedBlocks: NodeMaterialBlock[];
  59704. /**
  59705. * Create a new node based material
  59706. * @param name defines the material name
  59707. * @param scene defines the hosting scene
  59708. * @param options defines creation option
  59709. */
  59710. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59711. /**
  59712. * Gets the current class name of the material e.g. "NodeMaterial"
  59713. * @returns the class name
  59714. */
  59715. getClassName(): string;
  59716. /**
  59717. * Keep track of the image processing observer to allow dispose and replace.
  59718. */
  59719. private _imageProcessingObserver;
  59720. /**
  59721. * Attaches a new image processing configuration to the Standard Material.
  59722. * @param configuration
  59723. */
  59724. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59725. /**
  59726. * Get a block by its name
  59727. * @param name defines the name of the block to retrieve
  59728. * @returns the required block or null if not found
  59729. */
  59730. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59731. /**
  59732. * Get a block by its name
  59733. * @param predicate defines the predicate used to find the good candidate
  59734. * @returns the required block or null if not found
  59735. */
  59736. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59737. /**
  59738. * Get an input block by its name
  59739. * @param predicate defines the predicate used to find the good candidate
  59740. * @returns the required input block or null if not found
  59741. */
  59742. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59743. /**
  59744. * Gets the list of input blocks attached to this material
  59745. * @returns an array of InputBlocks
  59746. */
  59747. getInputBlocks(): InputBlock[];
  59748. /**
  59749. * Adds a new optimizer to the list of optimizers
  59750. * @param optimizer defines the optimizers to add
  59751. * @returns the current material
  59752. */
  59753. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59754. /**
  59755. * Remove an optimizer from the list of optimizers
  59756. * @param optimizer defines the optimizers to remove
  59757. * @returns the current material
  59758. */
  59759. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59760. /**
  59761. * Add a new block to the list of output nodes
  59762. * @param node defines the node to add
  59763. * @returns the current material
  59764. */
  59765. addOutputNode(node: NodeMaterialBlock): this;
  59766. /**
  59767. * Remove a block from the list of root nodes
  59768. * @param node defines the node to remove
  59769. * @returns the current material
  59770. */
  59771. removeOutputNode(node: NodeMaterialBlock): this;
  59772. private _addVertexOutputNode;
  59773. private _removeVertexOutputNode;
  59774. private _addFragmentOutputNode;
  59775. private _removeFragmentOutputNode;
  59776. /**
  59777. * Specifies if the material will require alpha blending
  59778. * @returns a boolean specifying if alpha blending is needed
  59779. */
  59780. needAlphaBlending(): boolean;
  59781. /**
  59782. * Specifies if this material should be rendered in alpha test mode
  59783. * @returns a boolean specifying if an alpha test is needed.
  59784. */
  59785. needAlphaTesting(): boolean;
  59786. private _initializeBlock;
  59787. private _resetDualBlocks;
  59788. /**
  59789. * Remove a block from the current node material
  59790. * @param block defines the block to remove
  59791. */
  59792. removeBlock(block: NodeMaterialBlock): void;
  59793. /**
  59794. * Build the material and generates the inner effect
  59795. * @param verbose defines if the build should log activity
  59796. */
  59797. build(verbose?: boolean): void;
  59798. /**
  59799. * Runs an otpimization phase to try to improve the shader code
  59800. */
  59801. optimize(): void;
  59802. private _prepareDefinesForAttributes;
  59803. /**
  59804. * Get if the submesh is ready to be used and all its information available.
  59805. * Child classes can use it to update shaders
  59806. * @param mesh defines the mesh to check
  59807. * @param subMesh defines which submesh to check
  59808. * @param useInstances specifies that instances should be used
  59809. * @returns a boolean indicating that the submesh is ready or not
  59810. */
  59811. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59812. /**
  59813. * Get a string representing the shaders built by the current node graph
  59814. */
  59815. get compiledShaders(): string;
  59816. /**
  59817. * Binds the world matrix to the material
  59818. * @param world defines the world transformation matrix
  59819. */
  59820. bindOnlyWorldMatrix(world: Matrix): void;
  59821. /**
  59822. * Binds the submesh to this material by preparing the effect and shader to draw
  59823. * @param world defines the world transformation matrix
  59824. * @param mesh defines the mesh containing the submesh
  59825. * @param subMesh defines the submesh to bind the material to
  59826. */
  59827. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59828. /**
  59829. * Gets the active textures from the material
  59830. * @returns an array of textures
  59831. */
  59832. getActiveTextures(): BaseTexture[];
  59833. /**
  59834. * Gets the list of texture blocks
  59835. * @returns an array of texture blocks
  59836. */
  59837. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59838. /**
  59839. * Specifies if the material uses a texture
  59840. * @param texture defines the texture to check against the material
  59841. * @returns a boolean specifying if the material uses the texture
  59842. */
  59843. hasTexture(texture: BaseTexture): boolean;
  59844. /**
  59845. * Disposes the material
  59846. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59847. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59848. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59849. */
  59850. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59851. /** Creates the node editor window. */
  59852. private _createNodeEditor;
  59853. /**
  59854. * Launch the node material editor
  59855. * @param config Define the configuration of the editor
  59856. * @return a promise fulfilled when the node editor is visible
  59857. */
  59858. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59859. /**
  59860. * Clear the current material
  59861. */
  59862. clear(): void;
  59863. /**
  59864. * Clear the current material and set it to a default state
  59865. */
  59866. setToDefault(): void;
  59867. /**
  59868. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59869. * @param url defines the url to load from
  59870. * @returns a promise that will fullfil when the material is fully loaded
  59871. */
  59872. loadAsync(url: string): Promise<void>;
  59873. private _gatherBlocks;
  59874. /**
  59875. * Generate a string containing the code declaration required to create an equivalent of this material
  59876. * @returns a string
  59877. */
  59878. generateCode(): string;
  59879. /**
  59880. * Serializes this material in a JSON representation
  59881. * @returns the serialized material object
  59882. */
  59883. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59884. private _restoreConnections;
  59885. /**
  59886. * Clear the current graph and load a new one from a serialization object
  59887. * @param source defines the JSON representation of the material
  59888. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59889. */
  59890. loadFromSerialization(source: any, rootUrl?: string): void;
  59891. /**
  59892. * Creates a node material from parsed material data
  59893. * @param source defines the JSON representation of the material
  59894. * @param scene defines the hosting scene
  59895. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59896. * @returns a new node material
  59897. */
  59898. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59899. /**
  59900. * Creates a node material from a snippet saved by the node material editor
  59901. * @param snippetId defines the snippet to load
  59902. * @param scene defines the hosting scene
  59903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59904. * @returns a promise that will resolve to the new node material
  59905. */
  59906. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59907. /**
  59908. * Creates a new node material set to default basic configuration
  59909. * @param name defines the name of the material
  59910. * @param scene defines the hosting scene
  59911. * @returns a new NodeMaterial
  59912. */
  59913. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59914. }
  59915. }
  59916. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59919. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59922. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59923. import { Effect } from "babylonjs/Materials/effect";
  59924. import { Mesh } from "babylonjs/Meshes/mesh";
  59925. import { Nullable } from "babylonjs/types";
  59926. import { Texture } from "babylonjs/Materials/Textures/texture";
  59927. import { Scene } from "babylonjs/scene";
  59928. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59929. /**
  59930. * Block used to read a texture from a sampler
  59931. */
  59932. export class TextureBlock extends NodeMaterialBlock {
  59933. private _defineName;
  59934. private _linearDefineName;
  59935. private _tempTextureRead;
  59936. private _samplerName;
  59937. private _transformedUVName;
  59938. private _textureTransformName;
  59939. private _textureInfoName;
  59940. private _mainUVName;
  59941. private _mainUVDefineName;
  59942. /**
  59943. * Gets or sets the texture associated with the node
  59944. */
  59945. texture: Nullable<Texture>;
  59946. /**
  59947. * Create a new TextureBlock
  59948. * @param name defines the block name
  59949. */
  59950. constructor(name: string);
  59951. /**
  59952. * Gets the current class name
  59953. * @returns the class name
  59954. */
  59955. getClassName(): string;
  59956. /**
  59957. * Gets the uv input component
  59958. */
  59959. get uv(): NodeMaterialConnectionPoint;
  59960. /**
  59961. * Gets the rgba output component
  59962. */
  59963. get rgba(): NodeMaterialConnectionPoint;
  59964. /**
  59965. * Gets the rgb output component
  59966. */
  59967. get rgb(): NodeMaterialConnectionPoint;
  59968. /**
  59969. * Gets the r output component
  59970. */
  59971. get r(): NodeMaterialConnectionPoint;
  59972. /**
  59973. * Gets the g output component
  59974. */
  59975. get g(): NodeMaterialConnectionPoint;
  59976. /**
  59977. * Gets the b output component
  59978. */
  59979. get b(): NodeMaterialConnectionPoint;
  59980. /**
  59981. * Gets the a output component
  59982. */
  59983. get a(): NodeMaterialConnectionPoint;
  59984. get target(): NodeMaterialBlockTargets;
  59985. autoConfigure(material: NodeMaterial): void;
  59986. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59987. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59988. isReady(): boolean;
  59989. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59990. private get _isMixed();
  59991. private _injectVertexCode;
  59992. private _writeTextureRead;
  59993. private _writeOutput;
  59994. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59995. protected _dumpPropertiesCode(): string;
  59996. serialize(): any;
  59997. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59998. }
  59999. }
  60000. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60003. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60004. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60005. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60006. import { Scene } from "babylonjs/scene";
  60007. /**
  60008. * Class used to store shared data between 2 NodeMaterialBuildState
  60009. */
  60010. export class NodeMaterialBuildStateSharedData {
  60011. /**
  60012. * Gets the list of emitted varyings
  60013. */
  60014. temps: string[];
  60015. /**
  60016. * Gets the list of emitted varyings
  60017. */
  60018. varyings: string[];
  60019. /**
  60020. * Gets the varying declaration string
  60021. */
  60022. varyingDeclaration: string;
  60023. /**
  60024. * Input blocks
  60025. */
  60026. inputBlocks: InputBlock[];
  60027. /**
  60028. * Input blocks
  60029. */
  60030. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60031. /**
  60032. * Bindable blocks (Blocks that need to set data to the effect)
  60033. */
  60034. bindableBlocks: NodeMaterialBlock[];
  60035. /**
  60036. * List of blocks that can provide a compilation fallback
  60037. */
  60038. blocksWithFallbacks: NodeMaterialBlock[];
  60039. /**
  60040. * List of blocks that can provide a define update
  60041. */
  60042. blocksWithDefines: NodeMaterialBlock[];
  60043. /**
  60044. * List of blocks that can provide a repeatable content
  60045. */
  60046. repeatableContentBlocks: NodeMaterialBlock[];
  60047. /**
  60048. * List of blocks that can provide a dynamic list of uniforms
  60049. */
  60050. dynamicUniformBlocks: NodeMaterialBlock[];
  60051. /**
  60052. * List of blocks that can block the isReady function for the material
  60053. */
  60054. blockingBlocks: NodeMaterialBlock[];
  60055. /**
  60056. * Gets the list of animated inputs
  60057. */
  60058. animatedInputs: InputBlock[];
  60059. /**
  60060. * Build Id used to avoid multiple recompilations
  60061. */
  60062. buildId: number;
  60063. /** List of emitted variables */
  60064. variableNames: {
  60065. [key: string]: number;
  60066. };
  60067. /** List of emitted defines */
  60068. defineNames: {
  60069. [key: string]: number;
  60070. };
  60071. /** Should emit comments? */
  60072. emitComments: boolean;
  60073. /** Emit build activity */
  60074. verbose: boolean;
  60075. /** Gets or sets the hosting scene */
  60076. scene: Scene;
  60077. /**
  60078. * Gets the compilation hints emitted at compilation time
  60079. */
  60080. hints: {
  60081. needWorldViewMatrix: boolean;
  60082. needWorldViewProjectionMatrix: boolean;
  60083. needAlphaBlending: boolean;
  60084. needAlphaTesting: boolean;
  60085. };
  60086. /**
  60087. * List of compilation checks
  60088. */
  60089. checks: {
  60090. emitVertex: boolean;
  60091. emitFragment: boolean;
  60092. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60093. };
  60094. /** Creates a new shared data */
  60095. constructor();
  60096. /**
  60097. * Emits console errors and exceptions if there is a failing check
  60098. */
  60099. emitErrors(): void;
  60100. }
  60101. }
  60102. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60103. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60104. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60105. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60106. /**
  60107. * Class used to store node based material build state
  60108. */
  60109. export class NodeMaterialBuildState {
  60110. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60111. supportUniformBuffers: boolean;
  60112. /**
  60113. * Gets the list of emitted attributes
  60114. */
  60115. attributes: string[];
  60116. /**
  60117. * Gets the list of emitted uniforms
  60118. */
  60119. uniforms: string[];
  60120. /**
  60121. * Gets the list of emitted constants
  60122. */
  60123. constants: string[];
  60124. /**
  60125. * Gets the list of emitted samplers
  60126. */
  60127. samplers: string[];
  60128. /**
  60129. * Gets the list of emitted functions
  60130. */
  60131. functions: {
  60132. [key: string]: string;
  60133. };
  60134. /**
  60135. * Gets the list of emitted extensions
  60136. */
  60137. extensions: {
  60138. [key: string]: string;
  60139. };
  60140. /**
  60141. * Gets the target of the compilation state
  60142. */
  60143. target: NodeMaterialBlockTargets;
  60144. /**
  60145. * Gets the list of emitted counters
  60146. */
  60147. counters: {
  60148. [key: string]: number;
  60149. };
  60150. /**
  60151. * Shared data between multiple NodeMaterialBuildState instances
  60152. */
  60153. sharedData: NodeMaterialBuildStateSharedData;
  60154. /** @hidden */
  60155. _vertexState: NodeMaterialBuildState;
  60156. /** @hidden */
  60157. _attributeDeclaration: string;
  60158. /** @hidden */
  60159. _uniformDeclaration: string;
  60160. /** @hidden */
  60161. _constantDeclaration: string;
  60162. /** @hidden */
  60163. _samplerDeclaration: string;
  60164. /** @hidden */
  60165. _varyingTransfer: string;
  60166. private _repeatableContentAnchorIndex;
  60167. /** @hidden */
  60168. _builtCompilationString: string;
  60169. /**
  60170. * Gets the emitted compilation strings
  60171. */
  60172. compilationString: string;
  60173. /**
  60174. * Finalize the compilation strings
  60175. * @param state defines the current compilation state
  60176. */
  60177. finalize(state: NodeMaterialBuildState): void;
  60178. /** @hidden */
  60179. get _repeatableContentAnchor(): string;
  60180. /** @hidden */
  60181. _getFreeVariableName(prefix: string): string;
  60182. /** @hidden */
  60183. _getFreeDefineName(prefix: string): string;
  60184. /** @hidden */
  60185. _excludeVariableName(name: string): void;
  60186. /** @hidden */
  60187. _emit2DSampler(name: string): void;
  60188. /** @hidden */
  60189. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60190. /** @hidden */
  60191. _emitExtension(name: string, extension: string): void;
  60192. /** @hidden */
  60193. _emitFunction(name: string, code: string, comments: string): void;
  60194. /** @hidden */
  60195. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60196. replaceStrings?: {
  60197. search: RegExp;
  60198. replace: string;
  60199. }[];
  60200. repeatKey?: string;
  60201. }): string;
  60202. /** @hidden */
  60203. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60204. repeatKey?: string;
  60205. removeAttributes?: boolean;
  60206. removeUniforms?: boolean;
  60207. removeVaryings?: boolean;
  60208. removeIfDef?: boolean;
  60209. replaceStrings?: {
  60210. search: RegExp;
  60211. replace: string;
  60212. }[];
  60213. }, storeKey?: string): void;
  60214. /** @hidden */
  60215. _registerTempVariable(name: string): boolean;
  60216. /** @hidden */
  60217. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60218. /** @hidden */
  60219. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60220. /** @hidden */
  60221. _emitFloat(value: number): string;
  60222. }
  60223. }
  60224. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60225. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60227. import { Nullable } from "babylonjs/types";
  60228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60229. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60230. import { Effect } from "babylonjs/Materials/effect";
  60231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60232. import { Mesh } from "babylonjs/Meshes/mesh";
  60233. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60234. import { Scene } from "babylonjs/scene";
  60235. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60236. /**
  60237. * Defines a block that can be used inside a node based material
  60238. */
  60239. export class NodeMaterialBlock {
  60240. private _buildId;
  60241. private _buildTarget;
  60242. private _target;
  60243. private _isFinalMerger;
  60244. private _isInput;
  60245. protected _isUnique: boolean;
  60246. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60247. inputsAreExclusive: boolean;
  60248. /** @hidden */
  60249. _codeVariableName: string;
  60250. /** @hidden */
  60251. _inputs: NodeMaterialConnectionPoint[];
  60252. /** @hidden */
  60253. _outputs: NodeMaterialConnectionPoint[];
  60254. /** @hidden */
  60255. _preparationId: number;
  60256. /**
  60257. * Gets or sets the name of the block
  60258. */
  60259. name: string;
  60260. /**
  60261. * Gets or sets the unique id of the node
  60262. */
  60263. uniqueId: number;
  60264. /**
  60265. * Gets or sets the comments associated with this block
  60266. */
  60267. comments: string;
  60268. /**
  60269. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60270. */
  60271. get isUnique(): boolean;
  60272. /**
  60273. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60274. */
  60275. get isFinalMerger(): boolean;
  60276. /**
  60277. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60278. */
  60279. get isInput(): boolean;
  60280. /**
  60281. * Gets or sets the build Id
  60282. */
  60283. get buildId(): number;
  60284. set buildId(value: number);
  60285. /**
  60286. * Gets or sets the target of the block
  60287. */
  60288. get target(): NodeMaterialBlockTargets;
  60289. set target(value: NodeMaterialBlockTargets);
  60290. /**
  60291. * Gets the list of input points
  60292. */
  60293. get inputs(): NodeMaterialConnectionPoint[];
  60294. /** Gets the list of output points */
  60295. get outputs(): NodeMaterialConnectionPoint[];
  60296. /**
  60297. * Find an input by its name
  60298. * @param name defines the name of the input to look for
  60299. * @returns the input or null if not found
  60300. */
  60301. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60302. /**
  60303. * Find an output by its name
  60304. * @param name defines the name of the outputto look for
  60305. * @returns the output or null if not found
  60306. */
  60307. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60308. /**
  60309. * Creates a new NodeMaterialBlock
  60310. * @param name defines the block name
  60311. * @param target defines the target of that block (Vertex by default)
  60312. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60313. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60314. */
  60315. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60316. /**
  60317. * Initialize the block and prepare the context for build
  60318. * @param state defines the state that will be used for the build
  60319. */
  60320. initialize(state: NodeMaterialBuildState): void;
  60321. /**
  60322. * Bind data to effect. Will only be called for blocks with isBindable === true
  60323. * @param effect defines the effect to bind data to
  60324. * @param nodeMaterial defines the hosting NodeMaterial
  60325. * @param mesh defines the mesh that will be rendered
  60326. */
  60327. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60328. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60329. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60330. protected _writeFloat(value: number): string;
  60331. /**
  60332. * Gets the current class name e.g. "NodeMaterialBlock"
  60333. * @returns the class name
  60334. */
  60335. getClassName(): string;
  60336. /**
  60337. * Register a new input. Must be called inside a block constructor
  60338. * @param name defines the connection point name
  60339. * @param type defines the connection point type
  60340. * @param isOptional defines a boolean indicating that this input can be omitted
  60341. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60342. * @returns the current block
  60343. */
  60344. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60345. /**
  60346. * Register a new output. Must be called inside a block constructor
  60347. * @param name defines the connection point name
  60348. * @param type defines the connection point type
  60349. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60350. * @returns the current block
  60351. */
  60352. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60353. /**
  60354. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60355. * @param forOutput defines an optional connection point to check compatibility with
  60356. * @returns the first available input or null
  60357. */
  60358. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60359. /**
  60360. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60361. * @param forBlock defines an optional block to check compatibility with
  60362. * @returns the first available input or null
  60363. */
  60364. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60365. /**
  60366. * Gets the sibling of the given output
  60367. * @param current defines the current output
  60368. * @returns the next output in the list or null
  60369. */
  60370. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60371. /**
  60372. * Connect current block with another block
  60373. * @param other defines the block to connect with
  60374. * @param options define the various options to help pick the right connections
  60375. * @returns the current block
  60376. */
  60377. connectTo(other: NodeMaterialBlock, options?: {
  60378. input?: string;
  60379. output?: string;
  60380. outputSwizzle?: string;
  60381. }): this | undefined;
  60382. protected _buildBlock(state: NodeMaterialBuildState): void;
  60383. /**
  60384. * Add uniforms, samplers and uniform buffers at compilation time
  60385. * @param state defines the state to update
  60386. * @param nodeMaterial defines the node material requesting the update
  60387. * @param defines defines the material defines to update
  60388. * @param uniformBuffers defines the list of uniform buffer names
  60389. */
  60390. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60391. /**
  60392. * Add potential fallbacks if shader compilation fails
  60393. * @param mesh defines the mesh to be rendered
  60394. * @param fallbacks defines the current prioritized list of fallbacks
  60395. */
  60396. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60397. /**
  60398. * Initialize defines for shader compilation
  60399. * @param mesh defines the mesh to be rendered
  60400. * @param nodeMaterial defines the node material requesting the update
  60401. * @param defines defines the material defines to update
  60402. * @param useInstances specifies that instances should be used
  60403. */
  60404. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60405. /**
  60406. * Update defines for shader compilation
  60407. * @param mesh defines the mesh to be rendered
  60408. * @param nodeMaterial defines the node material requesting the update
  60409. * @param defines defines the material defines to update
  60410. * @param useInstances specifies that instances should be used
  60411. */
  60412. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60413. /**
  60414. * Lets the block try to connect some inputs automatically
  60415. * @param material defines the hosting NodeMaterial
  60416. */
  60417. autoConfigure(material: NodeMaterial): void;
  60418. /**
  60419. * Function called when a block is declared as repeatable content generator
  60420. * @param vertexShaderState defines the current compilation state for the vertex shader
  60421. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60422. * @param mesh defines the mesh to be rendered
  60423. * @param defines defines the material defines to update
  60424. */
  60425. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60426. /**
  60427. * Checks if the block is ready
  60428. * @param mesh defines the mesh to be rendered
  60429. * @param nodeMaterial defines the node material requesting the update
  60430. * @param defines defines the material defines to update
  60431. * @param useInstances specifies that instances should be used
  60432. * @returns true if the block is ready
  60433. */
  60434. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60435. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60436. private _processBuild;
  60437. /**
  60438. * Compile the current node and generate the shader code
  60439. * @param state defines the current compilation state (uniforms, samplers, current string)
  60440. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60441. * @returns true if already built
  60442. */
  60443. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60444. protected _inputRename(name: string): string;
  60445. protected _outputRename(name: string): string;
  60446. protected _dumpPropertiesCode(): string;
  60447. /** @hidden */
  60448. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60449. /** @hidden */
  60450. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60451. /**
  60452. * Clone the current block to a new identical block
  60453. * @param scene defines the hosting scene
  60454. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60455. * @returns a copy of the current block
  60456. */
  60457. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60458. /**
  60459. * Serializes this block in a JSON representation
  60460. * @returns the serialized block object
  60461. */
  60462. serialize(): any;
  60463. /** @hidden */
  60464. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60465. /**
  60466. * Release resources
  60467. */
  60468. dispose(): void;
  60469. }
  60470. }
  60471. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60472. /**
  60473. * Enum defining the type of animations supported by InputBlock
  60474. */
  60475. export enum AnimatedInputBlockTypes {
  60476. /** No animation */
  60477. None = 0,
  60478. /** Time based animation. Will only work for floats */
  60479. Time = 1
  60480. }
  60481. }
  60482. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60484. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60485. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60486. import { Nullable } from "babylonjs/types";
  60487. import { Effect } from "babylonjs/Materials/effect";
  60488. import { Matrix } from "babylonjs/Maths/math.vector";
  60489. import { Scene } from "babylonjs/scene";
  60490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60492. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60493. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60494. /**
  60495. * Block used to expose an input value
  60496. */
  60497. export class InputBlock extends NodeMaterialBlock {
  60498. private _mode;
  60499. private _associatedVariableName;
  60500. private _storedValue;
  60501. private _valueCallback;
  60502. private _type;
  60503. private _animationType;
  60504. /** Gets or set a value used to limit the range of float values */
  60505. min: number;
  60506. /** Gets or set a value used to limit the range of float values */
  60507. max: number;
  60508. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60509. isBoolean: boolean;
  60510. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60511. matrixMode: number;
  60512. /** @hidden */
  60513. _systemValue: Nullable<NodeMaterialSystemValues>;
  60514. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60515. visibleInInspector: boolean;
  60516. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60517. isConstant: boolean;
  60518. /** Gets or sets the group to use to display this block in the Inspector */
  60519. groupInInspector: string;
  60520. /**
  60521. * Gets or sets the connection point type (default is float)
  60522. */
  60523. get type(): NodeMaterialBlockConnectionPointTypes;
  60524. /**
  60525. * Creates a new InputBlock
  60526. * @param name defines the block name
  60527. * @param target defines the target of that block (Vertex by default)
  60528. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60529. */
  60530. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60531. /**
  60532. * Gets the output component
  60533. */
  60534. get output(): NodeMaterialConnectionPoint;
  60535. /**
  60536. * Set the source of this connection point to a vertex attribute
  60537. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60538. * @returns the current connection point
  60539. */
  60540. setAsAttribute(attributeName?: string): InputBlock;
  60541. /**
  60542. * Set the source of this connection point to a system value
  60543. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60544. * @returns the current connection point
  60545. */
  60546. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60547. /**
  60548. * Gets or sets the value of that point.
  60549. * Please note that this value will be ignored if valueCallback is defined
  60550. */
  60551. get value(): any;
  60552. set value(value: any);
  60553. /**
  60554. * Gets or sets a callback used to get the value of that point.
  60555. * Please note that setting this value will force the connection point to ignore the value property
  60556. */
  60557. get valueCallback(): () => any;
  60558. set valueCallback(value: () => any);
  60559. /**
  60560. * Gets or sets the associated variable name in the shader
  60561. */
  60562. get associatedVariableName(): string;
  60563. set associatedVariableName(value: string);
  60564. /** Gets or sets the type of animation applied to the input */
  60565. get animationType(): AnimatedInputBlockTypes;
  60566. set animationType(value: AnimatedInputBlockTypes);
  60567. /**
  60568. * Gets a boolean indicating that this connection point not defined yet
  60569. */
  60570. get isUndefined(): boolean;
  60571. /**
  60572. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60573. * In this case the connection point name must be the name of the uniform to use.
  60574. * Can only be set on inputs
  60575. */
  60576. get isUniform(): boolean;
  60577. set isUniform(value: boolean);
  60578. /**
  60579. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60580. * In this case the connection point name must be the name of the attribute to use
  60581. * Can only be set on inputs
  60582. */
  60583. get isAttribute(): boolean;
  60584. set isAttribute(value: boolean);
  60585. /**
  60586. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60587. * Can only be set on exit points
  60588. */
  60589. get isVarying(): boolean;
  60590. set isVarying(value: boolean);
  60591. /**
  60592. * Gets a boolean indicating that the current connection point is a system value
  60593. */
  60594. get isSystemValue(): boolean;
  60595. /**
  60596. * Gets or sets the current well known value or null if not defined as a system value
  60597. */
  60598. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60599. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60600. /**
  60601. * Gets the current class name
  60602. * @returns the class name
  60603. */
  60604. getClassName(): string;
  60605. /**
  60606. * Animate the input if animationType !== None
  60607. * @param scene defines the rendering scene
  60608. */
  60609. animate(scene: Scene): void;
  60610. private _emitDefine;
  60611. initialize(state: NodeMaterialBuildState): void;
  60612. /**
  60613. * Set the input block to its default value (based on its type)
  60614. */
  60615. setDefaultValue(): void;
  60616. private _emitConstant;
  60617. private _emit;
  60618. /** @hidden */
  60619. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60620. /** @hidden */
  60621. _transmit(effect: Effect, scene: Scene): void;
  60622. protected _buildBlock(state: NodeMaterialBuildState): void;
  60623. protected _dumpPropertiesCode(): string;
  60624. serialize(): any;
  60625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60626. }
  60627. }
  60628. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60629. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60630. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60631. import { Nullable } from "babylonjs/types";
  60632. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60633. import { Observable } from "babylonjs/Misc/observable";
  60634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60635. /**
  60636. * Enum used to define the compatibility state between two connection points
  60637. */
  60638. export enum NodeMaterialConnectionPointCompatibilityStates {
  60639. /** Points are compatibles */
  60640. Compatible = 0,
  60641. /** Points are incompatible because of their types */
  60642. TypeIncompatible = 1,
  60643. /** Points are incompatible because of their targets (vertex vs fragment) */
  60644. TargetIncompatible = 2
  60645. }
  60646. /**
  60647. * Defines the direction of a connection point
  60648. */
  60649. export enum NodeMaterialConnectionPointDirection {
  60650. /** Input */
  60651. Input = 0,
  60652. /** Output */
  60653. Output = 1
  60654. }
  60655. /**
  60656. * Defines a connection point for a block
  60657. */
  60658. export class NodeMaterialConnectionPoint {
  60659. /** @hidden */
  60660. _ownerBlock: NodeMaterialBlock;
  60661. /** @hidden */
  60662. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60663. private _endpoints;
  60664. private _associatedVariableName;
  60665. private _direction;
  60666. /** @hidden */
  60667. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60668. /** @hidden */
  60669. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60670. private _type;
  60671. /** @hidden */
  60672. _enforceAssociatedVariableName: boolean;
  60673. /** Gets the direction of the point */
  60674. get direction(): NodeMaterialConnectionPointDirection;
  60675. /**
  60676. * Gets or sets the additional types supported by this connection point
  60677. */
  60678. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60679. /**
  60680. * Gets or sets the additional types excluded by this connection point
  60681. */
  60682. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60683. /**
  60684. * Observable triggered when this point is connected
  60685. */
  60686. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60687. /**
  60688. * Gets or sets the associated variable name in the shader
  60689. */
  60690. get associatedVariableName(): string;
  60691. set associatedVariableName(value: string);
  60692. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60693. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60694. /**
  60695. * Gets or sets the connection point type (default is float)
  60696. */
  60697. get type(): NodeMaterialBlockConnectionPointTypes;
  60698. set type(value: NodeMaterialBlockConnectionPointTypes);
  60699. /**
  60700. * Gets or sets the connection point name
  60701. */
  60702. name: string;
  60703. /**
  60704. * Gets or sets a boolean indicating that this connection point can be omitted
  60705. */
  60706. isOptional: boolean;
  60707. /**
  60708. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60709. */
  60710. define: string;
  60711. /** @hidden */
  60712. _prioritizeVertex: boolean;
  60713. private _target;
  60714. /** Gets or sets the target of that connection point */
  60715. get target(): NodeMaterialBlockTargets;
  60716. set target(value: NodeMaterialBlockTargets);
  60717. /**
  60718. * Gets a boolean indicating that the current point is connected
  60719. */
  60720. get isConnected(): boolean;
  60721. /**
  60722. * Gets a boolean indicating that the current point is connected to an input block
  60723. */
  60724. get isConnectedToInputBlock(): boolean;
  60725. /**
  60726. * Gets a the connected input block (if any)
  60727. */
  60728. get connectInputBlock(): Nullable<InputBlock>;
  60729. /** Get the other side of the connection (if any) */
  60730. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60731. /** Get the block that owns this connection point */
  60732. get ownerBlock(): NodeMaterialBlock;
  60733. /** Get the block connected on the other side of this connection (if any) */
  60734. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60735. /** Get the block connected on the endpoints of this connection (if any) */
  60736. get connectedBlocks(): Array<NodeMaterialBlock>;
  60737. /** Gets the list of connected endpoints */
  60738. get endpoints(): NodeMaterialConnectionPoint[];
  60739. /** Gets a boolean indicating if that output point is connected to at least one input */
  60740. get hasEndpoints(): boolean;
  60741. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60742. get isConnectedInVertexShader(): boolean;
  60743. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60744. get isConnectedInFragmentShader(): boolean;
  60745. /**
  60746. * Creates a new connection point
  60747. * @param name defines the connection point name
  60748. * @param ownerBlock defines the block hosting this connection point
  60749. * @param direction defines the direction of the connection point
  60750. */
  60751. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60752. /**
  60753. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60754. * @returns the class name
  60755. */
  60756. getClassName(): string;
  60757. /**
  60758. * Gets a boolean indicating if the current point can be connected to another point
  60759. * @param connectionPoint defines the other connection point
  60760. * @returns a boolean
  60761. */
  60762. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60763. /**
  60764. * Gets a number indicating if the current point can be connected to another point
  60765. * @param connectionPoint defines the other connection point
  60766. * @returns a number defining the compatibility state
  60767. */
  60768. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60769. /**
  60770. * Connect this point to another connection point
  60771. * @param connectionPoint defines the other connection point
  60772. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60773. * @returns the current connection point
  60774. */
  60775. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60776. /**
  60777. * Disconnect this point from one of his endpoint
  60778. * @param endpoint defines the other connection point
  60779. * @returns the current connection point
  60780. */
  60781. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60782. /**
  60783. * Serializes this point in a JSON representation
  60784. * @returns the serialized point object
  60785. */
  60786. serialize(): any;
  60787. /**
  60788. * Release resources
  60789. */
  60790. dispose(): void;
  60791. }
  60792. }
  60793. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60794. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60795. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60797. import { Mesh } from "babylonjs/Meshes/mesh";
  60798. import { Effect } from "babylonjs/Materials/effect";
  60799. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60800. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60801. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60802. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60803. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60804. /**
  60805. * Block used to add support for vertex skinning (bones)
  60806. */
  60807. export class BonesBlock extends NodeMaterialBlock {
  60808. /**
  60809. * Creates a new BonesBlock
  60810. * @param name defines the block name
  60811. */
  60812. constructor(name: string);
  60813. /**
  60814. * Initialize the block and prepare the context for build
  60815. * @param state defines the state that will be used for the build
  60816. */
  60817. initialize(state: NodeMaterialBuildState): void;
  60818. /**
  60819. * Gets the current class name
  60820. * @returns the class name
  60821. */
  60822. getClassName(): string;
  60823. /**
  60824. * Gets the matrix indices input component
  60825. */
  60826. get matricesIndices(): NodeMaterialConnectionPoint;
  60827. /**
  60828. * Gets the matrix weights input component
  60829. */
  60830. get matricesWeights(): NodeMaterialConnectionPoint;
  60831. /**
  60832. * Gets the extra matrix indices input component
  60833. */
  60834. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60835. /**
  60836. * Gets the extra matrix weights input component
  60837. */
  60838. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60839. /**
  60840. * Gets the world input component
  60841. */
  60842. get world(): NodeMaterialConnectionPoint;
  60843. /**
  60844. * Gets the output component
  60845. */
  60846. get output(): NodeMaterialConnectionPoint;
  60847. autoConfigure(material: NodeMaterial): void;
  60848. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60850. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60851. protected _buildBlock(state: NodeMaterialBuildState): this;
  60852. }
  60853. }
  60854. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60859. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60860. /**
  60861. * Block used to add support for instances
  60862. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60863. */
  60864. export class InstancesBlock extends NodeMaterialBlock {
  60865. /**
  60866. * Creates a new InstancesBlock
  60867. * @param name defines the block name
  60868. */
  60869. constructor(name: string);
  60870. /**
  60871. * Gets the current class name
  60872. * @returns the class name
  60873. */
  60874. getClassName(): string;
  60875. /**
  60876. * Gets the first world row input component
  60877. */
  60878. get world0(): NodeMaterialConnectionPoint;
  60879. /**
  60880. * Gets the second world row input component
  60881. */
  60882. get world1(): NodeMaterialConnectionPoint;
  60883. /**
  60884. * Gets the third world row input component
  60885. */
  60886. get world2(): NodeMaterialConnectionPoint;
  60887. /**
  60888. * Gets the forth world row input component
  60889. */
  60890. get world3(): NodeMaterialConnectionPoint;
  60891. /**
  60892. * Gets the world input component
  60893. */
  60894. get world(): NodeMaterialConnectionPoint;
  60895. /**
  60896. * Gets the output component
  60897. */
  60898. get output(): NodeMaterialConnectionPoint;
  60899. autoConfigure(material: NodeMaterial): void;
  60900. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60901. protected _buildBlock(state: NodeMaterialBuildState): this;
  60902. }
  60903. }
  60904. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60905. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60906. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60907. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60909. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60910. import { Effect } from "babylonjs/Materials/effect";
  60911. import { Mesh } from "babylonjs/Meshes/mesh";
  60912. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60913. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60914. /**
  60915. * Block used to add morph targets support to vertex shader
  60916. */
  60917. export class MorphTargetsBlock extends NodeMaterialBlock {
  60918. private _repeatableContentAnchor;
  60919. /**
  60920. * Create a new MorphTargetsBlock
  60921. * @param name defines the block name
  60922. */
  60923. constructor(name: string);
  60924. /**
  60925. * Gets the current class name
  60926. * @returns the class name
  60927. */
  60928. getClassName(): string;
  60929. /**
  60930. * Gets the position input component
  60931. */
  60932. get position(): NodeMaterialConnectionPoint;
  60933. /**
  60934. * Gets the normal input component
  60935. */
  60936. get normal(): NodeMaterialConnectionPoint;
  60937. /**
  60938. * Gets the tangent input component
  60939. */
  60940. get tangent(): NodeMaterialConnectionPoint;
  60941. /**
  60942. * Gets the tangent input component
  60943. */
  60944. get uv(): NodeMaterialConnectionPoint;
  60945. /**
  60946. * Gets the position output component
  60947. */
  60948. get positionOutput(): NodeMaterialConnectionPoint;
  60949. /**
  60950. * Gets the normal output component
  60951. */
  60952. get normalOutput(): NodeMaterialConnectionPoint;
  60953. /**
  60954. * Gets the tangent output component
  60955. */
  60956. get tangentOutput(): NodeMaterialConnectionPoint;
  60957. /**
  60958. * Gets the tangent output component
  60959. */
  60960. get uvOutput(): NodeMaterialConnectionPoint;
  60961. initialize(state: NodeMaterialBuildState): void;
  60962. autoConfigure(material: NodeMaterial): void;
  60963. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60964. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60965. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60966. protected _buildBlock(state: NodeMaterialBuildState): this;
  60967. }
  60968. }
  60969. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60973. import { Nullable } from "babylonjs/types";
  60974. import { Scene } from "babylonjs/scene";
  60975. import { Effect } from "babylonjs/Materials/effect";
  60976. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60977. import { Mesh } from "babylonjs/Meshes/mesh";
  60978. import { Light } from "babylonjs/Lights/light";
  60979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60980. /**
  60981. * Block used to get data information from a light
  60982. */
  60983. export class LightInformationBlock extends NodeMaterialBlock {
  60984. private _lightDataUniformName;
  60985. private _lightColorUniformName;
  60986. private _lightTypeDefineName;
  60987. /**
  60988. * Gets or sets the light associated with this block
  60989. */
  60990. light: Nullable<Light>;
  60991. /**
  60992. * Creates a new LightInformationBlock
  60993. * @param name defines the block name
  60994. */
  60995. constructor(name: string);
  60996. /**
  60997. * Gets the current class name
  60998. * @returns the class name
  60999. */
  61000. getClassName(): string;
  61001. /**
  61002. * Gets the world position input component
  61003. */
  61004. get worldPosition(): NodeMaterialConnectionPoint;
  61005. /**
  61006. * Gets the direction output component
  61007. */
  61008. get direction(): NodeMaterialConnectionPoint;
  61009. /**
  61010. * Gets the direction output component
  61011. */
  61012. get color(): NodeMaterialConnectionPoint;
  61013. /**
  61014. * Gets the direction output component
  61015. */
  61016. get intensity(): NodeMaterialConnectionPoint;
  61017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61018. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61019. protected _buildBlock(state: NodeMaterialBuildState): this;
  61020. serialize(): any;
  61021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61022. }
  61023. }
  61024. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61025. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61026. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61027. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61028. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61029. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61030. }
  61031. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61036. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61037. import { Effect } from "babylonjs/Materials/effect";
  61038. import { Mesh } from "babylonjs/Meshes/mesh";
  61039. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61040. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61041. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61042. /**
  61043. * Block used to add image processing support to fragment shader
  61044. */
  61045. export class ImageProcessingBlock extends NodeMaterialBlock {
  61046. /**
  61047. * Create a new ImageProcessingBlock
  61048. * @param name defines the block name
  61049. */
  61050. constructor(name: string);
  61051. /**
  61052. * Gets the current class name
  61053. * @returns the class name
  61054. */
  61055. getClassName(): string;
  61056. /**
  61057. * Gets the color input component
  61058. */
  61059. get color(): NodeMaterialConnectionPoint;
  61060. /**
  61061. * Gets the output component
  61062. */
  61063. get output(): NodeMaterialConnectionPoint;
  61064. /**
  61065. * Initialize the block and prepare the context for build
  61066. * @param state defines the state that will be used for the build
  61067. */
  61068. initialize(state: NodeMaterialBuildState): void;
  61069. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61071. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61072. protected _buildBlock(state: NodeMaterialBuildState): this;
  61073. }
  61074. }
  61075. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61079. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61081. import { Effect } from "babylonjs/Materials/effect";
  61082. import { Mesh } from "babylonjs/Meshes/mesh";
  61083. import { Scene } from "babylonjs/scene";
  61084. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61085. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61086. /**
  61087. * Block used to pertub normals based on a normal map
  61088. */
  61089. export class PerturbNormalBlock extends NodeMaterialBlock {
  61090. private _tangentSpaceParameterName;
  61091. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61092. invertX: boolean;
  61093. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61094. invertY: boolean;
  61095. /**
  61096. * Create a new PerturbNormalBlock
  61097. * @param name defines the block name
  61098. */
  61099. constructor(name: string);
  61100. /**
  61101. * Gets the current class name
  61102. * @returns the class name
  61103. */
  61104. getClassName(): string;
  61105. /**
  61106. * Gets the world position input component
  61107. */
  61108. get worldPosition(): NodeMaterialConnectionPoint;
  61109. /**
  61110. * Gets the world normal input component
  61111. */
  61112. get worldNormal(): NodeMaterialConnectionPoint;
  61113. /**
  61114. * Gets the uv input component
  61115. */
  61116. get uv(): NodeMaterialConnectionPoint;
  61117. /**
  61118. * Gets the normal map color input component
  61119. */
  61120. get normalMapColor(): NodeMaterialConnectionPoint;
  61121. /**
  61122. * Gets the strength input component
  61123. */
  61124. get strength(): NodeMaterialConnectionPoint;
  61125. /**
  61126. * Gets the output component
  61127. */
  61128. get output(): NodeMaterialConnectionPoint;
  61129. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61130. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61131. autoConfigure(material: NodeMaterial): void;
  61132. protected _buildBlock(state: NodeMaterialBuildState): this;
  61133. protected _dumpPropertiesCode(): string;
  61134. serialize(): any;
  61135. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61136. }
  61137. }
  61138. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61142. /**
  61143. * Block used to discard a pixel if a value is smaller than a cutoff
  61144. */
  61145. export class DiscardBlock extends NodeMaterialBlock {
  61146. /**
  61147. * Create a new DiscardBlock
  61148. * @param name defines the block name
  61149. */
  61150. constructor(name: string);
  61151. /**
  61152. * Gets the current class name
  61153. * @returns the class name
  61154. */
  61155. getClassName(): string;
  61156. /**
  61157. * Gets the color input component
  61158. */
  61159. get value(): NodeMaterialConnectionPoint;
  61160. /**
  61161. * Gets the cutoff input component
  61162. */
  61163. get cutoff(): NodeMaterialConnectionPoint;
  61164. protected _buildBlock(state: NodeMaterialBuildState): this;
  61165. }
  61166. }
  61167. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61171. /**
  61172. * Block used to test if the fragment shader is front facing
  61173. */
  61174. export class FrontFacingBlock extends NodeMaterialBlock {
  61175. /**
  61176. * Creates a new FrontFacingBlock
  61177. * @param name defines the block name
  61178. */
  61179. constructor(name: string);
  61180. /**
  61181. * Gets the current class name
  61182. * @returns the class name
  61183. */
  61184. getClassName(): string;
  61185. /**
  61186. * Gets the output component
  61187. */
  61188. get output(): NodeMaterialConnectionPoint;
  61189. protected _buildBlock(state: NodeMaterialBuildState): this;
  61190. }
  61191. }
  61192. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61196. /**
  61197. * Block used to get the derivative value on x and y of a given input
  61198. */
  61199. export class DerivativeBlock extends NodeMaterialBlock {
  61200. /**
  61201. * Create a new DerivativeBlock
  61202. * @param name defines the block name
  61203. */
  61204. constructor(name: string);
  61205. /**
  61206. * Gets the current class name
  61207. * @returns the class name
  61208. */
  61209. getClassName(): string;
  61210. /**
  61211. * Gets the input component
  61212. */
  61213. get input(): NodeMaterialConnectionPoint;
  61214. /**
  61215. * Gets the derivative output on x
  61216. */
  61217. get dx(): NodeMaterialConnectionPoint;
  61218. /**
  61219. * Gets the derivative output on y
  61220. */
  61221. get dy(): NodeMaterialConnectionPoint;
  61222. protected _buildBlock(state: NodeMaterialBuildState): this;
  61223. }
  61224. }
  61225. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61226. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61227. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61228. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61229. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61230. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61231. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61232. }
  61233. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61236. import { Mesh } from "babylonjs/Meshes/mesh";
  61237. import { Effect } from "babylonjs/Materials/effect";
  61238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61240. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61241. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61242. /**
  61243. * Block used to add support for scene fog
  61244. */
  61245. export class FogBlock extends NodeMaterialBlock {
  61246. private _fogDistanceName;
  61247. private _fogParameters;
  61248. /**
  61249. * Create a new FogBlock
  61250. * @param name defines the block name
  61251. */
  61252. constructor(name: string);
  61253. /**
  61254. * Gets the current class name
  61255. * @returns the class name
  61256. */
  61257. getClassName(): string;
  61258. /**
  61259. * Gets the world position input component
  61260. */
  61261. get worldPosition(): NodeMaterialConnectionPoint;
  61262. /**
  61263. * Gets the view input component
  61264. */
  61265. get view(): NodeMaterialConnectionPoint;
  61266. /**
  61267. * Gets the color input component
  61268. */
  61269. get input(): NodeMaterialConnectionPoint;
  61270. /**
  61271. * Gets the fog color input component
  61272. */
  61273. get fogColor(): NodeMaterialConnectionPoint;
  61274. /**
  61275. * Gets the output component
  61276. */
  61277. get output(): NodeMaterialConnectionPoint;
  61278. autoConfigure(material: NodeMaterial): void;
  61279. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61281. protected _buildBlock(state: NodeMaterialBuildState): this;
  61282. }
  61283. }
  61284. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61289. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61290. import { Effect } from "babylonjs/Materials/effect";
  61291. import { Mesh } from "babylonjs/Meshes/mesh";
  61292. import { Light } from "babylonjs/Lights/light";
  61293. import { Nullable } from "babylonjs/types";
  61294. import { Scene } from "babylonjs/scene";
  61295. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61296. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61297. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61298. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61299. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61300. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61301. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61302. /**
  61303. * Block used to add light in the fragment shader
  61304. */
  61305. export class LightBlock extends NodeMaterialBlock {
  61306. private _lightId;
  61307. /**
  61308. * Gets or sets the light associated with this block
  61309. */
  61310. light: Nullable<Light>;
  61311. /**
  61312. * Create a new LightBlock
  61313. * @param name defines the block name
  61314. */
  61315. constructor(name: string);
  61316. /**
  61317. * Gets the current class name
  61318. * @returns the class name
  61319. */
  61320. getClassName(): string;
  61321. /**
  61322. * Gets the world position input component
  61323. */
  61324. get worldPosition(): NodeMaterialConnectionPoint;
  61325. /**
  61326. * Gets the world normal input component
  61327. */
  61328. get worldNormal(): NodeMaterialConnectionPoint;
  61329. /**
  61330. * Gets the camera (or eye) position component
  61331. */
  61332. get cameraPosition(): NodeMaterialConnectionPoint;
  61333. /**
  61334. * Gets the glossiness component
  61335. */
  61336. get glossiness(): NodeMaterialConnectionPoint;
  61337. /**
  61338. * Gets the glossinness power component
  61339. */
  61340. get glossPower(): NodeMaterialConnectionPoint;
  61341. /**
  61342. * Gets the diffuse color component
  61343. */
  61344. get diffuseColor(): NodeMaterialConnectionPoint;
  61345. /**
  61346. * Gets the specular color component
  61347. */
  61348. get specularColor(): NodeMaterialConnectionPoint;
  61349. /**
  61350. * Gets the diffuse output component
  61351. */
  61352. get diffuseOutput(): NodeMaterialConnectionPoint;
  61353. /**
  61354. * Gets the specular output component
  61355. */
  61356. get specularOutput(): NodeMaterialConnectionPoint;
  61357. /**
  61358. * Gets the shadow output component
  61359. */
  61360. get shadow(): NodeMaterialConnectionPoint;
  61361. autoConfigure(material: NodeMaterial): void;
  61362. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61363. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61364. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61365. private _injectVertexCode;
  61366. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61367. serialize(): any;
  61368. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61369. }
  61370. }
  61371. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61372. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61373. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61374. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61375. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61376. }
  61377. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61378. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61379. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61380. }
  61381. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61385. /**
  61386. * Block used to multiply 2 values
  61387. */
  61388. export class MultiplyBlock extends NodeMaterialBlock {
  61389. /**
  61390. * Creates a new MultiplyBlock
  61391. * @param name defines the block name
  61392. */
  61393. constructor(name: string);
  61394. /**
  61395. * Gets the current class name
  61396. * @returns the class name
  61397. */
  61398. getClassName(): string;
  61399. /**
  61400. * Gets the left operand input component
  61401. */
  61402. get left(): NodeMaterialConnectionPoint;
  61403. /**
  61404. * Gets the right operand input component
  61405. */
  61406. get right(): NodeMaterialConnectionPoint;
  61407. /**
  61408. * Gets the output component
  61409. */
  61410. get output(): NodeMaterialConnectionPoint;
  61411. protected _buildBlock(state: NodeMaterialBuildState): this;
  61412. }
  61413. }
  61414. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61418. /**
  61419. * Block used to add 2 vectors
  61420. */
  61421. export class AddBlock extends NodeMaterialBlock {
  61422. /**
  61423. * Creates a new AddBlock
  61424. * @param name defines the block name
  61425. */
  61426. constructor(name: string);
  61427. /**
  61428. * Gets the current class name
  61429. * @returns the class name
  61430. */
  61431. getClassName(): string;
  61432. /**
  61433. * Gets the left operand input component
  61434. */
  61435. get left(): NodeMaterialConnectionPoint;
  61436. /**
  61437. * Gets the right operand input component
  61438. */
  61439. get right(): NodeMaterialConnectionPoint;
  61440. /**
  61441. * Gets the output component
  61442. */
  61443. get output(): NodeMaterialConnectionPoint;
  61444. protected _buildBlock(state: NodeMaterialBuildState): this;
  61445. }
  61446. }
  61447. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61451. /**
  61452. * Block used to scale a vector by a float
  61453. */
  61454. export class ScaleBlock extends NodeMaterialBlock {
  61455. /**
  61456. * Creates a new ScaleBlock
  61457. * @param name defines the block name
  61458. */
  61459. constructor(name: string);
  61460. /**
  61461. * Gets the current class name
  61462. * @returns the class name
  61463. */
  61464. getClassName(): string;
  61465. /**
  61466. * Gets the input component
  61467. */
  61468. get input(): NodeMaterialConnectionPoint;
  61469. /**
  61470. * Gets the factor input component
  61471. */
  61472. get factor(): NodeMaterialConnectionPoint;
  61473. /**
  61474. * Gets the output component
  61475. */
  61476. get output(): NodeMaterialConnectionPoint;
  61477. protected _buildBlock(state: NodeMaterialBuildState): this;
  61478. }
  61479. }
  61480. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61484. import { Scene } from "babylonjs/scene";
  61485. /**
  61486. * Block used to clamp a float
  61487. */
  61488. export class ClampBlock extends NodeMaterialBlock {
  61489. /** Gets or sets the minimum range */
  61490. minimum: number;
  61491. /** Gets or sets the maximum range */
  61492. maximum: number;
  61493. /**
  61494. * Creates a new ClampBlock
  61495. * @param name defines the block name
  61496. */
  61497. constructor(name: string);
  61498. /**
  61499. * Gets the current class name
  61500. * @returns the class name
  61501. */
  61502. getClassName(): string;
  61503. /**
  61504. * Gets the value input component
  61505. */
  61506. get value(): NodeMaterialConnectionPoint;
  61507. /**
  61508. * Gets the output component
  61509. */
  61510. get output(): NodeMaterialConnectionPoint;
  61511. protected _buildBlock(state: NodeMaterialBuildState): this;
  61512. protected _dumpPropertiesCode(): string;
  61513. serialize(): any;
  61514. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61515. }
  61516. }
  61517. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61521. /**
  61522. * Block used to apply a cross product between 2 vectors
  61523. */
  61524. export class CrossBlock extends NodeMaterialBlock {
  61525. /**
  61526. * Creates a new CrossBlock
  61527. * @param name defines the block name
  61528. */
  61529. constructor(name: string);
  61530. /**
  61531. * Gets the current class name
  61532. * @returns the class name
  61533. */
  61534. getClassName(): string;
  61535. /**
  61536. * Gets the left operand input component
  61537. */
  61538. get left(): NodeMaterialConnectionPoint;
  61539. /**
  61540. * Gets the right operand input component
  61541. */
  61542. get right(): NodeMaterialConnectionPoint;
  61543. /**
  61544. * Gets the output component
  61545. */
  61546. get output(): NodeMaterialConnectionPoint;
  61547. protected _buildBlock(state: NodeMaterialBuildState): this;
  61548. }
  61549. }
  61550. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61554. /**
  61555. * Block used to apply a dot product between 2 vectors
  61556. */
  61557. export class DotBlock extends NodeMaterialBlock {
  61558. /**
  61559. * Creates a new DotBlock
  61560. * @param name defines the block name
  61561. */
  61562. constructor(name: string);
  61563. /**
  61564. * Gets the current class name
  61565. * @returns the class name
  61566. */
  61567. getClassName(): string;
  61568. /**
  61569. * Gets the left operand input component
  61570. */
  61571. get left(): NodeMaterialConnectionPoint;
  61572. /**
  61573. * Gets the right operand input component
  61574. */
  61575. get right(): NodeMaterialConnectionPoint;
  61576. /**
  61577. * Gets the output component
  61578. */
  61579. get output(): NodeMaterialConnectionPoint;
  61580. protected _buildBlock(state: NodeMaterialBuildState): this;
  61581. }
  61582. }
  61583. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61587. import { Vector2 } from "babylonjs/Maths/math.vector";
  61588. import { Scene } from "babylonjs/scene";
  61589. /**
  61590. * Block used to remap a float from a range to a new one
  61591. */
  61592. export class RemapBlock extends NodeMaterialBlock {
  61593. /**
  61594. * Gets or sets the source range
  61595. */
  61596. sourceRange: Vector2;
  61597. /**
  61598. * Gets or sets the target range
  61599. */
  61600. targetRange: Vector2;
  61601. /**
  61602. * Creates a new RemapBlock
  61603. * @param name defines the block name
  61604. */
  61605. constructor(name: string);
  61606. /**
  61607. * Gets the current class name
  61608. * @returns the class name
  61609. */
  61610. getClassName(): string;
  61611. /**
  61612. * Gets the input component
  61613. */
  61614. get input(): NodeMaterialConnectionPoint;
  61615. /**
  61616. * Gets the source min input component
  61617. */
  61618. get sourceMin(): NodeMaterialConnectionPoint;
  61619. /**
  61620. * Gets the source max input component
  61621. */
  61622. get sourceMax(): NodeMaterialConnectionPoint;
  61623. /**
  61624. * Gets the target min input component
  61625. */
  61626. get targetMin(): NodeMaterialConnectionPoint;
  61627. /**
  61628. * Gets the target max input component
  61629. */
  61630. get targetMax(): NodeMaterialConnectionPoint;
  61631. /**
  61632. * Gets the output component
  61633. */
  61634. get output(): NodeMaterialConnectionPoint;
  61635. protected _buildBlock(state: NodeMaterialBuildState): this;
  61636. protected _dumpPropertiesCode(): string;
  61637. serialize(): any;
  61638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61639. }
  61640. }
  61641. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61645. /**
  61646. * Block used to normalize a vector
  61647. */
  61648. export class NormalizeBlock extends NodeMaterialBlock {
  61649. /**
  61650. * Creates a new NormalizeBlock
  61651. * @param name defines the block name
  61652. */
  61653. constructor(name: string);
  61654. /**
  61655. * Gets the current class name
  61656. * @returns the class name
  61657. */
  61658. getClassName(): string;
  61659. /**
  61660. * Gets the input component
  61661. */
  61662. get input(): NodeMaterialConnectionPoint;
  61663. /**
  61664. * Gets the output component
  61665. */
  61666. get output(): NodeMaterialConnectionPoint;
  61667. protected _buildBlock(state: NodeMaterialBuildState): this;
  61668. }
  61669. }
  61670. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61672. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61673. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61674. import { Scene } from "babylonjs/scene";
  61675. /**
  61676. * Operations supported by the Trigonometry block
  61677. */
  61678. export enum TrigonometryBlockOperations {
  61679. /** Cos */
  61680. Cos = 0,
  61681. /** Sin */
  61682. Sin = 1,
  61683. /** Abs */
  61684. Abs = 2,
  61685. /** Exp */
  61686. Exp = 3,
  61687. /** Exp2 */
  61688. Exp2 = 4,
  61689. /** Round */
  61690. Round = 5,
  61691. /** Floor */
  61692. Floor = 6,
  61693. /** Ceiling */
  61694. Ceiling = 7,
  61695. /** Square root */
  61696. Sqrt = 8,
  61697. /** Log */
  61698. Log = 9,
  61699. /** Tangent */
  61700. Tan = 10,
  61701. /** Arc tangent */
  61702. ArcTan = 11,
  61703. /** Arc cosinus */
  61704. ArcCos = 12,
  61705. /** Arc sinus */
  61706. ArcSin = 13,
  61707. /** Fraction */
  61708. Fract = 14,
  61709. /** Sign */
  61710. Sign = 15,
  61711. /** To radians (from degrees) */
  61712. Radians = 16,
  61713. /** To degrees (from radians) */
  61714. Degrees = 17
  61715. }
  61716. /**
  61717. * Block used to apply trigonometry operation to floats
  61718. */
  61719. export class TrigonometryBlock extends NodeMaterialBlock {
  61720. /**
  61721. * Gets or sets the operation applied by the block
  61722. */
  61723. operation: TrigonometryBlockOperations;
  61724. /**
  61725. * Creates a new TrigonometryBlock
  61726. * @param name defines the block name
  61727. */
  61728. constructor(name: string);
  61729. /**
  61730. * Gets the current class name
  61731. * @returns the class name
  61732. */
  61733. getClassName(): string;
  61734. /**
  61735. * Gets the input component
  61736. */
  61737. get input(): NodeMaterialConnectionPoint;
  61738. /**
  61739. * Gets the output component
  61740. */
  61741. get output(): NodeMaterialConnectionPoint;
  61742. protected _buildBlock(state: NodeMaterialBuildState): this;
  61743. serialize(): any;
  61744. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61745. protected _dumpPropertiesCode(): string;
  61746. }
  61747. }
  61748. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61752. /**
  61753. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61754. */
  61755. export class ColorMergerBlock extends NodeMaterialBlock {
  61756. /**
  61757. * Create a new ColorMergerBlock
  61758. * @param name defines the block name
  61759. */
  61760. constructor(name: string);
  61761. /**
  61762. * Gets the current class name
  61763. * @returns the class name
  61764. */
  61765. getClassName(): string;
  61766. /**
  61767. * Gets the rgb component (input)
  61768. */
  61769. get rgbIn(): NodeMaterialConnectionPoint;
  61770. /**
  61771. * Gets the r component (input)
  61772. */
  61773. get r(): NodeMaterialConnectionPoint;
  61774. /**
  61775. * Gets the g component (input)
  61776. */
  61777. get g(): NodeMaterialConnectionPoint;
  61778. /**
  61779. * Gets the b component (input)
  61780. */
  61781. get b(): NodeMaterialConnectionPoint;
  61782. /**
  61783. * Gets the a component (input)
  61784. */
  61785. get a(): NodeMaterialConnectionPoint;
  61786. /**
  61787. * Gets the rgba component (output)
  61788. */
  61789. get rgba(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the rgb component (output)
  61792. */
  61793. get rgbOut(): NodeMaterialConnectionPoint;
  61794. /**
  61795. * Gets the rgb component (output)
  61796. * @deprecated Please use rgbOut instead.
  61797. */
  61798. get rgb(): NodeMaterialConnectionPoint;
  61799. protected _buildBlock(state: NodeMaterialBuildState): this;
  61800. }
  61801. }
  61802. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61803. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61804. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61805. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61806. /**
  61807. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61808. */
  61809. export class VectorMergerBlock extends NodeMaterialBlock {
  61810. /**
  61811. * Create a new VectorMergerBlock
  61812. * @param name defines the block name
  61813. */
  61814. constructor(name: string);
  61815. /**
  61816. * Gets the current class name
  61817. * @returns the class name
  61818. */
  61819. getClassName(): string;
  61820. /**
  61821. * Gets the xyz component (input)
  61822. */
  61823. get xyzIn(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the xy component (input)
  61826. */
  61827. get xyIn(): NodeMaterialConnectionPoint;
  61828. /**
  61829. * Gets the x component (input)
  61830. */
  61831. get x(): NodeMaterialConnectionPoint;
  61832. /**
  61833. * Gets the y component (input)
  61834. */
  61835. get y(): NodeMaterialConnectionPoint;
  61836. /**
  61837. * Gets the z component (input)
  61838. */
  61839. get z(): NodeMaterialConnectionPoint;
  61840. /**
  61841. * Gets the w component (input)
  61842. */
  61843. get w(): NodeMaterialConnectionPoint;
  61844. /**
  61845. * Gets the xyzw component (output)
  61846. */
  61847. get xyzw(): NodeMaterialConnectionPoint;
  61848. /**
  61849. * Gets the xyz component (output)
  61850. */
  61851. get xyzOut(): NodeMaterialConnectionPoint;
  61852. /**
  61853. * Gets the xy component (output)
  61854. */
  61855. get xyOut(): NodeMaterialConnectionPoint;
  61856. /**
  61857. * Gets the xy component (output)
  61858. * @deprecated Please use xyOut instead.
  61859. */
  61860. get xy(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the xyz component (output)
  61863. * @deprecated Please use xyzOut instead.
  61864. */
  61865. get xyz(): NodeMaterialConnectionPoint;
  61866. protected _buildBlock(state: NodeMaterialBuildState): this;
  61867. }
  61868. }
  61869. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61873. /**
  61874. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61875. */
  61876. export class ColorSplitterBlock extends NodeMaterialBlock {
  61877. /**
  61878. * Create a new ColorSplitterBlock
  61879. * @param name defines the block name
  61880. */
  61881. constructor(name: string);
  61882. /**
  61883. * Gets the current class name
  61884. * @returns the class name
  61885. */
  61886. getClassName(): string;
  61887. /**
  61888. * Gets the rgba component (input)
  61889. */
  61890. get rgba(): NodeMaterialConnectionPoint;
  61891. /**
  61892. * Gets the rgb component (input)
  61893. */
  61894. get rgbIn(): NodeMaterialConnectionPoint;
  61895. /**
  61896. * Gets the rgb component (output)
  61897. */
  61898. get rgbOut(): NodeMaterialConnectionPoint;
  61899. /**
  61900. * Gets the r component (output)
  61901. */
  61902. get r(): NodeMaterialConnectionPoint;
  61903. /**
  61904. * Gets the g component (output)
  61905. */
  61906. get g(): NodeMaterialConnectionPoint;
  61907. /**
  61908. * Gets the b component (output)
  61909. */
  61910. get b(): NodeMaterialConnectionPoint;
  61911. /**
  61912. * Gets the a component (output)
  61913. */
  61914. get a(): NodeMaterialConnectionPoint;
  61915. protected _inputRename(name: string): string;
  61916. protected _outputRename(name: string): string;
  61917. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61918. }
  61919. }
  61920. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61924. /**
  61925. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61926. */
  61927. export class VectorSplitterBlock extends NodeMaterialBlock {
  61928. /**
  61929. * Create a new VectorSplitterBlock
  61930. * @param name defines the block name
  61931. */
  61932. constructor(name: string);
  61933. /**
  61934. * Gets the current class name
  61935. * @returns the class name
  61936. */
  61937. getClassName(): string;
  61938. /**
  61939. * Gets the xyzw component (input)
  61940. */
  61941. get xyzw(): NodeMaterialConnectionPoint;
  61942. /**
  61943. * Gets the xyz component (input)
  61944. */
  61945. get xyzIn(): NodeMaterialConnectionPoint;
  61946. /**
  61947. * Gets the xy component (input)
  61948. */
  61949. get xyIn(): NodeMaterialConnectionPoint;
  61950. /**
  61951. * Gets the xyz component (output)
  61952. */
  61953. get xyzOut(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the xy component (output)
  61956. */
  61957. get xyOut(): NodeMaterialConnectionPoint;
  61958. /**
  61959. * Gets the x component (output)
  61960. */
  61961. get x(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the y component (output)
  61964. */
  61965. get y(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the z component (output)
  61968. */
  61969. get z(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the w component (output)
  61972. */
  61973. get w(): NodeMaterialConnectionPoint;
  61974. protected _inputRename(name: string): string;
  61975. protected _outputRename(name: string): string;
  61976. protected _buildBlock(state: NodeMaterialBuildState): this;
  61977. }
  61978. }
  61979. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  61980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61983. /**
  61984. * Block used to lerp between 2 values
  61985. */
  61986. export class LerpBlock extends NodeMaterialBlock {
  61987. /**
  61988. * Creates a new LerpBlock
  61989. * @param name defines the block name
  61990. */
  61991. constructor(name: string);
  61992. /**
  61993. * Gets the current class name
  61994. * @returns the class name
  61995. */
  61996. getClassName(): string;
  61997. /**
  61998. * Gets the left operand input component
  61999. */
  62000. get left(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the right operand input component
  62003. */
  62004. get right(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the gradient operand input component
  62007. */
  62008. get gradient(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the output component
  62011. */
  62012. get output(): NodeMaterialConnectionPoint;
  62013. protected _buildBlock(state: NodeMaterialBuildState): this;
  62014. }
  62015. }
  62016. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62017. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62018. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62020. /**
  62021. * Block used to divide 2 vectors
  62022. */
  62023. export class DivideBlock extends NodeMaterialBlock {
  62024. /**
  62025. * Creates a new DivideBlock
  62026. * @param name defines the block name
  62027. */
  62028. constructor(name: string);
  62029. /**
  62030. * Gets the current class name
  62031. * @returns the class name
  62032. */
  62033. getClassName(): string;
  62034. /**
  62035. * Gets the left operand input component
  62036. */
  62037. get left(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the right operand input component
  62040. */
  62041. get right(): NodeMaterialConnectionPoint;
  62042. /**
  62043. * Gets the output component
  62044. */
  62045. get output(): NodeMaterialConnectionPoint;
  62046. protected _buildBlock(state: NodeMaterialBuildState): this;
  62047. }
  62048. }
  62049. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62053. /**
  62054. * Block used to subtract 2 vectors
  62055. */
  62056. export class SubtractBlock extends NodeMaterialBlock {
  62057. /**
  62058. * Creates a new SubtractBlock
  62059. * @param name defines the block name
  62060. */
  62061. constructor(name: string);
  62062. /**
  62063. * Gets the current class name
  62064. * @returns the class name
  62065. */
  62066. getClassName(): string;
  62067. /**
  62068. * Gets the left operand input component
  62069. */
  62070. get left(): NodeMaterialConnectionPoint;
  62071. /**
  62072. * Gets the right operand input component
  62073. */
  62074. get right(): NodeMaterialConnectionPoint;
  62075. /**
  62076. * Gets the output component
  62077. */
  62078. get output(): NodeMaterialConnectionPoint;
  62079. protected _buildBlock(state: NodeMaterialBuildState): this;
  62080. }
  62081. }
  62082. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62084. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62085. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62086. /**
  62087. * Block used to step a value
  62088. */
  62089. export class StepBlock extends NodeMaterialBlock {
  62090. /**
  62091. * Creates a new StepBlock
  62092. * @param name defines the block name
  62093. */
  62094. constructor(name: string);
  62095. /**
  62096. * Gets the current class name
  62097. * @returns the class name
  62098. */
  62099. getClassName(): string;
  62100. /**
  62101. * Gets the value operand input component
  62102. */
  62103. get value(): NodeMaterialConnectionPoint;
  62104. /**
  62105. * Gets the edge operand input component
  62106. */
  62107. get edge(): NodeMaterialConnectionPoint;
  62108. /**
  62109. * Gets the output component
  62110. */
  62111. get output(): NodeMaterialConnectionPoint;
  62112. protected _buildBlock(state: NodeMaterialBuildState): this;
  62113. }
  62114. }
  62115. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62116. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62118. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62119. /**
  62120. * Block used to get the opposite (1 - x) of a value
  62121. */
  62122. export class OneMinusBlock extends NodeMaterialBlock {
  62123. /**
  62124. * Creates a new OneMinusBlock
  62125. * @param name defines the block name
  62126. */
  62127. constructor(name: string);
  62128. /**
  62129. * Gets the current class name
  62130. * @returns the class name
  62131. */
  62132. getClassName(): string;
  62133. /**
  62134. * Gets the input component
  62135. */
  62136. get input(): NodeMaterialConnectionPoint;
  62137. /**
  62138. * Gets the output component
  62139. */
  62140. get output(): NodeMaterialConnectionPoint;
  62141. protected _buildBlock(state: NodeMaterialBuildState): this;
  62142. }
  62143. }
  62144. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62148. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62149. /**
  62150. * Block used to get the view direction
  62151. */
  62152. export class ViewDirectionBlock extends NodeMaterialBlock {
  62153. /**
  62154. * Creates a new ViewDirectionBlock
  62155. * @param name defines the block name
  62156. */
  62157. constructor(name: string);
  62158. /**
  62159. * Gets the current class name
  62160. * @returns the class name
  62161. */
  62162. getClassName(): string;
  62163. /**
  62164. * Gets the world position component
  62165. */
  62166. get worldPosition(): NodeMaterialConnectionPoint;
  62167. /**
  62168. * Gets the camera position component
  62169. */
  62170. get cameraPosition(): NodeMaterialConnectionPoint;
  62171. /**
  62172. * Gets the output component
  62173. */
  62174. get output(): NodeMaterialConnectionPoint;
  62175. autoConfigure(material: NodeMaterial): void;
  62176. protected _buildBlock(state: NodeMaterialBuildState): this;
  62177. }
  62178. }
  62179. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  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. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62185. /**
  62186. * Block used to compute fresnel value
  62187. */
  62188. export class FresnelBlock extends NodeMaterialBlock {
  62189. /**
  62190. * Create a new FresnelBlock
  62191. * @param name defines the block name
  62192. */
  62193. constructor(name: string);
  62194. /**
  62195. * Gets the current class name
  62196. * @returns the class name
  62197. */
  62198. getClassName(): string;
  62199. /**
  62200. * Gets the world normal input component
  62201. */
  62202. get worldNormal(): NodeMaterialConnectionPoint;
  62203. /**
  62204. * Gets the view direction input component
  62205. */
  62206. get viewDirection(): NodeMaterialConnectionPoint;
  62207. /**
  62208. * Gets the bias input component
  62209. */
  62210. get bias(): NodeMaterialConnectionPoint;
  62211. /**
  62212. * Gets the camera (or eye) position component
  62213. */
  62214. get power(): NodeMaterialConnectionPoint;
  62215. /**
  62216. * Gets the fresnel output component
  62217. */
  62218. get fresnel(): NodeMaterialConnectionPoint;
  62219. autoConfigure(material: NodeMaterial): void;
  62220. protected _buildBlock(state: NodeMaterialBuildState): this;
  62221. }
  62222. }
  62223. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62227. /**
  62228. * Block used to get the max of 2 values
  62229. */
  62230. export class MaxBlock extends NodeMaterialBlock {
  62231. /**
  62232. * Creates a new MaxBlock
  62233. * @param name defines the block name
  62234. */
  62235. constructor(name: string);
  62236. /**
  62237. * Gets the current class name
  62238. * @returns the class name
  62239. */
  62240. getClassName(): string;
  62241. /**
  62242. * Gets the left operand input component
  62243. */
  62244. get left(): NodeMaterialConnectionPoint;
  62245. /**
  62246. * Gets the right operand input component
  62247. */
  62248. get right(): NodeMaterialConnectionPoint;
  62249. /**
  62250. * Gets the output component
  62251. */
  62252. get output(): NodeMaterialConnectionPoint;
  62253. protected _buildBlock(state: NodeMaterialBuildState): this;
  62254. }
  62255. }
  62256. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62257. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62258. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62259. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62260. /**
  62261. * Block used to get the min of 2 values
  62262. */
  62263. export class MinBlock extends NodeMaterialBlock {
  62264. /**
  62265. * Creates a new MinBlock
  62266. * @param name defines the block name
  62267. */
  62268. constructor(name: string);
  62269. /**
  62270. * Gets the current class name
  62271. * @returns the class name
  62272. */
  62273. getClassName(): string;
  62274. /**
  62275. * Gets the left operand input component
  62276. */
  62277. get left(): NodeMaterialConnectionPoint;
  62278. /**
  62279. * Gets the right operand input component
  62280. */
  62281. get right(): NodeMaterialConnectionPoint;
  62282. /**
  62283. * Gets the output component
  62284. */
  62285. get output(): NodeMaterialConnectionPoint;
  62286. protected _buildBlock(state: NodeMaterialBuildState): this;
  62287. }
  62288. }
  62289. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62293. /**
  62294. * Block used to get the distance between 2 values
  62295. */
  62296. export class DistanceBlock extends NodeMaterialBlock {
  62297. /**
  62298. * Creates a new DistanceBlock
  62299. * @param name defines the block name
  62300. */
  62301. constructor(name: string);
  62302. /**
  62303. * Gets the current class name
  62304. * @returns the class name
  62305. */
  62306. getClassName(): string;
  62307. /**
  62308. * Gets the left operand input component
  62309. */
  62310. get left(): NodeMaterialConnectionPoint;
  62311. /**
  62312. * Gets the right operand input component
  62313. */
  62314. get right(): NodeMaterialConnectionPoint;
  62315. /**
  62316. * Gets the output component
  62317. */
  62318. get output(): NodeMaterialConnectionPoint;
  62319. protected _buildBlock(state: NodeMaterialBuildState): this;
  62320. }
  62321. }
  62322. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62323. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62326. /**
  62327. * Block used to get the length of a vector
  62328. */
  62329. export class LengthBlock extends NodeMaterialBlock {
  62330. /**
  62331. * Creates a new LengthBlock
  62332. * @param name defines the block name
  62333. */
  62334. constructor(name: string);
  62335. /**
  62336. * Gets the current class name
  62337. * @returns the class name
  62338. */
  62339. getClassName(): string;
  62340. /**
  62341. * Gets the value input component
  62342. */
  62343. get value(): NodeMaterialConnectionPoint;
  62344. /**
  62345. * Gets the output component
  62346. */
  62347. get output(): NodeMaterialConnectionPoint;
  62348. protected _buildBlock(state: NodeMaterialBuildState): this;
  62349. }
  62350. }
  62351. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62355. /**
  62356. * Block used to get negative version of a value (i.e. x * -1)
  62357. */
  62358. export class NegateBlock extends NodeMaterialBlock {
  62359. /**
  62360. * Creates a new NegateBlock
  62361. * @param name defines the block name
  62362. */
  62363. constructor(name: string);
  62364. /**
  62365. * Gets the current class name
  62366. * @returns the class name
  62367. */
  62368. getClassName(): string;
  62369. /**
  62370. * Gets the value input component
  62371. */
  62372. get value(): NodeMaterialConnectionPoint;
  62373. /**
  62374. * Gets the output component
  62375. */
  62376. get output(): NodeMaterialConnectionPoint;
  62377. protected _buildBlock(state: NodeMaterialBuildState): this;
  62378. }
  62379. }
  62380. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62384. /**
  62385. * Block used to get the value of the first parameter raised to the power of the second
  62386. */
  62387. export class PowBlock extends NodeMaterialBlock {
  62388. /**
  62389. * Creates a new PowBlock
  62390. * @param name defines the block name
  62391. */
  62392. constructor(name: string);
  62393. /**
  62394. * Gets the current class name
  62395. * @returns the class name
  62396. */
  62397. getClassName(): string;
  62398. /**
  62399. * Gets the value operand input component
  62400. */
  62401. get value(): NodeMaterialConnectionPoint;
  62402. /**
  62403. * Gets the power operand input component
  62404. */
  62405. get power(): NodeMaterialConnectionPoint;
  62406. /**
  62407. * Gets the output component
  62408. */
  62409. get output(): NodeMaterialConnectionPoint;
  62410. protected _buildBlock(state: NodeMaterialBuildState): this;
  62411. }
  62412. }
  62413. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62417. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62418. /**
  62419. * Block used to get a random number
  62420. */
  62421. export class RandomNumberBlock extends NodeMaterialBlock {
  62422. /**
  62423. * Creates a new RandomNumberBlock
  62424. * @param name defines the block name
  62425. */
  62426. constructor(name: string);
  62427. /**
  62428. * Gets the current class name
  62429. * @returns the class name
  62430. */
  62431. getClassName(): string;
  62432. /**
  62433. * Gets the seed input component
  62434. */
  62435. get seed(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the output component
  62438. */
  62439. get output(): NodeMaterialConnectionPoint;
  62440. protected _buildBlock(state: NodeMaterialBuildState): this;
  62441. }
  62442. }
  62443. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62447. /**
  62448. * Block used to compute arc tangent of 2 values
  62449. */
  62450. export class ArcTan2Block extends NodeMaterialBlock {
  62451. /**
  62452. * Creates a new ArcTan2Block
  62453. * @param name defines the block name
  62454. */
  62455. constructor(name: string);
  62456. /**
  62457. * Gets the current class name
  62458. * @returns the class name
  62459. */
  62460. getClassName(): string;
  62461. /**
  62462. * Gets the x operand input component
  62463. */
  62464. get x(): NodeMaterialConnectionPoint;
  62465. /**
  62466. * Gets the y operand input component
  62467. */
  62468. get y(): NodeMaterialConnectionPoint;
  62469. /**
  62470. * Gets the output component
  62471. */
  62472. get output(): NodeMaterialConnectionPoint;
  62473. protected _buildBlock(state: NodeMaterialBuildState): this;
  62474. }
  62475. }
  62476. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62480. /**
  62481. * Block used to smooth step a value
  62482. */
  62483. export class SmoothStepBlock extends NodeMaterialBlock {
  62484. /**
  62485. * Creates a new SmoothStepBlock
  62486. * @param name defines the block name
  62487. */
  62488. constructor(name: string);
  62489. /**
  62490. * Gets the current class name
  62491. * @returns the class name
  62492. */
  62493. getClassName(): string;
  62494. /**
  62495. * Gets the value operand input component
  62496. */
  62497. get value(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the first edge operand input component
  62500. */
  62501. get edge0(): NodeMaterialConnectionPoint;
  62502. /**
  62503. * Gets the second edge operand input component
  62504. */
  62505. get edge1(): NodeMaterialConnectionPoint;
  62506. /**
  62507. * Gets the output component
  62508. */
  62509. get output(): NodeMaterialConnectionPoint;
  62510. protected _buildBlock(state: NodeMaterialBuildState): this;
  62511. }
  62512. }
  62513. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62517. /**
  62518. * Block used to get the reciprocal (1 / x) of a value
  62519. */
  62520. export class ReciprocalBlock extends NodeMaterialBlock {
  62521. /**
  62522. * Creates a new ReciprocalBlock
  62523. * @param name defines the block name
  62524. */
  62525. constructor(name: string);
  62526. /**
  62527. * Gets the current class name
  62528. * @returns the class name
  62529. */
  62530. getClassName(): string;
  62531. /**
  62532. * Gets the input component
  62533. */
  62534. get input(): NodeMaterialConnectionPoint;
  62535. /**
  62536. * Gets the output component
  62537. */
  62538. get output(): NodeMaterialConnectionPoint;
  62539. protected _buildBlock(state: NodeMaterialBuildState): this;
  62540. }
  62541. }
  62542. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62544. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62545. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62546. /**
  62547. * Block used to replace a color by another one
  62548. */
  62549. export class ReplaceColorBlock extends NodeMaterialBlock {
  62550. /**
  62551. * Creates a new ReplaceColorBlock
  62552. * @param name defines the block name
  62553. */
  62554. constructor(name: string);
  62555. /**
  62556. * Gets the current class name
  62557. * @returns the class name
  62558. */
  62559. getClassName(): string;
  62560. /**
  62561. * Gets the value input component
  62562. */
  62563. get value(): NodeMaterialConnectionPoint;
  62564. /**
  62565. * Gets the reference input component
  62566. */
  62567. get reference(): NodeMaterialConnectionPoint;
  62568. /**
  62569. * Gets the distance input component
  62570. */
  62571. get distance(): NodeMaterialConnectionPoint;
  62572. /**
  62573. * Gets the replacement input component
  62574. */
  62575. get replacement(): NodeMaterialConnectionPoint;
  62576. /**
  62577. * Gets the output component
  62578. */
  62579. get output(): NodeMaterialConnectionPoint;
  62580. protected _buildBlock(state: NodeMaterialBuildState): this;
  62581. }
  62582. }
  62583. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62587. /**
  62588. * Block used to posterize a value
  62589. * @see https://en.wikipedia.org/wiki/Posterization
  62590. */
  62591. export class PosterizeBlock extends NodeMaterialBlock {
  62592. /**
  62593. * Creates a new PosterizeBlock
  62594. * @param name defines the block name
  62595. */
  62596. constructor(name: string);
  62597. /**
  62598. * Gets the current class name
  62599. * @returns the class name
  62600. */
  62601. getClassName(): string;
  62602. /**
  62603. * Gets the value input component
  62604. */
  62605. get value(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the steps input component
  62608. */
  62609. get steps(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the output component
  62612. */
  62613. get output(): NodeMaterialConnectionPoint;
  62614. protected _buildBlock(state: NodeMaterialBuildState): this;
  62615. }
  62616. }
  62617. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62621. import { Scene } from "babylonjs/scene";
  62622. /**
  62623. * Operations supported by the Wave block
  62624. */
  62625. export enum WaveBlockKind {
  62626. /** SawTooth */
  62627. SawTooth = 0,
  62628. /** Square */
  62629. Square = 1,
  62630. /** Triangle */
  62631. Triangle = 2
  62632. }
  62633. /**
  62634. * Block used to apply wave operation to floats
  62635. */
  62636. export class WaveBlock extends NodeMaterialBlock {
  62637. /**
  62638. * Gets or sets the kibnd of wave to be applied by the block
  62639. */
  62640. kind: WaveBlockKind;
  62641. /**
  62642. * Creates a new WaveBlock
  62643. * @param name defines the block name
  62644. */
  62645. constructor(name: string);
  62646. /**
  62647. * Gets the current class name
  62648. * @returns the class name
  62649. */
  62650. getClassName(): string;
  62651. /**
  62652. * Gets the input component
  62653. */
  62654. get input(): NodeMaterialConnectionPoint;
  62655. /**
  62656. * Gets the output component
  62657. */
  62658. get output(): NodeMaterialConnectionPoint;
  62659. protected _buildBlock(state: NodeMaterialBuildState): this;
  62660. serialize(): any;
  62661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62662. }
  62663. }
  62664. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62666. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62668. import { Color3 } from "babylonjs/Maths/math.color";
  62669. import { Scene } from "babylonjs/scene";
  62670. /**
  62671. * Class used to store a color step for the GradientBlock
  62672. */
  62673. export class GradientBlockColorStep {
  62674. /**
  62675. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62676. */
  62677. step: number;
  62678. /**
  62679. * Gets or sets the color associated with this step
  62680. */
  62681. color: Color3;
  62682. /**
  62683. * Creates a new GradientBlockColorStep
  62684. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62685. * @param color defines the color associated with this step
  62686. */
  62687. constructor(
  62688. /**
  62689. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62690. */
  62691. step: number,
  62692. /**
  62693. * Gets or sets the color associated with this step
  62694. */
  62695. color: Color3);
  62696. }
  62697. /**
  62698. * Block used to return a color from a gradient based on an input value between 0 and 1
  62699. */
  62700. export class GradientBlock extends NodeMaterialBlock {
  62701. /**
  62702. * Gets or sets the list of color steps
  62703. */
  62704. colorSteps: GradientBlockColorStep[];
  62705. /**
  62706. * Creates a new GradientBlock
  62707. * @param name defines the block name
  62708. */
  62709. constructor(name: string);
  62710. /**
  62711. * Gets the current class name
  62712. * @returns the class name
  62713. */
  62714. getClassName(): string;
  62715. /**
  62716. * Gets the gradient input component
  62717. */
  62718. get gradient(): NodeMaterialConnectionPoint;
  62719. /**
  62720. * Gets the output component
  62721. */
  62722. get output(): NodeMaterialConnectionPoint;
  62723. private _writeColorConstant;
  62724. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62725. serialize(): any;
  62726. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62727. protected _dumpPropertiesCode(): string;
  62728. }
  62729. }
  62730. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62731. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62732. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62733. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62734. /**
  62735. * Block used to normalize lerp between 2 values
  62736. */
  62737. export class NLerpBlock extends NodeMaterialBlock {
  62738. /**
  62739. * Creates a new NLerpBlock
  62740. * @param name defines the block name
  62741. */
  62742. constructor(name: string);
  62743. /**
  62744. * Gets the current class name
  62745. * @returns the class name
  62746. */
  62747. getClassName(): string;
  62748. /**
  62749. * Gets the left operand input component
  62750. */
  62751. get left(): NodeMaterialConnectionPoint;
  62752. /**
  62753. * Gets the right operand input component
  62754. */
  62755. get right(): NodeMaterialConnectionPoint;
  62756. /**
  62757. * Gets the gradient operand input component
  62758. */
  62759. get gradient(): NodeMaterialConnectionPoint;
  62760. /**
  62761. * Gets the output component
  62762. */
  62763. get output(): NodeMaterialConnectionPoint;
  62764. protected _buildBlock(state: NodeMaterialBuildState): this;
  62765. }
  62766. }
  62767. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62768. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62769. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62770. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62771. import { Scene } from "babylonjs/scene";
  62772. /**
  62773. * block used to Generate a Worley Noise 3D Noise Pattern
  62774. */
  62775. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62776. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62777. manhattanDistance: boolean;
  62778. /**
  62779. * Creates a new WorleyNoise3DBlock
  62780. * @param name defines the block name
  62781. */
  62782. constructor(name: string);
  62783. /**
  62784. * Gets the current class name
  62785. * @returns the class name
  62786. */
  62787. getClassName(): string;
  62788. /**
  62789. * Gets the seed input component
  62790. */
  62791. get seed(): NodeMaterialConnectionPoint;
  62792. /**
  62793. * Gets the jitter input component
  62794. */
  62795. get jitter(): NodeMaterialConnectionPoint;
  62796. /**
  62797. * Gets the output component
  62798. */
  62799. get output(): NodeMaterialConnectionPoint;
  62800. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62801. /**
  62802. * Exposes the properties to the UI?
  62803. */
  62804. protected _dumpPropertiesCode(): string;
  62805. /**
  62806. * Exposes the properties to the Seralize?
  62807. */
  62808. serialize(): any;
  62809. /**
  62810. * Exposes the properties to the deseralize?
  62811. */
  62812. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62813. }
  62814. }
  62815. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62819. /**
  62820. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62821. */
  62822. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62823. /**
  62824. * Creates a new SimplexPerlin3DBlock
  62825. * @param name defines the block name
  62826. */
  62827. constructor(name: string);
  62828. /**
  62829. * Gets the current class name
  62830. * @returns the class name
  62831. */
  62832. getClassName(): string;
  62833. /**
  62834. * Gets the seed operand input component
  62835. */
  62836. get seed(): NodeMaterialConnectionPoint;
  62837. /**
  62838. * Gets the output component
  62839. */
  62840. get output(): NodeMaterialConnectionPoint;
  62841. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62842. }
  62843. }
  62844. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62848. /**
  62849. * Block used to blend normals
  62850. */
  62851. export class NormalBlendBlock extends NodeMaterialBlock {
  62852. /**
  62853. * Creates a new NormalBlendBlock
  62854. * @param name defines the block name
  62855. */
  62856. constructor(name: string);
  62857. /**
  62858. * Gets the current class name
  62859. * @returns the class name
  62860. */
  62861. getClassName(): string;
  62862. /**
  62863. * Gets the first input component
  62864. */
  62865. get normalMap0(): NodeMaterialConnectionPoint;
  62866. /**
  62867. * Gets the second input component
  62868. */
  62869. get normalMap1(): NodeMaterialConnectionPoint;
  62870. /**
  62871. * Gets the output component
  62872. */
  62873. get output(): NodeMaterialConnectionPoint;
  62874. protected _buildBlock(state: NodeMaterialBuildState): this;
  62875. }
  62876. }
  62877. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62881. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62882. /**
  62883. * Block used to rotate a 2d vector by a given angle
  62884. */
  62885. export class Rotate2dBlock extends NodeMaterialBlock {
  62886. /**
  62887. * Creates a new Rotate2dBlock
  62888. * @param name defines the block name
  62889. */
  62890. constructor(name: string);
  62891. /**
  62892. * Gets the current class name
  62893. * @returns the class name
  62894. */
  62895. getClassName(): string;
  62896. /**
  62897. * Gets the input vector
  62898. */
  62899. get input(): NodeMaterialConnectionPoint;
  62900. /**
  62901. * Gets the input angle
  62902. */
  62903. get angle(): NodeMaterialConnectionPoint;
  62904. /**
  62905. * Gets the output component
  62906. */
  62907. get output(): NodeMaterialConnectionPoint;
  62908. autoConfigure(material: NodeMaterial): void;
  62909. protected _buildBlock(state: NodeMaterialBuildState): this;
  62910. }
  62911. }
  62912. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  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. /**
  62917. * Block used to get the reflected vector from a direction and a normal
  62918. */
  62919. export class ReflectBlock extends NodeMaterialBlock {
  62920. /**
  62921. * Creates a new ReflectBlock
  62922. * @param name defines the block name
  62923. */
  62924. constructor(name: string);
  62925. /**
  62926. * Gets the current class name
  62927. * @returns the class name
  62928. */
  62929. getClassName(): string;
  62930. /**
  62931. * Gets the incident component
  62932. */
  62933. get incident(): NodeMaterialConnectionPoint;
  62934. /**
  62935. * Gets the normal component
  62936. */
  62937. get normal(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the output component
  62940. */
  62941. get output(): NodeMaterialConnectionPoint;
  62942. protected _buildBlock(state: NodeMaterialBuildState): this;
  62943. }
  62944. }
  62945. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62949. /**
  62950. * Block used to get the refracted vector from a direction and a normal
  62951. */
  62952. export class RefractBlock extends NodeMaterialBlock {
  62953. /**
  62954. * Creates a new RefractBlock
  62955. * @param name defines the block name
  62956. */
  62957. constructor(name: string);
  62958. /**
  62959. * Gets the current class name
  62960. * @returns the class name
  62961. */
  62962. getClassName(): string;
  62963. /**
  62964. * Gets the incident component
  62965. */
  62966. get incident(): NodeMaterialConnectionPoint;
  62967. /**
  62968. * Gets the normal component
  62969. */
  62970. get normal(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the index of refraction component
  62973. */
  62974. get ior(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the output component
  62977. */
  62978. get output(): NodeMaterialConnectionPoint;
  62979. protected _buildBlock(state: NodeMaterialBuildState): this;
  62980. }
  62981. }
  62982. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  62983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62986. /**
  62987. * Block used to desaturate a color
  62988. */
  62989. export class DesaturateBlock extends NodeMaterialBlock {
  62990. /**
  62991. * Creates a new DesaturateBlock
  62992. * @param name defines the block name
  62993. */
  62994. constructor(name: string);
  62995. /**
  62996. * Gets the current class name
  62997. * @returns the class name
  62998. */
  62999. getClassName(): string;
  63000. /**
  63001. * Gets the color operand input component
  63002. */
  63003. get color(): NodeMaterialConnectionPoint;
  63004. /**
  63005. * Gets the level operand input component
  63006. */
  63007. get level(): NodeMaterialConnectionPoint;
  63008. /**
  63009. * Gets the output component
  63010. */
  63011. get output(): NodeMaterialConnectionPoint;
  63012. protected _buildBlock(state: NodeMaterialBuildState): this;
  63013. }
  63014. }
  63015. declare module "babylonjs/Materials/Node/Blocks/index" {
  63016. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63017. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63018. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63019. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63020. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63021. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63022. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63023. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63024. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63025. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63026. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63027. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63028. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63029. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63030. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63031. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63032. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63033. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63034. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63035. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63036. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63037. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63038. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63039. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63040. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63041. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63042. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63043. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63044. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63045. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63046. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63047. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63048. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63049. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63050. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63051. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63052. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63053. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63054. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63055. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63056. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63057. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63058. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63063. }
  63064. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63065. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63066. }
  63067. declare module "babylonjs/Materials/Node/index" {
  63068. export * from "babylonjs/Materials/Node/Enums/index";
  63069. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63070. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63071. export * from "babylonjs/Materials/Node/nodeMaterial";
  63072. export * from "babylonjs/Materials/Node/Blocks/index";
  63073. export * from "babylonjs/Materials/Node/Optimizers/index";
  63074. }
  63075. declare module "babylonjs/Materials/effectRenderer" {
  63076. import { Nullable } from "babylonjs/types";
  63077. import { Texture } from "babylonjs/Materials/Textures/texture";
  63078. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63079. import { Viewport } from "babylonjs/Maths/math.viewport";
  63080. import { Observable } from "babylonjs/Misc/observable";
  63081. import { Effect } from "babylonjs/Materials/effect";
  63082. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63083. import "babylonjs/Shaders/postprocess.vertex";
  63084. /**
  63085. * Effect Render Options
  63086. */
  63087. export interface IEffectRendererOptions {
  63088. /**
  63089. * Defines the vertices positions.
  63090. */
  63091. positions?: number[];
  63092. /**
  63093. * Defines the indices.
  63094. */
  63095. indices?: number[];
  63096. }
  63097. /**
  63098. * Helper class to render one or more effects
  63099. */
  63100. export class EffectRenderer {
  63101. private engine;
  63102. private static _DefaultOptions;
  63103. private _vertexBuffers;
  63104. private _indexBuffer;
  63105. private _ringBufferIndex;
  63106. private _ringScreenBuffer;
  63107. private _fullscreenViewport;
  63108. private _getNextFrameBuffer;
  63109. /**
  63110. * Creates an effect renderer
  63111. * @param engine the engine to use for rendering
  63112. * @param options defines the options of the effect renderer
  63113. */
  63114. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63115. /**
  63116. * Sets the current viewport in normalized coordinates 0-1
  63117. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63118. */
  63119. setViewport(viewport?: Viewport): void;
  63120. /**
  63121. * Binds the embedded attributes buffer to the effect.
  63122. * @param effect Defines the effect to bind the attributes for
  63123. */
  63124. bindBuffers(effect: Effect): void;
  63125. /**
  63126. * Sets the current effect wrapper to use during draw.
  63127. * The effect needs to be ready before calling this api.
  63128. * This also sets the default full screen position attribute.
  63129. * @param effectWrapper Defines the effect to draw with
  63130. */
  63131. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63132. /**
  63133. * Draws a full screen quad.
  63134. */
  63135. draw(): void;
  63136. /**
  63137. * renders one or more effects to a specified texture
  63138. * @param effectWrappers list of effects to renderer
  63139. * @param outputTexture texture to draw to, if null it will render to the screen
  63140. */
  63141. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63142. /**
  63143. * Disposes of the effect renderer
  63144. */
  63145. dispose(): void;
  63146. }
  63147. /**
  63148. * Options to create an EffectWrapper
  63149. */
  63150. interface EffectWrapperCreationOptions {
  63151. /**
  63152. * Engine to use to create the effect
  63153. */
  63154. engine: ThinEngine;
  63155. /**
  63156. * Fragment shader for the effect
  63157. */
  63158. fragmentShader: string;
  63159. /**
  63160. * Vertex shader for the effect
  63161. */
  63162. vertexShader?: string;
  63163. /**
  63164. * Attributes to use in the shader
  63165. */
  63166. attributeNames?: Array<string>;
  63167. /**
  63168. * Uniforms to use in the shader
  63169. */
  63170. uniformNames?: Array<string>;
  63171. /**
  63172. * Texture sampler names to use in the shader
  63173. */
  63174. samplerNames?: Array<string>;
  63175. /**
  63176. * The friendly name of the effect displayed in Spector.
  63177. */
  63178. name?: string;
  63179. }
  63180. /**
  63181. * Wraps an effect to be used for rendering
  63182. */
  63183. export class EffectWrapper {
  63184. /**
  63185. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63186. */
  63187. onApplyObservable: Observable<{}>;
  63188. /**
  63189. * The underlying effect
  63190. */
  63191. effect: Effect;
  63192. /**
  63193. * Creates an effect to be renderer
  63194. * @param creationOptions options to create the effect
  63195. */
  63196. constructor(creationOptions: EffectWrapperCreationOptions);
  63197. /**
  63198. * Disposes of the effect wrapper
  63199. */
  63200. dispose(): void;
  63201. }
  63202. }
  63203. declare module "babylonjs/Materials/index" {
  63204. export * from "babylonjs/Materials/Background/index";
  63205. export * from "babylonjs/Materials/colorCurves";
  63206. export * from "babylonjs/Materials/iEffectFallbacks";
  63207. export * from "babylonjs/Materials/effectFallbacks";
  63208. export * from "babylonjs/Materials/effect";
  63209. export * from "babylonjs/Materials/fresnelParameters";
  63210. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63211. export * from "babylonjs/Materials/material";
  63212. export * from "babylonjs/Materials/materialDefines";
  63213. export * from "babylonjs/Materials/materialHelper";
  63214. export * from "babylonjs/Materials/multiMaterial";
  63215. export * from "babylonjs/Materials/PBR/index";
  63216. export * from "babylonjs/Materials/pushMaterial";
  63217. export * from "babylonjs/Materials/shaderMaterial";
  63218. export * from "babylonjs/Materials/standardMaterial";
  63219. export * from "babylonjs/Materials/Textures/index";
  63220. export * from "babylonjs/Materials/uniformBuffer";
  63221. export * from "babylonjs/Materials/materialFlags";
  63222. export * from "babylonjs/Materials/Node/index";
  63223. export * from "babylonjs/Materials/effectRenderer";
  63224. }
  63225. declare module "babylonjs/Maths/index" {
  63226. export * from "babylonjs/Maths/math.scalar";
  63227. export * from "babylonjs/Maths/math";
  63228. export * from "babylonjs/Maths/sphericalPolynomial";
  63229. }
  63230. declare module "babylonjs/Misc/workerPool" {
  63231. import { IDisposable } from "babylonjs/scene";
  63232. /**
  63233. * Helper class to push actions to a pool of workers.
  63234. */
  63235. export class WorkerPool implements IDisposable {
  63236. private _workerInfos;
  63237. private _pendingActions;
  63238. /**
  63239. * Constructor
  63240. * @param workers Array of workers to use for actions
  63241. */
  63242. constructor(workers: Array<Worker>);
  63243. /**
  63244. * Terminates all workers and clears any pending actions.
  63245. */
  63246. dispose(): void;
  63247. /**
  63248. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63249. * pended until a worker has completed its action.
  63250. * @param action The action to perform. Call onComplete when the action is complete.
  63251. */
  63252. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63253. private _execute;
  63254. }
  63255. }
  63256. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63257. import { IDisposable } from "babylonjs/scene";
  63258. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63259. /**
  63260. * Configuration for Draco compression
  63261. */
  63262. export interface IDracoCompressionConfiguration {
  63263. /**
  63264. * Configuration for the decoder.
  63265. */
  63266. decoder: {
  63267. /**
  63268. * The url to the WebAssembly module.
  63269. */
  63270. wasmUrl?: string;
  63271. /**
  63272. * The url to the WebAssembly binary.
  63273. */
  63274. wasmBinaryUrl?: string;
  63275. /**
  63276. * The url to the fallback JavaScript module.
  63277. */
  63278. fallbackUrl?: string;
  63279. };
  63280. }
  63281. /**
  63282. * Draco compression (https://google.github.io/draco/)
  63283. *
  63284. * This class wraps the Draco module.
  63285. *
  63286. * **Encoder**
  63287. *
  63288. * The encoder is not currently implemented.
  63289. *
  63290. * **Decoder**
  63291. *
  63292. * 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.
  63293. *
  63294. * To update the configuration, use the following code:
  63295. * ```javascript
  63296. * DracoCompression.Configuration = {
  63297. * decoder: {
  63298. * wasmUrl: "<url to the WebAssembly library>",
  63299. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63300. * fallbackUrl: "<url to the fallback JavaScript library>",
  63301. * }
  63302. * };
  63303. * ```
  63304. *
  63305. * 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.
  63306. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63307. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63308. *
  63309. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63310. * ```javascript
  63311. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63312. * ```
  63313. *
  63314. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63315. */
  63316. export class DracoCompression implements IDisposable {
  63317. private _workerPoolPromise?;
  63318. private _decoderModulePromise?;
  63319. /**
  63320. * The configuration. Defaults to the following urls:
  63321. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63322. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63323. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63324. */
  63325. static Configuration: IDracoCompressionConfiguration;
  63326. /**
  63327. * Returns true if the decoder configuration is available.
  63328. */
  63329. static get DecoderAvailable(): boolean;
  63330. /**
  63331. * Default number of workers to create when creating the draco compression object.
  63332. */
  63333. static DefaultNumWorkers: number;
  63334. private static GetDefaultNumWorkers;
  63335. private static _Default;
  63336. /**
  63337. * Default instance for the draco compression object.
  63338. */
  63339. static get Default(): DracoCompression;
  63340. /**
  63341. * Constructor
  63342. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63343. */
  63344. constructor(numWorkers?: number);
  63345. /**
  63346. * Stop all async operations and release resources.
  63347. */
  63348. dispose(): void;
  63349. /**
  63350. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63351. * @returns a promise that resolves when ready
  63352. */
  63353. whenReadyAsync(): Promise<void>;
  63354. /**
  63355. * Decode Draco compressed mesh data to vertex data.
  63356. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63357. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63358. * @returns A promise that resolves with the decoded vertex data
  63359. */
  63360. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63361. [kind: string]: number;
  63362. }): Promise<VertexData>;
  63363. }
  63364. }
  63365. declare module "babylonjs/Meshes/Compression/index" {
  63366. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63367. }
  63368. declare module "babylonjs/Meshes/csg" {
  63369. import { Nullable } from "babylonjs/types";
  63370. import { Scene } from "babylonjs/scene";
  63371. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63372. import { Mesh } from "babylonjs/Meshes/mesh";
  63373. import { Material } from "babylonjs/Materials/material";
  63374. /**
  63375. * Class for building Constructive Solid Geometry
  63376. */
  63377. export class CSG {
  63378. private polygons;
  63379. /**
  63380. * The world matrix
  63381. */
  63382. matrix: Matrix;
  63383. /**
  63384. * Stores the position
  63385. */
  63386. position: Vector3;
  63387. /**
  63388. * Stores the rotation
  63389. */
  63390. rotation: Vector3;
  63391. /**
  63392. * Stores the rotation quaternion
  63393. */
  63394. rotationQuaternion: Nullable<Quaternion>;
  63395. /**
  63396. * Stores the scaling vector
  63397. */
  63398. scaling: Vector3;
  63399. /**
  63400. * Convert the Mesh to CSG
  63401. * @param mesh The Mesh to convert to CSG
  63402. * @returns A new CSG from the Mesh
  63403. */
  63404. static FromMesh(mesh: Mesh): CSG;
  63405. /**
  63406. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63407. * @param polygons Polygons used to construct a CSG solid
  63408. */
  63409. private static FromPolygons;
  63410. /**
  63411. * Clones, or makes a deep copy, of the CSG
  63412. * @returns A new CSG
  63413. */
  63414. clone(): CSG;
  63415. /**
  63416. * Unions this CSG with another CSG
  63417. * @param csg The CSG to union against this CSG
  63418. * @returns The unioned CSG
  63419. */
  63420. union(csg: CSG): CSG;
  63421. /**
  63422. * Unions this CSG with another CSG in place
  63423. * @param csg The CSG to union against this CSG
  63424. */
  63425. unionInPlace(csg: CSG): void;
  63426. /**
  63427. * Subtracts this CSG with another CSG
  63428. * @param csg The CSG to subtract against this CSG
  63429. * @returns A new CSG
  63430. */
  63431. subtract(csg: CSG): CSG;
  63432. /**
  63433. * Subtracts this CSG with another CSG in place
  63434. * @param csg The CSG to subtact against this CSG
  63435. */
  63436. subtractInPlace(csg: CSG): void;
  63437. /**
  63438. * Intersect this CSG with another CSG
  63439. * @param csg The CSG to intersect against this CSG
  63440. * @returns A new CSG
  63441. */
  63442. intersect(csg: CSG): CSG;
  63443. /**
  63444. * Intersects this CSG with another CSG in place
  63445. * @param csg The CSG to intersect against this CSG
  63446. */
  63447. intersectInPlace(csg: CSG): void;
  63448. /**
  63449. * Return a new CSG solid with solid and empty space switched. This solid is
  63450. * not modified.
  63451. * @returns A new CSG solid with solid and empty space switched
  63452. */
  63453. inverse(): CSG;
  63454. /**
  63455. * Inverses the CSG in place
  63456. */
  63457. inverseInPlace(): void;
  63458. /**
  63459. * This is used to keep meshes transformations so they can be restored
  63460. * when we build back a Babylon Mesh
  63461. * NB : All CSG operations are performed in world coordinates
  63462. * @param csg The CSG to copy the transform attributes from
  63463. * @returns This CSG
  63464. */
  63465. copyTransformAttributes(csg: CSG): CSG;
  63466. /**
  63467. * Build Raw mesh from CSG
  63468. * Coordinates here are in world space
  63469. * @param name The name of the mesh geometry
  63470. * @param scene The Scene
  63471. * @param keepSubMeshes Specifies if the submeshes should be kept
  63472. * @returns A new Mesh
  63473. */
  63474. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63475. /**
  63476. * Build Mesh from CSG taking material and transforms into account
  63477. * @param name The name of the Mesh
  63478. * @param material The material of the Mesh
  63479. * @param scene The Scene
  63480. * @param keepSubMeshes Specifies if submeshes should be kept
  63481. * @returns The new Mesh
  63482. */
  63483. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63484. }
  63485. }
  63486. declare module "babylonjs/Meshes/trailMesh" {
  63487. import { Mesh } from "babylonjs/Meshes/mesh";
  63488. import { Scene } from "babylonjs/scene";
  63489. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63490. /**
  63491. * Class used to create a trail following a mesh
  63492. */
  63493. export class TrailMesh extends Mesh {
  63494. private _generator;
  63495. private _autoStart;
  63496. private _running;
  63497. private _diameter;
  63498. private _length;
  63499. private _sectionPolygonPointsCount;
  63500. private _sectionVectors;
  63501. private _sectionNormalVectors;
  63502. private _beforeRenderObserver;
  63503. /**
  63504. * @constructor
  63505. * @param name The value used by scene.getMeshByName() to do a lookup.
  63506. * @param generator The mesh or transform node to generate a trail.
  63507. * @param scene The scene to add this mesh to.
  63508. * @param diameter Diameter of trailing mesh. Default is 1.
  63509. * @param length Length of trailing mesh. Default is 60.
  63510. * @param autoStart Automatically start trailing mesh. Default true.
  63511. */
  63512. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63513. /**
  63514. * "TrailMesh"
  63515. * @returns "TrailMesh"
  63516. */
  63517. getClassName(): string;
  63518. private _createMesh;
  63519. /**
  63520. * Start trailing mesh.
  63521. */
  63522. start(): void;
  63523. /**
  63524. * Stop trailing mesh.
  63525. */
  63526. stop(): void;
  63527. /**
  63528. * Update trailing mesh geometry.
  63529. */
  63530. update(): void;
  63531. /**
  63532. * Returns a new TrailMesh object.
  63533. * @param name is a string, the name given to the new mesh
  63534. * @param newGenerator use new generator object for cloned trail mesh
  63535. * @returns a new mesh
  63536. */
  63537. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63538. /**
  63539. * Serializes this trail mesh
  63540. * @param serializationObject object to write serialization to
  63541. */
  63542. serialize(serializationObject: any): void;
  63543. /**
  63544. * Parses a serialized trail mesh
  63545. * @param parsedMesh the serialized mesh
  63546. * @param scene the scene to create the trail mesh in
  63547. * @returns the created trail mesh
  63548. */
  63549. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63550. }
  63551. }
  63552. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63553. import { Nullable } from "babylonjs/types";
  63554. import { Scene } from "babylonjs/scene";
  63555. import { Vector4 } from "babylonjs/Maths/math.vector";
  63556. import { Color4 } from "babylonjs/Maths/math.color";
  63557. import { Mesh } from "babylonjs/Meshes/mesh";
  63558. /**
  63559. * Class containing static functions to help procedurally build meshes
  63560. */
  63561. export class TiledBoxBuilder {
  63562. /**
  63563. * Creates a box mesh
  63564. * 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)
  63565. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63569. * @param name defines the name of the mesh
  63570. * @param options defines the options used to create the mesh
  63571. * @param scene defines the hosting scene
  63572. * @returns the box mesh
  63573. */
  63574. static CreateTiledBox(name: string, options: {
  63575. pattern?: number;
  63576. width?: number;
  63577. height?: number;
  63578. depth?: number;
  63579. tileSize?: number;
  63580. tileWidth?: number;
  63581. tileHeight?: number;
  63582. alignHorizontal?: number;
  63583. alignVertical?: number;
  63584. faceUV?: Vector4[];
  63585. faceColors?: Color4[];
  63586. sideOrientation?: number;
  63587. updatable?: boolean;
  63588. }, scene?: Nullable<Scene>): Mesh;
  63589. }
  63590. }
  63591. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63592. import { Vector4 } from "babylonjs/Maths/math.vector";
  63593. import { Mesh } from "babylonjs/Meshes/mesh";
  63594. /**
  63595. * Class containing static functions to help procedurally build meshes
  63596. */
  63597. export class TorusKnotBuilder {
  63598. /**
  63599. * Creates a torus knot mesh
  63600. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63601. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63602. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63603. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63607. * @param name defines the name of the mesh
  63608. * @param options defines the options used to create the mesh
  63609. * @param scene defines the hosting scene
  63610. * @returns the torus knot mesh
  63611. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63612. */
  63613. static CreateTorusKnot(name: string, options: {
  63614. radius?: number;
  63615. tube?: number;
  63616. radialSegments?: number;
  63617. tubularSegments?: number;
  63618. p?: number;
  63619. q?: number;
  63620. updatable?: boolean;
  63621. sideOrientation?: number;
  63622. frontUVs?: Vector4;
  63623. backUVs?: Vector4;
  63624. }, scene: any): Mesh;
  63625. }
  63626. }
  63627. declare module "babylonjs/Meshes/polygonMesh" {
  63628. import { Scene } from "babylonjs/scene";
  63629. import { Vector2 } from "babylonjs/Maths/math.vector";
  63630. import { Mesh } from "babylonjs/Meshes/mesh";
  63631. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63632. import { Path2 } from "babylonjs/Maths/math.path";
  63633. /**
  63634. * Polygon
  63635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63636. */
  63637. export class Polygon {
  63638. /**
  63639. * Creates a rectangle
  63640. * @param xmin bottom X coord
  63641. * @param ymin bottom Y coord
  63642. * @param xmax top X coord
  63643. * @param ymax top Y coord
  63644. * @returns points that make the resulting rectation
  63645. */
  63646. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63647. /**
  63648. * Creates a circle
  63649. * @param radius radius of circle
  63650. * @param cx scale in x
  63651. * @param cy scale in y
  63652. * @param numberOfSides number of sides that make up the circle
  63653. * @returns points that make the resulting circle
  63654. */
  63655. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63656. /**
  63657. * Creates a polygon from input string
  63658. * @param input Input polygon data
  63659. * @returns the parsed points
  63660. */
  63661. static Parse(input: string): Vector2[];
  63662. /**
  63663. * Starts building a polygon from x and y coordinates
  63664. * @param x x coordinate
  63665. * @param y y coordinate
  63666. * @returns the started path2
  63667. */
  63668. static StartingAt(x: number, y: number): Path2;
  63669. }
  63670. /**
  63671. * Builds a polygon
  63672. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63673. */
  63674. export class PolygonMeshBuilder {
  63675. private _points;
  63676. private _outlinepoints;
  63677. private _holes;
  63678. private _name;
  63679. private _scene;
  63680. private _epoints;
  63681. private _eholes;
  63682. private _addToepoint;
  63683. /**
  63684. * Babylon reference to the earcut plugin.
  63685. */
  63686. bjsEarcut: any;
  63687. /**
  63688. * Creates a PolygonMeshBuilder
  63689. * @param name name of the builder
  63690. * @param contours Path of the polygon
  63691. * @param scene scene to add to when creating the mesh
  63692. * @param earcutInjection can be used to inject your own earcut reference
  63693. */
  63694. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63695. /**
  63696. * Adds a whole within the polygon
  63697. * @param hole Array of points defining the hole
  63698. * @returns this
  63699. */
  63700. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63701. /**
  63702. * Creates the polygon
  63703. * @param updatable If the mesh should be updatable
  63704. * @param depth The depth of the mesh created
  63705. * @returns the created mesh
  63706. */
  63707. build(updatable?: boolean, depth?: number): Mesh;
  63708. /**
  63709. * Creates the polygon
  63710. * @param depth The depth of the mesh created
  63711. * @returns the created VertexData
  63712. */
  63713. buildVertexData(depth?: number): VertexData;
  63714. /**
  63715. * Adds a side to the polygon
  63716. * @param positions points that make the polygon
  63717. * @param normals normals of the polygon
  63718. * @param uvs uvs of the polygon
  63719. * @param indices indices of the polygon
  63720. * @param bounds bounds of the polygon
  63721. * @param points points of the polygon
  63722. * @param depth depth of the polygon
  63723. * @param flip flip of the polygon
  63724. */
  63725. private addSide;
  63726. }
  63727. }
  63728. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63729. import { Scene } from "babylonjs/scene";
  63730. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63731. import { Color4 } from "babylonjs/Maths/math.color";
  63732. import { Mesh } from "babylonjs/Meshes/mesh";
  63733. import { Nullable } from "babylonjs/types";
  63734. /**
  63735. * Class containing static functions to help procedurally build meshes
  63736. */
  63737. export class PolygonBuilder {
  63738. /**
  63739. * Creates a polygon mesh
  63740. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63741. * * 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
  63742. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63745. * * Remember you can only change the shape positions, not their number when updating a polygon
  63746. * @param name defines the name of the mesh
  63747. * @param options defines the options used to create the mesh
  63748. * @param scene defines the hosting scene
  63749. * @param earcutInjection can be used to inject your own earcut reference
  63750. * @returns the polygon mesh
  63751. */
  63752. static CreatePolygon(name: string, options: {
  63753. shape: Vector3[];
  63754. holes?: Vector3[][];
  63755. depth?: number;
  63756. faceUV?: Vector4[];
  63757. faceColors?: Color4[];
  63758. updatable?: boolean;
  63759. sideOrientation?: number;
  63760. frontUVs?: Vector4;
  63761. backUVs?: Vector4;
  63762. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63763. /**
  63764. * Creates an extruded polygon mesh, with depth in the Y direction.
  63765. * * 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)
  63766. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63767. * @param name defines the name of the mesh
  63768. * @param options defines the options used to create the mesh
  63769. * @param scene defines the hosting scene
  63770. * @param earcutInjection can be used to inject your own earcut reference
  63771. * @returns the polygon mesh
  63772. */
  63773. static ExtrudePolygon(name: string, options: {
  63774. shape: Vector3[];
  63775. holes?: Vector3[][];
  63776. depth?: number;
  63777. faceUV?: Vector4[];
  63778. faceColors?: Color4[];
  63779. updatable?: boolean;
  63780. sideOrientation?: number;
  63781. frontUVs?: Vector4;
  63782. backUVs?: Vector4;
  63783. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63784. }
  63785. }
  63786. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63787. import { Scene } from "babylonjs/scene";
  63788. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63789. import { Mesh } from "babylonjs/Meshes/mesh";
  63790. import { Nullable } from "babylonjs/types";
  63791. /**
  63792. * Class containing static functions to help procedurally build meshes
  63793. */
  63794. export class LatheBuilder {
  63795. /**
  63796. * Creates lathe mesh.
  63797. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63798. * * 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
  63799. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63800. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63801. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63802. * * 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
  63803. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63804. * * 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
  63805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63807. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63809. * @param name defines the name of the mesh
  63810. * @param options defines the options used to create the mesh
  63811. * @param scene defines the hosting scene
  63812. * @returns the lathe mesh
  63813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63814. */
  63815. static CreateLathe(name: string, options: {
  63816. shape: Vector3[];
  63817. radius?: number;
  63818. tessellation?: number;
  63819. clip?: number;
  63820. arc?: number;
  63821. closed?: boolean;
  63822. updatable?: boolean;
  63823. sideOrientation?: number;
  63824. frontUVs?: Vector4;
  63825. backUVs?: Vector4;
  63826. cap?: number;
  63827. invertUV?: boolean;
  63828. }, scene?: Nullable<Scene>): Mesh;
  63829. }
  63830. }
  63831. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63832. import { Nullable } from "babylonjs/types";
  63833. import { Scene } from "babylonjs/scene";
  63834. import { Vector4 } from "babylonjs/Maths/math.vector";
  63835. import { Mesh } from "babylonjs/Meshes/mesh";
  63836. /**
  63837. * Class containing static functions to help procedurally build meshes
  63838. */
  63839. export class TiledPlaneBuilder {
  63840. /**
  63841. * Creates a tiled plane mesh
  63842. * * The parameter `pattern` will, depending on value, do nothing or
  63843. * * * flip (reflect about central vertical) alternate tiles across and up
  63844. * * * flip every tile on alternate rows
  63845. * * * rotate (180 degs) alternate tiles across and up
  63846. * * * rotate every tile on alternate rows
  63847. * * * flip and rotate alternate tiles across and up
  63848. * * * flip and rotate every tile on alternate rows
  63849. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63850. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63852. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63853. * * 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)
  63854. * * 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)
  63855. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63856. * @param name defines the name of the mesh
  63857. * @param options defines the options used to create the mesh
  63858. * @param scene defines the hosting scene
  63859. * @returns the box mesh
  63860. */
  63861. static CreateTiledPlane(name: string, options: {
  63862. pattern?: number;
  63863. tileSize?: number;
  63864. tileWidth?: number;
  63865. tileHeight?: number;
  63866. size?: number;
  63867. width?: number;
  63868. height?: number;
  63869. alignHorizontal?: number;
  63870. alignVertical?: number;
  63871. sideOrientation?: number;
  63872. frontUVs?: Vector4;
  63873. backUVs?: Vector4;
  63874. updatable?: boolean;
  63875. }, scene?: Nullable<Scene>): Mesh;
  63876. }
  63877. }
  63878. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63879. import { Nullable } from "babylonjs/types";
  63880. import { Scene } from "babylonjs/scene";
  63881. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63882. import { Mesh } from "babylonjs/Meshes/mesh";
  63883. /**
  63884. * Class containing static functions to help procedurally build meshes
  63885. */
  63886. export class TubeBuilder {
  63887. /**
  63888. * Creates a tube mesh.
  63889. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63890. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63891. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63892. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63893. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63894. * * 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)
  63895. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63896. * * 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
  63897. * * 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
  63898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63902. * @param name defines the name of the mesh
  63903. * @param options defines the options used to create the mesh
  63904. * @param scene defines the hosting scene
  63905. * @returns the tube mesh
  63906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63907. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63908. */
  63909. static CreateTube(name: string, options: {
  63910. path: Vector3[];
  63911. radius?: number;
  63912. tessellation?: number;
  63913. radiusFunction?: {
  63914. (i: number, distance: number): number;
  63915. };
  63916. cap?: number;
  63917. arc?: number;
  63918. updatable?: boolean;
  63919. sideOrientation?: number;
  63920. frontUVs?: Vector4;
  63921. backUVs?: Vector4;
  63922. instance?: Mesh;
  63923. invertUV?: boolean;
  63924. }, scene?: Nullable<Scene>): Mesh;
  63925. }
  63926. }
  63927. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63928. import { Scene } from "babylonjs/scene";
  63929. import { Vector4 } from "babylonjs/Maths/math.vector";
  63930. import { Mesh } from "babylonjs/Meshes/mesh";
  63931. import { Nullable } from "babylonjs/types";
  63932. /**
  63933. * Class containing static functions to help procedurally build meshes
  63934. */
  63935. export class IcoSphereBuilder {
  63936. /**
  63937. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63938. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63939. * * 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`)
  63940. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63941. * * 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
  63942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63945. * @param name defines the name of the mesh
  63946. * @param options defines the options used to create the mesh
  63947. * @param scene defines the hosting scene
  63948. * @returns the icosahedron mesh
  63949. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63950. */
  63951. static CreateIcoSphere(name: string, options: {
  63952. radius?: number;
  63953. radiusX?: number;
  63954. radiusY?: number;
  63955. radiusZ?: number;
  63956. flat?: boolean;
  63957. subdivisions?: number;
  63958. sideOrientation?: number;
  63959. frontUVs?: Vector4;
  63960. backUVs?: Vector4;
  63961. updatable?: boolean;
  63962. }, scene?: Nullable<Scene>): Mesh;
  63963. }
  63964. }
  63965. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63966. import { Vector3 } from "babylonjs/Maths/math.vector";
  63967. import { Mesh } from "babylonjs/Meshes/mesh";
  63968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63969. /**
  63970. * Class containing static functions to help procedurally build meshes
  63971. */
  63972. export class DecalBuilder {
  63973. /**
  63974. * Creates a decal mesh.
  63975. * 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
  63976. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63977. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63978. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63979. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63980. * @param name defines the name of the mesh
  63981. * @param sourceMesh defines the mesh where the decal must be applied
  63982. * @param options defines the options used to create the mesh
  63983. * @param scene defines the hosting scene
  63984. * @returns the decal mesh
  63985. * @see https://doc.babylonjs.com/how_to/decals
  63986. */
  63987. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63988. position?: Vector3;
  63989. normal?: Vector3;
  63990. size?: Vector3;
  63991. angle?: number;
  63992. }): Mesh;
  63993. }
  63994. }
  63995. declare module "babylonjs/Meshes/meshBuilder" {
  63996. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  63997. import { Nullable } from "babylonjs/types";
  63998. import { Scene } from "babylonjs/scene";
  63999. import { Mesh } from "babylonjs/Meshes/mesh";
  64000. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64001. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64003. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64004. import { Plane } from "babylonjs/Maths/math.plane";
  64005. /**
  64006. * Class containing static functions to help procedurally build meshes
  64007. */
  64008. export class MeshBuilder {
  64009. /**
  64010. * Creates a box mesh
  64011. * * The parameter `size` sets the size (float) of each box side (default 1)
  64012. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64013. * * 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)
  64014. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64018. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64019. * @param name defines the name of the mesh
  64020. * @param options defines the options used to create the mesh
  64021. * @param scene defines the hosting scene
  64022. * @returns the box mesh
  64023. */
  64024. static CreateBox(name: string, options: {
  64025. size?: number;
  64026. width?: number;
  64027. height?: number;
  64028. depth?: number;
  64029. faceUV?: Vector4[];
  64030. faceColors?: Color4[];
  64031. sideOrientation?: number;
  64032. frontUVs?: Vector4;
  64033. backUVs?: Vector4;
  64034. updatable?: boolean;
  64035. }, scene?: Nullable<Scene>): Mesh;
  64036. /**
  64037. * Creates a tiled box mesh
  64038. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64040. * @param name defines the name of the mesh
  64041. * @param options defines the options used to create the mesh
  64042. * @param scene defines the hosting scene
  64043. * @returns the tiled box mesh
  64044. */
  64045. static CreateTiledBox(name: string, options: {
  64046. pattern?: number;
  64047. size?: number;
  64048. width?: number;
  64049. height?: number;
  64050. depth: number;
  64051. tileSize?: number;
  64052. tileWidth?: number;
  64053. tileHeight?: number;
  64054. faceUV?: Vector4[];
  64055. faceColors?: Color4[];
  64056. alignHorizontal?: number;
  64057. alignVertical?: number;
  64058. sideOrientation?: number;
  64059. updatable?: boolean;
  64060. }, scene?: Nullable<Scene>): Mesh;
  64061. /**
  64062. * Creates a sphere mesh
  64063. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64064. * * 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`)
  64065. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64066. * * 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
  64067. * * 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)
  64068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64071. * @param name defines the name of the mesh
  64072. * @param options defines the options used to create the mesh
  64073. * @param scene defines the hosting scene
  64074. * @returns the sphere mesh
  64075. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64076. */
  64077. static CreateSphere(name: string, options: {
  64078. segments?: number;
  64079. diameter?: number;
  64080. diameterX?: number;
  64081. diameterY?: number;
  64082. diameterZ?: number;
  64083. arc?: number;
  64084. slice?: number;
  64085. sideOrientation?: number;
  64086. frontUVs?: Vector4;
  64087. backUVs?: Vector4;
  64088. updatable?: boolean;
  64089. }, scene?: Nullable<Scene>): Mesh;
  64090. /**
  64091. * Creates a plane polygonal mesh. By default, this is a disc
  64092. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64093. * * 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
  64094. * * 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
  64095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64098. * @param name defines the name of the mesh
  64099. * @param options defines the options used to create the mesh
  64100. * @param scene defines the hosting scene
  64101. * @returns the plane polygonal mesh
  64102. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64103. */
  64104. static CreateDisc(name: string, options: {
  64105. radius?: number;
  64106. tessellation?: number;
  64107. arc?: number;
  64108. updatable?: boolean;
  64109. sideOrientation?: number;
  64110. frontUVs?: Vector4;
  64111. backUVs?: Vector4;
  64112. }, scene?: Nullable<Scene>): Mesh;
  64113. /**
  64114. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64115. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64116. * * 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`)
  64117. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64118. * * 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
  64119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64122. * @param name defines the name of the mesh
  64123. * @param options defines the options used to create the mesh
  64124. * @param scene defines the hosting scene
  64125. * @returns the icosahedron mesh
  64126. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64127. */
  64128. static CreateIcoSphere(name: string, options: {
  64129. radius?: number;
  64130. radiusX?: number;
  64131. radiusY?: number;
  64132. radiusZ?: number;
  64133. flat?: boolean;
  64134. subdivisions?: number;
  64135. sideOrientation?: number;
  64136. frontUVs?: Vector4;
  64137. backUVs?: Vector4;
  64138. updatable?: boolean;
  64139. }, scene?: Nullable<Scene>): Mesh;
  64140. /**
  64141. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64142. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64143. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64144. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64145. * * 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
  64146. * * 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
  64147. * * 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
  64148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64151. * * 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
  64152. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64153. * * 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
  64154. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64156. * @param name defines the name of the mesh
  64157. * @param options defines the options used to create the mesh
  64158. * @param scene defines the hosting scene
  64159. * @returns the ribbon mesh
  64160. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64162. */
  64163. static CreateRibbon(name: string, options: {
  64164. pathArray: Vector3[][];
  64165. closeArray?: boolean;
  64166. closePath?: boolean;
  64167. offset?: number;
  64168. updatable?: boolean;
  64169. sideOrientation?: number;
  64170. frontUVs?: Vector4;
  64171. backUVs?: Vector4;
  64172. instance?: Mesh;
  64173. invertUV?: boolean;
  64174. uvs?: Vector2[];
  64175. colors?: Color4[];
  64176. }, scene?: Nullable<Scene>): Mesh;
  64177. /**
  64178. * Creates a cylinder or a cone mesh
  64179. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64180. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64181. * * 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.
  64182. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64183. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64184. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64185. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64186. * * 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).
  64187. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64188. * * 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).
  64189. * * 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
  64190. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64191. * * 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
  64192. * * 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.
  64193. * * If `enclose` is false, a ring surface is one element.
  64194. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64195. * * 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
  64196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64199. * @param name defines the name of the mesh
  64200. * @param options defines the options used to create the mesh
  64201. * @param scene defines the hosting scene
  64202. * @returns the cylinder mesh
  64203. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64204. */
  64205. static CreateCylinder(name: string, options: {
  64206. height?: number;
  64207. diameterTop?: number;
  64208. diameterBottom?: number;
  64209. diameter?: number;
  64210. tessellation?: number;
  64211. subdivisions?: number;
  64212. arc?: number;
  64213. faceColors?: Color4[];
  64214. faceUV?: Vector4[];
  64215. updatable?: boolean;
  64216. hasRings?: boolean;
  64217. enclose?: boolean;
  64218. cap?: number;
  64219. sideOrientation?: number;
  64220. frontUVs?: Vector4;
  64221. backUVs?: Vector4;
  64222. }, scene?: Nullable<Scene>): Mesh;
  64223. /**
  64224. * Creates a torus mesh
  64225. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64226. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64227. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64231. * @param name defines the name of the mesh
  64232. * @param options defines the options used to create the mesh
  64233. * @param scene defines the hosting scene
  64234. * @returns the torus mesh
  64235. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64236. */
  64237. static CreateTorus(name: string, options: {
  64238. diameter?: number;
  64239. thickness?: number;
  64240. tessellation?: number;
  64241. updatable?: boolean;
  64242. sideOrientation?: number;
  64243. frontUVs?: Vector4;
  64244. backUVs?: Vector4;
  64245. }, scene?: Nullable<Scene>): Mesh;
  64246. /**
  64247. * Creates a torus knot mesh
  64248. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64249. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64250. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64251. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64255. * @param name defines the name of the mesh
  64256. * @param options defines the options used to create the mesh
  64257. * @param scene defines the hosting scene
  64258. * @returns the torus knot mesh
  64259. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64260. */
  64261. static CreateTorusKnot(name: string, options: {
  64262. radius?: number;
  64263. tube?: number;
  64264. radialSegments?: number;
  64265. tubularSegments?: number;
  64266. p?: number;
  64267. q?: number;
  64268. updatable?: boolean;
  64269. sideOrientation?: number;
  64270. frontUVs?: Vector4;
  64271. backUVs?: Vector4;
  64272. }, scene?: Nullable<Scene>): Mesh;
  64273. /**
  64274. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64275. * * 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
  64276. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64277. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64278. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64279. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64280. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64281. * * 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
  64282. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64284. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64285. * @param name defines the name of the new line system
  64286. * @param options defines the options used to create the line system
  64287. * @param scene defines the hosting scene
  64288. * @returns a new line system mesh
  64289. */
  64290. static CreateLineSystem(name: string, options: {
  64291. lines: Vector3[][];
  64292. updatable?: boolean;
  64293. instance?: Nullable<LinesMesh>;
  64294. colors?: Nullable<Color4[][]>;
  64295. useVertexAlpha?: boolean;
  64296. }, scene: Nullable<Scene>): LinesMesh;
  64297. /**
  64298. * Creates a line mesh
  64299. * 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
  64300. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64301. * * The parameter `points` is an array successive Vector3
  64302. * * 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
  64303. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64304. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64305. * * When updating an instance, remember that only point positions can change, not the number of points
  64306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64307. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64308. * @param name defines the name of the new line system
  64309. * @param options defines the options used to create the line system
  64310. * @param scene defines the hosting scene
  64311. * @returns a new line mesh
  64312. */
  64313. static CreateLines(name: string, options: {
  64314. points: Vector3[];
  64315. updatable?: boolean;
  64316. instance?: Nullable<LinesMesh>;
  64317. colors?: Color4[];
  64318. useVertexAlpha?: boolean;
  64319. }, scene?: Nullable<Scene>): LinesMesh;
  64320. /**
  64321. * Creates a dashed line mesh
  64322. * * 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
  64323. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64324. * * The parameter `points` is an array successive Vector3
  64325. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64326. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64327. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64328. * * 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
  64329. * * When updating an instance, remember that only point positions can change, not the number of points
  64330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64331. * @param name defines the name of the mesh
  64332. * @param options defines the options used to create the mesh
  64333. * @param scene defines the hosting scene
  64334. * @returns the dashed line mesh
  64335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64336. */
  64337. static CreateDashedLines(name: string, options: {
  64338. points: Vector3[];
  64339. dashSize?: number;
  64340. gapSize?: number;
  64341. dashNb?: number;
  64342. updatable?: boolean;
  64343. instance?: LinesMesh;
  64344. }, scene?: Nullable<Scene>): LinesMesh;
  64345. /**
  64346. * 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.
  64347. * * 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.
  64348. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64349. * * 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.
  64350. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64351. * * 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
  64352. * * 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
  64353. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64358. * @param name defines the name of the mesh
  64359. * @param options defines the options used to create the mesh
  64360. * @param scene defines the hosting scene
  64361. * @returns the extruded shape mesh
  64362. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64364. */
  64365. static ExtrudeShape(name: string, options: {
  64366. shape: Vector3[];
  64367. path: Vector3[];
  64368. scale?: number;
  64369. rotation?: number;
  64370. cap?: number;
  64371. updatable?: boolean;
  64372. sideOrientation?: number;
  64373. frontUVs?: Vector4;
  64374. backUVs?: Vector4;
  64375. instance?: Mesh;
  64376. invertUV?: boolean;
  64377. }, scene?: Nullable<Scene>): Mesh;
  64378. /**
  64379. * Creates an custom extruded shape mesh.
  64380. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64381. * * 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.
  64382. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64383. * * 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
  64384. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64385. * * 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
  64386. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64387. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64388. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64389. * * 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
  64390. * * 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
  64391. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64396. * @param name defines the name of the mesh
  64397. * @param options defines the options used to create the mesh
  64398. * @param scene defines the hosting scene
  64399. * @returns the custom extruded shape mesh
  64400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64401. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64403. */
  64404. static ExtrudeShapeCustom(name: string, options: {
  64405. shape: Vector3[];
  64406. path: Vector3[];
  64407. scaleFunction?: any;
  64408. rotationFunction?: any;
  64409. ribbonCloseArray?: boolean;
  64410. ribbonClosePath?: boolean;
  64411. cap?: number;
  64412. updatable?: boolean;
  64413. sideOrientation?: number;
  64414. frontUVs?: Vector4;
  64415. backUVs?: Vector4;
  64416. instance?: Mesh;
  64417. invertUV?: boolean;
  64418. }, scene?: Nullable<Scene>): Mesh;
  64419. /**
  64420. * Creates lathe mesh.
  64421. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64422. * * 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
  64423. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64424. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64425. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64426. * * 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
  64427. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64428. * * 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
  64429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64431. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64433. * @param name defines the name of the mesh
  64434. * @param options defines the options used to create the mesh
  64435. * @param scene defines the hosting scene
  64436. * @returns the lathe mesh
  64437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64438. */
  64439. static CreateLathe(name: string, options: {
  64440. shape: Vector3[];
  64441. radius?: number;
  64442. tessellation?: number;
  64443. clip?: number;
  64444. arc?: number;
  64445. closed?: boolean;
  64446. updatable?: boolean;
  64447. sideOrientation?: number;
  64448. frontUVs?: Vector4;
  64449. backUVs?: Vector4;
  64450. cap?: number;
  64451. invertUV?: boolean;
  64452. }, scene?: Nullable<Scene>): Mesh;
  64453. /**
  64454. * Creates a tiled plane mesh
  64455. * * You can set a limited pattern arrangement with the tiles
  64456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64459. * @param name defines the name of the mesh
  64460. * @param options defines the options used to create the mesh
  64461. * @param scene defines the hosting scene
  64462. * @returns the plane mesh
  64463. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64464. */
  64465. static CreateTiledPlane(name: string, options: {
  64466. pattern?: number;
  64467. tileSize?: number;
  64468. tileWidth?: number;
  64469. tileHeight?: number;
  64470. size?: number;
  64471. width?: number;
  64472. height?: number;
  64473. alignHorizontal?: number;
  64474. alignVertical?: number;
  64475. sideOrientation?: number;
  64476. frontUVs?: Vector4;
  64477. backUVs?: Vector4;
  64478. updatable?: boolean;
  64479. }, scene?: Nullable<Scene>): Mesh;
  64480. /**
  64481. * Creates a plane mesh
  64482. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64483. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64484. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64488. * @param name defines the name of the mesh
  64489. * @param options defines the options used to create the mesh
  64490. * @param scene defines the hosting scene
  64491. * @returns the plane mesh
  64492. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64493. */
  64494. static CreatePlane(name: string, options: {
  64495. size?: number;
  64496. width?: number;
  64497. height?: number;
  64498. sideOrientation?: number;
  64499. frontUVs?: Vector4;
  64500. backUVs?: Vector4;
  64501. updatable?: boolean;
  64502. sourcePlane?: Plane;
  64503. }, scene?: Nullable<Scene>): Mesh;
  64504. /**
  64505. * Creates a ground mesh
  64506. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64507. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64509. * @param name defines the name of the mesh
  64510. * @param options defines the options used to create the mesh
  64511. * @param scene defines the hosting scene
  64512. * @returns the ground mesh
  64513. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64514. */
  64515. static CreateGround(name: string, options: {
  64516. width?: number;
  64517. height?: number;
  64518. subdivisions?: number;
  64519. subdivisionsX?: number;
  64520. subdivisionsY?: number;
  64521. updatable?: boolean;
  64522. }, scene?: Nullable<Scene>): Mesh;
  64523. /**
  64524. * Creates a tiled ground mesh
  64525. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64526. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64527. * * 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
  64528. * * 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
  64529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64530. * @param name defines the name of the mesh
  64531. * @param options defines the options used to create the mesh
  64532. * @param scene defines the hosting scene
  64533. * @returns the tiled ground mesh
  64534. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64535. */
  64536. static CreateTiledGround(name: string, options: {
  64537. xmin: number;
  64538. zmin: number;
  64539. xmax: number;
  64540. zmax: number;
  64541. subdivisions?: {
  64542. w: number;
  64543. h: number;
  64544. };
  64545. precision?: {
  64546. w: number;
  64547. h: number;
  64548. };
  64549. updatable?: boolean;
  64550. }, scene?: Nullable<Scene>): Mesh;
  64551. /**
  64552. * Creates a ground mesh from a height map
  64553. * * The parameter `url` sets the URL of the height map image resource.
  64554. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64555. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64556. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64557. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64558. * * 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.
  64559. * * 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).
  64560. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64562. * @param name defines the name of the mesh
  64563. * @param url defines the url to the height map
  64564. * @param options defines the options used to create the mesh
  64565. * @param scene defines the hosting scene
  64566. * @returns the ground mesh
  64567. * @see https://doc.babylonjs.com/babylon101/height_map
  64568. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64569. */
  64570. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64571. width?: number;
  64572. height?: number;
  64573. subdivisions?: number;
  64574. minHeight?: number;
  64575. maxHeight?: number;
  64576. colorFilter?: Color3;
  64577. alphaFilter?: number;
  64578. updatable?: boolean;
  64579. onReady?: (mesh: GroundMesh) => void;
  64580. }, scene?: Nullable<Scene>): GroundMesh;
  64581. /**
  64582. * Creates a polygon mesh
  64583. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64584. * * 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
  64585. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64588. * * Remember you can only change the shape positions, not their number when updating a polygon
  64589. * @param name defines the name of the mesh
  64590. * @param options defines the options used to create the mesh
  64591. * @param scene defines the hosting scene
  64592. * @param earcutInjection can be used to inject your own earcut reference
  64593. * @returns the polygon mesh
  64594. */
  64595. static CreatePolygon(name: string, options: {
  64596. shape: Vector3[];
  64597. holes?: Vector3[][];
  64598. depth?: number;
  64599. faceUV?: Vector4[];
  64600. faceColors?: Color4[];
  64601. updatable?: boolean;
  64602. sideOrientation?: number;
  64603. frontUVs?: Vector4;
  64604. backUVs?: Vector4;
  64605. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64606. /**
  64607. * Creates an extruded polygon mesh, with depth in the Y direction.
  64608. * * 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)
  64609. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64610. * @param name defines the name of the mesh
  64611. * @param options defines the options used to create the mesh
  64612. * @param scene defines the hosting scene
  64613. * @param earcutInjection can be used to inject your own earcut reference
  64614. * @returns the polygon mesh
  64615. */
  64616. static ExtrudePolygon(name: string, options: {
  64617. shape: Vector3[];
  64618. holes?: Vector3[][];
  64619. depth?: number;
  64620. faceUV?: Vector4[];
  64621. faceColors?: Color4[];
  64622. updatable?: boolean;
  64623. sideOrientation?: number;
  64624. frontUVs?: Vector4;
  64625. backUVs?: Vector4;
  64626. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64627. /**
  64628. * Creates a tube mesh.
  64629. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64630. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64631. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64632. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64633. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64634. * * 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)
  64635. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64636. * * 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
  64637. * * 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
  64638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64640. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64642. * @param name defines the name of the mesh
  64643. * @param options defines the options used to create the mesh
  64644. * @param scene defines the hosting scene
  64645. * @returns the tube mesh
  64646. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64647. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64648. */
  64649. static CreateTube(name: string, options: {
  64650. path: Vector3[];
  64651. radius?: number;
  64652. tessellation?: number;
  64653. radiusFunction?: {
  64654. (i: number, distance: number): number;
  64655. };
  64656. cap?: number;
  64657. arc?: number;
  64658. updatable?: boolean;
  64659. sideOrientation?: number;
  64660. frontUVs?: Vector4;
  64661. backUVs?: Vector4;
  64662. instance?: Mesh;
  64663. invertUV?: boolean;
  64664. }, scene?: Nullable<Scene>): Mesh;
  64665. /**
  64666. * Creates a polyhedron mesh
  64667. * * 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
  64668. * * The parameter `size` (positive float, default 1) sets the polygon size
  64669. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64670. * * 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`
  64671. * * 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
  64672. * * 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)`)
  64673. * * 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
  64674. * * 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
  64675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64678. * @param name defines the name of the mesh
  64679. * @param options defines the options used to create the mesh
  64680. * @param scene defines the hosting scene
  64681. * @returns the polyhedron mesh
  64682. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64683. */
  64684. static CreatePolyhedron(name: string, options: {
  64685. type?: number;
  64686. size?: number;
  64687. sizeX?: number;
  64688. sizeY?: number;
  64689. sizeZ?: number;
  64690. custom?: any;
  64691. faceUV?: Vector4[];
  64692. faceColors?: Color4[];
  64693. flat?: boolean;
  64694. updatable?: boolean;
  64695. sideOrientation?: number;
  64696. frontUVs?: Vector4;
  64697. backUVs?: Vector4;
  64698. }, scene?: Nullable<Scene>): Mesh;
  64699. /**
  64700. * Creates a decal mesh.
  64701. * 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
  64702. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64703. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64704. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64705. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64706. * @param name defines the name of the mesh
  64707. * @param sourceMesh defines the mesh where the decal must be applied
  64708. * @param options defines the options used to create the mesh
  64709. * @param scene defines the hosting scene
  64710. * @returns the decal mesh
  64711. * @see https://doc.babylonjs.com/how_to/decals
  64712. */
  64713. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64714. position?: Vector3;
  64715. normal?: Vector3;
  64716. size?: Vector3;
  64717. angle?: number;
  64718. }): Mesh;
  64719. }
  64720. }
  64721. declare module "babylonjs/Meshes/meshSimplification" {
  64722. import { Mesh } from "babylonjs/Meshes/mesh";
  64723. /**
  64724. * A simplifier interface for future simplification implementations
  64725. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64726. */
  64727. export interface ISimplifier {
  64728. /**
  64729. * Simplification of a given mesh according to the given settings.
  64730. * Since this requires computation, it is assumed that the function runs async.
  64731. * @param settings The settings of the simplification, including quality and distance
  64732. * @param successCallback A callback that will be called after the mesh was simplified.
  64733. * @param errorCallback in case of an error, this callback will be called. optional.
  64734. */
  64735. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64736. }
  64737. /**
  64738. * Expected simplification settings.
  64739. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64740. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64741. */
  64742. export interface ISimplificationSettings {
  64743. /**
  64744. * Gets or sets the expected quality
  64745. */
  64746. quality: number;
  64747. /**
  64748. * Gets or sets the distance when this optimized version should be used
  64749. */
  64750. distance: number;
  64751. /**
  64752. * Gets an already optimized mesh
  64753. */
  64754. optimizeMesh?: boolean;
  64755. }
  64756. /**
  64757. * Class used to specify simplification options
  64758. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64759. */
  64760. export class SimplificationSettings implements ISimplificationSettings {
  64761. /** expected quality */
  64762. quality: number;
  64763. /** distance when this optimized version should be used */
  64764. distance: number;
  64765. /** already optimized mesh */
  64766. optimizeMesh?: boolean | undefined;
  64767. /**
  64768. * Creates a SimplificationSettings
  64769. * @param quality expected quality
  64770. * @param distance distance when this optimized version should be used
  64771. * @param optimizeMesh already optimized mesh
  64772. */
  64773. constructor(
  64774. /** expected quality */
  64775. quality: number,
  64776. /** distance when this optimized version should be used */
  64777. distance: number,
  64778. /** already optimized mesh */
  64779. optimizeMesh?: boolean | undefined);
  64780. }
  64781. /**
  64782. * Interface used to define a simplification task
  64783. */
  64784. export interface ISimplificationTask {
  64785. /**
  64786. * Array of settings
  64787. */
  64788. settings: Array<ISimplificationSettings>;
  64789. /**
  64790. * Simplification type
  64791. */
  64792. simplificationType: SimplificationType;
  64793. /**
  64794. * Mesh to simplify
  64795. */
  64796. mesh: Mesh;
  64797. /**
  64798. * Callback called on success
  64799. */
  64800. successCallback?: () => void;
  64801. /**
  64802. * Defines if parallel processing can be used
  64803. */
  64804. parallelProcessing: boolean;
  64805. }
  64806. /**
  64807. * Queue used to order the simplification tasks
  64808. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64809. */
  64810. export class SimplificationQueue {
  64811. private _simplificationArray;
  64812. /**
  64813. * Gets a boolean indicating that the process is still running
  64814. */
  64815. running: boolean;
  64816. /**
  64817. * Creates a new queue
  64818. */
  64819. constructor();
  64820. /**
  64821. * Adds a new simplification task
  64822. * @param task defines a task to add
  64823. */
  64824. addTask(task: ISimplificationTask): void;
  64825. /**
  64826. * Execute next task
  64827. */
  64828. executeNext(): void;
  64829. /**
  64830. * Execute a simplification task
  64831. * @param task defines the task to run
  64832. */
  64833. runSimplification(task: ISimplificationTask): void;
  64834. private getSimplifier;
  64835. }
  64836. /**
  64837. * The implemented types of simplification
  64838. * At the moment only Quadratic Error Decimation is implemented
  64839. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64840. */
  64841. export enum SimplificationType {
  64842. /** Quadratic error decimation */
  64843. QUADRATIC = 0
  64844. }
  64845. }
  64846. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64847. import { Scene } from "babylonjs/scene";
  64848. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64849. import { ISceneComponent } from "babylonjs/sceneComponent";
  64850. module "babylonjs/scene" {
  64851. interface Scene {
  64852. /** @hidden (Backing field) */
  64853. _simplificationQueue: SimplificationQueue;
  64854. /**
  64855. * Gets or sets the simplification queue attached to the scene
  64856. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64857. */
  64858. simplificationQueue: SimplificationQueue;
  64859. }
  64860. }
  64861. module "babylonjs/Meshes/mesh" {
  64862. interface Mesh {
  64863. /**
  64864. * Simplify the mesh according to the given array of settings.
  64865. * Function will return immediately and will simplify async
  64866. * @param settings a collection of simplification settings
  64867. * @param parallelProcessing should all levels calculate parallel or one after the other
  64868. * @param simplificationType the type of simplification to run
  64869. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64870. * @returns the current mesh
  64871. */
  64872. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64873. }
  64874. }
  64875. /**
  64876. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64877. * created in a scene
  64878. */
  64879. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64880. /**
  64881. * The component name helpfull to identify the component in the list of scene components.
  64882. */
  64883. readonly name: string;
  64884. /**
  64885. * The scene the component belongs to.
  64886. */
  64887. scene: Scene;
  64888. /**
  64889. * Creates a new instance of the component for the given scene
  64890. * @param scene Defines the scene to register the component in
  64891. */
  64892. constructor(scene: Scene);
  64893. /**
  64894. * Registers the component in a given scene
  64895. */
  64896. register(): void;
  64897. /**
  64898. * Rebuilds the elements related to this component in case of
  64899. * context lost for instance.
  64900. */
  64901. rebuild(): void;
  64902. /**
  64903. * Disposes the component and the associated ressources
  64904. */
  64905. dispose(): void;
  64906. private _beforeCameraUpdate;
  64907. }
  64908. }
  64909. declare module "babylonjs/Meshes/Builders/index" {
  64910. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64911. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64912. export * from "babylonjs/Meshes/Builders/discBuilder";
  64913. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64914. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64915. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64916. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64917. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64918. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64919. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64920. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64921. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64922. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64923. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64924. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64925. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64926. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64927. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64928. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64929. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64930. }
  64931. declare module "babylonjs/Meshes/index" {
  64932. export * from "babylonjs/Meshes/abstractMesh";
  64933. export * from "babylonjs/Meshes/buffer";
  64934. export * from "babylonjs/Meshes/Compression/index";
  64935. export * from "babylonjs/Meshes/csg";
  64936. export * from "babylonjs/Meshes/geometry";
  64937. export * from "babylonjs/Meshes/groundMesh";
  64938. export * from "babylonjs/Meshes/trailMesh";
  64939. export * from "babylonjs/Meshes/instancedMesh";
  64940. export * from "babylonjs/Meshes/linesMesh";
  64941. export * from "babylonjs/Meshes/mesh";
  64942. export * from "babylonjs/Meshes/mesh.vertexData";
  64943. export * from "babylonjs/Meshes/meshBuilder";
  64944. export * from "babylonjs/Meshes/meshSimplification";
  64945. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64946. export * from "babylonjs/Meshes/polygonMesh";
  64947. export * from "babylonjs/Meshes/subMesh";
  64948. export * from "babylonjs/Meshes/meshLODLevel";
  64949. export * from "babylonjs/Meshes/transformNode";
  64950. export * from "babylonjs/Meshes/Builders/index";
  64951. export * from "babylonjs/Meshes/dataBuffer";
  64952. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64953. }
  64954. declare module "babylonjs/Morph/index" {
  64955. export * from "babylonjs/Morph/morphTarget";
  64956. export * from "babylonjs/Morph/morphTargetManager";
  64957. }
  64958. declare module "babylonjs/Navigation/INavigationEngine" {
  64959. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64960. import { Vector3 } from "babylonjs/Maths/math";
  64961. import { Mesh } from "babylonjs/Meshes/mesh";
  64962. import { Scene } from "babylonjs/scene";
  64963. /**
  64964. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64965. */
  64966. export interface INavigationEnginePlugin {
  64967. /**
  64968. * plugin name
  64969. */
  64970. name: string;
  64971. /**
  64972. * Creates a navigation mesh
  64973. * @param meshes array of all the geometry used to compute the navigatio mesh
  64974. * @param parameters bunch of parameters used to filter geometry
  64975. */
  64976. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64977. /**
  64978. * Create a navigation mesh debug mesh
  64979. * @param scene is where the mesh will be added
  64980. * @returns debug display mesh
  64981. */
  64982. createDebugNavMesh(scene: Scene): Mesh;
  64983. /**
  64984. * Get a navigation mesh constrained position, closest to the parameter position
  64985. * @param position world position
  64986. * @returns the closest point to position constrained by the navigation mesh
  64987. */
  64988. getClosestPoint(position: Vector3): Vector3;
  64989. /**
  64990. * Get a navigation mesh constrained position, within a particular radius
  64991. * @param position world position
  64992. * @param maxRadius the maximum distance to the constrained world position
  64993. * @returns the closest point to position constrained by the navigation mesh
  64994. */
  64995. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64996. /**
  64997. * Compute the final position from a segment made of destination-position
  64998. * @param position world position
  64999. * @param destination world position
  65000. * @returns the resulting point along the navmesh
  65001. */
  65002. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65003. /**
  65004. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65005. * @param start world position
  65006. * @param end world position
  65007. * @returns array containing world position composing the path
  65008. */
  65009. computePath(start: Vector3, end: Vector3): Vector3[];
  65010. /**
  65011. * If this plugin is supported
  65012. * @returns true if plugin is supported
  65013. */
  65014. isSupported(): boolean;
  65015. /**
  65016. * Create a new Crowd so you can add agents
  65017. * @param maxAgents the maximum agent count in the crowd
  65018. * @param maxAgentRadius the maximum radius an agent can have
  65019. * @param scene to attach the crowd to
  65020. * @returns the crowd you can add agents to
  65021. */
  65022. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65023. /**
  65024. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65025. * The queries will try to find a solution within those bounds
  65026. * default is (1,1,1)
  65027. * @param extent x,y,z value that define the extent around the queries point of reference
  65028. */
  65029. setDefaultQueryExtent(extent: Vector3): void;
  65030. /**
  65031. * Get the Bounding box extent specified by setDefaultQueryExtent
  65032. * @returns the box extent values
  65033. */
  65034. getDefaultQueryExtent(): Vector3;
  65035. /**
  65036. * Release all resources
  65037. */
  65038. dispose(): void;
  65039. }
  65040. /**
  65041. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65042. */
  65043. export interface ICrowd {
  65044. /**
  65045. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65046. * You can attach anything to that node. The node position is updated in the scene update tick.
  65047. * @param pos world position that will be constrained by the navigation mesh
  65048. * @param parameters agent parameters
  65049. * @param transform hooked to the agent that will be update by the scene
  65050. * @returns agent index
  65051. */
  65052. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65053. /**
  65054. * Returns the agent position in world space
  65055. * @param index agent index returned by addAgent
  65056. * @returns world space position
  65057. */
  65058. getAgentPosition(index: number): Vector3;
  65059. /**
  65060. * Gets the agent velocity in world space
  65061. * @param index agent index returned by addAgent
  65062. * @returns world space velocity
  65063. */
  65064. getAgentVelocity(index: number): Vector3;
  65065. /**
  65066. * remove a particular agent previously created
  65067. * @param index agent index returned by addAgent
  65068. */
  65069. removeAgent(index: number): void;
  65070. /**
  65071. * get the list of all agents attached to this crowd
  65072. * @returns list of agent indices
  65073. */
  65074. getAgents(): number[];
  65075. /**
  65076. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65077. * @param deltaTime in seconds
  65078. */
  65079. update(deltaTime: number): void;
  65080. /**
  65081. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65082. * @param index agent index returned by addAgent
  65083. * @param destination targeted world position
  65084. */
  65085. agentGoto(index: number, destination: Vector3): void;
  65086. /**
  65087. * Teleport the agent to a new position
  65088. * @param index agent index returned by addAgent
  65089. * @param destination targeted world position
  65090. */
  65091. agentTeleport(index: number, destination: Vector3): void;
  65092. /**
  65093. * Update agent parameters
  65094. * @param index agent index returned by addAgent
  65095. * @param parameters agent parameters
  65096. */
  65097. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65098. /**
  65099. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65100. * The queries will try to find a solution within those bounds
  65101. * default is (1,1,1)
  65102. * @param extent x,y,z value that define the extent around the queries point of reference
  65103. */
  65104. setDefaultQueryExtent(extent: Vector3): void;
  65105. /**
  65106. * Get the Bounding box extent specified by setDefaultQueryExtent
  65107. * @returns the box extent values
  65108. */
  65109. getDefaultQueryExtent(): Vector3;
  65110. /**
  65111. * Release all resources
  65112. */
  65113. dispose(): void;
  65114. }
  65115. /**
  65116. * Configures an agent
  65117. */
  65118. export interface IAgentParameters {
  65119. /**
  65120. * Agent radius. [Limit: >= 0]
  65121. */
  65122. radius: number;
  65123. /**
  65124. * Agent height. [Limit: > 0]
  65125. */
  65126. height: number;
  65127. /**
  65128. * Maximum allowed acceleration. [Limit: >= 0]
  65129. */
  65130. maxAcceleration: number;
  65131. /**
  65132. * Maximum allowed speed. [Limit: >= 0]
  65133. */
  65134. maxSpeed: number;
  65135. /**
  65136. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65137. */
  65138. collisionQueryRange: number;
  65139. /**
  65140. * The path visibility optimization range. [Limit: > 0]
  65141. */
  65142. pathOptimizationRange: number;
  65143. /**
  65144. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65145. */
  65146. separationWeight: number;
  65147. }
  65148. /**
  65149. * Configures the navigation mesh creation
  65150. */
  65151. export interface INavMeshParameters {
  65152. /**
  65153. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65154. */
  65155. cs: number;
  65156. /**
  65157. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65158. */
  65159. ch: number;
  65160. /**
  65161. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65162. */
  65163. walkableSlopeAngle: number;
  65164. /**
  65165. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65166. * be considered walkable. [Limit: >= 3] [Units: vx]
  65167. */
  65168. walkableHeight: number;
  65169. /**
  65170. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65171. */
  65172. walkableClimb: number;
  65173. /**
  65174. * The distance to erode/shrink the walkable area of the heightfield away from
  65175. * obstructions. [Limit: >=0] [Units: vx]
  65176. */
  65177. walkableRadius: number;
  65178. /**
  65179. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65180. */
  65181. maxEdgeLen: number;
  65182. /**
  65183. * The maximum distance a simplfied contour's border edges should deviate
  65184. * the original raw contour. [Limit: >=0] [Units: vx]
  65185. */
  65186. maxSimplificationError: number;
  65187. /**
  65188. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65189. */
  65190. minRegionArea: number;
  65191. /**
  65192. * Any regions with a span count smaller than this value will, if possible,
  65193. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65194. */
  65195. mergeRegionArea: number;
  65196. /**
  65197. * The maximum number of vertices allowed for polygons generated during the
  65198. * contour to polygon conversion process. [Limit: >= 3]
  65199. */
  65200. maxVertsPerPoly: number;
  65201. /**
  65202. * Sets the sampling distance to use when generating the detail mesh.
  65203. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65204. */
  65205. detailSampleDist: number;
  65206. /**
  65207. * The maximum distance the detail mesh surface should deviate from heightfield
  65208. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65209. */
  65210. detailSampleMaxError: number;
  65211. }
  65212. }
  65213. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65214. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65215. import { Mesh } from "babylonjs/Meshes/mesh";
  65216. import { Scene } from "babylonjs/scene";
  65217. import { Vector3 } from "babylonjs/Maths/math";
  65218. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65219. /**
  65220. * RecastJS navigation plugin
  65221. */
  65222. export class RecastJSPlugin implements INavigationEnginePlugin {
  65223. /**
  65224. * Reference to the Recast library
  65225. */
  65226. bjsRECAST: any;
  65227. /**
  65228. * plugin name
  65229. */
  65230. name: string;
  65231. /**
  65232. * the first navmesh created. We might extend this to support multiple navmeshes
  65233. */
  65234. navMesh: any;
  65235. /**
  65236. * Initializes the recastJS plugin
  65237. * @param recastInjection can be used to inject your own recast reference
  65238. */
  65239. constructor(recastInjection?: any);
  65240. /**
  65241. * Creates a navigation mesh
  65242. * @param meshes array of all the geometry used to compute the navigatio mesh
  65243. * @param parameters bunch of parameters used to filter geometry
  65244. */
  65245. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65246. /**
  65247. * Create a navigation mesh debug mesh
  65248. * @param scene is where the mesh will be added
  65249. * @returns debug display mesh
  65250. */
  65251. createDebugNavMesh(scene: Scene): Mesh;
  65252. /**
  65253. * Get a navigation mesh constrained position, closest to the parameter position
  65254. * @param position world position
  65255. * @returns the closest point to position constrained by the navigation mesh
  65256. */
  65257. getClosestPoint(position: Vector3): Vector3;
  65258. /**
  65259. * Get a navigation mesh constrained position, within a particular radius
  65260. * @param position world position
  65261. * @param maxRadius the maximum distance to the constrained world position
  65262. * @returns the closest point to position constrained by the navigation mesh
  65263. */
  65264. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65265. /**
  65266. * Compute the final position from a segment made of destination-position
  65267. * @param position world position
  65268. * @param destination world position
  65269. * @returns the resulting point along the navmesh
  65270. */
  65271. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65272. /**
  65273. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65274. * @param start world position
  65275. * @param end world position
  65276. * @returns array containing world position composing the path
  65277. */
  65278. computePath(start: Vector3, end: Vector3): Vector3[];
  65279. /**
  65280. * Create a new Crowd so you can add agents
  65281. * @param maxAgents the maximum agent count in the crowd
  65282. * @param maxAgentRadius the maximum radius an agent can have
  65283. * @param scene to attach the crowd to
  65284. * @returns the crowd you can add agents to
  65285. */
  65286. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65287. /**
  65288. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65289. * The queries will try to find a solution within those bounds
  65290. * default is (1,1,1)
  65291. * @param extent x,y,z value that define the extent around the queries point of reference
  65292. */
  65293. setDefaultQueryExtent(extent: Vector3): void;
  65294. /**
  65295. * Get the Bounding box extent specified by setDefaultQueryExtent
  65296. * @returns the box extent values
  65297. */
  65298. getDefaultQueryExtent(): Vector3;
  65299. /**
  65300. * Disposes
  65301. */
  65302. dispose(): void;
  65303. /**
  65304. * If this plugin is supported
  65305. * @returns true if plugin is supported
  65306. */
  65307. isSupported(): boolean;
  65308. }
  65309. /**
  65310. * Recast detour crowd implementation
  65311. */
  65312. export class RecastJSCrowd implements ICrowd {
  65313. /**
  65314. * Recast/detour plugin
  65315. */
  65316. bjsRECASTPlugin: RecastJSPlugin;
  65317. /**
  65318. * Link to the detour crowd
  65319. */
  65320. recastCrowd: any;
  65321. /**
  65322. * One transform per agent
  65323. */
  65324. transforms: TransformNode[];
  65325. /**
  65326. * All agents created
  65327. */
  65328. agents: number[];
  65329. /**
  65330. * Link to the scene is kept to unregister the crowd from the scene
  65331. */
  65332. private _scene;
  65333. /**
  65334. * Observer for crowd updates
  65335. */
  65336. private _onBeforeAnimationsObserver;
  65337. /**
  65338. * Constructor
  65339. * @param plugin recastJS plugin
  65340. * @param maxAgents the maximum agent count in the crowd
  65341. * @param maxAgentRadius the maximum radius an agent can have
  65342. * @param scene to attach the crowd to
  65343. * @returns the crowd you can add agents to
  65344. */
  65345. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65346. /**
  65347. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65348. * You can attach anything to that node. The node position is updated in the scene update tick.
  65349. * @param pos world position that will be constrained by the navigation mesh
  65350. * @param parameters agent parameters
  65351. * @param transform hooked to the agent that will be update by the scene
  65352. * @returns agent index
  65353. */
  65354. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65355. /**
  65356. * Returns the agent position in world space
  65357. * @param index agent index returned by addAgent
  65358. * @returns world space position
  65359. */
  65360. getAgentPosition(index: number): Vector3;
  65361. /**
  65362. * Returns the agent velocity in world space
  65363. * @param index agent index returned by addAgent
  65364. * @returns world space velocity
  65365. */
  65366. getAgentVelocity(index: number): Vector3;
  65367. /**
  65368. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65369. * @param index agent index returned by addAgent
  65370. * @param destination targeted world position
  65371. */
  65372. agentGoto(index: number, destination: Vector3): void;
  65373. /**
  65374. * Teleport the agent to a new position
  65375. * @param index agent index returned by addAgent
  65376. * @param destination targeted world position
  65377. */
  65378. agentTeleport(index: number, destination: Vector3): void;
  65379. /**
  65380. * Update agent parameters
  65381. * @param index agent index returned by addAgent
  65382. * @param parameters agent parameters
  65383. */
  65384. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65385. /**
  65386. * remove a particular agent previously created
  65387. * @param index agent index returned by addAgent
  65388. */
  65389. removeAgent(index: number): void;
  65390. /**
  65391. * get the list of all agents attached to this crowd
  65392. * @returns list of agent indices
  65393. */
  65394. getAgents(): number[];
  65395. /**
  65396. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65397. * @param deltaTime in seconds
  65398. */
  65399. update(deltaTime: number): void;
  65400. /**
  65401. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65402. * The queries will try to find a solution within those bounds
  65403. * default is (1,1,1)
  65404. * @param extent x,y,z value that define the extent around the queries point of reference
  65405. */
  65406. setDefaultQueryExtent(extent: Vector3): void;
  65407. /**
  65408. * Get the Bounding box extent specified by setDefaultQueryExtent
  65409. * @returns the box extent values
  65410. */
  65411. getDefaultQueryExtent(): Vector3;
  65412. /**
  65413. * Release all resources
  65414. */
  65415. dispose(): void;
  65416. }
  65417. }
  65418. declare module "babylonjs/Navigation/Plugins/index" {
  65419. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65420. }
  65421. declare module "babylonjs/Navigation/index" {
  65422. export * from "babylonjs/Navigation/INavigationEngine";
  65423. export * from "babylonjs/Navigation/Plugins/index";
  65424. }
  65425. declare module "babylonjs/Offline/database" {
  65426. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65427. /**
  65428. * Class used to enable access to IndexedDB
  65429. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65430. */
  65431. export class Database implements IOfflineProvider {
  65432. private _callbackManifestChecked;
  65433. private _currentSceneUrl;
  65434. private _db;
  65435. private _enableSceneOffline;
  65436. private _enableTexturesOffline;
  65437. private _manifestVersionFound;
  65438. private _mustUpdateRessources;
  65439. private _hasReachedQuota;
  65440. private _isSupported;
  65441. private _idbFactory;
  65442. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65443. private static IsUASupportingBlobStorage;
  65444. /**
  65445. * Gets a boolean indicating if Database storate is enabled (off by default)
  65446. */
  65447. static IDBStorageEnabled: boolean;
  65448. /**
  65449. * Gets a boolean indicating if scene must be saved in the database
  65450. */
  65451. get enableSceneOffline(): boolean;
  65452. /**
  65453. * Gets a boolean indicating if textures must be saved in the database
  65454. */
  65455. get enableTexturesOffline(): boolean;
  65456. /**
  65457. * Creates a new Database
  65458. * @param urlToScene defines the url to load the scene
  65459. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65460. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65461. */
  65462. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65463. private static _ParseURL;
  65464. private static _ReturnFullUrlLocation;
  65465. private _checkManifestFile;
  65466. /**
  65467. * Open the database and make it available
  65468. * @param successCallback defines the callback to call on success
  65469. * @param errorCallback defines the callback to call on error
  65470. */
  65471. open(successCallback: () => void, errorCallback: () => void): void;
  65472. /**
  65473. * Loads an image from the database
  65474. * @param url defines the url to load from
  65475. * @param image defines the target DOM image
  65476. */
  65477. loadImage(url: string, image: HTMLImageElement): void;
  65478. private _loadImageFromDBAsync;
  65479. private _saveImageIntoDBAsync;
  65480. private _checkVersionFromDB;
  65481. private _loadVersionFromDBAsync;
  65482. private _saveVersionIntoDBAsync;
  65483. /**
  65484. * Loads a file from database
  65485. * @param url defines the URL to load from
  65486. * @param sceneLoaded defines a callback to call on success
  65487. * @param progressCallBack defines a callback to call when progress changed
  65488. * @param errorCallback defines a callback to call on error
  65489. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65490. */
  65491. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65492. private _loadFileAsync;
  65493. private _saveFileAsync;
  65494. /**
  65495. * Validates if xhr data is correct
  65496. * @param xhr defines the request to validate
  65497. * @param dataType defines the expected data type
  65498. * @returns true if data is correct
  65499. */
  65500. private static _ValidateXHRData;
  65501. }
  65502. }
  65503. declare module "babylonjs/Offline/index" {
  65504. export * from "babylonjs/Offline/database";
  65505. export * from "babylonjs/Offline/IOfflineProvider";
  65506. }
  65507. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65508. /** @hidden */
  65509. export var gpuUpdateParticlesPixelShader: {
  65510. name: string;
  65511. shader: string;
  65512. };
  65513. }
  65514. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65515. /** @hidden */
  65516. export var gpuUpdateParticlesVertexShader: {
  65517. name: string;
  65518. shader: string;
  65519. };
  65520. }
  65521. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65522. /** @hidden */
  65523. export var clipPlaneFragmentDeclaration2: {
  65524. name: string;
  65525. shader: string;
  65526. };
  65527. }
  65528. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65529. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65530. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65531. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65532. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65533. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65534. /** @hidden */
  65535. export var gpuRenderParticlesPixelShader: {
  65536. name: string;
  65537. shader: string;
  65538. };
  65539. }
  65540. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65541. /** @hidden */
  65542. export var clipPlaneVertexDeclaration2: {
  65543. name: string;
  65544. shader: string;
  65545. };
  65546. }
  65547. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65548. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65549. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65550. /** @hidden */
  65551. export var gpuRenderParticlesVertexShader: {
  65552. name: string;
  65553. shader: string;
  65554. };
  65555. }
  65556. declare module "babylonjs/Particles/gpuParticleSystem" {
  65557. import { Nullable } from "babylonjs/types";
  65558. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65559. import { Observable } from "babylonjs/Misc/observable";
  65560. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65561. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65562. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65563. import { Scene, IDisposable } from "babylonjs/scene";
  65564. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65565. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65566. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65567. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65568. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65569. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65570. /**
  65571. * This represents a GPU particle system in Babylon
  65572. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65573. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65574. */
  65575. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65576. /**
  65577. * The layer mask we are rendering the particles through.
  65578. */
  65579. layerMask: number;
  65580. private _capacity;
  65581. private _activeCount;
  65582. private _currentActiveCount;
  65583. private _accumulatedCount;
  65584. private _renderEffect;
  65585. private _updateEffect;
  65586. private _buffer0;
  65587. private _buffer1;
  65588. private _spriteBuffer;
  65589. private _updateVAO;
  65590. private _renderVAO;
  65591. private _targetIndex;
  65592. private _sourceBuffer;
  65593. private _targetBuffer;
  65594. private _engine;
  65595. private _currentRenderId;
  65596. private _started;
  65597. private _stopped;
  65598. private _timeDelta;
  65599. private _randomTexture;
  65600. private _randomTexture2;
  65601. private _attributesStrideSize;
  65602. private _updateEffectOptions;
  65603. private _randomTextureSize;
  65604. private _actualFrame;
  65605. private readonly _rawTextureWidth;
  65606. /**
  65607. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65608. */
  65609. static get IsSupported(): boolean;
  65610. /**
  65611. * An event triggered when the system is disposed.
  65612. */
  65613. onDisposeObservable: Observable<GPUParticleSystem>;
  65614. /**
  65615. * Gets the maximum number of particles active at the same time.
  65616. * @returns The max number of active particles.
  65617. */
  65618. getCapacity(): number;
  65619. /**
  65620. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65621. * to override the particles.
  65622. */
  65623. forceDepthWrite: boolean;
  65624. /**
  65625. * Gets or set the number of active particles
  65626. */
  65627. get activeParticleCount(): number;
  65628. set activeParticleCount(value: number);
  65629. private _preWarmDone;
  65630. /**
  65631. * Is this system ready to be used/rendered
  65632. * @return true if the system is ready
  65633. */
  65634. isReady(): boolean;
  65635. /**
  65636. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65637. * @returns True if it has been started, otherwise false.
  65638. */
  65639. isStarted(): boolean;
  65640. /**
  65641. * Starts the particle system and begins to emit
  65642. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65643. */
  65644. start(delay?: number): void;
  65645. /**
  65646. * Stops the particle system.
  65647. */
  65648. stop(): void;
  65649. /**
  65650. * Remove all active particles
  65651. */
  65652. reset(): void;
  65653. /**
  65654. * Returns the string "GPUParticleSystem"
  65655. * @returns a string containing the class name
  65656. */
  65657. getClassName(): string;
  65658. private _colorGradientsTexture;
  65659. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65660. /**
  65661. * Adds a new color gradient
  65662. * @param gradient defines the gradient to use (between 0 and 1)
  65663. * @param color1 defines the color to affect to the specified gradient
  65664. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65665. * @returns the current particle system
  65666. */
  65667. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65668. /**
  65669. * Remove a specific color gradient
  65670. * @param gradient defines the gradient to remove
  65671. * @returns the current particle system
  65672. */
  65673. removeColorGradient(gradient: number): GPUParticleSystem;
  65674. private _angularSpeedGradientsTexture;
  65675. private _sizeGradientsTexture;
  65676. private _velocityGradientsTexture;
  65677. private _limitVelocityGradientsTexture;
  65678. private _dragGradientsTexture;
  65679. private _addFactorGradient;
  65680. /**
  65681. * Adds a new size gradient
  65682. * @param gradient defines the gradient to use (between 0 and 1)
  65683. * @param factor defines the size factor to affect to the specified gradient
  65684. * @returns the current particle system
  65685. */
  65686. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65687. /**
  65688. * Remove a specific size gradient
  65689. * @param gradient defines the gradient to remove
  65690. * @returns the current particle system
  65691. */
  65692. removeSizeGradient(gradient: number): GPUParticleSystem;
  65693. /**
  65694. * Adds a new angular speed gradient
  65695. * @param gradient defines the gradient to use (between 0 and 1)
  65696. * @param factor defines the angular speed to affect to the specified gradient
  65697. * @returns the current particle system
  65698. */
  65699. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65700. /**
  65701. * Remove a specific angular speed gradient
  65702. * @param gradient defines the gradient to remove
  65703. * @returns the current particle system
  65704. */
  65705. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65706. /**
  65707. * Adds a new velocity gradient
  65708. * @param gradient defines the gradient to use (between 0 and 1)
  65709. * @param factor defines the velocity to affect to the specified gradient
  65710. * @returns the current particle system
  65711. */
  65712. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65713. /**
  65714. * Remove a specific velocity gradient
  65715. * @param gradient defines the gradient to remove
  65716. * @returns the current particle system
  65717. */
  65718. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65719. /**
  65720. * Adds a new limit velocity gradient
  65721. * @param gradient defines the gradient to use (between 0 and 1)
  65722. * @param factor defines the limit velocity value to affect to the specified gradient
  65723. * @returns the current particle system
  65724. */
  65725. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65726. /**
  65727. * Remove a specific limit velocity gradient
  65728. * @param gradient defines the gradient to remove
  65729. * @returns the current particle system
  65730. */
  65731. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65732. /**
  65733. * Adds a new drag gradient
  65734. * @param gradient defines the gradient to use (between 0 and 1)
  65735. * @param factor defines the drag value to affect to the specified gradient
  65736. * @returns the current particle system
  65737. */
  65738. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65739. /**
  65740. * Remove a specific drag gradient
  65741. * @param gradient defines the gradient to remove
  65742. * @returns the current particle system
  65743. */
  65744. removeDragGradient(gradient: number): GPUParticleSystem;
  65745. /**
  65746. * Not supported by GPUParticleSystem
  65747. * @param gradient defines the gradient to use (between 0 and 1)
  65748. * @param factor defines the emit rate value to affect to the specified gradient
  65749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65750. * @returns the current particle system
  65751. */
  65752. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65753. /**
  65754. * Not supported by GPUParticleSystem
  65755. * @param gradient defines the gradient to remove
  65756. * @returns the current particle system
  65757. */
  65758. removeEmitRateGradient(gradient: number): IParticleSystem;
  65759. /**
  65760. * Not supported by GPUParticleSystem
  65761. * @param gradient defines the gradient to use (between 0 and 1)
  65762. * @param factor defines the start size value to affect to the specified gradient
  65763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65764. * @returns the current particle system
  65765. */
  65766. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65767. /**
  65768. * Not supported by GPUParticleSystem
  65769. * @param gradient defines the gradient to remove
  65770. * @returns the current particle system
  65771. */
  65772. removeStartSizeGradient(gradient: number): IParticleSystem;
  65773. /**
  65774. * Not supported by GPUParticleSystem
  65775. * @param gradient defines the gradient to use (between 0 and 1)
  65776. * @param min defines the color remap minimal range
  65777. * @param max defines the color remap maximal range
  65778. * @returns the current particle system
  65779. */
  65780. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65781. /**
  65782. * Not supported by GPUParticleSystem
  65783. * @param gradient defines the gradient to remove
  65784. * @returns the current particle system
  65785. */
  65786. removeColorRemapGradient(): IParticleSystem;
  65787. /**
  65788. * Not supported by GPUParticleSystem
  65789. * @param gradient defines the gradient to use (between 0 and 1)
  65790. * @param min defines the alpha remap minimal range
  65791. * @param max defines the alpha remap maximal range
  65792. * @returns the current particle system
  65793. */
  65794. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65795. /**
  65796. * Not supported by GPUParticleSystem
  65797. * @param gradient defines the gradient to remove
  65798. * @returns the current particle system
  65799. */
  65800. removeAlphaRemapGradient(): IParticleSystem;
  65801. /**
  65802. * Not supported by GPUParticleSystem
  65803. * @param gradient defines the gradient to use (between 0 and 1)
  65804. * @param color defines the color to affect to the specified gradient
  65805. * @returns the current particle system
  65806. */
  65807. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65808. /**
  65809. * Not supported by GPUParticleSystem
  65810. * @param gradient defines the gradient to remove
  65811. * @returns the current particle system
  65812. */
  65813. removeRampGradient(): IParticleSystem;
  65814. /**
  65815. * Not supported by GPUParticleSystem
  65816. * @returns the list of ramp gradients
  65817. */
  65818. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65819. /**
  65820. * Not supported by GPUParticleSystem
  65821. * Gets or sets a boolean indicating that ramp gradients must be used
  65822. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65823. */
  65824. get useRampGradients(): boolean;
  65825. set useRampGradients(value: boolean);
  65826. /**
  65827. * Not supported by GPUParticleSystem
  65828. * @param gradient defines the gradient to use (between 0 and 1)
  65829. * @param factor defines the life time factor to affect to the specified gradient
  65830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65831. * @returns the current particle system
  65832. */
  65833. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65834. /**
  65835. * Not supported by GPUParticleSystem
  65836. * @param gradient defines the gradient to remove
  65837. * @returns the current particle system
  65838. */
  65839. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65840. /**
  65841. * Instantiates a GPU particle system.
  65842. * 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.
  65843. * @param name The name of the particle system
  65844. * @param options The options used to create the system
  65845. * @param scene The scene the particle system belongs to
  65846. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65847. */
  65848. constructor(name: string, options: Partial<{
  65849. capacity: number;
  65850. randomTextureSize: number;
  65851. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65852. protected _reset(): void;
  65853. private _createUpdateVAO;
  65854. private _createRenderVAO;
  65855. private _initialize;
  65856. /** @hidden */
  65857. _recreateUpdateEffect(): void;
  65858. /** @hidden */
  65859. _recreateRenderEffect(): void;
  65860. /**
  65861. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65862. * @param preWarm defines if we are in the pre-warmimg phase
  65863. */
  65864. animate(preWarm?: boolean): void;
  65865. private _createFactorGradientTexture;
  65866. private _createSizeGradientTexture;
  65867. private _createAngularSpeedGradientTexture;
  65868. private _createVelocityGradientTexture;
  65869. private _createLimitVelocityGradientTexture;
  65870. private _createDragGradientTexture;
  65871. private _createColorGradientTexture;
  65872. /**
  65873. * Renders the particle system in its current state
  65874. * @param preWarm defines if the system should only update the particles but not render them
  65875. * @returns the current number of particles
  65876. */
  65877. render(preWarm?: boolean): number;
  65878. /**
  65879. * Rebuilds the particle system
  65880. */
  65881. rebuild(): void;
  65882. private _releaseBuffers;
  65883. private _releaseVAOs;
  65884. /**
  65885. * Disposes the particle system and free the associated resources
  65886. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65887. */
  65888. dispose(disposeTexture?: boolean): void;
  65889. /**
  65890. * Clones the particle system.
  65891. * @param name The name of the cloned object
  65892. * @param newEmitter The new emitter to use
  65893. * @returns the cloned particle system
  65894. */
  65895. clone(name: string, newEmitter: any): GPUParticleSystem;
  65896. /**
  65897. * Serializes the particle system to a JSON object.
  65898. * @returns the JSON object
  65899. */
  65900. serialize(): any;
  65901. /**
  65902. * Parses a JSON object to create a GPU particle system.
  65903. * @param parsedParticleSystem The JSON object to parse
  65904. * @param scene The scene to create the particle system in
  65905. * @param rootUrl The root url to use to load external dependencies like texture
  65906. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65907. * @returns the parsed GPU particle system
  65908. */
  65909. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65910. }
  65911. }
  65912. declare module "babylonjs/Particles/particleSystemSet" {
  65913. import { Nullable } from "babylonjs/types";
  65914. import { Color3 } from "babylonjs/Maths/math.color";
  65915. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65917. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65918. import { Scene, IDisposable } from "babylonjs/scene";
  65919. /**
  65920. * Represents a set of particle systems working together to create a specific effect
  65921. */
  65922. export class ParticleSystemSet implements IDisposable {
  65923. /**
  65924. * Gets or sets base Assets URL
  65925. */
  65926. static BaseAssetsUrl: string;
  65927. private _emitterCreationOptions;
  65928. private _emitterNode;
  65929. /**
  65930. * Gets the particle system list
  65931. */
  65932. systems: IParticleSystem[];
  65933. /**
  65934. * Gets the emitter node used with this set
  65935. */
  65936. get emitterNode(): Nullable<TransformNode>;
  65937. /**
  65938. * Creates a new emitter mesh as a sphere
  65939. * @param options defines the options used to create the sphere
  65940. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65941. * @param scene defines the hosting scene
  65942. */
  65943. setEmitterAsSphere(options: {
  65944. diameter: number;
  65945. segments: number;
  65946. color: Color3;
  65947. }, renderingGroupId: number, scene: Scene): void;
  65948. /**
  65949. * Starts all particle systems of the set
  65950. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65951. */
  65952. start(emitter?: AbstractMesh): void;
  65953. /**
  65954. * Release all associated resources
  65955. */
  65956. dispose(): void;
  65957. /**
  65958. * Serialize the set into a JSON compatible object
  65959. * @returns a JSON compatible representation of the set
  65960. */
  65961. serialize(): any;
  65962. /**
  65963. * Parse a new ParticleSystemSet from a serialized source
  65964. * @param data defines a JSON compatible representation of the set
  65965. * @param scene defines the hosting scene
  65966. * @param gpu defines if we want GPU particles or CPU particles
  65967. * @returns a new ParticleSystemSet
  65968. */
  65969. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65970. }
  65971. }
  65972. declare module "babylonjs/Particles/particleHelper" {
  65973. import { Nullable } from "babylonjs/types";
  65974. import { Scene } from "babylonjs/scene";
  65975. import { Vector3 } from "babylonjs/Maths/math.vector";
  65976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65977. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65978. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  65979. /**
  65980. * This class is made for on one-liner static method to help creating particle system set.
  65981. */
  65982. export class ParticleHelper {
  65983. /**
  65984. * Gets or sets base Assets URL
  65985. */
  65986. static BaseAssetsUrl: string;
  65987. /**
  65988. * Create a default particle system that you can tweak
  65989. * @param emitter defines the emitter to use
  65990. * @param capacity defines the system capacity (default is 500 particles)
  65991. * @param scene defines the hosting scene
  65992. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65993. * @returns the new Particle system
  65994. */
  65995. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65996. /**
  65997. * This is the main static method (one-liner) of this helper to create different particle systems
  65998. * @param type This string represents the type to the particle system to create
  65999. * @param scene The scene where the particle system should live
  66000. * @param gpu If the system will use gpu
  66001. * @returns the ParticleSystemSet created
  66002. */
  66003. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66004. /**
  66005. * Static function used to export a particle system to a ParticleSystemSet variable.
  66006. * Please note that the emitter shape is not exported
  66007. * @param systems defines the particle systems to export
  66008. * @returns the created particle system set
  66009. */
  66010. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66011. }
  66012. }
  66013. declare module "babylonjs/Particles/particleSystemComponent" {
  66014. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66015. import { Effect } from "babylonjs/Materials/effect";
  66016. import "babylonjs/Shaders/particles.vertex";
  66017. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66018. module "babylonjs/Engines/engine" {
  66019. interface Engine {
  66020. /**
  66021. * Create an effect to use with particle systems.
  66022. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66023. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66024. * @param uniformsNames defines a list of attribute names
  66025. * @param samplers defines an array of string used to represent textures
  66026. * @param defines defines the string containing the defines to use to compile the shaders
  66027. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66028. * @param onCompiled defines a function to call when the effect creation is successful
  66029. * @param onError defines a function to call when the effect creation has failed
  66030. * @returns the new Effect
  66031. */
  66032. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66033. }
  66034. }
  66035. module "babylonjs/Meshes/mesh" {
  66036. interface Mesh {
  66037. /**
  66038. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66039. * @returns an array of IParticleSystem
  66040. */
  66041. getEmittedParticleSystems(): IParticleSystem[];
  66042. /**
  66043. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66044. * @returns an array of IParticleSystem
  66045. */
  66046. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66047. }
  66048. }
  66049. /**
  66050. * @hidden
  66051. */
  66052. export var _IDoNeedToBeInTheBuild: number;
  66053. }
  66054. declare module "babylonjs/Particles/pointsCloudSystem" {
  66055. import { Color4 } from "babylonjs/Maths/math";
  66056. import { Mesh } from "babylonjs/Meshes/mesh";
  66057. import { Scene, IDisposable } from "babylonjs/scene";
  66058. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66059. /** Defines the 4 color options */
  66060. export enum PointColor {
  66061. /** color value */
  66062. Color = 2,
  66063. /** uv value */
  66064. UV = 1,
  66065. /** random value */
  66066. Random = 0,
  66067. /** stated value */
  66068. Stated = 3
  66069. }
  66070. /**
  66071. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66072. * 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.
  66073. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66074. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66075. *
  66076. * Full documentation here : TO BE ENTERED
  66077. */
  66078. export class PointsCloudSystem implements IDisposable {
  66079. /**
  66080. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66081. * Example : var p = SPS.particles[i];
  66082. */
  66083. particles: CloudPoint[];
  66084. /**
  66085. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66086. */
  66087. nbParticles: number;
  66088. /**
  66089. * This a counter for your own usage. It's not set by any SPS functions.
  66090. */
  66091. counter: number;
  66092. /**
  66093. * The PCS name. This name is also given to the underlying mesh.
  66094. */
  66095. name: string;
  66096. /**
  66097. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66098. */
  66099. mesh: Mesh;
  66100. /**
  66101. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66102. * Please read :
  66103. */
  66104. vars: any;
  66105. /**
  66106. * @hidden
  66107. */
  66108. _size: number;
  66109. private _scene;
  66110. private _promises;
  66111. private _positions;
  66112. private _indices;
  66113. private _normals;
  66114. private _colors;
  66115. private _uvs;
  66116. private _indices32;
  66117. private _positions32;
  66118. private _colors32;
  66119. private _uvs32;
  66120. private _updatable;
  66121. private _isVisibilityBoxLocked;
  66122. private _alwaysVisible;
  66123. private _groups;
  66124. private _groupCounter;
  66125. private _computeParticleColor;
  66126. private _computeParticleTexture;
  66127. private _computeParticleRotation;
  66128. private _computeBoundingBox;
  66129. private _isReady;
  66130. /**
  66131. * Creates a PCS (Points Cloud System) object
  66132. * @param name (String) is the PCS name, this will be the underlying mesh name
  66133. * @param pointSize (number) is the size for each point
  66134. * @param scene (Scene) is the scene in which the PCS is added
  66135. * @param options defines the options of the PCS e.g.
  66136. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66137. */
  66138. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66139. updatable?: boolean;
  66140. });
  66141. /**
  66142. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66143. * If no points were added to the PCS, the returned mesh is just a single point.
  66144. * @returns a promise for the created mesh
  66145. */
  66146. buildMeshAsync(): Promise<Mesh>;
  66147. /**
  66148. * @hidden
  66149. */
  66150. private _buildMesh;
  66151. private _addParticle;
  66152. private _randomUnitVector;
  66153. private _getColorIndicesForCoord;
  66154. private _setPointsColorOrUV;
  66155. private _colorFromTexture;
  66156. private _calculateDensity;
  66157. /**
  66158. * Adds points to the PCS in random positions within a unit sphere
  66159. * @param nb (positive integer) the number of particles to be created from this model
  66160. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66161. * @returns the number of groups in the system
  66162. */
  66163. addPoints(nb: number, pointFunction?: any): number;
  66164. /**
  66165. * Adds points to the PCS from the surface of the model shape
  66166. * @param mesh is any Mesh object that will be used as a surface model for the points
  66167. * @param nb (positive integer) the number of particles to be created from this model
  66168. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66169. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66170. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66171. * @returns the number of groups in the system
  66172. */
  66173. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66174. /**
  66175. * Adds points to the PCS inside the model shape
  66176. * @param mesh is any Mesh object that will be used as a surface model for the points
  66177. * @param nb (positive integer) the number of particles to be created from this model
  66178. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66179. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66180. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66181. * @returns the number of groups in the system
  66182. */
  66183. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66184. /**
  66185. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66186. * This method calls `updateParticle()` for each particle of the SPS.
  66187. * For an animated SPS, it is usually called within the render loop.
  66188. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66189. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66190. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66191. * @returns the PCS.
  66192. */
  66193. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66194. /**
  66195. * Disposes the PCS.
  66196. */
  66197. dispose(): void;
  66198. /**
  66199. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66200. * doc :
  66201. * @returns the PCS.
  66202. */
  66203. refreshVisibleSize(): PointsCloudSystem;
  66204. /**
  66205. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66206. * @param size the size (float) of the visibility box
  66207. * note : this doesn't lock the PCS mesh bounding box.
  66208. * doc :
  66209. */
  66210. setVisibilityBox(size: number): void;
  66211. /**
  66212. * Gets whether the PCS is always visible or not
  66213. * doc :
  66214. */
  66215. get isAlwaysVisible(): boolean;
  66216. /**
  66217. * Sets the PCS as always visible or not
  66218. * doc :
  66219. */
  66220. set isAlwaysVisible(val: boolean);
  66221. /**
  66222. * Tells to `setParticles()` to compute the particle rotations or not
  66223. * Default value : false. The PCS is faster when it's set to false
  66224. * Note : particle rotations are only applied to parent particles
  66225. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66226. */
  66227. set computeParticleRotation(val: boolean);
  66228. /**
  66229. * Tells to `setParticles()` to compute the particle colors or not.
  66230. * Default value : true. The PCS is faster when it's set to false.
  66231. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66232. */
  66233. set computeParticleColor(val: boolean);
  66234. set computeParticleTexture(val: boolean);
  66235. /**
  66236. * Gets if `setParticles()` computes the particle colors or not.
  66237. * Default value : false. The PCS is faster when it's set to false.
  66238. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66239. */
  66240. get computeParticleColor(): boolean;
  66241. /**
  66242. * Gets if `setParticles()` computes the particle textures or not.
  66243. * Default value : false. The PCS is faster when it's set to false.
  66244. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66245. */
  66246. get computeParticleTexture(): boolean;
  66247. /**
  66248. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66249. */
  66250. set computeBoundingBox(val: boolean);
  66251. /**
  66252. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66253. */
  66254. get computeBoundingBox(): boolean;
  66255. /**
  66256. * This function does nothing. It may be overwritten to set all the particle first values.
  66257. * The PCS doesn't call this function, you may have to call it by your own.
  66258. * doc :
  66259. */
  66260. initParticles(): void;
  66261. /**
  66262. * This function does nothing. It may be overwritten to recycle a particle
  66263. * The PCS doesn't call this function, you can to call it
  66264. * doc :
  66265. * @param particle The particle to recycle
  66266. * @returns the recycled particle
  66267. */
  66268. recycleParticle(particle: CloudPoint): CloudPoint;
  66269. /**
  66270. * Updates a particle : this function should be overwritten by the user.
  66271. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66272. * doc :
  66273. * @example : just set a particle position or velocity and recycle conditions
  66274. * @param particle The particle to update
  66275. * @returns the updated particle
  66276. */
  66277. updateParticle(particle: CloudPoint): CloudPoint;
  66278. /**
  66279. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66280. * This does nothing and may be overwritten by the user.
  66281. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66282. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66283. * @param update the boolean update value actually passed to setParticles()
  66284. */
  66285. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66286. /**
  66287. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66288. * This will be passed three parameters.
  66289. * This does nothing and may be overwritten by the user.
  66290. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66291. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66292. * @param update the boolean update value actually passed to setParticles()
  66293. */
  66294. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66295. }
  66296. }
  66297. declare module "babylonjs/Particles/cloudPoint" {
  66298. import { Nullable } from "babylonjs/types";
  66299. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66300. import { Mesh } from "babylonjs/Meshes/mesh";
  66301. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66302. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66303. /**
  66304. * Represents one particle of a points cloud system.
  66305. */
  66306. export class CloudPoint {
  66307. /**
  66308. * particle global index
  66309. */
  66310. idx: number;
  66311. /**
  66312. * The color of the particle
  66313. */
  66314. color: Nullable<Color4>;
  66315. /**
  66316. * The world space position of the particle.
  66317. */
  66318. position: Vector3;
  66319. /**
  66320. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66321. */
  66322. rotation: Vector3;
  66323. /**
  66324. * The world space rotation quaternion of the particle.
  66325. */
  66326. rotationQuaternion: Nullable<Quaternion>;
  66327. /**
  66328. * The uv of the particle.
  66329. */
  66330. uv: Nullable<Vector2>;
  66331. /**
  66332. * The current speed of the particle.
  66333. */
  66334. velocity: Vector3;
  66335. /**
  66336. * The pivot point in the particle local space.
  66337. */
  66338. pivot: Vector3;
  66339. /**
  66340. * Must the particle be translated from its pivot point in its local space ?
  66341. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66342. * Default : false
  66343. */
  66344. translateFromPivot: boolean;
  66345. /**
  66346. * Index of this particle in the global "positions" array (Internal use)
  66347. * @hidden
  66348. */
  66349. _pos: number;
  66350. /**
  66351. * @hidden Index of this particle in the global "indices" array (Internal use)
  66352. */
  66353. _ind: number;
  66354. /**
  66355. * Group this particle belongs to
  66356. */
  66357. _group: PointsGroup;
  66358. /**
  66359. * Group id of this particle
  66360. */
  66361. groupId: number;
  66362. /**
  66363. * Index of the particle in its group id (Internal use)
  66364. */
  66365. idxInGroup: number;
  66366. /**
  66367. * @hidden Particle BoundingInfo object (Internal use)
  66368. */
  66369. _boundingInfo: BoundingInfo;
  66370. /**
  66371. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66372. */
  66373. _pcs: PointsCloudSystem;
  66374. /**
  66375. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66376. */
  66377. _stillInvisible: boolean;
  66378. /**
  66379. * @hidden Last computed particle rotation matrix
  66380. */
  66381. _rotationMatrix: number[];
  66382. /**
  66383. * Parent particle Id, if any.
  66384. * Default null.
  66385. */
  66386. parentId: Nullable<number>;
  66387. /**
  66388. * @hidden Internal global position in the PCS.
  66389. */
  66390. _globalPosition: Vector3;
  66391. /**
  66392. * Creates a Point Cloud object.
  66393. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66394. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66395. * @param group (PointsGroup) is the group the particle belongs to
  66396. * @param groupId (integer) is the group identifier in the PCS.
  66397. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66398. * @param pcs defines the PCS it is associated to
  66399. */
  66400. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66401. /**
  66402. * get point size
  66403. */
  66404. get size(): Vector3;
  66405. /**
  66406. * Set point size
  66407. */
  66408. set size(scale: Vector3);
  66409. /**
  66410. * Legacy support, changed quaternion to rotationQuaternion
  66411. */
  66412. get quaternion(): Nullable<Quaternion>;
  66413. /**
  66414. * Legacy support, changed quaternion to rotationQuaternion
  66415. */
  66416. set quaternion(q: Nullable<Quaternion>);
  66417. /**
  66418. * Returns a boolean. True if the particle intersects a mesh, else false
  66419. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66420. * @param target is the object (point or mesh) what the intersection is computed against
  66421. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66422. * @returns true if it intersects
  66423. */
  66424. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66425. /**
  66426. * get the rotation matrix of the particle
  66427. * @hidden
  66428. */
  66429. getRotationMatrix(m: Matrix): void;
  66430. }
  66431. /**
  66432. * Represents a group of points in a points cloud system
  66433. * * PCS internal tool, don't use it manually.
  66434. */
  66435. export class PointsGroup {
  66436. /**
  66437. * The group id
  66438. * @hidden
  66439. */
  66440. groupID: number;
  66441. /**
  66442. * image data for group (internal use)
  66443. * @hidden
  66444. */
  66445. _groupImageData: Nullable<ArrayBufferView>;
  66446. /**
  66447. * Image Width (internal use)
  66448. * @hidden
  66449. */
  66450. _groupImgWidth: number;
  66451. /**
  66452. * Image Height (internal use)
  66453. * @hidden
  66454. */
  66455. _groupImgHeight: number;
  66456. /**
  66457. * Custom position function (internal use)
  66458. * @hidden
  66459. */
  66460. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66461. /**
  66462. * density per facet for surface points
  66463. * @hidden
  66464. */
  66465. _groupDensity: number[];
  66466. /**
  66467. * Only when points are colored by texture carries pointer to texture list array
  66468. * @hidden
  66469. */
  66470. _textureNb: number;
  66471. /**
  66472. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66473. * PCS internal tool, don't use it manually.
  66474. * @hidden
  66475. */
  66476. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66477. }
  66478. }
  66479. declare module "babylonjs/Particles/index" {
  66480. export * from "babylonjs/Particles/baseParticleSystem";
  66481. export * from "babylonjs/Particles/EmitterTypes/index";
  66482. export * from "babylonjs/Particles/gpuParticleSystem";
  66483. export * from "babylonjs/Particles/IParticleSystem";
  66484. export * from "babylonjs/Particles/particle";
  66485. export * from "babylonjs/Particles/particleHelper";
  66486. export * from "babylonjs/Particles/particleSystem";
  66487. export * from "babylonjs/Particles/particleSystemComponent";
  66488. export * from "babylonjs/Particles/particleSystemSet";
  66489. export * from "babylonjs/Particles/solidParticle";
  66490. export * from "babylonjs/Particles/solidParticleSystem";
  66491. export * from "babylonjs/Particles/cloudPoint";
  66492. export * from "babylonjs/Particles/pointsCloudSystem";
  66493. export * from "babylonjs/Particles/subEmitter";
  66494. }
  66495. declare module "babylonjs/Physics/physicsEngineComponent" {
  66496. import { Nullable } from "babylonjs/types";
  66497. import { Observable, Observer } from "babylonjs/Misc/observable";
  66498. import { Vector3 } from "babylonjs/Maths/math.vector";
  66499. import { Mesh } from "babylonjs/Meshes/mesh";
  66500. import { ISceneComponent } from "babylonjs/sceneComponent";
  66501. import { Scene } from "babylonjs/scene";
  66502. import { Node } from "babylonjs/node";
  66503. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66504. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66505. module "babylonjs/scene" {
  66506. interface Scene {
  66507. /** @hidden (Backing field) */
  66508. _physicsEngine: Nullable<IPhysicsEngine>;
  66509. /** @hidden */
  66510. _physicsTimeAccumulator: number;
  66511. /**
  66512. * Gets the current physics engine
  66513. * @returns a IPhysicsEngine or null if none attached
  66514. */
  66515. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66516. /**
  66517. * Enables physics to the current scene
  66518. * @param gravity defines the scene's gravity for the physics engine
  66519. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66520. * @return a boolean indicating if the physics engine was initialized
  66521. */
  66522. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66523. /**
  66524. * Disables and disposes the physics engine associated with the scene
  66525. */
  66526. disablePhysicsEngine(): void;
  66527. /**
  66528. * Gets a boolean indicating if there is an active physics engine
  66529. * @returns a boolean indicating if there is an active physics engine
  66530. */
  66531. isPhysicsEnabled(): boolean;
  66532. /**
  66533. * Deletes a physics compound impostor
  66534. * @param compound defines the compound to delete
  66535. */
  66536. deleteCompoundImpostor(compound: any): void;
  66537. /**
  66538. * An event triggered when physic simulation is about to be run
  66539. */
  66540. onBeforePhysicsObservable: Observable<Scene>;
  66541. /**
  66542. * An event triggered when physic simulation has been done
  66543. */
  66544. onAfterPhysicsObservable: Observable<Scene>;
  66545. }
  66546. }
  66547. module "babylonjs/Meshes/abstractMesh" {
  66548. interface AbstractMesh {
  66549. /** @hidden */
  66550. _physicsImpostor: Nullable<PhysicsImpostor>;
  66551. /**
  66552. * Gets or sets impostor used for physic simulation
  66553. * @see http://doc.babylonjs.com/features/physics_engine
  66554. */
  66555. physicsImpostor: Nullable<PhysicsImpostor>;
  66556. /**
  66557. * Gets the current physics impostor
  66558. * @see http://doc.babylonjs.com/features/physics_engine
  66559. * @returns a physics impostor or null
  66560. */
  66561. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66562. /** Apply a physic impulse to the mesh
  66563. * @param force defines the force to apply
  66564. * @param contactPoint defines where to apply the force
  66565. * @returns the current mesh
  66566. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66567. */
  66568. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66569. /**
  66570. * Creates a physic joint between two meshes
  66571. * @param otherMesh defines the other mesh to use
  66572. * @param pivot1 defines the pivot to use on this mesh
  66573. * @param pivot2 defines the pivot to use on the other mesh
  66574. * @param options defines additional options (can be plugin dependent)
  66575. * @returns the current mesh
  66576. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66577. */
  66578. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66579. /** @hidden */
  66580. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66581. }
  66582. }
  66583. /**
  66584. * Defines the physics engine scene component responsible to manage a physics engine
  66585. */
  66586. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66587. /**
  66588. * The component name helpful to identify the component in the list of scene components.
  66589. */
  66590. readonly name: string;
  66591. /**
  66592. * The scene the component belongs to.
  66593. */
  66594. scene: Scene;
  66595. /**
  66596. * Creates a new instance of the component for the given scene
  66597. * @param scene Defines the scene to register the component in
  66598. */
  66599. constructor(scene: Scene);
  66600. /**
  66601. * Registers the component in a given scene
  66602. */
  66603. register(): void;
  66604. /**
  66605. * Rebuilds the elements related to this component in case of
  66606. * context lost for instance.
  66607. */
  66608. rebuild(): void;
  66609. /**
  66610. * Disposes the component and the associated ressources
  66611. */
  66612. dispose(): void;
  66613. }
  66614. }
  66615. declare module "babylonjs/Physics/physicsHelper" {
  66616. import { Nullable } from "babylonjs/types";
  66617. import { Vector3 } from "babylonjs/Maths/math.vector";
  66618. import { Mesh } from "babylonjs/Meshes/mesh";
  66619. import { Scene } from "babylonjs/scene";
  66620. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66621. /**
  66622. * A helper for physics simulations
  66623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66624. */
  66625. export class PhysicsHelper {
  66626. private _scene;
  66627. private _physicsEngine;
  66628. /**
  66629. * Initializes the Physics helper
  66630. * @param scene Babylon.js scene
  66631. */
  66632. constructor(scene: Scene);
  66633. /**
  66634. * Applies a radial explosion impulse
  66635. * @param origin the origin of the explosion
  66636. * @param radiusOrEventOptions the radius or the options of radial explosion
  66637. * @param strength the explosion strength
  66638. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66639. * @returns A physics radial explosion event, or null
  66640. */
  66641. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66642. /**
  66643. * Applies a radial explosion force
  66644. * @param origin the origin of the explosion
  66645. * @param radiusOrEventOptions the radius or the options of radial explosion
  66646. * @param strength the explosion strength
  66647. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66648. * @returns A physics radial explosion event, or null
  66649. */
  66650. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66651. /**
  66652. * Creates a gravitational field
  66653. * @param origin the origin of the explosion
  66654. * @param radiusOrEventOptions the radius or the options of radial explosion
  66655. * @param strength the explosion strength
  66656. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66657. * @returns A physics gravitational field event, or null
  66658. */
  66659. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66660. /**
  66661. * Creates a physics updraft event
  66662. * @param origin the origin of the updraft
  66663. * @param radiusOrEventOptions the radius or the options of the updraft
  66664. * @param strength the strength of the updraft
  66665. * @param height the height of the updraft
  66666. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66667. * @returns A physics updraft event, or null
  66668. */
  66669. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66670. /**
  66671. * Creates a physics vortex event
  66672. * @param origin the of the vortex
  66673. * @param radiusOrEventOptions the radius or the options of the vortex
  66674. * @param strength the strength of the vortex
  66675. * @param height the height of the vortex
  66676. * @returns a Physics vortex event, or null
  66677. * A physics vortex event or null
  66678. */
  66679. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66680. }
  66681. /**
  66682. * Represents a physics radial explosion event
  66683. */
  66684. class PhysicsRadialExplosionEvent {
  66685. private _scene;
  66686. private _options;
  66687. private _sphere;
  66688. private _dataFetched;
  66689. /**
  66690. * Initializes a radial explosioin event
  66691. * @param _scene BabylonJS scene
  66692. * @param _options The options for the vortex event
  66693. */
  66694. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66695. /**
  66696. * Returns the data related to the radial explosion event (sphere).
  66697. * @returns The radial explosion event data
  66698. */
  66699. getData(): PhysicsRadialExplosionEventData;
  66700. /**
  66701. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66702. * @param impostor A physics imposter
  66703. * @param origin the origin of the explosion
  66704. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66705. */
  66706. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66707. /**
  66708. * Triggers affecterd impostors callbacks
  66709. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66710. */
  66711. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66712. /**
  66713. * Disposes the sphere.
  66714. * @param force Specifies if the sphere should be disposed by force
  66715. */
  66716. dispose(force?: boolean): void;
  66717. /*** Helpers ***/
  66718. private _prepareSphere;
  66719. private _intersectsWithSphere;
  66720. }
  66721. /**
  66722. * Represents a gravitational field event
  66723. */
  66724. class PhysicsGravitationalFieldEvent {
  66725. private _physicsHelper;
  66726. private _scene;
  66727. private _origin;
  66728. private _options;
  66729. private _tickCallback;
  66730. private _sphere;
  66731. private _dataFetched;
  66732. /**
  66733. * Initializes the physics gravitational field event
  66734. * @param _physicsHelper A physics helper
  66735. * @param _scene BabylonJS scene
  66736. * @param _origin The origin position of the gravitational field event
  66737. * @param _options The options for the vortex event
  66738. */
  66739. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66740. /**
  66741. * Returns the data related to the gravitational field event (sphere).
  66742. * @returns A gravitational field event
  66743. */
  66744. getData(): PhysicsGravitationalFieldEventData;
  66745. /**
  66746. * Enables the gravitational field.
  66747. */
  66748. enable(): void;
  66749. /**
  66750. * Disables the gravitational field.
  66751. */
  66752. disable(): void;
  66753. /**
  66754. * Disposes the sphere.
  66755. * @param force The force to dispose from the gravitational field event
  66756. */
  66757. dispose(force?: boolean): void;
  66758. private _tick;
  66759. }
  66760. /**
  66761. * Represents a physics updraft event
  66762. */
  66763. class PhysicsUpdraftEvent {
  66764. private _scene;
  66765. private _origin;
  66766. private _options;
  66767. private _physicsEngine;
  66768. private _originTop;
  66769. private _originDirection;
  66770. private _tickCallback;
  66771. private _cylinder;
  66772. private _cylinderPosition;
  66773. private _dataFetched;
  66774. /**
  66775. * Initializes the physics updraft event
  66776. * @param _scene BabylonJS scene
  66777. * @param _origin The origin position of the updraft
  66778. * @param _options The options for the updraft event
  66779. */
  66780. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66781. /**
  66782. * Returns the data related to the updraft event (cylinder).
  66783. * @returns A physics updraft event
  66784. */
  66785. getData(): PhysicsUpdraftEventData;
  66786. /**
  66787. * Enables the updraft.
  66788. */
  66789. enable(): void;
  66790. /**
  66791. * Disables the updraft.
  66792. */
  66793. disable(): void;
  66794. /**
  66795. * Disposes the cylinder.
  66796. * @param force Specifies if the updraft should be disposed by force
  66797. */
  66798. dispose(force?: boolean): void;
  66799. private getImpostorHitData;
  66800. private _tick;
  66801. /*** Helpers ***/
  66802. private _prepareCylinder;
  66803. private _intersectsWithCylinder;
  66804. }
  66805. /**
  66806. * Represents a physics vortex event
  66807. */
  66808. class PhysicsVortexEvent {
  66809. private _scene;
  66810. private _origin;
  66811. private _options;
  66812. private _physicsEngine;
  66813. private _originTop;
  66814. private _tickCallback;
  66815. private _cylinder;
  66816. private _cylinderPosition;
  66817. private _dataFetched;
  66818. /**
  66819. * Initializes the physics vortex event
  66820. * @param _scene The BabylonJS scene
  66821. * @param _origin The origin position of the vortex
  66822. * @param _options The options for the vortex event
  66823. */
  66824. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66825. /**
  66826. * Returns the data related to the vortex event (cylinder).
  66827. * @returns The physics vortex event data
  66828. */
  66829. getData(): PhysicsVortexEventData;
  66830. /**
  66831. * Enables the vortex.
  66832. */
  66833. enable(): void;
  66834. /**
  66835. * Disables the cortex.
  66836. */
  66837. disable(): void;
  66838. /**
  66839. * Disposes the sphere.
  66840. * @param force
  66841. */
  66842. dispose(force?: boolean): void;
  66843. private getImpostorHitData;
  66844. private _tick;
  66845. /*** Helpers ***/
  66846. private _prepareCylinder;
  66847. private _intersectsWithCylinder;
  66848. }
  66849. /**
  66850. * Options fot the radial explosion event
  66851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66852. */
  66853. export class PhysicsRadialExplosionEventOptions {
  66854. /**
  66855. * The radius of the sphere for the radial explosion.
  66856. */
  66857. radius: number;
  66858. /**
  66859. * The strenth of the explosion.
  66860. */
  66861. strength: number;
  66862. /**
  66863. * The strenght of the force in correspondence to the distance of the affected object
  66864. */
  66865. falloff: PhysicsRadialImpulseFalloff;
  66866. /**
  66867. * Sphere options for the radial explosion.
  66868. */
  66869. sphere: {
  66870. segments: number;
  66871. diameter: number;
  66872. };
  66873. /**
  66874. * Sphere options for the radial explosion.
  66875. */
  66876. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66877. }
  66878. /**
  66879. * Options fot the updraft event
  66880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66881. */
  66882. export class PhysicsUpdraftEventOptions {
  66883. /**
  66884. * The radius of the cylinder for the vortex
  66885. */
  66886. radius: number;
  66887. /**
  66888. * The strenth of the updraft.
  66889. */
  66890. strength: number;
  66891. /**
  66892. * The height of the cylinder for the updraft.
  66893. */
  66894. height: number;
  66895. /**
  66896. * The mode for the the updraft.
  66897. */
  66898. updraftMode: PhysicsUpdraftMode;
  66899. }
  66900. /**
  66901. * Options fot the vortex event
  66902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66903. */
  66904. export class PhysicsVortexEventOptions {
  66905. /**
  66906. * The radius of the cylinder for the vortex
  66907. */
  66908. radius: number;
  66909. /**
  66910. * The strenth of the vortex.
  66911. */
  66912. strength: number;
  66913. /**
  66914. * The height of the cylinder for the vortex.
  66915. */
  66916. height: number;
  66917. /**
  66918. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66919. */
  66920. centripetalForceThreshold: number;
  66921. /**
  66922. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66923. */
  66924. centripetalForceMultiplier: number;
  66925. /**
  66926. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66927. */
  66928. centrifugalForceMultiplier: number;
  66929. /**
  66930. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66931. */
  66932. updraftForceMultiplier: number;
  66933. }
  66934. /**
  66935. * The strenght of the force in correspondence to the distance of the affected object
  66936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66937. */
  66938. export enum PhysicsRadialImpulseFalloff {
  66939. /** Defines that impulse is constant in strength across it's whole radius */
  66940. Constant = 0,
  66941. /** Defines that impulse gets weaker if it's further from the origin */
  66942. Linear = 1
  66943. }
  66944. /**
  66945. * The strength of the force in correspondence to the distance of the affected object
  66946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66947. */
  66948. export enum PhysicsUpdraftMode {
  66949. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66950. Center = 0,
  66951. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66952. Perpendicular = 1
  66953. }
  66954. /**
  66955. * Interface for a physics hit data
  66956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66957. */
  66958. export interface PhysicsHitData {
  66959. /**
  66960. * The force applied at the contact point
  66961. */
  66962. force: Vector3;
  66963. /**
  66964. * The contact point
  66965. */
  66966. contactPoint: Vector3;
  66967. /**
  66968. * The distance from the origin to the contact point
  66969. */
  66970. distanceFromOrigin: number;
  66971. }
  66972. /**
  66973. * Interface for radial explosion event data
  66974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66975. */
  66976. export interface PhysicsRadialExplosionEventData {
  66977. /**
  66978. * A sphere used for the radial explosion event
  66979. */
  66980. sphere: Mesh;
  66981. }
  66982. /**
  66983. * Interface for gravitational field event data
  66984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66985. */
  66986. export interface PhysicsGravitationalFieldEventData {
  66987. /**
  66988. * A sphere mesh used for the gravitational field event
  66989. */
  66990. sphere: Mesh;
  66991. }
  66992. /**
  66993. * Interface for updraft event data
  66994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66995. */
  66996. export interface PhysicsUpdraftEventData {
  66997. /**
  66998. * A cylinder used for the updraft event
  66999. */
  67000. cylinder: Mesh;
  67001. }
  67002. /**
  67003. * Interface for vortex event data
  67004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67005. */
  67006. export interface PhysicsVortexEventData {
  67007. /**
  67008. * A cylinder used for the vortex event
  67009. */
  67010. cylinder: Mesh;
  67011. }
  67012. /**
  67013. * Interface for an affected physics impostor
  67014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67015. */
  67016. export interface PhysicsAffectedImpostorWithData {
  67017. /**
  67018. * The impostor affected by the effect
  67019. */
  67020. impostor: PhysicsImpostor;
  67021. /**
  67022. * The data about the hit/horce from the explosion
  67023. */
  67024. hitData: PhysicsHitData;
  67025. }
  67026. }
  67027. declare module "babylonjs/Physics/Plugins/index" {
  67028. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67029. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67030. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67031. }
  67032. declare module "babylonjs/Physics/index" {
  67033. export * from "babylonjs/Physics/IPhysicsEngine";
  67034. export * from "babylonjs/Physics/physicsEngine";
  67035. export * from "babylonjs/Physics/physicsEngineComponent";
  67036. export * from "babylonjs/Physics/physicsHelper";
  67037. export * from "babylonjs/Physics/physicsImpostor";
  67038. export * from "babylonjs/Physics/physicsJoint";
  67039. export * from "babylonjs/Physics/Plugins/index";
  67040. }
  67041. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67042. /** @hidden */
  67043. export var blackAndWhitePixelShader: {
  67044. name: string;
  67045. shader: string;
  67046. };
  67047. }
  67048. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67049. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67050. import { Camera } from "babylonjs/Cameras/camera";
  67051. import { Engine } from "babylonjs/Engines/engine";
  67052. import "babylonjs/Shaders/blackAndWhite.fragment";
  67053. /**
  67054. * Post process used to render in black and white
  67055. */
  67056. export class BlackAndWhitePostProcess extends PostProcess {
  67057. /**
  67058. * Linear about to convert he result to black and white (default: 1)
  67059. */
  67060. degree: number;
  67061. /**
  67062. * Creates a black and white post process
  67063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67064. * @param name The name of the effect.
  67065. * @param options The required width/height ratio to downsize to before computing the render pass.
  67066. * @param camera The camera to apply the render pass to.
  67067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67068. * @param engine The engine which the post process will be applied. (default: current engine)
  67069. * @param reusable If the post process can be reused on the same frame. (default: false)
  67070. */
  67071. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67072. }
  67073. }
  67074. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67075. import { Nullable } from "babylonjs/types";
  67076. import { Camera } from "babylonjs/Cameras/camera";
  67077. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67078. import { Engine } from "babylonjs/Engines/engine";
  67079. /**
  67080. * This represents a set of one or more post processes in Babylon.
  67081. * A post process can be used to apply a shader to a texture after it is rendered.
  67082. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67083. */
  67084. export class PostProcessRenderEffect {
  67085. private _postProcesses;
  67086. private _getPostProcesses;
  67087. private _singleInstance;
  67088. private _cameras;
  67089. private _indicesForCamera;
  67090. /**
  67091. * Name of the effect
  67092. * @hidden
  67093. */
  67094. _name: string;
  67095. /**
  67096. * Instantiates a post process render effect.
  67097. * A post process can be used to apply a shader to a texture after it is rendered.
  67098. * @param engine The engine the effect is tied to
  67099. * @param name The name of the effect
  67100. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67101. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67102. */
  67103. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67104. /**
  67105. * Checks if all the post processes in the effect are supported.
  67106. */
  67107. get isSupported(): boolean;
  67108. /**
  67109. * Updates the current state of the effect
  67110. * @hidden
  67111. */
  67112. _update(): void;
  67113. /**
  67114. * Attaches the effect on cameras
  67115. * @param cameras The camera to attach to.
  67116. * @hidden
  67117. */
  67118. _attachCameras(cameras: Camera): void;
  67119. /**
  67120. * Attaches the effect on cameras
  67121. * @param cameras The camera to attach to.
  67122. * @hidden
  67123. */
  67124. _attachCameras(cameras: Camera[]): void;
  67125. /**
  67126. * Detaches the effect on cameras
  67127. * @param cameras The camera to detatch from.
  67128. * @hidden
  67129. */
  67130. _detachCameras(cameras: Camera): void;
  67131. /**
  67132. * Detatches the effect on cameras
  67133. * @param cameras The camera to detatch from.
  67134. * @hidden
  67135. */
  67136. _detachCameras(cameras: Camera[]): void;
  67137. /**
  67138. * Enables the effect on given cameras
  67139. * @param cameras The camera to enable.
  67140. * @hidden
  67141. */
  67142. _enable(cameras: Camera): void;
  67143. /**
  67144. * Enables the effect on given cameras
  67145. * @param cameras The camera to enable.
  67146. * @hidden
  67147. */
  67148. _enable(cameras: Nullable<Camera[]>): void;
  67149. /**
  67150. * Disables the effect on the given cameras
  67151. * @param cameras The camera to disable.
  67152. * @hidden
  67153. */
  67154. _disable(cameras: Camera): void;
  67155. /**
  67156. * Disables the effect on the given cameras
  67157. * @param cameras The camera to disable.
  67158. * @hidden
  67159. */
  67160. _disable(cameras: Nullable<Camera[]>): void;
  67161. /**
  67162. * Gets a list of the post processes contained in the effect.
  67163. * @param camera The camera to get the post processes on.
  67164. * @returns The list of the post processes in the effect.
  67165. */
  67166. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67167. }
  67168. }
  67169. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67170. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67171. /** @hidden */
  67172. export var extractHighlightsPixelShader: {
  67173. name: string;
  67174. shader: string;
  67175. };
  67176. }
  67177. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67178. import { Nullable } from "babylonjs/types";
  67179. import { Camera } from "babylonjs/Cameras/camera";
  67180. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67181. import { Engine } from "babylonjs/Engines/engine";
  67182. import "babylonjs/Shaders/extractHighlights.fragment";
  67183. /**
  67184. * 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.
  67185. */
  67186. export class ExtractHighlightsPostProcess extends PostProcess {
  67187. /**
  67188. * The luminance threshold, pixels below this value will be set to black.
  67189. */
  67190. threshold: number;
  67191. /** @hidden */
  67192. _exposure: number;
  67193. /**
  67194. * Post process which has the input texture to be used when performing highlight extraction
  67195. * @hidden
  67196. */
  67197. _inputPostProcess: Nullable<PostProcess>;
  67198. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67199. }
  67200. }
  67201. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67202. /** @hidden */
  67203. export var bloomMergePixelShader: {
  67204. name: string;
  67205. shader: string;
  67206. };
  67207. }
  67208. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67209. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67210. import { Nullable } from "babylonjs/types";
  67211. import { Engine } from "babylonjs/Engines/engine";
  67212. import { Camera } from "babylonjs/Cameras/camera";
  67213. import "babylonjs/Shaders/bloomMerge.fragment";
  67214. /**
  67215. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67216. */
  67217. export class BloomMergePostProcess extends PostProcess {
  67218. /** Weight of the bloom to be added to the original input. */
  67219. weight: number;
  67220. /**
  67221. * Creates a new instance of @see BloomMergePostProcess
  67222. * @param name The name of the effect.
  67223. * @param originalFromInput Post process which's input will be used for the merge.
  67224. * @param blurred Blurred highlights post process which's output will be used.
  67225. * @param weight Weight of the bloom to be added to the original input.
  67226. * @param options The required width/height ratio to downsize to before computing the render pass.
  67227. * @param camera The camera to apply the render pass to.
  67228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67229. * @param engine The engine which the post process will be applied. (default: current engine)
  67230. * @param reusable If the post process can be reused on the same frame. (default: false)
  67231. * @param textureType Type of textures used when performing the post process. (default: 0)
  67232. * @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)
  67233. */
  67234. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67235. /** Weight of the bloom to be added to the original input. */
  67236. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67237. }
  67238. }
  67239. declare module "babylonjs/PostProcesses/bloomEffect" {
  67240. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67242. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67243. import { Camera } from "babylonjs/Cameras/camera";
  67244. import { Scene } from "babylonjs/scene";
  67245. /**
  67246. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67247. */
  67248. export class BloomEffect extends PostProcessRenderEffect {
  67249. private bloomScale;
  67250. /**
  67251. * @hidden Internal
  67252. */
  67253. _effects: Array<PostProcess>;
  67254. /**
  67255. * @hidden Internal
  67256. */
  67257. _downscale: ExtractHighlightsPostProcess;
  67258. private _blurX;
  67259. private _blurY;
  67260. private _merge;
  67261. /**
  67262. * The luminance threshold to find bright areas of the image to bloom.
  67263. */
  67264. get threshold(): number;
  67265. set threshold(value: number);
  67266. /**
  67267. * The strength of the bloom.
  67268. */
  67269. get weight(): number;
  67270. set weight(value: number);
  67271. /**
  67272. * Specifies the size of the bloom blur kernel, relative to the final output size
  67273. */
  67274. get kernel(): number;
  67275. set kernel(value: number);
  67276. /**
  67277. * Creates a new instance of @see BloomEffect
  67278. * @param scene The scene the effect belongs to.
  67279. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67280. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67281. * @param bloomWeight The the strength of bloom.
  67282. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67283. * @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)
  67284. */
  67285. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67286. /**
  67287. * Disposes each of the internal effects for a given camera.
  67288. * @param camera The camera to dispose the effect on.
  67289. */
  67290. disposeEffects(camera: Camera): void;
  67291. /**
  67292. * @hidden Internal
  67293. */
  67294. _updateEffects(): void;
  67295. /**
  67296. * Internal
  67297. * @returns if all the contained post processes are ready.
  67298. * @hidden
  67299. */
  67300. _isReady(): boolean;
  67301. }
  67302. }
  67303. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67304. /** @hidden */
  67305. export var chromaticAberrationPixelShader: {
  67306. name: string;
  67307. shader: string;
  67308. };
  67309. }
  67310. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67311. import { Vector2 } from "babylonjs/Maths/math.vector";
  67312. import { Nullable } from "babylonjs/types";
  67313. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67314. import { Camera } from "babylonjs/Cameras/camera";
  67315. import { Engine } from "babylonjs/Engines/engine";
  67316. import "babylonjs/Shaders/chromaticAberration.fragment";
  67317. /**
  67318. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67319. */
  67320. export class ChromaticAberrationPostProcess extends PostProcess {
  67321. /**
  67322. * The amount of seperation of rgb channels (default: 30)
  67323. */
  67324. aberrationAmount: number;
  67325. /**
  67326. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67327. */
  67328. radialIntensity: number;
  67329. /**
  67330. * 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))
  67331. */
  67332. direction: Vector2;
  67333. /**
  67334. * 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))
  67335. */
  67336. centerPosition: Vector2;
  67337. /**
  67338. * Creates a new instance ChromaticAberrationPostProcess
  67339. * @param name The name of the effect.
  67340. * @param screenWidth The width of the screen to apply the effect on.
  67341. * @param screenHeight The height of the screen to apply the effect on.
  67342. * @param options The required width/height ratio to downsize to before computing the render pass.
  67343. * @param camera The camera to apply the render pass to.
  67344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67345. * @param engine The engine which the post process will be applied. (default: current engine)
  67346. * @param reusable If the post process can be reused on the same frame. (default: false)
  67347. * @param textureType Type of textures used when performing the post process. (default: 0)
  67348. * @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)
  67349. */
  67350. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67351. }
  67352. }
  67353. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67354. /** @hidden */
  67355. export var circleOfConfusionPixelShader: {
  67356. name: string;
  67357. shader: string;
  67358. };
  67359. }
  67360. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67361. import { Nullable } from "babylonjs/types";
  67362. import { Engine } from "babylonjs/Engines/engine";
  67363. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67364. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67365. import { Camera } from "babylonjs/Cameras/camera";
  67366. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67367. /**
  67368. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67369. */
  67370. export class CircleOfConfusionPostProcess extends PostProcess {
  67371. /**
  67372. * 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.
  67373. */
  67374. lensSize: number;
  67375. /**
  67376. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67377. */
  67378. fStop: number;
  67379. /**
  67380. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67381. */
  67382. focusDistance: number;
  67383. /**
  67384. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67385. */
  67386. focalLength: number;
  67387. private _depthTexture;
  67388. /**
  67389. * Creates a new instance CircleOfConfusionPostProcess
  67390. * @param name The name of the effect.
  67391. * @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.
  67392. * @param options The required width/height ratio to downsize to before computing the render pass.
  67393. * @param camera The camera to apply the render pass to.
  67394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67395. * @param engine The engine which the post process will be applied. (default: current engine)
  67396. * @param reusable If the post process can be reused on the same frame. (default: false)
  67397. * @param textureType Type of textures used when performing the post process. (default: 0)
  67398. * @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)
  67399. */
  67400. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67401. /**
  67402. * 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.
  67403. */
  67404. set depthTexture(value: RenderTargetTexture);
  67405. }
  67406. }
  67407. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67408. /** @hidden */
  67409. export var colorCorrectionPixelShader: {
  67410. name: string;
  67411. shader: string;
  67412. };
  67413. }
  67414. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67415. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67416. import { Engine } from "babylonjs/Engines/engine";
  67417. import { Camera } from "babylonjs/Cameras/camera";
  67418. import "babylonjs/Shaders/colorCorrection.fragment";
  67419. /**
  67420. *
  67421. * This post-process allows the modification of rendered colors by using
  67422. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67423. *
  67424. * The object needs to be provided an url to a texture containing the color
  67425. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67426. * Use an image editing software to tweak the LUT to match your needs.
  67427. *
  67428. * For an example of a color LUT, see here:
  67429. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67430. * For explanations on color grading, see here:
  67431. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67432. *
  67433. */
  67434. export class ColorCorrectionPostProcess extends PostProcess {
  67435. private _colorTableTexture;
  67436. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67437. }
  67438. }
  67439. declare module "babylonjs/Shaders/convolution.fragment" {
  67440. /** @hidden */
  67441. export var convolutionPixelShader: {
  67442. name: string;
  67443. shader: string;
  67444. };
  67445. }
  67446. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67447. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67448. import { Nullable } from "babylonjs/types";
  67449. import { Camera } from "babylonjs/Cameras/camera";
  67450. import { Engine } from "babylonjs/Engines/engine";
  67451. import "babylonjs/Shaders/convolution.fragment";
  67452. /**
  67453. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67454. * input texture to perform effects such as edge detection or sharpening
  67455. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67456. */
  67457. export class ConvolutionPostProcess extends PostProcess {
  67458. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67459. kernel: number[];
  67460. /**
  67461. * Creates a new instance ConvolutionPostProcess
  67462. * @param name The name of the effect.
  67463. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67464. * @param options The required width/height ratio to downsize to before computing the render pass.
  67465. * @param camera The camera to apply the render pass to.
  67466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67467. * @param engine The engine which the post process will be applied. (default: current engine)
  67468. * @param reusable If the post process can be reused on the same frame. (default: false)
  67469. * @param textureType Type of textures used when performing the post process. (default: 0)
  67470. */
  67471. constructor(name: string,
  67472. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67473. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67474. /**
  67475. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67476. */
  67477. static EdgeDetect0Kernel: number[];
  67478. /**
  67479. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67480. */
  67481. static EdgeDetect1Kernel: number[];
  67482. /**
  67483. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67484. */
  67485. static EdgeDetect2Kernel: number[];
  67486. /**
  67487. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67488. */
  67489. static SharpenKernel: number[];
  67490. /**
  67491. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67492. */
  67493. static EmbossKernel: number[];
  67494. /**
  67495. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67496. */
  67497. static GaussianKernel: number[];
  67498. }
  67499. }
  67500. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67501. import { Nullable } from "babylonjs/types";
  67502. import { Vector2 } from "babylonjs/Maths/math.vector";
  67503. import { Camera } from "babylonjs/Cameras/camera";
  67504. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67505. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67506. import { Engine } from "babylonjs/Engines/engine";
  67507. import { Scene } from "babylonjs/scene";
  67508. /**
  67509. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67510. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67511. * based on samples that have a large difference in distance than the center pixel.
  67512. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67513. */
  67514. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67515. direction: Vector2;
  67516. /**
  67517. * Creates a new instance CircleOfConfusionPostProcess
  67518. * @param name The name of the effect.
  67519. * @param scene The scene the effect belongs to.
  67520. * @param direction The direction the blur should be applied.
  67521. * @param kernel The size of the kernel used to blur.
  67522. * @param options The required width/height ratio to downsize to before computing the render pass.
  67523. * @param camera The camera to apply the render pass to.
  67524. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67525. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67527. * @param engine The engine which the post process will be applied. (default: current engine)
  67528. * @param reusable If the post process can be reused on the same frame. (default: false)
  67529. * @param textureType Type of textures used when performing the post process. (default: 0)
  67530. * @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)
  67531. */
  67532. 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);
  67533. }
  67534. }
  67535. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67536. /** @hidden */
  67537. export var depthOfFieldMergePixelShader: {
  67538. name: string;
  67539. shader: string;
  67540. };
  67541. }
  67542. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67543. import { Nullable } from "babylonjs/types";
  67544. import { Camera } from "babylonjs/Cameras/camera";
  67545. import { Effect } from "babylonjs/Materials/effect";
  67546. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67547. import { Engine } from "babylonjs/Engines/engine";
  67548. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67549. /**
  67550. * Options to be set when merging outputs from the default pipeline.
  67551. */
  67552. export class DepthOfFieldMergePostProcessOptions {
  67553. /**
  67554. * The original image to merge on top of
  67555. */
  67556. originalFromInput: PostProcess;
  67557. /**
  67558. * Parameters to perform the merge of the depth of field effect
  67559. */
  67560. depthOfField?: {
  67561. circleOfConfusion: PostProcess;
  67562. blurSteps: Array<PostProcess>;
  67563. };
  67564. /**
  67565. * Parameters to perform the merge of bloom effect
  67566. */
  67567. bloom?: {
  67568. blurred: PostProcess;
  67569. weight: number;
  67570. };
  67571. }
  67572. /**
  67573. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67574. */
  67575. export class DepthOfFieldMergePostProcess extends PostProcess {
  67576. private blurSteps;
  67577. /**
  67578. * Creates a new instance of DepthOfFieldMergePostProcess
  67579. * @param name The name of the effect.
  67580. * @param originalFromInput Post process which's input will be used for the merge.
  67581. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67582. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67583. * @param options The required width/height ratio to downsize to before computing the render pass.
  67584. * @param camera The camera to apply the render pass to.
  67585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67586. * @param engine The engine which the post process will be applied. (default: current engine)
  67587. * @param reusable If the post process can be reused on the same frame. (default: false)
  67588. * @param textureType Type of textures used when performing the post process. (default: 0)
  67589. * @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)
  67590. */
  67591. 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);
  67592. /**
  67593. * Updates the effect with the current post process compile time values and recompiles the shader.
  67594. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67595. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67596. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67597. * @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
  67598. * @param onCompiled Called when the shader has been compiled.
  67599. * @param onError Called if there is an error when compiling a shader.
  67600. */
  67601. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67602. }
  67603. }
  67604. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67605. import { Nullable } from "babylonjs/types";
  67606. import { Camera } from "babylonjs/Cameras/camera";
  67607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67608. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67609. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67610. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67611. import { Scene } from "babylonjs/scene";
  67612. /**
  67613. * Specifies the level of max blur that should be applied when using the depth of field effect
  67614. */
  67615. export enum DepthOfFieldEffectBlurLevel {
  67616. /**
  67617. * Subtle blur
  67618. */
  67619. Low = 0,
  67620. /**
  67621. * Medium blur
  67622. */
  67623. Medium = 1,
  67624. /**
  67625. * Large blur
  67626. */
  67627. High = 2
  67628. }
  67629. /**
  67630. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67631. */
  67632. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67633. private _circleOfConfusion;
  67634. /**
  67635. * @hidden Internal, blurs from high to low
  67636. */
  67637. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67638. private _depthOfFieldBlurY;
  67639. private _dofMerge;
  67640. /**
  67641. * @hidden Internal post processes in depth of field effect
  67642. */
  67643. _effects: Array<PostProcess>;
  67644. /**
  67645. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67646. */
  67647. set focalLength(value: number);
  67648. get focalLength(): number;
  67649. /**
  67650. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67651. */
  67652. set fStop(value: number);
  67653. get fStop(): number;
  67654. /**
  67655. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67656. */
  67657. set focusDistance(value: number);
  67658. get focusDistance(): number;
  67659. /**
  67660. * 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.
  67661. */
  67662. set lensSize(value: number);
  67663. get lensSize(): number;
  67664. /**
  67665. * Creates a new instance DepthOfFieldEffect
  67666. * @param scene The scene the effect belongs to.
  67667. * @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.
  67668. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67669. * @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)
  67670. */
  67671. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67672. /**
  67673. * Get the current class name of the current effet
  67674. * @returns "DepthOfFieldEffect"
  67675. */
  67676. getClassName(): string;
  67677. /**
  67678. * 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.
  67679. */
  67680. set depthTexture(value: RenderTargetTexture);
  67681. /**
  67682. * Disposes each of the internal effects for a given camera.
  67683. * @param camera The camera to dispose the effect on.
  67684. */
  67685. disposeEffects(camera: Camera): void;
  67686. /**
  67687. * @hidden Internal
  67688. */
  67689. _updateEffects(): void;
  67690. /**
  67691. * Internal
  67692. * @returns if all the contained post processes are ready.
  67693. * @hidden
  67694. */
  67695. _isReady(): boolean;
  67696. }
  67697. }
  67698. declare module "babylonjs/Shaders/displayPass.fragment" {
  67699. /** @hidden */
  67700. export var displayPassPixelShader: {
  67701. name: string;
  67702. shader: string;
  67703. };
  67704. }
  67705. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67706. import { Nullable } from "babylonjs/types";
  67707. import { Camera } from "babylonjs/Cameras/camera";
  67708. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67709. import { Engine } from "babylonjs/Engines/engine";
  67710. import "babylonjs/Shaders/displayPass.fragment";
  67711. /**
  67712. * DisplayPassPostProcess which produces an output the same as it's input
  67713. */
  67714. export class DisplayPassPostProcess extends PostProcess {
  67715. /**
  67716. * Creates the DisplayPassPostProcess
  67717. * @param name The name of the effect.
  67718. * @param options The required width/height ratio to downsize to before computing the render pass.
  67719. * @param camera The camera to apply the render pass to.
  67720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67721. * @param engine The engine which the post process will be applied. (default: current engine)
  67722. * @param reusable If the post process can be reused on the same frame. (default: false)
  67723. */
  67724. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67725. }
  67726. }
  67727. declare module "babylonjs/Shaders/filter.fragment" {
  67728. /** @hidden */
  67729. export var filterPixelShader: {
  67730. name: string;
  67731. shader: string;
  67732. };
  67733. }
  67734. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67735. import { Nullable } from "babylonjs/types";
  67736. import { Matrix } from "babylonjs/Maths/math.vector";
  67737. import { Camera } from "babylonjs/Cameras/camera";
  67738. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67739. import { Engine } from "babylonjs/Engines/engine";
  67740. import "babylonjs/Shaders/filter.fragment";
  67741. /**
  67742. * Applies a kernel filter to the image
  67743. */
  67744. export class FilterPostProcess extends PostProcess {
  67745. /** The matrix to be applied to the image */
  67746. kernelMatrix: Matrix;
  67747. /**
  67748. *
  67749. * @param name The name of the effect.
  67750. * @param kernelMatrix The matrix to be applied to the image
  67751. * @param options The required width/height ratio to downsize to before computing the render pass.
  67752. * @param camera The camera to apply the render pass to.
  67753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67754. * @param engine The engine which the post process will be applied. (default: current engine)
  67755. * @param reusable If the post process can be reused on the same frame. (default: false)
  67756. */
  67757. constructor(name: string,
  67758. /** The matrix to be applied to the image */
  67759. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67760. }
  67761. }
  67762. declare module "babylonjs/Shaders/fxaa.fragment" {
  67763. /** @hidden */
  67764. export var fxaaPixelShader: {
  67765. name: string;
  67766. shader: string;
  67767. };
  67768. }
  67769. declare module "babylonjs/Shaders/fxaa.vertex" {
  67770. /** @hidden */
  67771. export var fxaaVertexShader: {
  67772. name: string;
  67773. shader: string;
  67774. };
  67775. }
  67776. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67777. import { Nullable } from "babylonjs/types";
  67778. import { Camera } from "babylonjs/Cameras/camera";
  67779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67780. import { Engine } from "babylonjs/Engines/engine";
  67781. import "babylonjs/Shaders/fxaa.fragment";
  67782. import "babylonjs/Shaders/fxaa.vertex";
  67783. /**
  67784. * Fxaa post process
  67785. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67786. */
  67787. export class FxaaPostProcess extends PostProcess {
  67788. /** @hidden */
  67789. texelWidth: number;
  67790. /** @hidden */
  67791. texelHeight: number;
  67792. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67793. private _getDefines;
  67794. }
  67795. }
  67796. declare module "babylonjs/Shaders/grain.fragment" {
  67797. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67798. /** @hidden */
  67799. export var grainPixelShader: {
  67800. name: string;
  67801. shader: string;
  67802. };
  67803. }
  67804. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67805. import { Nullable } from "babylonjs/types";
  67806. import { Camera } from "babylonjs/Cameras/camera";
  67807. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67808. import { Engine } from "babylonjs/Engines/engine";
  67809. import "babylonjs/Shaders/grain.fragment";
  67810. /**
  67811. * The GrainPostProcess adds noise to the image at mid luminance levels
  67812. */
  67813. export class GrainPostProcess extends PostProcess {
  67814. /**
  67815. * The intensity of the grain added (default: 30)
  67816. */
  67817. intensity: number;
  67818. /**
  67819. * If the grain should be randomized on every frame
  67820. */
  67821. animated: boolean;
  67822. /**
  67823. * Creates a new instance of @see GrainPostProcess
  67824. * @param name The name of the effect.
  67825. * @param options The required width/height ratio to downsize to before computing the render pass.
  67826. * @param camera The camera to apply the render pass to.
  67827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67828. * @param engine The engine which the post process will be applied. (default: current engine)
  67829. * @param reusable If the post process can be reused on the same frame. (default: false)
  67830. * @param textureType Type of textures used when performing the post process. (default: 0)
  67831. * @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)
  67832. */
  67833. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67834. }
  67835. }
  67836. declare module "babylonjs/Shaders/highlights.fragment" {
  67837. /** @hidden */
  67838. export var highlightsPixelShader: {
  67839. name: string;
  67840. shader: string;
  67841. };
  67842. }
  67843. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67844. import { Nullable } from "babylonjs/types";
  67845. import { Camera } from "babylonjs/Cameras/camera";
  67846. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67847. import { Engine } from "babylonjs/Engines/engine";
  67848. import "babylonjs/Shaders/highlights.fragment";
  67849. /**
  67850. * Extracts highlights from the image
  67851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67852. */
  67853. export class HighlightsPostProcess extends PostProcess {
  67854. /**
  67855. * Extracts highlights from the image
  67856. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67857. * @param name The name of the effect.
  67858. * @param options The required width/height ratio to downsize to before computing the render pass.
  67859. * @param camera The camera to apply the render pass to.
  67860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67861. * @param engine The engine which the post process will be applied. (default: current engine)
  67862. * @param reusable If the post process can be reused on the same frame. (default: false)
  67863. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67864. */
  67865. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67866. }
  67867. }
  67868. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67869. /** @hidden */
  67870. export var mrtFragmentDeclaration: {
  67871. name: string;
  67872. shader: string;
  67873. };
  67874. }
  67875. declare module "babylonjs/Shaders/geometry.fragment" {
  67876. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67877. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67878. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67879. /** @hidden */
  67880. export var geometryPixelShader: {
  67881. name: string;
  67882. shader: string;
  67883. };
  67884. }
  67885. declare module "babylonjs/Shaders/geometry.vertex" {
  67886. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67887. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67888. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67889. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67890. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67891. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67892. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67893. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67894. /** @hidden */
  67895. export var geometryVertexShader: {
  67896. name: string;
  67897. shader: string;
  67898. };
  67899. }
  67900. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67901. import { Matrix } from "babylonjs/Maths/math.vector";
  67902. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67903. import { Mesh } from "babylonjs/Meshes/mesh";
  67904. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67905. import { Effect } from "babylonjs/Materials/effect";
  67906. import { Scene } from "babylonjs/scene";
  67907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67908. import "babylonjs/Shaders/geometry.fragment";
  67909. import "babylonjs/Shaders/geometry.vertex";
  67910. /** @hidden */
  67911. interface ISavedTransformationMatrix {
  67912. world: Matrix;
  67913. viewProjection: Matrix;
  67914. }
  67915. /**
  67916. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67917. */
  67918. export class GeometryBufferRenderer {
  67919. /**
  67920. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67921. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67922. */
  67923. static readonly POSITION_TEXTURE_TYPE: number;
  67924. /**
  67925. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67926. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67927. */
  67928. static readonly VELOCITY_TEXTURE_TYPE: number;
  67929. /**
  67930. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67931. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67932. */
  67933. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67934. /**
  67935. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67936. * in order to compute objects velocities when enableVelocity is set to "true"
  67937. * @hidden
  67938. */
  67939. _previousTransformationMatrices: {
  67940. [index: number]: ISavedTransformationMatrix;
  67941. };
  67942. /**
  67943. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67944. * in order to compute objects velocities when enableVelocity is set to "true"
  67945. * @hidden
  67946. */
  67947. _previousBonesTransformationMatrices: {
  67948. [index: number]: Float32Array;
  67949. };
  67950. /**
  67951. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67952. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67953. */
  67954. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67955. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67956. renderTransparentMeshes: boolean;
  67957. private _scene;
  67958. private _multiRenderTarget;
  67959. private _ratio;
  67960. private _enablePosition;
  67961. private _enableVelocity;
  67962. private _enableReflectivity;
  67963. private _positionIndex;
  67964. private _velocityIndex;
  67965. private _reflectivityIndex;
  67966. protected _effect: Effect;
  67967. protected _cachedDefines: string;
  67968. /**
  67969. * Set the render list (meshes to be rendered) used in the G buffer.
  67970. */
  67971. set renderList(meshes: Mesh[]);
  67972. /**
  67973. * Gets wether or not G buffer are supported by the running hardware.
  67974. * This requires draw buffer supports
  67975. */
  67976. get isSupported(): boolean;
  67977. /**
  67978. * Returns the index of the given texture type in the G-Buffer textures array
  67979. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67980. * @returns the index of the given texture type in the G-Buffer textures array
  67981. */
  67982. getTextureIndex(textureType: number): number;
  67983. /**
  67984. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67985. */
  67986. get enablePosition(): boolean;
  67987. /**
  67988. * Sets whether or not objects positions are enabled for the G buffer.
  67989. */
  67990. set enablePosition(enable: boolean);
  67991. /**
  67992. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67993. */
  67994. get enableVelocity(): boolean;
  67995. /**
  67996. * Sets wether or not objects velocities are enabled for the G buffer.
  67997. */
  67998. set enableVelocity(enable: boolean);
  67999. /**
  68000. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68001. */
  68002. get enableReflectivity(): boolean;
  68003. /**
  68004. * Sets wether or not objects roughness are enabled for the G buffer.
  68005. */
  68006. set enableReflectivity(enable: boolean);
  68007. /**
  68008. * Gets the scene associated with the buffer.
  68009. */
  68010. get scene(): Scene;
  68011. /**
  68012. * Gets the ratio used by the buffer during its creation.
  68013. * How big is the buffer related to the main canvas.
  68014. */
  68015. get ratio(): number;
  68016. /** @hidden */
  68017. static _SceneComponentInitialization: (scene: Scene) => void;
  68018. /**
  68019. * Creates a new G Buffer for the scene
  68020. * @param scene The scene the buffer belongs to
  68021. * @param ratio How big is the buffer related to the main canvas.
  68022. */
  68023. constructor(scene: Scene, ratio?: number);
  68024. /**
  68025. * Checks wether everything is ready to render a submesh to the G buffer.
  68026. * @param subMesh the submesh to check readiness for
  68027. * @param useInstances is the mesh drawn using instance or not
  68028. * @returns true if ready otherwise false
  68029. */
  68030. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68031. /**
  68032. * Gets the current underlying G Buffer.
  68033. * @returns the buffer
  68034. */
  68035. getGBuffer(): MultiRenderTarget;
  68036. /**
  68037. * Gets the number of samples used to render the buffer (anti aliasing).
  68038. */
  68039. get samples(): number;
  68040. /**
  68041. * Sets the number of samples used to render the buffer (anti aliasing).
  68042. */
  68043. set samples(value: number);
  68044. /**
  68045. * Disposes the renderer and frees up associated resources.
  68046. */
  68047. dispose(): void;
  68048. protected _createRenderTargets(): void;
  68049. private _copyBonesTransformationMatrices;
  68050. }
  68051. }
  68052. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68053. import { Nullable } from "babylonjs/types";
  68054. import { Scene } from "babylonjs/scene";
  68055. import { ISceneComponent } from "babylonjs/sceneComponent";
  68056. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68057. module "babylonjs/scene" {
  68058. interface Scene {
  68059. /** @hidden (Backing field) */
  68060. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68061. /**
  68062. * Gets or Sets the current geometry buffer associated to the scene.
  68063. */
  68064. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68065. /**
  68066. * Enables a GeometryBufferRender and associates it with the scene
  68067. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68068. * @returns the GeometryBufferRenderer
  68069. */
  68070. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68071. /**
  68072. * Disables the GeometryBufferRender associated with the scene
  68073. */
  68074. disableGeometryBufferRenderer(): void;
  68075. }
  68076. }
  68077. /**
  68078. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68079. * in several rendering techniques.
  68080. */
  68081. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68082. /**
  68083. * The component name helpful to identify the component in the list of scene components.
  68084. */
  68085. readonly name: string;
  68086. /**
  68087. * The scene the component belongs to.
  68088. */
  68089. scene: Scene;
  68090. /**
  68091. * Creates a new instance of the component for the given scene
  68092. * @param scene Defines the scene to register the component in
  68093. */
  68094. constructor(scene: Scene);
  68095. /**
  68096. * Registers the component in a given scene
  68097. */
  68098. register(): void;
  68099. /**
  68100. * Rebuilds the elements related to this component in case of
  68101. * context lost for instance.
  68102. */
  68103. rebuild(): void;
  68104. /**
  68105. * Disposes the component and the associated ressources
  68106. */
  68107. dispose(): void;
  68108. private _gatherRenderTargets;
  68109. }
  68110. }
  68111. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68112. /** @hidden */
  68113. export var motionBlurPixelShader: {
  68114. name: string;
  68115. shader: string;
  68116. };
  68117. }
  68118. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68119. import { Nullable } from "babylonjs/types";
  68120. import { Camera } from "babylonjs/Cameras/camera";
  68121. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68122. import { Scene } from "babylonjs/scene";
  68123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68124. import "babylonjs/Animations/animatable";
  68125. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68126. import "babylonjs/Shaders/motionBlur.fragment";
  68127. import { Engine } from "babylonjs/Engines/engine";
  68128. /**
  68129. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68130. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68131. * As an example, all you have to do is to create the post-process:
  68132. * var mb = new BABYLON.MotionBlurPostProcess(
  68133. * 'mb', // The name of the effect.
  68134. * scene, // The scene containing the objects to blur according to their velocity.
  68135. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68136. * camera // The camera to apply the render pass to.
  68137. * );
  68138. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68139. */
  68140. export class MotionBlurPostProcess extends PostProcess {
  68141. /**
  68142. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68143. */
  68144. motionStrength: number;
  68145. /**
  68146. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68147. */
  68148. get motionBlurSamples(): number;
  68149. /**
  68150. * Sets the number of iterations to be used for motion blur quality
  68151. */
  68152. set motionBlurSamples(samples: number);
  68153. private _motionBlurSamples;
  68154. private _geometryBufferRenderer;
  68155. /**
  68156. * Creates a new instance MotionBlurPostProcess
  68157. * @param name The name of the effect.
  68158. * @param scene The scene containing the objects to blur according to their velocity.
  68159. * @param options The required width/height ratio to downsize to before computing the render pass.
  68160. * @param camera The camera to apply the render pass to.
  68161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68162. * @param engine The engine which the post process will be applied. (default: current engine)
  68163. * @param reusable If the post process can be reused on the same frame. (default: false)
  68164. * @param textureType Type of textures used when performing the post process. (default: 0)
  68165. * @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)
  68166. */
  68167. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68168. /**
  68169. * Excludes the given skinned mesh from computing bones velocities.
  68170. * 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.
  68171. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68172. */
  68173. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68174. /**
  68175. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68176. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68177. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68178. */
  68179. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68180. /**
  68181. * Disposes the post process.
  68182. * @param camera The camera to dispose the post process on.
  68183. */
  68184. dispose(camera?: Camera): void;
  68185. }
  68186. }
  68187. declare module "babylonjs/Shaders/refraction.fragment" {
  68188. /** @hidden */
  68189. export var refractionPixelShader: {
  68190. name: string;
  68191. shader: string;
  68192. };
  68193. }
  68194. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68195. import { Color3 } from "babylonjs/Maths/math.color";
  68196. import { Camera } from "babylonjs/Cameras/camera";
  68197. import { Texture } from "babylonjs/Materials/Textures/texture";
  68198. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68199. import { Engine } from "babylonjs/Engines/engine";
  68200. import "babylonjs/Shaders/refraction.fragment";
  68201. /**
  68202. * Post process which applies a refractin texture
  68203. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68204. */
  68205. export class RefractionPostProcess extends PostProcess {
  68206. /** the base color of the refraction (used to taint the rendering) */
  68207. color: Color3;
  68208. /** simulated refraction depth */
  68209. depth: number;
  68210. /** the coefficient of the base color (0 to remove base color tainting) */
  68211. colorLevel: number;
  68212. private _refTexture;
  68213. private _ownRefractionTexture;
  68214. /**
  68215. * Gets or sets the refraction texture
  68216. * Please note that you are responsible for disposing the texture if you set it manually
  68217. */
  68218. get refractionTexture(): Texture;
  68219. set refractionTexture(value: Texture);
  68220. /**
  68221. * Initializes the RefractionPostProcess
  68222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68223. * @param name The name of the effect.
  68224. * @param refractionTextureUrl Url of the refraction texture to use
  68225. * @param color the base color of the refraction (used to taint the rendering)
  68226. * @param depth simulated refraction depth
  68227. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68228. * @param camera The camera to apply the render pass to.
  68229. * @param options The required width/height ratio to downsize to before computing the render pass.
  68230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68231. * @param engine The engine which the post process will be applied. (default: current engine)
  68232. * @param reusable If the post process can be reused on the same frame. (default: false)
  68233. */
  68234. constructor(name: string, refractionTextureUrl: string,
  68235. /** the base color of the refraction (used to taint the rendering) */
  68236. color: Color3,
  68237. /** simulated refraction depth */
  68238. depth: number,
  68239. /** the coefficient of the base color (0 to remove base color tainting) */
  68240. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68241. /**
  68242. * Disposes of the post process
  68243. * @param camera Camera to dispose post process on
  68244. */
  68245. dispose(camera: Camera): void;
  68246. }
  68247. }
  68248. declare module "babylonjs/Shaders/sharpen.fragment" {
  68249. /** @hidden */
  68250. export var sharpenPixelShader: {
  68251. name: string;
  68252. shader: string;
  68253. };
  68254. }
  68255. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68256. import { Nullable } from "babylonjs/types";
  68257. import { Camera } from "babylonjs/Cameras/camera";
  68258. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68259. import "babylonjs/Shaders/sharpen.fragment";
  68260. import { Engine } from "babylonjs/Engines/engine";
  68261. /**
  68262. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68263. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68264. */
  68265. export class SharpenPostProcess extends PostProcess {
  68266. /**
  68267. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68268. */
  68269. colorAmount: number;
  68270. /**
  68271. * How much sharpness should be applied (default: 0.3)
  68272. */
  68273. edgeAmount: number;
  68274. /**
  68275. * Creates a new instance ConvolutionPostProcess
  68276. * @param name The name of the effect.
  68277. * @param options The required width/height ratio to downsize to before computing the render pass.
  68278. * @param camera The camera to apply the render pass to.
  68279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68280. * @param engine The engine which the post process will be applied. (default: current engine)
  68281. * @param reusable If the post process can be reused on the same frame. (default: false)
  68282. * @param textureType Type of textures used when performing the post process. (default: 0)
  68283. * @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)
  68284. */
  68285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68286. }
  68287. }
  68288. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68289. import { Nullable } from "babylonjs/types";
  68290. import { Camera } from "babylonjs/Cameras/camera";
  68291. import { Engine } from "babylonjs/Engines/engine";
  68292. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68293. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68294. /**
  68295. * PostProcessRenderPipeline
  68296. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68297. */
  68298. export class PostProcessRenderPipeline {
  68299. private engine;
  68300. private _renderEffects;
  68301. private _renderEffectsForIsolatedPass;
  68302. /**
  68303. * List of inspectable custom properties (used by the Inspector)
  68304. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68305. */
  68306. inspectableCustomProperties: IInspectable[];
  68307. /**
  68308. * @hidden
  68309. */
  68310. protected _cameras: Camera[];
  68311. /** @hidden */
  68312. _name: string;
  68313. /**
  68314. * Gets pipeline name
  68315. */
  68316. get name(): string;
  68317. /** Gets the list of attached cameras */
  68318. get cameras(): Camera[];
  68319. /**
  68320. * Initializes a PostProcessRenderPipeline
  68321. * @param engine engine to add the pipeline to
  68322. * @param name name of the pipeline
  68323. */
  68324. constructor(engine: Engine, name: string);
  68325. /**
  68326. * Gets the class name
  68327. * @returns "PostProcessRenderPipeline"
  68328. */
  68329. getClassName(): string;
  68330. /**
  68331. * If all the render effects in the pipeline are supported
  68332. */
  68333. get isSupported(): boolean;
  68334. /**
  68335. * Adds an effect to the pipeline
  68336. * @param renderEffect the effect to add
  68337. */
  68338. addEffect(renderEffect: PostProcessRenderEffect): void;
  68339. /** @hidden */
  68340. _rebuild(): void;
  68341. /** @hidden */
  68342. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68343. /** @hidden */
  68344. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68345. /** @hidden */
  68346. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68347. /** @hidden */
  68348. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68349. /** @hidden */
  68350. _attachCameras(cameras: Camera, unique: boolean): void;
  68351. /** @hidden */
  68352. _attachCameras(cameras: Camera[], unique: boolean): void;
  68353. /** @hidden */
  68354. _detachCameras(cameras: Camera): void;
  68355. /** @hidden */
  68356. _detachCameras(cameras: Nullable<Camera[]>): void;
  68357. /** @hidden */
  68358. _update(): void;
  68359. /** @hidden */
  68360. _reset(): void;
  68361. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68362. /**
  68363. * Disposes of the pipeline
  68364. */
  68365. dispose(): void;
  68366. }
  68367. }
  68368. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68369. import { Camera } from "babylonjs/Cameras/camera";
  68370. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68371. /**
  68372. * PostProcessRenderPipelineManager class
  68373. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68374. */
  68375. export class PostProcessRenderPipelineManager {
  68376. private _renderPipelines;
  68377. /**
  68378. * Initializes a PostProcessRenderPipelineManager
  68379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68380. */
  68381. constructor();
  68382. /**
  68383. * Gets the list of supported render pipelines
  68384. */
  68385. get supportedPipelines(): PostProcessRenderPipeline[];
  68386. /**
  68387. * Adds a pipeline to the manager
  68388. * @param renderPipeline The pipeline to add
  68389. */
  68390. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68391. /**
  68392. * Attaches a camera to the pipeline
  68393. * @param renderPipelineName The name of the pipeline to attach to
  68394. * @param cameras the camera to attach
  68395. * @param unique if the camera can be attached multiple times to the pipeline
  68396. */
  68397. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68398. /**
  68399. * Detaches a camera from the pipeline
  68400. * @param renderPipelineName The name of the pipeline to detach from
  68401. * @param cameras the camera to detach
  68402. */
  68403. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68404. /**
  68405. * Enables an effect by name on a pipeline
  68406. * @param renderPipelineName the name of the pipeline to enable the effect in
  68407. * @param renderEffectName the name of the effect to enable
  68408. * @param cameras the cameras that the effect should be enabled on
  68409. */
  68410. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68411. /**
  68412. * Disables an effect by name on a pipeline
  68413. * @param renderPipelineName the name of the pipeline to disable the effect in
  68414. * @param renderEffectName the name of the effect to disable
  68415. * @param cameras the cameras that the effect should be disabled on
  68416. */
  68417. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68418. /**
  68419. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68420. */
  68421. update(): void;
  68422. /** @hidden */
  68423. _rebuild(): void;
  68424. /**
  68425. * Disposes of the manager and pipelines
  68426. */
  68427. dispose(): void;
  68428. }
  68429. }
  68430. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68431. import { ISceneComponent } from "babylonjs/sceneComponent";
  68432. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68433. import { Scene } from "babylonjs/scene";
  68434. module "babylonjs/scene" {
  68435. interface Scene {
  68436. /** @hidden (Backing field) */
  68437. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68438. /**
  68439. * Gets the postprocess render pipeline manager
  68440. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68441. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68442. */
  68443. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68444. }
  68445. }
  68446. /**
  68447. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68448. */
  68449. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68450. /**
  68451. * The component name helpfull to identify the component in the list of scene components.
  68452. */
  68453. readonly name: string;
  68454. /**
  68455. * The scene the component belongs to.
  68456. */
  68457. scene: Scene;
  68458. /**
  68459. * Creates a new instance of the component for the given scene
  68460. * @param scene Defines the scene to register the component in
  68461. */
  68462. constructor(scene: Scene);
  68463. /**
  68464. * Registers the component in a given scene
  68465. */
  68466. register(): void;
  68467. /**
  68468. * Rebuilds the elements related to this component in case of
  68469. * context lost for instance.
  68470. */
  68471. rebuild(): void;
  68472. /**
  68473. * Disposes the component and the associated ressources
  68474. */
  68475. dispose(): void;
  68476. private _gatherRenderTargets;
  68477. }
  68478. }
  68479. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68480. import { Nullable } from "babylonjs/types";
  68481. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68482. import { Camera } from "babylonjs/Cameras/camera";
  68483. import { IDisposable } from "babylonjs/scene";
  68484. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68485. import { Scene } from "babylonjs/scene";
  68486. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68487. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68488. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68489. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68490. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68491. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68492. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68493. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68494. import { Animation } from "babylonjs/Animations/animation";
  68495. /**
  68496. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68497. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68498. */
  68499. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68500. private _scene;
  68501. private _camerasToBeAttached;
  68502. /**
  68503. * ID of the sharpen post process,
  68504. */
  68505. private readonly SharpenPostProcessId;
  68506. /**
  68507. * @ignore
  68508. * ID of the image processing post process;
  68509. */
  68510. readonly ImageProcessingPostProcessId: string;
  68511. /**
  68512. * @ignore
  68513. * ID of the Fast Approximate Anti-Aliasing post process;
  68514. */
  68515. readonly FxaaPostProcessId: string;
  68516. /**
  68517. * ID of the chromatic aberration post process,
  68518. */
  68519. private readonly ChromaticAberrationPostProcessId;
  68520. /**
  68521. * ID of the grain post process
  68522. */
  68523. private readonly GrainPostProcessId;
  68524. /**
  68525. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68526. */
  68527. sharpen: SharpenPostProcess;
  68528. private _sharpenEffect;
  68529. private bloom;
  68530. /**
  68531. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68532. */
  68533. depthOfField: DepthOfFieldEffect;
  68534. /**
  68535. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68536. */
  68537. fxaa: FxaaPostProcess;
  68538. /**
  68539. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68540. */
  68541. imageProcessing: ImageProcessingPostProcess;
  68542. /**
  68543. * Chromatic aberration post process which will shift rgb colors in the image
  68544. */
  68545. chromaticAberration: ChromaticAberrationPostProcess;
  68546. private _chromaticAberrationEffect;
  68547. /**
  68548. * Grain post process which add noise to the image
  68549. */
  68550. grain: GrainPostProcess;
  68551. private _grainEffect;
  68552. /**
  68553. * Glow post process which adds a glow to emissive areas of the image
  68554. */
  68555. private _glowLayer;
  68556. /**
  68557. * Animations which can be used to tweak settings over a period of time
  68558. */
  68559. animations: Animation[];
  68560. private _imageProcessingConfigurationObserver;
  68561. private _sharpenEnabled;
  68562. private _bloomEnabled;
  68563. private _depthOfFieldEnabled;
  68564. private _depthOfFieldBlurLevel;
  68565. private _fxaaEnabled;
  68566. private _imageProcessingEnabled;
  68567. private _defaultPipelineTextureType;
  68568. private _bloomScale;
  68569. private _chromaticAberrationEnabled;
  68570. private _grainEnabled;
  68571. private _buildAllowed;
  68572. /**
  68573. * Gets active scene
  68574. */
  68575. get scene(): Scene;
  68576. /**
  68577. * Enable or disable the sharpen process from the pipeline
  68578. */
  68579. set sharpenEnabled(enabled: boolean);
  68580. get sharpenEnabled(): boolean;
  68581. private _resizeObserver;
  68582. private _hardwareScaleLevel;
  68583. private _bloomKernel;
  68584. /**
  68585. * Specifies the size of the bloom blur kernel, relative to the final output size
  68586. */
  68587. get bloomKernel(): number;
  68588. set bloomKernel(value: number);
  68589. /**
  68590. * Specifies the weight of the bloom in the final rendering
  68591. */
  68592. private _bloomWeight;
  68593. /**
  68594. * Specifies the luma threshold for the area that will be blurred by the bloom
  68595. */
  68596. private _bloomThreshold;
  68597. private _hdr;
  68598. /**
  68599. * The strength of the bloom.
  68600. */
  68601. set bloomWeight(value: number);
  68602. get bloomWeight(): number;
  68603. /**
  68604. * The strength of the bloom.
  68605. */
  68606. set bloomThreshold(value: number);
  68607. get bloomThreshold(): number;
  68608. /**
  68609. * The scale of the bloom, lower value will provide better performance.
  68610. */
  68611. set bloomScale(value: number);
  68612. get bloomScale(): number;
  68613. /**
  68614. * Enable or disable the bloom from the pipeline
  68615. */
  68616. set bloomEnabled(enabled: boolean);
  68617. get bloomEnabled(): boolean;
  68618. private _rebuildBloom;
  68619. /**
  68620. * If the depth of field is enabled.
  68621. */
  68622. get depthOfFieldEnabled(): boolean;
  68623. set depthOfFieldEnabled(enabled: boolean);
  68624. /**
  68625. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68626. */
  68627. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68628. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68629. /**
  68630. * If the anti aliasing is enabled.
  68631. */
  68632. set fxaaEnabled(enabled: boolean);
  68633. get fxaaEnabled(): boolean;
  68634. private _samples;
  68635. /**
  68636. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68637. */
  68638. set samples(sampleCount: number);
  68639. get samples(): number;
  68640. /**
  68641. * If image processing is enabled.
  68642. */
  68643. set imageProcessingEnabled(enabled: boolean);
  68644. get imageProcessingEnabled(): boolean;
  68645. /**
  68646. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68647. */
  68648. set glowLayerEnabled(enabled: boolean);
  68649. get glowLayerEnabled(): boolean;
  68650. /**
  68651. * Gets the glow layer (or null if not defined)
  68652. */
  68653. get glowLayer(): Nullable<GlowLayer>;
  68654. /**
  68655. * Enable or disable the chromaticAberration process from the pipeline
  68656. */
  68657. set chromaticAberrationEnabled(enabled: boolean);
  68658. get chromaticAberrationEnabled(): boolean;
  68659. /**
  68660. * Enable or disable the grain process from the pipeline
  68661. */
  68662. set grainEnabled(enabled: boolean);
  68663. get grainEnabled(): boolean;
  68664. /**
  68665. * @constructor
  68666. * @param name - The rendering pipeline name (default: "")
  68667. * @param hdr - If high dynamic range textures should be used (default: true)
  68668. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68669. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68670. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68671. */
  68672. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68673. /**
  68674. * Get the class name
  68675. * @returns "DefaultRenderingPipeline"
  68676. */
  68677. getClassName(): string;
  68678. /**
  68679. * Force the compilation of the entire pipeline.
  68680. */
  68681. prepare(): void;
  68682. private _hasCleared;
  68683. private _prevPostProcess;
  68684. private _prevPrevPostProcess;
  68685. private _setAutoClearAndTextureSharing;
  68686. private _depthOfFieldSceneObserver;
  68687. private _buildPipeline;
  68688. private _disposePostProcesses;
  68689. /**
  68690. * Adds a camera to the pipeline
  68691. * @param camera the camera to be added
  68692. */
  68693. addCamera(camera: Camera): void;
  68694. /**
  68695. * Removes a camera from the pipeline
  68696. * @param camera the camera to remove
  68697. */
  68698. removeCamera(camera: Camera): void;
  68699. /**
  68700. * Dispose of the pipeline and stop all post processes
  68701. */
  68702. dispose(): void;
  68703. /**
  68704. * Serialize the rendering pipeline (Used when exporting)
  68705. * @returns the serialized object
  68706. */
  68707. serialize(): any;
  68708. /**
  68709. * Parse the serialized pipeline
  68710. * @param source Source pipeline.
  68711. * @param scene The scene to load the pipeline to.
  68712. * @param rootUrl The URL of the serialized pipeline.
  68713. * @returns An instantiated pipeline from the serialized object.
  68714. */
  68715. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68716. }
  68717. }
  68718. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68719. /** @hidden */
  68720. export var lensHighlightsPixelShader: {
  68721. name: string;
  68722. shader: string;
  68723. };
  68724. }
  68725. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68726. /** @hidden */
  68727. export var depthOfFieldPixelShader: {
  68728. name: string;
  68729. shader: string;
  68730. };
  68731. }
  68732. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68733. import { Camera } from "babylonjs/Cameras/camera";
  68734. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68735. import { Scene } from "babylonjs/scene";
  68736. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68737. import "babylonjs/Shaders/chromaticAberration.fragment";
  68738. import "babylonjs/Shaders/lensHighlights.fragment";
  68739. import "babylonjs/Shaders/depthOfField.fragment";
  68740. /**
  68741. * BABYLON.JS Chromatic Aberration GLSL Shader
  68742. * Author: Olivier Guyot
  68743. * Separates very slightly R, G and B colors on the edges of the screen
  68744. * Inspired by Francois Tarlier & Martins Upitis
  68745. */
  68746. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68747. /**
  68748. * @ignore
  68749. * The chromatic aberration PostProcess id in the pipeline
  68750. */
  68751. LensChromaticAberrationEffect: string;
  68752. /**
  68753. * @ignore
  68754. * The highlights enhancing PostProcess id in the pipeline
  68755. */
  68756. HighlightsEnhancingEffect: string;
  68757. /**
  68758. * @ignore
  68759. * The depth-of-field PostProcess id in the pipeline
  68760. */
  68761. LensDepthOfFieldEffect: string;
  68762. private _scene;
  68763. private _depthTexture;
  68764. private _grainTexture;
  68765. private _chromaticAberrationPostProcess;
  68766. private _highlightsPostProcess;
  68767. private _depthOfFieldPostProcess;
  68768. private _edgeBlur;
  68769. private _grainAmount;
  68770. private _chromaticAberration;
  68771. private _distortion;
  68772. private _highlightsGain;
  68773. private _highlightsThreshold;
  68774. private _dofDistance;
  68775. private _dofAperture;
  68776. private _dofDarken;
  68777. private _dofPentagon;
  68778. private _blurNoise;
  68779. /**
  68780. * @constructor
  68781. *
  68782. * Effect parameters are as follow:
  68783. * {
  68784. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68785. * edge_blur: number; // from 0 to x (1 for realism)
  68786. * distortion: number; // from 0 to x (1 for realism)
  68787. * grain_amount: number; // from 0 to 1
  68788. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68789. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68790. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68791. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68792. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68793. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68794. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68795. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68796. * }
  68797. * Note: if an effect parameter is unset, effect is disabled
  68798. *
  68799. * @param name The rendering pipeline name
  68800. * @param parameters - An object containing all parameters (see above)
  68801. * @param scene The scene linked to this pipeline
  68802. * @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)
  68803. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68804. */
  68805. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68806. /**
  68807. * Get the class name
  68808. * @returns "LensRenderingPipeline"
  68809. */
  68810. getClassName(): string;
  68811. /**
  68812. * Gets associated scene
  68813. */
  68814. get scene(): Scene;
  68815. /**
  68816. * Gets or sets the edge blur
  68817. */
  68818. get edgeBlur(): number;
  68819. set edgeBlur(value: number);
  68820. /**
  68821. * Gets or sets the grain amount
  68822. */
  68823. get grainAmount(): number;
  68824. set grainAmount(value: number);
  68825. /**
  68826. * Gets or sets the chromatic aberration amount
  68827. */
  68828. get chromaticAberration(): number;
  68829. set chromaticAberration(value: number);
  68830. /**
  68831. * Gets or sets the depth of field aperture
  68832. */
  68833. get dofAperture(): number;
  68834. set dofAperture(value: number);
  68835. /**
  68836. * Gets or sets the edge distortion
  68837. */
  68838. get edgeDistortion(): number;
  68839. set edgeDistortion(value: number);
  68840. /**
  68841. * Gets or sets the depth of field distortion
  68842. */
  68843. get dofDistortion(): number;
  68844. set dofDistortion(value: number);
  68845. /**
  68846. * Gets or sets the darken out of focus amount
  68847. */
  68848. get darkenOutOfFocus(): number;
  68849. set darkenOutOfFocus(value: number);
  68850. /**
  68851. * Gets or sets a boolean indicating if blur noise is enabled
  68852. */
  68853. get blurNoise(): boolean;
  68854. set blurNoise(value: boolean);
  68855. /**
  68856. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68857. */
  68858. get pentagonBokeh(): boolean;
  68859. set pentagonBokeh(value: boolean);
  68860. /**
  68861. * Gets or sets the highlight grain amount
  68862. */
  68863. get highlightsGain(): number;
  68864. set highlightsGain(value: number);
  68865. /**
  68866. * Gets or sets the highlight threshold
  68867. */
  68868. get highlightsThreshold(): number;
  68869. set highlightsThreshold(value: number);
  68870. /**
  68871. * Sets the amount of blur at the edges
  68872. * @param amount blur amount
  68873. */
  68874. setEdgeBlur(amount: number): void;
  68875. /**
  68876. * Sets edge blur to 0
  68877. */
  68878. disableEdgeBlur(): void;
  68879. /**
  68880. * Sets the amout of grain
  68881. * @param amount Amount of grain
  68882. */
  68883. setGrainAmount(amount: number): void;
  68884. /**
  68885. * Set grain amount to 0
  68886. */
  68887. disableGrain(): void;
  68888. /**
  68889. * Sets the chromatic aberration amount
  68890. * @param amount amount of chromatic aberration
  68891. */
  68892. setChromaticAberration(amount: number): void;
  68893. /**
  68894. * Sets chromatic aberration amount to 0
  68895. */
  68896. disableChromaticAberration(): void;
  68897. /**
  68898. * Sets the EdgeDistortion amount
  68899. * @param amount amount of EdgeDistortion
  68900. */
  68901. setEdgeDistortion(amount: number): void;
  68902. /**
  68903. * Sets edge distortion to 0
  68904. */
  68905. disableEdgeDistortion(): void;
  68906. /**
  68907. * Sets the FocusDistance amount
  68908. * @param amount amount of FocusDistance
  68909. */
  68910. setFocusDistance(amount: number): void;
  68911. /**
  68912. * Disables depth of field
  68913. */
  68914. disableDepthOfField(): void;
  68915. /**
  68916. * Sets the Aperture amount
  68917. * @param amount amount of Aperture
  68918. */
  68919. setAperture(amount: number): void;
  68920. /**
  68921. * Sets the DarkenOutOfFocus amount
  68922. * @param amount amount of DarkenOutOfFocus
  68923. */
  68924. setDarkenOutOfFocus(amount: number): void;
  68925. private _pentagonBokehIsEnabled;
  68926. /**
  68927. * Creates a pentagon bokeh effect
  68928. */
  68929. enablePentagonBokeh(): void;
  68930. /**
  68931. * Disables the pentagon bokeh effect
  68932. */
  68933. disablePentagonBokeh(): void;
  68934. /**
  68935. * Enables noise blur
  68936. */
  68937. enableNoiseBlur(): void;
  68938. /**
  68939. * Disables noise blur
  68940. */
  68941. disableNoiseBlur(): void;
  68942. /**
  68943. * Sets the HighlightsGain amount
  68944. * @param amount amount of HighlightsGain
  68945. */
  68946. setHighlightsGain(amount: number): void;
  68947. /**
  68948. * Sets the HighlightsThreshold amount
  68949. * @param amount amount of HighlightsThreshold
  68950. */
  68951. setHighlightsThreshold(amount: number): void;
  68952. /**
  68953. * Disables highlights
  68954. */
  68955. disableHighlights(): void;
  68956. /**
  68957. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68958. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68959. */
  68960. dispose(disableDepthRender?: boolean): void;
  68961. private _createChromaticAberrationPostProcess;
  68962. private _createHighlightsPostProcess;
  68963. private _createDepthOfFieldPostProcess;
  68964. private _createGrainTexture;
  68965. }
  68966. }
  68967. declare module "babylonjs/Shaders/ssao2.fragment" {
  68968. /** @hidden */
  68969. export var ssao2PixelShader: {
  68970. name: string;
  68971. shader: string;
  68972. };
  68973. }
  68974. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  68975. /** @hidden */
  68976. export var ssaoCombinePixelShader: {
  68977. name: string;
  68978. shader: string;
  68979. };
  68980. }
  68981. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  68982. import { Camera } from "babylonjs/Cameras/camera";
  68983. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68984. import { Scene } from "babylonjs/scene";
  68985. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68986. import "babylonjs/Shaders/ssao2.fragment";
  68987. import "babylonjs/Shaders/ssaoCombine.fragment";
  68988. /**
  68989. * Render pipeline to produce ssao effect
  68990. */
  68991. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68992. /**
  68993. * @ignore
  68994. * The PassPostProcess id in the pipeline that contains the original scene color
  68995. */
  68996. SSAOOriginalSceneColorEffect: string;
  68997. /**
  68998. * @ignore
  68999. * The SSAO PostProcess id in the pipeline
  69000. */
  69001. SSAORenderEffect: string;
  69002. /**
  69003. * @ignore
  69004. * The horizontal blur PostProcess id in the pipeline
  69005. */
  69006. SSAOBlurHRenderEffect: string;
  69007. /**
  69008. * @ignore
  69009. * The vertical blur PostProcess id in the pipeline
  69010. */
  69011. SSAOBlurVRenderEffect: string;
  69012. /**
  69013. * @ignore
  69014. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69015. */
  69016. SSAOCombineRenderEffect: string;
  69017. /**
  69018. * The output strength of the SSAO post-process. Default value is 1.0.
  69019. */
  69020. totalStrength: number;
  69021. /**
  69022. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69023. */
  69024. maxZ: number;
  69025. /**
  69026. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69027. */
  69028. minZAspect: number;
  69029. private _samples;
  69030. /**
  69031. * Number of samples used for the SSAO calculations. Default value is 8
  69032. */
  69033. set samples(n: number);
  69034. get samples(): number;
  69035. private _textureSamples;
  69036. /**
  69037. * Number of samples to use for antialiasing
  69038. */
  69039. set textureSamples(n: number);
  69040. get textureSamples(): number;
  69041. /**
  69042. * Ratio object used for SSAO ratio and blur ratio
  69043. */
  69044. private _ratio;
  69045. /**
  69046. * Dynamically generated sphere sampler.
  69047. */
  69048. private _sampleSphere;
  69049. /**
  69050. * Blur filter offsets
  69051. */
  69052. private _samplerOffsets;
  69053. private _expensiveBlur;
  69054. /**
  69055. * If bilateral blur should be used
  69056. */
  69057. set expensiveBlur(b: boolean);
  69058. get expensiveBlur(): boolean;
  69059. /**
  69060. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69061. */
  69062. radius: number;
  69063. /**
  69064. * The base color of the SSAO post-process
  69065. * The final result is "base + ssao" between [0, 1]
  69066. */
  69067. base: number;
  69068. /**
  69069. * Support test.
  69070. */
  69071. static get IsSupported(): boolean;
  69072. private _scene;
  69073. private _depthTexture;
  69074. private _normalTexture;
  69075. private _randomTexture;
  69076. private _originalColorPostProcess;
  69077. private _ssaoPostProcess;
  69078. private _blurHPostProcess;
  69079. private _blurVPostProcess;
  69080. private _ssaoCombinePostProcess;
  69081. /**
  69082. * Gets active scene
  69083. */
  69084. get scene(): Scene;
  69085. /**
  69086. * @constructor
  69087. * @param name The rendering pipeline name
  69088. * @param scene The scene linked to this pipeline
  69089. * @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 }
  69090. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69091. */
  69092. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69093. /**
  69094. * Get the class name
  69095. * @returns "SSAO2RenderingPipeline"
  69096. */
  69097. getClassName(): string;
  69098. /**
  69099. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69100. */
  69101. dispose(disableGeometryBufferRenderer?: boolean): void;
  69102. private _createBlurPostProcess;
  69103. /** @hidden */
  69104. _rebuild(): void;
  69105. private _bits;
  69106. private _radicalInverse_VdC;
  69107. private _hammersley;
  69108. private _hemisphereSample_uniform;
  69109. private _generateHemisphere;
  69110. private _createSSAOPostProcess;
  69111. private _createSSAOCombinePostProcess;
  69112. private _createRandomTexture;
  69113. /**
  69114. * Serialize the rendering pipeline (Used when exporting)
  69115. * @returns the serialized object
  69116. */
  69117. serialize(): any;
  69118. /**
  69119. * Parse the serialized pipeline
  69120. * @param source Source pipeline.
  69121. * @param scene The scene to load the pipeline to.
  69122. * @param rootUrl The URL of the serialized pipeline.
  69123. * @returns An instantiated pipeline from the serialized object.
  69124. */
  69125. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69126. }
  69127. }
  69128. declare module "babylonjs/Shaders/ssao.fragment" {
  69129. /** @hidden */
  69130. export var ssaoPixelShader: {
  69131. name: string;
  69132. shader: string;
  69133. };
  69134. }
  69135. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69136. import { Camera } from "babylonjs/Cameras/camera";
  69137. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69138. import { Scene } from "babylonjs/scene";
  69139. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69140. import "babylonjs/Shaders/ssao.fragment";
  69141. import "babylonjs/Shaders/ssaoCombine.fragment";
  69142. /**
  69143. * Render pipeline to produce ssao effect
  69144. */
  69145. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69146. /**
  69147. * @ignore
  69148. * The PassPostProcess id in the pipeline that contains the original scene color
  69149. */
  69150. SSAOOriginalSceneColorEffect: string;
  69151. /**
  69152. * @ignore
  69153. * The SSAO PostProcess id in the pipeline
  69154. */
  69155. SSAORenderEffect: string;
  69156. /**
  69157. * @ignore
  69158. * The horizontal blur PostProcess id in the pipeline
  69159. */
  69160. SSAOBlurHRenderEffect: string;
  69161. /**
  69162. * @ignore
  69163. * The vertical blur PostProcess id in the pipeline
  69164. */
  69165. SSAOBlurVRenderEffect: string;
  69166. /**
  69167. * @ignore
  69168. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69169. */
  69170. SSAOCombineRenderEffect: string;
  69171. /**
  69172. * The output strength of the SSAO post-process. Default value is 1.0.
  69173. */
  69174. totalStrength: number;
  69175. /**
  69176. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69177. */
  69178. radius: number;
  69179. /**
  69180. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69181. * Must not be equal to fallOff and superior to fallOff.
  69182. * Default value is 0.0075
  69183. */
  69184. area: number;
  69185. /**
  69186. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69187. * Must not be equal to area and inferior to area.
  69188. * Default value is 0.000001
  69189. */
  69190. fallOff: number;
  69191. /**
  69192. * The base color of the SSAO post-process
  69193. * The final result is "base + ssao" between [0, 1]
  69194. */
  69195. base: number;
  69196. private _scene;
  69197. private _depthTexture;
  69198. private _randomTexture;
  69199. private _originalColorPostProcess;
  69200. private _ssaoPostProcess;
  69201. private _blurHPostProcess;
  69202. private _blurVPostProcess;
  69203. private _ssaoCombinePostProcess;
  69204. private _firstUpdate;
  69205. /**
  69206. * Gets active scene
  69207. */
  69208. get scene(): Scene;
  69209. /**
  69210. * @constructor
  69211. * @param name - The rendering pipeline name
  69212. * @param scene - The scene linked to this pipeline
  69213. * @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 }
  69214. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69215. */
  69216. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69217. /**
  69218. * Get the class name
  69219. * @returns "SSAORenderingPipeline"
  69220. */
  69221. getClassName(): string;
  69222. /**
  69223. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69224. */
  69225. dispose(disableDepthRender?: boolean): void;
  69226. private _createBlurPostProcess;
  69227. /** @hidden */
  69228. _rebuild(): void;
  69229. private _createSSAOPostProcess;
  69230. private _createSSAOCombinePostProcess;
  69231. private _createRandomTexture;
  69232. }
  69233. }
  69234. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69235. /** @hidden */
  69236. export var screenSpaceReflectionPixelShader: {
  69237. name: string;
  69238. shader: string;
  69239. };
  69240. }
  69241. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69242. import { Nullable } from "babylonjs/types";
  69243. import { Camera } from "babylonjs/Cameras/camera";
  69244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69245. import { Scene } from "babylonjs/scene";
  69246. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69247. import { Engine } from "babylonjs/Engines/engine";
  69248. /**
  69249. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69250. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69251. */
  69252. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69253. /**
  69254. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69255. */
  69256. threshold: number;
  69257. /**
  69258. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69259. */
  69260. strength: number;
  69261. /**
  69262. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69263. */
  69264. reflectionSpecularFalloffExponent: number;
  69265. /**
  69266. * 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]
  69267. */
  69268. step: number;
  69269. /**
  69270. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69271. */
  69272. roughnessFactor: number;
  69273. private _geometryBufferRenderer;
  69274. private _enableSmoothReflections;
  69275. private _reflectionSamples;
  69276. private _smoothSteps;
  69277. /**
  69278. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69279. * @param name The name of the effect.
  69280. * @param scene The scene containing the objects to calculate reflections.
  69281. * @param options The required width/height ratio to downsize to before computing the render pass.
  69282. * @param camera The camera to apply the render pass to.
  69283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69284. * @param engine The engine which the post process will be applied. (default: current engine)
  69285. * @param reusable If the post process can be reused on the same frame. (default: false)
  69286. * @param textureType Type of textures used when performing the post process. (default: 0)
  69287. * @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)
  69288. */
  69289. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69290. /**
  69291. * Gets wether or not smoothing reflections is enabled.
  69292. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69293. */
  69294. get enableSmoothReflections(): boolean;
  69295. /**
  69296. * Sets wether or not smoothing reflections is enabled.
  69297. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69298. */
  69299. set enableSmoothReflections(enabled: boolean);
  69300. /**
  69301. * Gets the number of samples taken while computing reflections. More samples count is high,
  69302. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69303. */
  69304. get reflectionSamples(): number;
  69305. /**
  69306. * Sets the number of samples taken while computing reflections. More samples count is high,
  69307. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69308. */
  69309. set reflectionSamples(samples: number);
  69310. /**
  69311. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69312. * more the post-process will require GPU power and can generate a drop in FPS.
  69313. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69314. */
  69315. get smoothSteps(): number;
  69316. set smoothSteps(steps: number);
  69317. private _updateEffectDefines;
  69318. }
  69319. }
  69320. declare module "babylonjs/Shaders/standard.fragment" {
  69321. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69322. /** @hidden */
  69323. export var standardPixelShader: {
  69324. name: string;
  69325. shader: string;
  69326. };
  69327. }
  69328. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69329. import { Nullable } from "babylonjs/types";
  69330. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69331. import { Camera } from "babylonjs/Cameras/camera";
  69332. import { Texture } from "babylonjs/Materials/Textures/texture";
  69333. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69334. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69335. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69336. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69337. import { IDisposable } from "babylonjs/scene";
  69338. import { SpotLight } from "babylonjs/Lights/spotLight";
  69339. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69340. import { Scene } from "babylonjs/scene";
  69341. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69342. import { Animation } from "babylonjs/Animations/animation";
  69343. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69344. import "babylonjs/Shaders/standard.fragment";
  69345. /**
  69346. * Standard rendering pipeline
  69347. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69348. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69349. */
  69350. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69351. /**
  69352. * Public members
  69353. */
  69354. /**
  69355. * Post-process which contains the original scene color before the pipeline applies all the effects
  69356. */
  69357. originalPostProcess: Nullable<PostProcess>;
  69358. /**
  69359. * Post-process used to down scale an image x4
  69360. */
  69361. downSampleX4PostProcess: Nullable<PostProcess>;
  69362. /**
  69363. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69364. */
  69365. brightPassPostProcess: Nullable<PostProcess>;
  69366. /**
  69367. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69368. */
  69369. blurHPostProcesses: PostProcess[];
  69370. /**
  69371. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69372. */
  69373. blurVPostProcesses: PostProcess[];
  69374. /**
  69375. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69376. */
  69377. textureAdderPostProcess: Nullable<PostProcess>;
  69378. /**
  69379. * Post-process used to create volumetric lighting effect
  69380. */
  69381. volumetricLightPostProcess: Nullable<PostProcess>;
  69382. /**
  69383. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69384. */
  69385. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69386. /**
  69387. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69388. */
  69389. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69390. /**
  69391. * Post-process used to merge the volumetric light effect and the real scene color
  69392. */
  69393. volumetricLightMergePostProces: Nullable<PostProcess>;
  69394. /**
  69395. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69396. */
  69397. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69398. /**
  69399. * Base post-process used to calculate the average luminance of the final image for HDR
  69400. */
  69401. luminancePostProcess: Nullable<PostProcess>;
  69402. /**
  69403. * Post-processes used to create down sample post-processes in order to get
  69404. * the average luminance of the final image for HDR
  69405. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69406. */
  69407. luminanceDownSamplePostProcesses: PostProcess[];
  69408. /**
  69409. * Post-process used to create a HDR effect (light adaptation)
  69410. */
  69411. hdrPostProcess: Nullable<PostProcess>;
  69412. /**
  69413. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69414. */
  69415. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69416. /**
  69417. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69418. */
  69419. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69420. /**
  69421. * Post-process used to merge the final HDR post-process and the real scene color
  69422. */
  69423. hdrFinalPostProcess: Nullable<PostProcess>;
  69424. /**
  69425. * Post-process used to create a lens flare effect
  69426. */
  69427. lensFlarePostProcess: Nullable<PostProcess>;
  69428. /**
  69429. * Post-process that merges the result of the lens flare post-process and the real scene color
  69430. */
  69431. lensFlareComposePostProcess: Nullable<PostProcess>;
  69432. /**
  69433. * Post-process used to create a motion blur effect
  69434. */
  69435. motionBlurPostProcess: Nullable<PostProcess>;
  69436. /**
  69437. * Post-process used to create a depth of field effect
  69438. */
  69439. depthOfFieldPostProcess: Nullable<PostProcess>;
  69440. /**
  69441. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69442. */
  69443. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69444. /**
  69445. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69446. */
  69447. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69448. /**
  69449. * Represents the brightness threshold in order to configure the illuminated surfaces
  69450. */
  69451. brightThreshold: number;
  69452. /**
  69453. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69454. */
  69455. blurWidth: number;
  69456. /**
  69457. * Sets if the blur for highlighted surfaces must be only horizontal
  69458. */
  69459. horizontalBlur: boolean;
  69460. /**
  69461. * Gets the overall exposure used by the pipeline
  69462. */
  69463. get exposure(): number;
  69464. /**
  69465. * Sets the overall exposure used by the pipeline
  69466. */
  69467. set exposure(value: number);
  69468. /**
  69469. * Texture used typically to simulate "dirty" on camera lens
  69470. */
  69471. lensTexture: Nullable<Texture>;
  69472. /**
  69473. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69474. */
  69475. volumetricLightCoefficient: number;
  69476. /**
  69477. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69478. */
  69479. volumetricLightPower: number;
  69480. /**
  69481. * Used the set the blur intensity to smooth the volumetric lights
  69482. */
  69483. volumetricLightBlurScale: number;
  69484. /**
  69485. * Light (spot or directional) used to generate the volumetric lights rays
  69486. * The source light must have a shadow generate so the pipeline can get its
  69487. * depth map
  69488. */
  69489. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69490. /**
  69491. * For eye adaptation, represents the minimum luminance the eye can see
  69492. */
  69493. hdrMinimumLuminance: number;
  69494. /**
  69495. * For eye adaptation, represents the decrease luminance speed
  69496. */
  69497. hdrDecreaseRate: number;
  69498. /**
  69499. * For eye adaptation, represents the increase luminance speed
  69500. */
  69501. hdrIncreaseRate: number;
  69502. /**
  69503. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69504. */
  69505. get hdrAutoExposure(): boolean;
  69506. /**
  69507. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69508. */
  69509. set hdrAutoExposure(value: boolean);
  69510. /**
  69511. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69512. */
  69513. lensColorTexture: Nullable<Texture>;
  69514. /**
  69515. * The overall strengh for the lens flare effect
  69516. */
  69517. lensFlareStrength: number;
  69518. /**
  69519. * Dispersion coefficient for lens flare ghosts
  69520. */
  69521. lensFlareGhostDispersal: number;
  69522. /**
  69523. * Main lens flare halo width
  69524. */
  69525. lensFlareHaloWidth: number;
  69526. /**
  69527. * Based on the lens distortion effect, defines how much the lens flare result
  69528. * is distorted
  69529. */
  69530. lensFlareDistortionStrength: number;
  69531. /**
  69532. * Configures the blur intensity used for for lens flare (halo)
  69533. */
  69534. lensFlareBlurWidth: number;
  69535. /**
  69536. * Lens star texture must be used to simulate rays on the flares and is available
  69537. * in the documentation
  69538. */
  69539. lensStarTexture: Nullable<Texture>;
  69540. /**
  69541. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69542. * flare effect by taking account of the dirt texture
  69543. */
  69544. lensFlareDirtTexture: Nullable<Texture>;
  69545. /**
  69546. * Represents the focal length for the depth of field effect
  69547. */
  69548. depthOfFieldDistance: number;
  69549. /**
  69550. * Represents the blur intensity for the blurred part of the depth of field effect
  69551. */
  69552. depthOfFieldBlurWidth: number;
  69553. /**
  69554. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69555. */
  69556. get motionStrength(): number;
  69557. /**
  69558. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69559. */
  69560. set motionStrength(strength: number);
  69561. /**
  69562. * Gets wether or not the motion blur post-process is object based or screen based.
  69563. */
  69564. get objectBasedMotionBlur(): boolean;
  69565. /**
  69566. * Sets wether or not the motion blur post-process should be object based or screen based
  69567. */
  69568. set objectBasedMotionBlur(value: boolean);
  69569. /**
  69570. * List of animations for the pipeline (IAnimatable implementation)
  69571. */
  69572. animations: Animation[];
  69573. /**
  69574. * Private members
  69575. */
  69576. private _scene;
  69577. private _currentDepthOfFieldSource;
  69578. private _basePostProcess;
  69579. private _fixedExposure;
  69580. private _currentExposure;
  69581. private _hdrAutoExposure;
  69582. private _hdrCurrentLuminance;
  69583. private _motionStrength;
  69584. private _isObjectBasedMotionBlur;
  69585. private _floatTextureType;
  69586. private _camerasToBeAttached;
  69587. private _ratio;
  69588. private _bloomEnabled;
  69589. private _depthOfFieldEnabled;
  69590. private _vlsEnabled;
  69591. private _lensFlareEnabled;
  69592. private _hdrEnabled;
  69593. private _motionBlurEnabled;
  69594. private _fxaaEnabled;
  69595. private _screenSpaceReflectionsEnabled;
  69596. private _motionBlurSamples;
  69597. private _volumetricLightStepsCount;
  69598. private _samples;
  69599. /**
  69600. * @ignore
  69601. * Specifies if the bloom pipeline is enabled
  69602. */
  69603. get BloomEnabled(): boolean;
  69604. set BloomEnabled(enabled: boolean);
  69605. /**
  69606. * @ignore
  69607. * Specifies if the depth of field pipeline is enabed
  69608. */
  69609. get DepthOfFieldEnabled(): boolean;
  69610. set DepthOfFieldEnabled(enabled: boolean);
  69611. /**
  69612. * @ignore
  69613. * Specifies if the lens flare pipeline is enabed
  69614. */
  69615. get LensFlareEnabled(): boolean;
  69616. set LensFlareEnabled(enabled: boolean);
  69617. /**
  69618. * @ignore
  69619. * Specifies if the HDR pipeline is enabled
  69620. */
  69621. get HDREnabled(): boolean;
  69622. set HDREnabled(enabled: boolean);
  69623. /**
  69624. * @ignore
  69625. * Specifies if the volumetric lights scattering effect is enabled
  69626. */
  69627. get VLSEnabled(): boolean;
  69628. set VLSEnabled(enabled: boolean);
  69629. /**
  69630. * @ignore
  69631. * Specifies if the motion blur effect is enabled
  69632. */
  69633. get MotionBlurEnabled(): boolean;
  69634. set MotionBlurEnabled(enabled: boolean);
  69635. /**
  69636. * Specifies if anti-aliasing is enabled
  69637. */
  69638. get fxaaEnabled(): boolean;
  69639. set fxaaEnabled(enabled: boolean);
  69640. /**
  69641. * Specifies if screen space reflections are enabled.
  69642. */
  69643. get screenSpaceReflectionsEnabled(): boolean;
  69644. set screenSpaceReflectionsEnabled(enabled: boolean);
  69645. /**
  69646. * Specifies the number of steps used to calculate the volumetric lights
  69647. * Typically in interval [50, 200]
  69648. */
  69649. get volumetricLightStepsCount(): number;
  69650. set volumetricLightStepsCount(count: number);
  69651. /**
  69652. * Specifies the number of samples used for the motion blur effect
  69653. * Typically in interval [16, 64]
  69654. */
  69655. get motionBlurSamples(): number;
  69656. set motionBlurSamples(samples: number);
  69657. /**
  69658. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69659. */
  69660. get samples(): number;
  69661. set samples(sampleCount: number);
  69662. /**
  69663. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69664. * @constructor
  69665. * @param name The rendering pipeline name
  69666. * @param scene The scene linked to this pipeline
  69667. * @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)
  69668. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69669. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69670. */
  69671. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69672. private _buildPipeline;
  69673. private _createDownSampleX4PostProcess;
  69674. private _createBrightPassPostProcess;
  69675. private _createBlurPostProcesses;
  69676. private _createTextureAdderPostProcess;
  69677. private _createVolumetricLightPostProcess;
  69678. private _createLuminancePostProcesses;
  69679. private _createHdrPostProcess;
  69680. private _createLensFlarePostProcess;
  69681. private _createDepthOfFieldPostProcess;
  69682. private _createMotionBlurPostProcess;
  69683. private _getDepthTexture;
  69684. private _disposePostProcesses;
  69685. /**
  69686. * Dispose of the pipeline and stop all post processes
  69687. */
  69688. dispose(): void;
  69689. /**
  69690. * Serialize the rendering pipeline (Used when exporting)
  69691. * @returns the serialized object
  69692. */
  69693. serialize(): any;
  69694. /**
  69695. * Parse the serialized pipeline
  69696. * @param source Source pipeline.
  69697. * @param scene The scene to load the pipeline to.
  69698. * @param rootUrl The URL of the serialized pipeline.
  69699. * @returns An instantiated pipeline from the serialized object.
  69700. */
  69701. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69702. /**
  69703. * Luminance steps
  69704. */
  69705. static LuminanceSteps: number;
  69706. }
  69707. }
  69708. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69709. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69710. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69711. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69712. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69713. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69714. }
  69715. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69716. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69717. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69718. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69719. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69720. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69721. }
  69722. declare module "babylonjs/Shaders/tonemap.fragment" {
  69723. /** @hidden */
  69724. export var tonemapPixelShader: {
  69725. name: string;
  69726. shader: string;
  69727. };
  69728. }
  69729. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69730. import { Camera } from "babylonjs/Cameras/camera";
  69731. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69732. import "babylonjs/Shaders/tonemap.fragment";
  69733. import { Engine } from "babylonjs/Engines/engine";
  69734. /** Defines operator used for tonemapping */
  69735. export enum TonemappingOperator {
  69736. /** Hable */
  69737. Hable = 0,
  69738. /** Reinhard */
  69739. Reinhard = 1,
  69740. /** HejiDawson */
  69741. HejiDawson = 2,
  69742. /** Photographic */
  69743. Photographic = 3
  69744. }
  69745. /**
  69746. * Defines a post process to apply tone mapping
  69747. */
  69748. export class TonemapPostProcess extends PostProcess {
  69749. private _operator;
  69750. /** Defines the required exposure adjustement */
  69751. exposureAdjustment: number;
  69752. /**
  69753. * Creates a new TonemapPostProcess
  69754. * @param name defines the name of the postprocess
  69755. * @param _operator defines the operator to use
  69756. * @param exposureAdjustment defines the required exposure adjustement
  69757. * @param camera defines the camera to use (can be null)
  69758. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69759. * @param engine defines the hosting engine (can be ignore if camera is set)
  69760. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69761. */
  69762. constructor(name: string, _operator: TonemappingOperator,
  69763. /** Defines the required exposure adjustement */
  69764. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69765. }
  69766. }
  69767. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69768. /** @hidden */
  69769. export var volumetricLightScatteringPixelShader: {
  69770. name: string;
  69771. shader: string;
  69772. };
  69773. }
  69774. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69775. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69776. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69777. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69778. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69779. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69780. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69781. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69782. /** @hidden */
  69783. export var volumetricLightScatteringPassVertexShader: {
  69784. name: string;
  69785. shader: string;
  69786. };
  69787. }
  69788. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69789. /** @hidden */
  69790. export var volumetricLightScatteringPassPixelShader: {
  69791. name: string;
  69792. shader: string;
  69793. };
  69794. }
  69795. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69796. import { Vector3 } from "babylonjs/Maths/math.vector";
  69797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69798. import { Mesh } from "babylonjs/Meshes/mesh";
  69799. import { Camera } from "babylonjs/Cameras/camera";
  69800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69801. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69802. import { Scene } from "babylonjs/scene";
  69803. import "babylonjs/Meshes/Builders/planeBuilder";
  69804. import "babylonjs/Shaders/depth.vertex";
  69805. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69806. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69807. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69808. import { Engine } from "babylonjs/Engines/engine";
  69809. /**
  69810. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69811. */
  69812. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69813. private _volumetricLightScatteringPass;
  69814. private _volumetricLightScatteringRTT;
  69815. private _viewPort;
  69816. private _screenCoordinates;
  69817. private _cachedDefines;
  69818. /**
  69819. * If not undefined, the mesh position is computed from the attached node position
  69820. */
  69821. attachedNode: {
  69822. position: Vector3;
  69823. };
  69824. /**
  69825. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69826. */
  69827. customMeshPosition: Vector3;
  69828. /**
  69829. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69830. */
  69831. useCustomMeshPosition: boolean;
  69832. /**
  69833. * If the post-process should inverse the light scattering direction
  69834. */
  69835. invert: boolean;
  69836. /**
  69837. * The internal mesh used by the post-process
  69838. */
  69839. mesh: Mesh;
  69840. /**
  69841. * @hidden
  69842. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69843. */
  69844. get useDiffuseColor(): boolean;
  69845. set useDiffuseColor(useDiffuseColor: boolean);
  69846. /**
  69847. * Array containing the excluded meshes not rendered in the internal pass
  69848. */
  69849. excludedMeshes: AbstractMesh[];
  69850. /**
  69851. * Controls the overall intensity of the post-process
  69852. */
  69853. exposure: number;
  69854. /**
  69855. * Dissipates each sample's contribution in range [0, 1]
  69856. */
  69857. decay: number;
  69858. /**
  69859. * Controls the overall intensity of each sample
  69860. */
  69861. weight: number;
  69862. /**
  69863. * Controls the density of each sample
  69864. */
  69865. density: number;
  69866. /**
  69867. * @constructor
  69868. * @param name The post-process name
  69869. * @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)
  69870. * @param camera The camera that the post-process will be attached to
  69871. * @param mesh The mesh used to create the light scattering
  69872. * @param samples The post-process quality, default 100
  69873. * @param samplingModeThe post-process filtering mode
  69874. * @param engine The babylon engine
  69875. * @param reusable If the post-process is reusable
  69876. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69877. */
  69878. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69879. /**
  69880. * Returns the string "VolumetricLightScatteringPostProcess"
  69881. * @returns "VolumetricLightScatteringPostProcess"
  69882. */
  69883. getClassName(): string;
  69884. private _isReady;
  69885. /**
  69886. * Sets the new light position for light scattering effect
  69887. * @param position The new custom light position
  69888. */
  69889. setCustomMeshPosition(position: Vector3): void;
  69890. /**
  69891. * Returns the light position for light scattering effect
  69892. * @return Vector3 The custom light position
  69893. */
  69894. getCustomMeshPosition(): Vector3;
  69895. /**
  69896. * Disposes the internal assets and detaches the post-process from the camera
  69897. */
  69898. dispose(camera: Camera): void;
  69899. /**
  69900. * Returns the render target texture used by the post-process
  69901. * @return the render target texture used by the post-process
  69902. */
  69903. getPass(): RenderTargetTexture;
  69904. private _meshExcluded;
  69905. private _createPass;
  69906. private _updateMeshScreenCoordinates;
  69907. /**
  69908. * Creates a default mesh for the Volumeric Light Scattering post-process
  69909. * @param name The mesh name
  69910. * @param scene The scene where to create the mesh
  69911. * @return the default mesh
  69912. */
  69913. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69914. }
  69915. }
  69916. declare module "babylonjs/PostProcesses/index" {
  69917. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69918. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69919. export * from "babylonjs/PostProcesses/bloomEffect";
  69920. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69921. export * from "babylonjs/PostProcesses/blurPostProcess";
  69922. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69923. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69924. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69925. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69926. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69927. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69928. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69929. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69930. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69931. export * from "babylonjs/PostProcesses/filterPostProcess";
  69932. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69933. export * from "babylonjs/PostProcesses/grainPostProcess";
  69934. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69935. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69936. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69937. export * from "babylonjs/PostProcesses/passPostProcess";
  69938. export * from "babylonjs/PostProcesses/postProcess";
  69939. export * from "babylonjs/PostProcesses/postProcessManager";
  69940. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69941. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69942. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69943. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69944. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69945. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69946. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69947. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69948. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69949. }
  69950. declare module "babylonjs/Probes/index" {
  69951. export * from "babylonjs/Probes/reflectionProbe";
  69952. }
  69953. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69954. import { Scene } from "babylonjs/scene";
  69955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69956. import { SmartArray } from "babylonjs/Misc/smartArray";
  69957. import { ISceneComponent } from "babylonjs/sceneComponent";
  69958. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69959. import "babylonjs/Meshes/Builders/boxBuilder";
  69960. import "babylonjs/Shaders/color.fragment";
  69961. import "babylonjs/Shaders/color.vertex";
  69962. import { Color3 } from "babylonjs/Maths/math.color";
  69963. module "babylonjs/scene" {
  69964. interface Scene {
  69965. /** @hidden (Backing field) */
  69966. _boundingBoxRenderer: BoundingBoxRenderer;
  69967. /** @hidden (Backing field) */
  69968. _forceShowBoundingBoxes: boolean;
  69969. /**
  69970. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69971. */
  69972. forceShowBoundingBoxes: boolean;
  69973. /**
  69974. * Gets the bounding box renderer associated with the scene
  69975. * @returns a BoundingBoxRenderer
  69976. */
  69977. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69978. }
  69979. }
  69980. module "babylonjs/Meshes/abstractMesh" {
  69981. interface AbstractMesh {
  69982. /** @hidden (Backing field) */
  69983. _showBoundingBox: boolean;
  69984. /**
  69985. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69986. */
  69987. showBoundingBox: boolean;
  69988. }
  69989. }
  69990. /**
  69991. * Component responsible of rendering the bounding box of the meshes in a scene.
  69992. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69993. */
  69994. export class BoundingBoxRenderer implements ISceneComponent {
  69995. /**
  69996. * The component name helpfull to identify the component in the list of scene components.
  69997. */
  69998. readonly name: string;
  69999. /**
  70000. * The scene the component belongs to.
  70001. */
  70002. scene: Scene;
  70003. /**
  70004. * Color of the bounding box lines placed in front of an object
  70005. */
  70006. frontColor: Color3;
  70007. /**
  70008. * Color of the bounding box lines placed behind an object
  70009. */
  70010. backColor: Color3;
  70011. /**
  70012. * Defines if the renderer should show the back lines or not
  70013. */
  70014. showBackLines: boolean;
  70015. /**
  70016. * @hidden
  70017. */
  70018. renderList: SmartArray<BoundingBox>;
  70019. private _colorShader;
  70020. private _vertexBuffers;
  70021. private _indexBuffer;
  70022. private _fillIndexBuffer;
  70023. private _fillIndexData;
  70024. /**
  70025. * Instantiates a new bounding box renderer in a scene.
  70026. * @param scene the scene the renderer renders in
  70027. */
  70028. constructor(scene: Scene);
  70029. /**
  70030. * Registers the component in a given scene
  70031. */
  70032. register(): void;
  70033. private _evaluateSubMesh;
  70034. private _activeMesh;
  70035. private _prepareRessources;
  70036. private _createIndexBuffer;
  70037. /**
  70038. * Rebuilds the elements related to this component in case of
  70039. * context lost for instance.
  70040. */
  70041. rebuild(): void;
  70042. /**
  70043. * @hidden
  70044. */
  70045. reset(): void;
  70046. /**
  70047. * Render the bounding boxes of a specific rendering group
  70048. * @param renderingGroupId defines the rendering group to render
  70049. */
  70050. render(renderingGroupId: number): void;
  70051. /**
  70052. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70053. * @param mesh Define the mesh to render the occlusion bounding box for
  70054. */
  70055. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70056. /**
  70057. * Dispose and release the resources attached to this renderer.
  70058. */
  70059. dispose(): void;
  70060. }
  70061. }
  70062. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70063. import { Nullable } from "babylonjs/types";
  70064. import { Scene } from "babylonjs/scene";
  70065. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70066. import { Camera } from "babylonjs/Cameras/camera";
  70067. import { ISceneComponent } from "babylonjs/sceneComponent";
  70068. module "babylonjs/scene" {
  70069. interface Scene {
  70070. /** @hidden (Backing field) */
  70071. _depthRenderer: {
  70072. [id: string]: DepthRenderer;
  70073. };
  70074. /**
  70075. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70076. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70077. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70078. * @returns the created depth renderer
  70079. */
  70080. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70081. /**
  70082. * Disables a depth renderer for a given camera
  70083. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70084. */
  70085. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70086. }
  70087. }
  70088. /**
  70089. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70090. * in several rendering techniques.
  70091. */
  70092. export class DepthRendererSceneComponent implements ISceneComponent {
  70093. /**
  70094. * The component name helpfull to identify the component in the list of scene components.
  70095. */
  70096. readonly name: string;
  70097. /**
  70098. * The scene the component belongs to.
  70099. */
  70100. scene: Scene;
  70101. /**
  70102. * Creates a new instance of the component for the given scene
  70103. * @param scene Defines the scene to register the component in
  70104. */
  70105. constructor(scene: Scene);
  70106. /**
  70107. * Registers the component in a given scene
  70108. */
  70109. register(): void;
  70110. /**
  70111. * Rebuilds the elements related to this component in case of
  70112. * context lost for instance.
  70113. */
  70114. rebuild(): void;
  70115. /**
  70116. * Disposes the component and the associated ressources
  70117. */
  70118. dispose(): void;
  70119. private _gatherRenderTargets;
  70120. private _gatherActiveCameraRenderTargets;
  70121. }
  70122. }
  70123. declare module "babylonjs/Shaders/outline.fragment" {
  70124. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70125. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70126. /** @hidden */
  70127. export var outlinePixelShader: {
  70128. name: string;
  70129. shader: string;
  70130. };
  70131. }
  70132. declare module "babylonjs/Shaders/outline.vertex" {
  70133. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70134. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70135. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70136. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70137. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70138. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70139. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70140. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70141. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70142. /** @hidden */
  70143. export var outlineVertexShader: {
  70144. name: string;
  70145. shader: string;
  70146. };
  70147. }
  70148. declare module "babylonjs/Rendering/outlineRenderer" {
  70149. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70150. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70151. import { Scene } from "babylonjs/scene";
  70152. import { ISceneComponent } from "babylonjs/sceneComponent";
  70153. import "babylonjs/Shaders/outline.fragment";
  70154. import "babylonjs/Shaders/outline.vertex";
  70155. module "babylonjs/scene" {
  70156. interface Scene {
  70157. /** @hidden */
  70158. _outlineRenderer: OutlineRenderer;
  70159. /**
  70160. * Gets the outline renderer associated with the scene
  70161. * @returns a OutlineRenderer
  70162. */
  70163. getOutlineRenderer(): OutlineRenderer;
  70164. }
  70165. }
  70166. module "babylonjs/Meshes/abstractMesh" {
  70167. interface AbstractMesh {
  70168. /** @hidden (Backing field) */
  70169. _renderOutline: boolean;
  70170. /**
  70171. * Gets or sets a boolean indicating if the outline must be rendered as well
  70172. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70173. */
  70174. renderOutline: boolean;
  70175. /** @hidden (Backing field) */
  70176. _renderOverlay: boolean;
  70177. /**
  70178. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70179. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70180. */
  70181. renderOverlay: boolean;
  70182. }
  70183. }
  70184. /**
  70185. * This class is responsible to draw bothe outline/overlay of meshes.
  70186. * It should not be used directly but through the available method on mesh.
  70187. */
  70188. export class OutlineRenderer implements ISceneComponent {
  70189. /**
  70190. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70191. */
  70192. private static _StencilReference;
  70193. /**
  70194. * The name of the component. Each component must have a unique name.
  70195. */
  70196. name: string;
  70197. /**
  70198. * The scene the component belongs to.
  70199. */
  70200. scene: Scene;
  70201. /**
  70202. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70203. */
  70204. zOffset: number;
  70205. private _engine;
  70206. private _effect;
  70207. private _cachedDefines;
  70208. private _savedDepthWrite;
  70209. /**
  70210. * Instantiates a new outline renderer. (There could be only one per scene).
  70211. * @param scene Defines the scene it belongs to
  70212. */
  70213. constructor(scene: Scene);
  70214. /**
  70215. * Register the component to one instance of a scene.
  70216. */
  70217. register(): void;
  70218. /**
  70219. * Rebuilds the elements related to this component in case of
  70220. * context lost for instance.
  70221. */
  70222. rebuild(): void;
  70223. /**
  70224. * Disposes the component and the associated ressources.
  70225. */
  70226. dispose(): void;
  70227. /**
  70228. * Renders the outline in the canvas.
  70229. * @param subMesh Defines the sumesh to render
  70230. * @param batch Defines the batch of meshes in case of instances
  70231. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70232. */
  70233. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70234. /**
  70235. * Returns whether or not the outline renderer is ready for a given submesh.
  70236. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70237. * @param subMesh Defines the submesh to check readyness for
  70238. * @param useInstances Defines wheter wee are trying to render instances or not
  70239. * @returns true if ready otherwise false
  70240. */
  70241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70242. private _beforeRenderingMesh;
  70243. private _afterRenderingMesh;
  70244. }
  70245. }
  70246. declare module "babylonjs/Rendering/index" {
  70247. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70248. export * from "babylonjs/Rendering/depthRenderer";
  70249. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70250. export * from "babylonjs/Rendering/edgesRenderer";
  70251. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70252. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70253. export * from "babylonjs/Rendering/outlineRenderer";
  70254. export * from "babylonjs/Rendering/renderingGroup";
  70255. export * from "babylonjs/Rendering/renderingManager";
  70256. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70257. }
  70258. declare module "babylonjs/Sprites/ISprites" {
  70259. /**
  70260. * Defines the basic options interface of a Sprite Frame Source Size.
  70261. */
  70262. export interface ISpriteJSONSpriteSourceSize {
  70263. /**
  70264. * number of the original width of the Frame
  70265. */
  70266. w: number;
  70267. /**
  70268. * number of the original height of the Frame
  70269. */
  70270. h: number;
  70271. }
  70272. /**
  70273. * Defines the basic options interface of a Sprite Frame Data.
  70274. */
  70275. export interface ISpriteJSONSpriteFrameData {
  70276. /**
  70277. * number of the x offset of the Frame
  70278. */
  70279. x: number;
  70280. /**
  70281. * number of the y offset of the Frame
  70282. */
  70283. y: number;
  70284. /**
  70285. * number of the width of the Frame
  70286. */
  70287. w: number;
  70288. /**
  70289. * number of the height of the Frame
  70290. */
  70291. h: number;
  70292. }
  70293. /**
  70294. * Defines the basic options interface of a JSON Sprite.
  70295. */
  70296. export interface ISpriteJSONSprite {
  70297. /**
  70298. * string name of the Frame
  70299. */
  70300. filename: string;
  70301. /**
  70302. * ISpriteJSONSpriteFrame basic object of the frame data
  70303. */
  70304. frame: ISpriteJSONSpriteFrameData;
  70305. /**
  70306. * boolean to flag is the frame was rotated.
  70307. */
  70308. rotated: boolean;
  70309. /**
  70310. * boolean to flag is the frame was trimmed.
  70311. */
  70312. trimmed: boolean;
  70313. /**
  70314. * ISpriteJSONSpriteFrame basic object of the source data
  70315. */
  70316. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70317. /**
  70318. * ISpriteJSONSpriteFrame basic object of the source data
  70319. */
  70320. sourceSize: ISpriteJSONSpriteSourceSize;
  70321. }
  70322. /**
  70323. * Defines the basic options interface of a JSON atlas.
  70324. */
  70325. export interface ISpriteJSONAtlas {
  70326. /**
  70327. * Array of objects that contain the frame data.
  70328. */
  70329. frames: Array<ISpriteJSONSprite>;
  70330. /**
  70331. * object basic object containing the sprite meta data.
  70332. */
  70333. meta?: object;
  70334. }
  70335. }
  70336. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70337. /** @hidden */
  70338. export var spriteMapPixelShader: {
  70339. name: string;
  70340. shader: string;
  70341. };
  70342. }
  70343. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70344. /** @hidden */
  70345. export var spriteMapVertexShader: {
  70346. name: string;
  70347. shader: string;
  70348. };
  70349. }
  70350. declare module "babylonjs/Sprites/spriteMap" {
  70351. import { IDisposable, Scene } from "babylonjs/scene";
  70352. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70353. import { Texture } from "babylonjs/Materials/Textures/texture";
  70354. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70355. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70356. import "babylonjs/Meshes/Builders/planeBuilder";
  70357. import "babylonjs/Shaders/spriteMap.fragment";
  70358. import "babylonjs/Shaders/spriteMap.vertex";
  70359. /**
  70360. * Defines the basic options interface of a SpriteMap
  70361. */
  70362. export interface ISpriteMapOptions {
  70363. /**
  70364. * Vector2 of the number of cells in the grid.
  70365. */
  70366. stageSize?: Vector2;
  70367. /**
  70368. * Vector2 of the size of the output plane in World Units.
  70369. */
  70370. outputSize?: Vector2;
  70371. /**
  70372. * Vector3 of the position of the output plane in World Units.
  70373. */
  70374. outputPosition?: Vector3;
  70375. /**
  70376. * Vector3 of the rotation of the output plane.
  70377. */
  70378. outputRotation?: Vector3;
  70379. /**
  70380. * number of layers that the system will reserve in resources.
  70381. */
  70382. layerCount?: number;
  70383. /**
  70384. * number of max animation frames a single cell will reserve in resources.
  70385. */
  70386. maxAnimationFrames?: number;
  70387. /**
  70388. * number cell index of the base tile when the system compiles.
  70389. */
  70390. baseTile?: number;
  70391. /**
  70392. * boolean flip the sprite after its been repositioned by the framing data.
  70393. */
  70394. flipU?: boolean;
  70395. /**
  70396. * Vector3 scalar of the global RGB values of the SpriteMap.
  70397. */
  70398. colorMultiply?: Vector3;
  70399. }
  70400. /**
  70401. * Defines the IDisposable interface in order to be cleanable from resources.
  70402. */
  70403. export interface ISpriteMap extends IDisposable {
  70404. /**
  70405. * String name of the SpriteMap.
  70406. */
  70407. name: string;
  70408. /**
  70409. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70410. */
  70411. atlasJSON: ISpriteJSONAtlas;
  70412. /**
  70413. * Texture of the SpriteMap.
  70414. */
  70415. spriteSheet: Texture;
  70416. /**
  70417. * The parameters to initialize the SpriteMap with.
  70418. */
  70419. options: ISpriteMapOptions;
  70420. }
  70421. /**
  70422. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70423. */
  70424. export class SpriteMap implements ISpriteMap {
  70425. /** The Name of the spriteMap */
  70426. name: string;
  70427. /** The JSON file with the frame and meta data */
  70428. atlasJSON: ISpriteJSONAtlas;
  70429. /** The systems Sprite Sheet Texture */
  70430. spriteSheet: Texture;
  70431. /** Arguments passed with the Constructor */
  70432. options: ISpriteMapOptions;
  70433. /** Public Sprite Storage array, parsed from atlasJSON */
  70434. sprites: Array<ISpriteJSONSprite>;
  70435. /** Returns the Number of Sprites in the System */
  70436. get spriteCount(): number;
  70437. /** Returns the Position of Output Plane*/
  70438. get position(): Vector3;
  70439. /** Returns the Position of Output Plane*/
  70440. set position(v: Vector3);
  70441. /** Returns the Rotation of Output Plane*/
  70442. get rotation(): Vector3;
  70443. /** Returns the Rotation of Output Plane*/
  70444. set rotation(v: Vector3);
  70445. /** Sets the AnimationMap*/
  70446. get animationMap(): RawTexture;
  70447. /** Sets the AnimationMap*/
  70448. set animationMap(v: RawTexture);
  70449. /** Scene that the SpriteMap was created in */
  70450. private _scene;
  70451. /** Texture Buffer of Float32 that holds tile frame data*/
  70452. private _frameMap;
  70453. /** Texture Buffers of Float32 that holds tileMap data*/
  70454. private _tileMaps;
  70455. /** Texture Buffer of Float32 that holds Animation Data*/
  70456. private _animationMap;
  70457. /** Custom ShaderMaterial Central to the System*/
  70458. private _material;
  70459. /** Custom ShaderMaterial Central to the System*/
  70460. private _output;
  70461. /** Systems Time Ticker*/
  70462. private _time;
  70463. /**
  70464. * Creates a new SpriteMap
  70465. * @param name defines the SpriteMaps Name
  70466. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70467. * @param spriteSheet is the Texture that the Sprites are on.
  70468. * @param options a basic deployment configuration
  70469. * @param scene The Scene that the map is deployed on
  70470. */
  70471. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70472. /**
  70473. * Returns tileID location
  70474. * @returns Vector2 the cell position ID
  70475. */
  70476. getTileID(): Vector2;
  70477. /**
  70478. * Gets the UV location of the mouse over the SpriteMap.
  70479. * @returns Vector2 the UV position of the mouse interaction
  70480. */
  70481. getMousePosition(): Vector2;
  70482. /**
  70483. * Creates the "frame" texture Buffer
  70484. * -------------------------------------
  70485. * Structure of frames
  70486. * "filename": "Falling-Water-2.png",
  70487. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70488. * "rotated": true,
  70489. * "trimmed": true,
  70490. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70491. * "sourceSize": {"w":32,"h":32}
  70492. * @returns RawTexture of the frameMap
  70493. */
  70494. private _createFrameBuffer;
  70495. /**
  70496. * Creates the tileMap texture Buffer
  70497. * @param buffer normally and array of numbers, or a false to generate from scratch
  70498. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70499. * @returns RawTexture of the tileMap
  70500. */
  70501. private _createTileBuffer;
  70502. /**
  70503. * Modifies the data of the tileMaps
  70504. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70505. * @param pos is the iVector2 Coordinates of the Tile
  70506. * @param tile The SpriteIndex of the new Tile
  70507. */
  70508. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70509. /**
  70510. * Creates the animationMap texture Buffer
  70511. * @param buffer normally and array of numbers, or a false to generate from scratch
  70512. * @returns RawTexture of the animationMap
  70513. */
  70514. private _createTileAnimationBuffer;
  70515. /**
  70516. * Modifies the data of the animationMap
  70517. * @param cellID is the Index of the Sprite
  70518. * @param _frame is the target Animation frame
  70519. * @param toCell is the Target Index of the next frame of the animation
  70520. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70521. * @param speed is a global scalar of the time variable on the map.
  70522. */
  70523. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70524. /**
  70525. * Exports the .tilemaps file
  70526. */
  70527. saveTileMaps(): void;
  70528. /**
  70529. * Imports the .tilemaps file
  70530. * @param url of the .tilemaps file
  70531. */
  70532. loadTileMaps(url: string): void;
  70533. /**
  70534. * Release associated resources
  70535. */
  70536. dispose(): void;
  70537. }
  70538. }
  70539. declare module "babylonjs/Sprites/spritePackedManager" {
  70540. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70541. import { Scene } from "babylonjs/scene";
  70542. /**
  70543. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70544. * @see http://doc.babylonjs.com/babylon101/sprites
  70545. */
  70546. export class SpritePackedManager extends SpriteManager {
  70547. /** defines the packed manager's name */
  70548. name: string;
  70549. /**
  70550. * Creates a new sprite manager from a packed sprite sheet
  70551. * @param name defines the manager's name
  70552. * @param imgUrl defines the sprite sheet url
  70553. * @param capacity defines the maximum allowed number of sprites
  70554. * @param scene defines the hosting scene
  70555. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70556. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70557. * @param samplingMode defines the smapling mode to use with spritesheet
  70558. * @param fromPacked set to true; do not alter
  70559. */
  70560. constructor(
  70561. /** defines the packed manager's name */
  70562. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70563. }
  70564. }
  70565. declare module "babylonjs/Sprites/index" {
  70566. export * from "babylonjs/Sprites/sprite";
  70567. export * from "babylonjs/Sprites/ISprites";
  70568. export * from "babylonjs/Sprites/spriteManager";
  70569. export * from "babylonjs/Sprites/spriteMap";
  70570. export * from "babylonjs/Sprites/spritePackedManager";
  70571. export * from "babylonjs/Sprites/spriteSceneComponent";
  70572. }
  70573. declare module "babylonjs/States/index" {
  70574. export * from "babylonjs/States/alphaCullingState";
  70575. export * from "babylonjs/States/depthCullingState";
  70576. export * from "babylonjs/States/stencilState";
  70577. }
  70578. declare module "babylonjs/Misc/assetsManager" {
  70579. import { Scene } from "babylonjs/scene";
  70580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70581. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70582. import { Skeleton } from "babylonjs/Bones/skeleton";
  70583. import { Observable } from "babylonjs/Misc/observable";
  70584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70585. import { Texture } from "babylonjs/Materials/Textures/texture";
  70586. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70587. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70588. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70589. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70590. /**
  70591. * Defines the list of states available for a task inside a AssetsManager
  70592. */
  70593. export enum AssetTaskState {
  70594. /**
  70595. * Initialization
  70596. */
  70597. INIT = 0,
  70598. /**
  70599. * Running
  70600. */
  70601. RUNNING = 1,
  70602. /**
  70603. * Done
  70604. */
  70605. DONE = 2,
  70606. /**
  70607. * Error
  70608. */
  70609. ERROR = 3
  70610. }
  70611. /**
  70612. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70613. */
  70614. export abstract class AbstractAssetTask {
  70615. /**
  70616. * Task name
  70617. */ name: string;
  70618. /**
  70619. * Callback called when the task is successful
  70620. */
  70621. onSuccess: (task: any) => void;
  70622. /**
  70623. * Callback called when the task is not successful
  70624. */
  70625. onError: (task: any, message?: string, exception?: any) => void;
  70626. /**
  70627. * Creates a new AssetsManager
  70628. * @param name defines the name of the task
  70629. */
  70630. constructor(
  70631. /**
  70632. * Task name
  70633. */ name: string);
  70634. private _isCompleted;
  70635. private _taskState;
  70636. private _errorObject;
  70637. /**
  70638. * Get if the task is completed
  70639. */
  70640. get isCompleted(): boolean;
  70641. /**
  70642. * Gets the current state of the task
  70643. */
  70644. get taskState(): AssetTaskState;
  70645. /**
  70646. * Gets the current error object (if task is in error)
  70647. */
  70648. get errorObject(): {
  70649. message?: string;
  70650. exception?: any;
  70651. };
  70652. /**
  70653. * Internal only
  70654. * @hidden
  70655. */
  70656. _setErrorObject(message?: string, exception?: any): void;
  70657. /**
  70658. * Execute the current task
  70659. * @param scene defines the scene where you want your assets to be loaded
  70660. * @param onSuccess is a callback called when the task is successfully executed
  70661. * @param onError is a callback called if an error occurs
  70662. */
  70663. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70664. /**
  70665. * Execute the current task
  70666. * @param scene defines the scene where you want your assets to be loaded
  70667. * @param onSuccess is a callback called when the task is successfully executed
  70668. * @param onError is a callback called if an error occurs
  70669. */
  70670. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70671. /**
  70672. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70673. * This can be used with failed tasks that have the reason for failure fixed.
  70674. */
  70675. reset(): void;
  70676. private onErrorCallback;
  70677. private onDoneCallback;
  70678. }
  70679. /**
  70680. * Define the interface used by progress events raised during assets loading
  70681. */
  70682. export interface IAssetsProgressEvent {
  70683. /**
  70684. * Defines the number of remaining tasks to process
  70685. */
  70686. remainingCount: number;
  70687. /**
  70688. * Defines the total number of tasks
  70689. */
  70690. totalCount: number;
  70691. /**
  70692. * Defines the task that was just processed
  70693. */
  70694. task: AbstractAssetTask;
  70695. }
  70696. /**
  70697. * Class used to share progress information about assets loading
  70698. */
  70699. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70700. /**
  70701. * Defines the number of remaining tasks to process
  70702. */
  70703. remainingCount: number;
  70704. /**
  70705. * Defines the total number of tasks
  70706. */
  70707. totalCount: number;
  70708. /**
  70709. * Defines the task that was just processed
  70710. */
  70711. task: AbstractAssetTask;
  70712. /**
  70713. * Creates a AssetsProgressEvent
  70714. * @param remainingCount defines the number of remaining tasks to process
  70715. * @param totalCount defines the total number of tasks
  70716. * @param task defines the task that was just processed
  70717. */
  70718. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70719. }
  70720. /**
  70721. * Define a task used by AssetsManager to load meshes
  70722. */
  70723. export class MeshAssetTask extends AbstractAssetTask {
  70724. /**
  70725. * Defines the name of the task
  70726. */
  70727. name: string;
  70728. /**
  70729. * Defines the list of mesh's names you want to load
  70730. */
  70731. meshesNames: any;
  70732. /**
  70733. * Defines the root url to use as a base to load your meshes and associated resources
  70734. */
  70735. rootUrl: string;
  70736. /**
  70737. * Defines the filename of the scene to load from
  70738. */
  70739. sceneFilename: string;
  70740. /**
  70741. * Gets the list of loaded meshes
  70742. */
  70743. loadedMeshes: Array<AbstractMesh>;
  70744. /**
  70745. * Gets the list of loaded particle systems
  70746. */
  70747. loadedParticleSystems: Array<IParticleSystem>;
  70748. /**
  70749. * Gets the list of loaded skeletons
  70750. */
  70751. loadedSkeletons: Array<Skeleton>;
  70752. /**
  70753. * Gets the list of loaded animation groups
  70754. */
  70755. loadedAnimationGroups: Array<AnimationGroup>;
  70756. /**
  70757. * Callback called when the task is successful
  70758. */
  70759. onSuccess: (task: MeshAssetTask) => void;
  70760. /**
  70761. * Callback called when the task is successful
  70762. */
  70763. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70764. /**
  70765. * Creates a new MeshAssetTask
  70766. * @param name defines the name of the task
  70767. * @param meshesNames defines the list of mesh's names you want to load
  70768. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70769. * @param sceneFilename defines the filename of the scene to load from
  70770. */
  70771. constructor(
  70772. /**
  70773. * Defines the name of the task
  70774. */
  70775. name: string,
  70776. /**
  70777. * Defines the list of mesh's names you want to load
  70778. */
  70779. meshesNames: any,
  70780. /**
  70781. * Defines the root url to use as a base to load your meshes and associated resources
  70782. */
  70783. rootUrl: string,
  70784. /**
  70785. * Defines the filename of the scene to load from
  70786. */
  70787. sceneFilename: string);
  70788. /**
  70789. * Execute the current task
  70790. * @param scene defines the scene where you want your assets to be loaded
  70791. * @param onSuccess is a callback called when the task is successfully executed
  70792. * @param onError is a callback called if an error occurs
  70793. */
  70794. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70795. }
  70796. /**
  70797. * Define a task used by AssetsManager to load text content
  70798. */
  70799. export class TextFileAssetTask extends AbstractAssetTask {
  70800. /**
  70801. * Defines the name of the task
  70802. */
  70803. name: string;
  70804. /**
  70805. * Defines the location of the file to load
  70806. */
  70807. url: string;
  70808. /**
  70809. * Gets the loaded text string
  70810. */
  70811. text: string;
  70812. /**
  70813. * Callback called when the task is successful
  70814. */
  70815. onSuccess: (task: TextFileAssetTask) => void;
  70816. /**
  70817. * Callback called when the task is successful
  70818. */
  70819. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70820. /**
  70821. * Creates a new TextFileAssetTask object
  70822. * @param name defines the name of the task
  70823. * @param url defines the location of the file to load
  70824. */
  70825. constructor(
  70826. /**
  70827. * Defines the name of the task
  70828. */
  70829. name: string,
  70830. /**
  70831. * Defines the location of the file to load
  70832. */
  70833. url: string);
  70834. /**
  70835. * Execute the current task
  70836. * @param scene defines the scene where you want your assets to be loaded
  70837. * @param onSuccess is a callback called when the task is successfully executed
  70838. * @param onError is a callback called if an error occurs
  70839. */
  70840. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70841. }
  70842. /**
  70843. * Define a task used by AssetsManager to load binary data
  70844. */
  70845. export class BinaryFileAssetTask extends AbstractAssetTask {
  70846. /**
  70847. * Defines the name of the task
  70848. */
  70849. name: string;
  70850. /**
  70851. * Defines the location of the file to load
  70852. */
  70853. url: string;
  70854. /**
  70855. * Gets the lodaded data (as an array buffer)
  70856. */
  70857. data: ArrayBuffer;
  70858. /**
  70859. * Callback called when the task is successful
  70860. */
  70861. onSuccess: (task: BinaryFileAssetTask) => void;
  70862. /**
  70863. * Callback called when the task is successful
  70864. */
  70865. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70866. /**
  70867. * Creates a new BinaryFileAssetTask object
  70868. * @param name defines the name of the new task
  70869. * @param url defines the location of the file to load
  70870. */
  70871. constructor(
  70872. /**
  70873. * Defines the name of the task
  70874. */
  70875. name: string,
  70876. /**
  70877. * Defines the location of the file to load
  70878. */
  70879. url: string);
  70880. /**
  70881. * Execute the current task
  70882. * @param scene defines the scene where you want your assets to be loaded
  70883. * @param onSuccess is a callback called when the task is successfully executed
  70884. * @param onError is a callback called if an error occurs
  70885. */
  70886. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70887. }
  70888. /**
  70889. * Define a task used by AssetsManager to load images
  70890. */
  70891. export class ImageAssetTask extends AbstractAssetTask {
  70892. /**
  70893. * Defines the name of the task
  70894. */
  70895. name: string;
  70896. /**
  70897. * Defines the location of the image to load
  70898. */
  70899. url: string;
  70900. /**
  70901. * Gets the loaded images
  70902. */
  70903. image: HTMLImageElement;
  70904. /**
  70905. * Callback called when the task is successful
  70906. */
  70907. onSuccess: (task: ImageAssetTask) => void;
  70908. /**
  70909. * Callback called when the task is successful
  70910. */
  70911. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70912. /**
  70913. * Creates a new ImageAssetTask
  70914. * @param name defines the name of the task
  70915. * @param url defines the location of the image to load
  70916. */
  70917. constructor(
  70918. /**
  70919. * Defines the name of the task
  70920. */
  70921. name: string,
  70922. /**
  70923. * Defines the location of the image to load
  70924. */
  70925. url: string);
  70926. /**
  70927. * Execute the current task
  70928. * @param scene defines the scene where you want your assets to be loaded
  70929. * @param onSuccess is a callback called when the task is successfully executed
  70930. * @param onError is a callback called if an error occurs
  70931. */
  70932. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70933. }
  70934. /**
  70935. * Defines the interface used by texture loading tasks
  70936. */
  70937. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70938. /**
  70939. * Gets the loaded texture
  70940. */
  70941. texture: TEX;
  70942. }
  70943. /**
  70944. * Define a task used by AssetsManager to load 2D textures
  70945. */
  70946. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70947. /**
  70948. * Defines the name of the task
  70949. */
  70950. name: string;
  70951. /**
  70952. * Defines the location of the file to load
  70953. */
  70954. url: string;
  70955. /**
  70956. * Defines if mipmap should not be generated (default is false)
  70957. */
  70958. noMipmap?: boolean | undefined;
  70959. /**
  70960. * Defines if texture must be inverted on Y axis (default is false)
  70961. */
  70962. invertY?: boolean | undefined;
  70963. /**
  70964. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70965. */
  70966. samplingMode: number;
  70967. /**
  70968. * Gets the loaded texture
  70969. */
  70970. texture: Texture;
  70971. /**
  70972. * Callback called when the task is successful
  70973. */
  70974. onSuccess: (task: TextureAssetTask) => void;
  70975. /**
  70976. * Callback called when the task is successful
  70977. */
  70978. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70979. /**
  70980. * Creates a new TextureAssetTask object
  70981. * @param name defines the name of the task
  70982. * @param url defines the location of the file to load
  70983. * @param noMipmap defines if mipmap should not be generated (default is false)
  70984. * @param invertY defines if texture must be inverted on Y axis (default is false)
  70985. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70986. */
  70987. constructor(
  70988. /**
  70989. * Defines the name of the task
  70990. */
  70991. name: string,
  70992. /**
  70993. * Defines the location of the file to load
  70994. */
  70995. url: string,
  70996. /**
  70997. * Defines if mipmap should not be generated (default is false)
  70998. */
  70999. noMipmap?: boolean | undefined,
  71000. /**
  71001. * Defines if texture must be inverted on Y axis (default is false)
  71002. */
  71003. invertY?: boolean | undefined,
  71004. /**
  71005. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71006. */
  71007. samplingMode?: number);
  71008. /**
  71009. * Execute the current task
  71010. * @param scene defines the scene where you want your assets to be loaded
  71011. * @param onSuccess is a callback called when the task is successfully executed
  71012. * @param onError is a callback called if an error occurs
  71013. */
  71014. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71015. }
  71016. /**
  71017. * Define a task used by AssetsManager to load cube textures
  71018. */
  71019. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71020. /**
  71021. * Defines the name of the task
  71022. */
  71023. name: string;
  71024. /**
  71025. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71026. */
  71027. url: string;
  71028. /**
  71029. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71030. */
  71031. extensions?: string[] | undefined;
  71032. /**
  71033. * Defines if mipmaps should not be generated (default is false)
  71034. */
  71035. noMipmap?: boolean | undefined;
  71036. /**
  71037. * Defines the explicit list of files (undefined by default)
  71038. */
  71039. files?: string[] | undefined;
  71040. /**
  71041. * Gets the loaded texture
  71042. */
  71043. texture: CubeTexture;
  71044. /**
  71045. * Callback called when the task is successful
  71046. */
  71047. onSuccess: (task: CubeTextureAssetTask) => void;
  71048. /**
  71049. * Callback called when the task is successful
  71050. */
  71051. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71052. /**
  71053. * Creates a new CubeTextureAssetTask
  71054. * @param name defines the name of the task
  71055. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71056. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71057. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71058. * @param files defines the explicit list of files (undefined by default)
  71059. */
  71060. constructor(
  71061. /**
  71062. * Defines the name of the task
  71063. */
  71064. name: string,
  71065. /**
  71066. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71067. */
  71068. url: string,
  71069. /**
  71070. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71071. */
  71072. extensions?: string[] | undefined,
  71073. /**
  71074. * Defines if mipmaps should not be generated (default is false)
  71075. */
  71076. noMipmap?: boolean | undefined,
  71077. /**
  71078. * Defines the explicit list of files (undefined by default)
  71079. */
  71080. files?: string[] | undefined);
  71081. /**
  71082. * Execute the current task
  71083. * @param scene defines the scene where you want your assets to be loaded
  71084. * @param onSuccess is a callback called when the task is successfully executed
  71085. * @param onError is a callback called if an error occurs
  71086. */
  71087. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71088. }
  71089. /**
  71090. * Define a task used by AssetsManager to load HDR cube textures
  71091. */
  71092. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71093. /**
  71094. * Defines the name of the task
  71095. */
  71096. name: string;
  71097. /**
  71098. * Defines the location of the file to load
  71099. */
  71100. url: string;
  71101. /**
  71102. * Defines the desired size (the more it increases the longer the generation will be)
  71103. */
  71104. size: number;
  71105. /**
  71106. * Defines if mipmaps should not be generated (default is false)
  71107. */
  71108. noMipmap: boolean;
  71109. /**
  71110. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71111. */
  71112. generateHarmonics: boolean;
  71113. /**
  71114. * 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)
  71115. */
  71116. gammaSpace: boolean;
  71117. /**
  71118. * Internal Use Only
  71119. */
  71120. reserved: boolean;
  71121. /**
  71122. * Gets the loaded texture
  71123. */
  71124. texture: HDRCubeTexture;
  71125. /**
  71126. * Callback called when the task is successful
  71127. */
  71128. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71129. /**
  71130. * Callback called when the task is successful
  71131. */
  71132. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71133. /**
  71134. * Creates a new HDRCubeTextureAssetTask object
  71135. * @param name defines the name of the task
  71136. * @param url defines the location of the file to load
  71137. * @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.
  71138. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71139. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71140. * @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)
  71141. * @param reserved Internal use only
  71142. */
  71143. constructor(
  71144. /**
  71145. * Defines the name of the task
  71146. */
  71147. name: string,
  71148. /**
  71149. * Defines the location of the file to load
  71150. */
  71151. url: string,
  71152. /**
  71153. * Defines the desired size (the more it increases the longer the generation will be)
  71154. */
  71155. size: number,
  71156. /**
  71157. * Defines if mipmaps should not be generated (default is false)
  71158. */
  71159. noMipmap?: boolean,
  71160. /**
  71161. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71162. */
  71163. generateHarmonics?: boolean,
  71164. /**
  71165. * 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)
  71166. */
  71167. gammaSpace?: boolean,
  71168. /**
  71169. * Internal Use Only
  71170. */
  71171. reserved?: boolean);
  71172. /**
  71173. * Execute the current task
  71174. * @param scene defines the scene where you want your assets to be loaded
  71175. * @param onSuccess is a callback called when the task is successfully executed
  71176. * @param onError is a callback called if an error occurs
  71177. */
  71178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71179. }
  71180. /**
  71181. * Define a task used by AssetsManager to load Equirectangular cube textures
  71182. */
  71183. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71184. /**
  71185. * Defines the name of the task
  71186. */
  71187. name: string;
  71188. /**
  71189. * Defines the location of the file to load
  71190. */
  71191. url: string;
  71192. /**
  71193. * Defines the desired size (the more it increases the longer the generation will be)
  71194. */
  71195. size: number;
  71196. /**
  71197. * Defines if mipmaps should not be generated (default is false)
  71198. */
  71199. noMipmap: boolean;
  71200. /**
  71201. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71202. * but the standard material would require them in Gamma space) (default is true)
  71203. */
  71204. gammaSpace: boolean;
  71205. /**
  71206. * Gets the loaded texture
  71207. */
  71208. texture: EquiRectangularCubeTexture;
  71209. /**
  71210. * Callback called when the task is successful
  71211. */
  71212. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71213. /**
  71214. * Callback called when the task is successful
  71215. */
  71216. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71217. /**
  71218. * Creates a new EquiRectangularCubeTextureAssetTask object
  71219. * @param name defines the name of the task
  71220. * @param url defines the location of the file to load
  71221. * @param size defines the desired size (the more it increases the longer the generation will be)
  71222. * If the size is omitted this implies you are using a preprocessed cubemap.
  71223. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71224. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71225. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71226. * (default is true)
  71227. */
  71228. constructor(
  71229. /**
  71230. * Defines the name of the task
  71231. */
  71232. name: string,
  71233. /**
  71234. * Defines the location of the file to load
  71235. */
  71236. url: string,
  71237. /**
  71238. * Defines the desired size (the more it increases the longer the generation will be)
  71239. */
  71240. size: number,
  71241. /**
  71242. * Defines if mipmaps should not be generated (default is false)
  71243. */
  71244. noMipmap?: boolean,
  71245. /**
  71246. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71247. * but the standard material would require them in Gamma space) (default is true)
  71248. */
  71249. gammaSpace?: boolean);
  71250. /**
  71251. * Execute the current task
  71252. * @param scene defines the scene where you want your assets to be loaded
  71253. * @param onSuccess is a callback called when the task is successfully executed
  71254. * @param onError is a callback called if an error occurs
  71255. */
  71256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71257. }
  71258. /**
  71259. * This class can be used to easily import assets into a scene
  71260. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71261. */
  71262. export class AssetsManager {
  71263. private _scene;
  71264. private _isLoading;
  71265. protected _tasks: AbstractAssetTask[];
  71266. protected _waitingTasksCount: number;
  71267. protected _totalTasksCount: number;
  71268. /**
  71269. * Callback called when all tasks are processed
  71270. */
  71271. onFinish: (tasks: AbstractAssetTask[]) => void;
  71272. /**
  71273. * Callback called when a task is successful
  71274. */
  71275. onTaskSuccess: (task: AbstractAssetTask) => void;
  71276. /**
  71277. * Callback called when a task had an error
  71278. */
  71279. onTaskError: (task: AbstractAssetTask) => void;
  71280. /**
  71281. * Callback called when a task is done (whatever the result is)
  71282. */
  71283. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71284. /**
  71285. * Observable called when all tasks are processed
  71286. */
  71287. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71288. /**
  71289. * Observable called when a task had an error
  71290. */
  71291. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71292. /**
  71293. * Observable called when all tasks were executed
  71294. */
  71295. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71296. /**
  71297. * Observable called when a task is done (whatever the result is)
  71298. */
  71299. onProgressObservable: Observable<IAssetsProgressEvent>;
  71300. /**
  71301. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71302. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71303. */
  71304. useDefaultLoadingScreen: boolean;
  71305. /**
  71306. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71307. * when all assets have been downloaded.
  71308. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71309. */
  71310. autoHideLoadingUI: boolean;
  71311. /**
  71312. * Creates a new AssetsManager
  71313. * @param scene defines the scene to work on
  71314. */
  71315. constructor(scene: Scene);
  71316. /**
  71317. * Add a MeshAssetTask to the list of active tasks
  71318. * @param taskName defines the name of the new task
  71319. * @param meshesNames defines the name of meshes to load
  71320. * @param rootUrl defines the root url to use to locate files
  71321. * @param sceneFilename defines the filename of the scene file
  71322. * @returns a new MeshAssetTask object
  71323. */
  71324. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71325. /**
  71326. * Add a TextFileAssetTask to the list of active tasks
  71327. * @param taskName defines the name of the new task
  71328. * @param url defines the url of the file to load
  71329. * @returns a new TextFileAssetTask object
  71330. */
  71331. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71332. /**
  71333. * Add a BinaryFileAssetTask to the list of active tasks
  71334. * @param taskName defines the name of the new task
  71335. * @param url defines the url of the file to load
  71336. * @returns a new BinaryFileAssetTask object
  71337. */
  71338. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71339. /**
  71340. * Add a ImageAssetTask to the list of active tasks
  71341. * @param taskName defines the name of the new task
  71342. * @param url defines the url of the file to load
  71343. * @returns a new ImageAssetTask object
  71344. */
  71345. addImageTask(taskName: string, url: string): ImageAssetTask;
  71346. /**
  71347. * Add a TextureAssetTask to the list of active tasks
  71348. * @param taskName defines the name of the new task
  71349. * @param url defines the url of the file to load
  71350. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71351. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71352. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71353. * @returns a new TextureAssetTask object
  71354. */
  71355. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71356. /**
  71357. * Add a CubeTextureAssetTask to the list of active tasks
  71358. * @param taskName defines the name of the new task
  71359. * @param url defines the url of the file to load
  71360. * @param extensions defines the extension to use to load the cube map (can be null)
  71361. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71362. * @param files defines the list of files to load (can be null)
  71363. * @returns a new CubeTextureAssetTask object
  71364. */
  71365. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71366. /**
  71367. *
  71368. * Add a HDRCubeTextureAssetTask 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. * @param size defines the size you want for the cubemap (can be null)
  71372. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71373. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71374. * @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)
  71375. * @param reserved Internal use only
  71376. * @returns a new HDRCubeTextureAssetTask object
  71377. */
  71378. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71379. /**
  71380. *
  71381. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71382. * @param taskName defines the name of the new task
  71383. * @param url defines the url of the file to load
  71384. * @param size defines the size you want for the cubemap (can be null)
  71385. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71386. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71387. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71388. * @returns a new EquiRectangularCubeTextureAssetTask object
  71389. */
  71390. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71391. /**
  71392. * Remove a task from the assets manager.
  71393. * @param task the task to remove
  71394. */
  71395. removeTask(task: AbstractAssetTask): void;
  71396. private _decreaseWaitingTasksCount;
  71397. private _runTask;
  71398. /**
  71399. * Reset the AssetsManager and remove all tasks
  71400. * @return the current instance of the AssetsManager
  71401. */
  71402. reset(): AssetsManager;
  71403. /**
  71404. * Start the loading process
  71405. * @return the current instance of the AssetsManager
  71406. */
  71407. load(): AssetsManager;
  71408. /**
  71409. * Start the loading process as an async operation
  71410. * @return a promise returning the list of failed tasks
  71411. */
  71412. loadAsync(): Promise<void>;
  71413. }
  71414. }
  71415. declare module "babylonjs/Misc/deferred" {
  71416. /**
  71417. * Wrapper class for promise with external resolve and reject.
  71418. */
  71419. export class Deferred<T> {
  71420. /**
  71421. * The promise associated with this deferred object.
  71422. */
  71423. readonly promise: Promise<T>;
  71424. private _resolve;
  71425. private _reject;
  71426. /**
  71427. * The resolve method of the promise associated with this deferred object.
  71428. */
  71429. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71430. /**
  71431. * The reject method of the promise associated with this deferred object.
  71432. */
  71433. get reject(): (reason?: any) => void;
  71434. /**
  71435. * Constructor for this deferred object.
  71436. */
  71437. constructor();
  71438. }
  71439. }
  71440. declare module "babylonjs/Misc/meshExploder" {
  71441. import { Mesh } from "babylonjs/Meshes/mesh";
  71442. /**
  71443. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71444. */
  71445. export class MeshExploder {
  71446. private _centerMesh;
  71447. private _meshes;
  71448. private _meshesOrigins;
  71449. private _toCenterVectors;
  71450. private _scaledDirection;
  71451. private _newPosition;
  71452. private _centerPosition;
  71453. /**
  71454. * Explodes meshes from a center mesh.
  71455. * @param meshes The meshes to explode.
  71456. * @param centerMesh The mesh to be center of explosion.
  71457. */
  71458. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71459. private _setCenterMesh;
  71460. /**
  71461. * Get class name
  71462. * @returns "MeshExploder"
  71463. */
  71464. getClassName(): string;
  71465. /**
  71466. * "Exploded meshes"
  71467. * @returns Array of meshes with the centerMesh at index 0.
  71468. */
  71469. getMeshes(): Array<Mesh>;
  71470. /**
  71471. * Explodes meshes giving a specific direction
  71472. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71473. */
  71474. explode(direction?: number): void;
  71475. }
  71476. }
  71477. declare module "babylonjs/Misc/filesInput" {
  71478. import { Engine } from "babylonjs/Engines/engine";
  71479. import { Scene } from "babylonjs/scene";
  71480. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71481. /**
  71482. * Class used to help managing file picking and drag'n'drop
  71483. */
  71484. export class FilesInput {
  71485. /**
  71486. * List of files ready to be loaded
  71487. */
  71488. static get FilesToLoad(): {
  71489. [key: string]: File;
  71490. };
  71491. /**
  71492. * Callback called when a file is processed
  71493. */
  71494. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71495. private _engine;
  71496. private _currentScene;
  71497. private _sceneLoadedCallback;
  71498. private _progressCallback;
  71499. private _additionalRenderLoopLogicCallback;
  71500. private _textureLoadingCallback;
  71501. private _startingProcessingFilesCallback;
  71502. private _onReloadCallback;
  71503. private _errorCallback;
  71504. private _elementToMonitor;
  71505. private _sceneFileToLoad;
  71506. private _filesToLoad;
  71507. /**
  71508. * Creates a new FilesInput
  71509. * @param engine defines the rendering engine
  71510. * @param scene defines the hosting scene
  71511. * @param sceneLoadedCallback callback called when scene is loaded
  71512. * @param progressCallback callback called to track progress
  71513. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71514. * @param textureLoadingCallback callback called when a texture is loading
  71515. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71516. * @param onReloadCallback callback called when a reload is requested
  71517. * @param errorCallback callback call if an error occurs
  71518. */
  71519. 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);
  71520. private _dragEnterHandler;
  71521. private _dragOverHandler;
  71522. private _dropHandler;
  71523. /**
  71524. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71525. * @param elementToMonitor defines the DOM element to track
  71526. */
  71527. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71528. /**
  71529. * Release all associated resources
  71530. */
  71531. dispose(): void;
  71532. private renderFunction;
  71533. private drag;
  71534. private drop;
  71535. private _traverseFolder;
  71536. private _processFiles;
  71537. /**
  71538. * Load files from a drop event
  71539. * @param event defines the drop event to use as source
  71540. */
  71541. loadFiles(event: any): void;
  71542. private _processReload;
  71543. /**
  71544. * Reload the current scene from the loaded files
  71545. */
  71546. reload(): void;
  71547. }
  71548. }
  71549. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71550. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71551. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71552. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71553. }
  71554. declare module "babylonjs/Misc/sceneOptimizer" {
  71555. import { Scene, IDisposable } from "babylonjs/scene";
  71556. import { Observable } from "babylonjs/Misc/observable";
  71557. /**
  71558. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71559. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71560. */
  71561. export class SceneOptimization {
  71562. /**
  71563. * Defines the priority of this optimization (0 by default which means first in the list)
  71564. */
  71565. priority: number;
  71566. /**
  71567. * Gets a string describing the action executed by the current optimization
  71568. * @returns description string
  71569. */
  71570. getDescription(): string;
  71571. /**
  71572. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71573. * @param scene defines the current scene where to apply this optimization
  71574. * @param optimizer defines the current optimizer
  71575. * @returns true if everything that can be done was applied
  71576. */
  71577. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71578. /**
  71579. * Creates the SceneOptimization object
  71580. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71581. * @param desc defines the description associated with the optimization
  71582. */
  71583. constructor(
  71584. /**
  71585. * Defines the priority of this optimization (0 by default which means first in the list)
  71586. */
  71587. priority?: number);
  71588. }
  71589. /**
  71590. * Defines an optimization used to reduce the size of render target textures
  71591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71592. */
  71593. export class TextureOptimization extends SceneOptimization {
  71594. /**
  71595. * Defines the priority of this optimization (0 by default which means first in the list)
  71596. */
  71597. priority: number;
  71598. /**
  71599. * 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
  71600. */
  71601. maximumSize: number;
  71602. /**
  71603. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71604. */
  71605. step: number;
  71606. /**
  71607. * Gets a string describing the action executed by the current optimization
  71608. * @returns description string
  71609. */
  71610. getDescription(): string;
  71611. /**
  71612. * Creates the TextureOptimization object
  71613. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71614. * @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
  71615. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71616. */
  71617. constructor(
  71618. /**
  71619. * Defines the priority of this optimization (0 by default which means first in the list)
  71620. */
  71621. priority?: number,
  71622. /**
  71623. * 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
  71624. */
  71625. maximumSize?: number,
  71626. /**
  71627. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71628. */
  71629. step?: number);
  71630. /**
  71631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71632. * @param scene defines the current scene where to apply this optimization
  71633. * @param optimizer defines the current optimizer
  71634. * @returns true if everything that can be done was applied
  71635. */
  71636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71637. }
  71638. /**
  71639. * Defines an optimization used to increase or decrease the rendering resolution
  71640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71641. */
  71642. export class HardwareScalingOptimization extends SceneOptimization {
  71643. /**
  71644. * Defines the priority of this optimization (0 by default which means first in the list)
  71645. */
  71646. priority: number;
  71647. /**
  71648. * Defines the maximum scale to use (2 by default)
  71649. */
  71650. maximumScale: number;
  71651. /**
  71652. * Defines the step to use between two passes (0.5 by default)
  71653. */
  71654. step: number;
  71655. private _currentScale;
  71656. private _directionOffset;
  71657. /**
  71658. * Gets a string describing the action executed by the current optimization
  71659. * @return description string
  71660. */
  71661. getDescription(): string;
  71662. /**
  71663. * Creates the HardwareScalingOptimization object
  71664. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71665. * @param maximumScale defines the maximum scale to use (2 by default)
  71666. * @param step defines the step to use between two passes (0.5 by default)
  71667. */
  71668. constructor(
  71669. /**
  71670. * Defines the priority of this optimization (0 by default which means first in the list)
  71671. */
  71672. priority?: number,
  71673. /**
  71674. * Defines the maximum scale to use (2 by default)
  71675. */
  71676. maximumScale?: number,
  71677. /**
  71678. * Defines the step to use between two passes (0.5 by default)
  71679. */
  71680. step?: number);
  71681. /**
  71682. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71683. * @param scene defines the current scene where to apply this optimization
  71684. * @param optimizer defines the current optimizer
  71685. * @returns true if everything that can be done was applied
  71686. */
  71687. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71688. }
  71689. /**
  71690. * Defines an optimization used to remove shadows
  71691. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71692. */
  71693. export class ShadowsOptimization extends SceneOptimization {
  71694. /**
  71695. * Gets a string describing the action executed by the current optimization
  71696. * @return description string
  71697. */
  71698. getDescription(): string;
  71699. /**
  71700. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71701. * @param scene defines the current scene where to apply this optimization
  71702. * @param optimizer defines the current optimizer
  71703. * @returns true if everything that can be done was applied
  71704. */
  71705. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71706. }
  71707. /**
  71708. * Defines an optimization used to turn post-processes off
  71709. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71710. */
  71711. export class PostProcessesOptimization extends SceneOptimization {
  71712. /**
  71713. * Gets a string describing the action executed by the current optimization
  71714. * @return description string
  71715. */
  71716. getDescription(): string;
  71717. /**
  71718. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71719. * @param scene defines the current scene where to apply this optimization
  71720. * @param optimizer defines the current optimizer
  71721. * @returns true if everything that can be done was applied
  71722. */
  71723. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71724. }
  71725. /**
  71726. * Defines an optimization used to turn lens flares off
  71727. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71728. */
  71729. export class LensFlaresOptimization extends SceneOptimization {
  71730. /**
  71731. * Gets a string describing the action executed by the current optimization
  71732. * @return description string
  71733. */
  71734. getDescription(): string;
  71735. /**
  71736. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71737. * @param scene defines the current scene where to apply this optimization
  71738. * @param optimizer defines the current optimizer
  71739. * @returns true if everything that can be done was applied
  71740. */
  71741. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71742. }
  71743. /**
  71744. * Defines an optimization based on user defined callback.
  71745. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71746. */
  71747. export class CustomOptimization extends SceneOptimization {
  71748. /**
  71749. * Callback called to apply the custom optimization.
  71750. */
  71751. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71752. /**
  71753. * Callback called to get custom description
  71754. */
  71755. onGetDescription: () => string;
  71756. /**
  71757. * Gets a string describing the action executed by the current optimization
  71758. * @returns description string
  71759. */
  71760. getDescription(): string;
  71761. /**
  71762. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71763. * @param scene defines the current scene where to apply this optimization
  71764. * @param optimizer defines the current optimizer
  71765. * @returns true if everything that can be done was applied
  71766. */
  71767. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71768. }
  71769. /**
  71770. * Defines an optimization used to turn particles off
  71771. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71772. */
  71773. export class ParticlesOptimization extends SceneOptimization {
  71774. /**
  71775. * Gets a string describing the action executed by the current optimization
  71776. * @return description string
  71777. */
  71778. getDescription(): string;
  71779. /**
  71780. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71781. * @param scene defines the current scene where to apply this optimization
  71782. * @param optimizer defines the current optimizer
  71783. * @returns true if everything that can be done was applied
  71784. */
  71785. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71786. }
  71787. /**
  71788. * Defines an optimization used to turn render targets off
  71789. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71790. */
  71791. export class RenderTargetsOptimization extends SceneOptimization {
  71792. /**
  71793. * Gets a string describing the action executed by the current optimization
  71794. * @return description string
  71795. */
  71796. getDescription(): string;
  71797. /**
  71798. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71799. * @param scene defines the current scene where to apply this optimization
  71800. * @param optimizer defines the current optimizer
  71801. * @returns true if everything that can be done was applied
  71802. */
  71803. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71804. }
  71805. /**
  71806. * Defines an optimization used to merge meshes with compatible materials
  71807. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71808. */
  71809. export class MergeMeshesOptimization extends SceneOptimization {
  71810. private static _UpdateSelectionTree;
  71811. /**
  71812. * Gets or sets a boolean which defines if optimization octree has to be updated
  71813. */
  71814. static get UpdateSelectionTree(): boolean;
  71815. /**
  71816. * Gets or sets a boolean which defines if optimization octree has to be updated
  71817. */
  71818. static set UpdateSelectionTree(value: boolean);
  71819. /**
  71820. * Gets a string describing the action executed by the current optimization
  71821. * @return description string
  71822. */
  71823. getDescription(): string;
  71824. private _canBeMerged;
  71825. /**
  71826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71827. * @param scene defines the current scene where to apply this optimization
  71828. * @param optimizer defines the current optimizer
  71829. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71830. * @returns true if everything that can be done was applied
  71831. */
  71832. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71833. }
  71834. /**
  71835. * Defines a list of options used by SceneOptimizer
  71836. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71837. */
  71838. export class SceneOptimizerOptions {
  71839. /**
  71840. * Defines the target frame rate to reach (60 by default)
  71841. */
  71842. targetFrameRate: number;
  71843. /**
  71844. * Defines the interval between two checkes (2000ms by default)
  71845. */
  71846. trackerDuration: number;
  71847. /**
  71848. * Gets the list of optimizations to apply
  71849. */
  71850. optimizations: SceneOptimization[];
  71851. /**
  71852. * Creates a new list of options used by SceneOptimizer
  71853. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71854. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71855. */
  71856. constructor(
  71857. /**
  71858. * Defines the target frame rate to reach (60 by default)
  71859. */
  71860. targetFrameRate?: number,
  71861. /**
  71862. * Defines the interval between two checkes (2000ms by default)
  71863. */
  71864. trackerDuration?: number);
  71865. /**
  71866. * Add a new optimization
  71867. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71868. * @returns the current SceneOptimizerOptions
  71869. */
  71870. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71871. /**
  71872. * Add a new custom optimization
  71873. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71874. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71875. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71876. * @returns the current SceneOptimizerOptions
  71877. */
  71878. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71879. /**
  71880. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71881. * @param targetFrameRate defines the target frame rate (60 by default)
  71882. * @returns a SceneOptimizerOptions object
  71883. */
  71884. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71885. /**
  71886. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71887. * @param targetFrameRate defines the target frame rate (60 by default)
  71888. * @returns a SceneOptimizerOptions object
  71889. */
  71890. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71891. /**
  71892. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71893. * @param targetFrameRate defines the target frame rate (60 by default)
  71894. * @returns a SceneOptimizerOptions object
  71895. */
  71896. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71897. }
  71898. /**
  71899. * Class used to run optimizations in order to reach a target frame rate
  71900. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71901. */
  71902. export class SceneOptimizer implements IDisposable {
  71903. private _isRunning;
  71904. private _options;
  71905. private _scene;
  71906. private _currentPriorityLevel;
  71907. private _targetFrameRate;
  71908. private _trackerDuration;
  71909. private _currentFrameRate;
  71910. private _sceneDisposeObserver;
  71911. private _improvementMode;
  71912. /**
  71913. * Defines an observable called when the optimizer reaches the target frame rate
  71914. */
  71915. onSuccessObservable: Observable<SceneOptimizer>;
  71916. /**
  71917. * Defines an observable called when the optimizer enables an optimization
  71918. */
  71919. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71920. /**
  71921. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71922. */
  71923. onFailureObservable: Observable<SceneOptimizer>;
  71924. /**
  71925. * Gets a boolean indicating if the optimizer is in improvement mode
  71926. */
  71927. get isInImprovementMode(): boolean;
  71928. /**
  71929. * Gets the current priority level (0 at start)
  71930. */
  71931. get currentPriorityLevel(): number;
  71932. /**
  71933. * Gets the current frame rate checked by the SceneOptimizer
  71934. */
  71935. get currentFrameRate(): number;
  71936. /**
  71937. * Gets or sets the current target frame rate (60 by default)
  71938. */
  71939. get targetFrameRate(): number;
  71940. /**
  71941. * Gets or sets the current target frame rate (60 by default)
  71942. */
  71943. set targetFrameRate(value: number);
  71944. /**
  71945. * Gets or sets the current interval between two checks (every 2000ms by default)
  71946. */
  71947. get trackerDuration(): number;
  71948. /**
  71949. * Gets or sets the current interval between two checks (every 2000ms by default)
  71950. */
  71951. set trackerDuration(value: number);
  71952. /**
  71953. * Gets the list of active optimizations
  71954. */
  71955. get optimizations(): SceneOptimization[];
  71956. /**
  71957. * Creates a new SceneOptimizer
  71958. * @param scene defines the scene to work on
  71959. * @param options defines the options to use with the SceneOptimizer
  71960. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71961. * @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)
  71962. */
  71963. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71964. /**
  71965. * Stops the current optimizer
  71966. */
  71967. stop(): void;
  71968. /**
  71969. * Reset the optimizer to initial step (current priority level = 0)
  71970. */
  71971. reset(): void;
  71972. /**
  71973. * Start the optimizer. By default it will try to reach a specific framerate
  71974. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71975. */
  71976. start(): void;
  71977. private _checkCurrentState;
  71978. /**
  71979. * Release all resources
  71980. */
  71981. dispose(): void;
  71982. /**
  71983. * Helper function to create a SceneOptimizer with one single line of code
  71984. * @param scene defines the scene to work on
  71985. * @param options defines the options to use with the SceneOptimizer
  71986. * @param onSuccess defines a callback to call on success
  71987. * @param onFailure defines a callback to call on failure
  71988. * @returns the new SceneOptimizer object
  71989. */
  71990. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71991. }
  71992. }
  71993. declare module "babylonjs/Misc/sceneSerializer" {
  71994. import { Scene } from "babylonjs/scene";
  71995. /**
  71996. * Class used to serialize a scene into a string
  71997. */
  71998. export class SceneSerializer {
  71999. /**
  72000. * Clear cache used by a previous serialization
  72001. */
  72002. static ClearCache(): void;
  72003. /**
  72004. * Serialize a scene into a JSON compatible object
  72005. * @param scene defines the scene to serialize
  72006. * @returns a JSON compatible object
  72007. */
  72008. static Serialize(scene: Scene): any;
  72009. /**
  72010. * Serialize a mesh into a JSON compatible object
  72011. * @param toSerialize defines the mesh to serialize
  72012. * @param withParents defines if parents must be serialized as well
  72013. * @param withChildren defines if children must be serialized as well
  72014. * @returns a JSON compatible object
  72015. */
  72016. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72017. }
  72018. }
  72019. declare module "babylonjs/Misc/textureTools" {
  72020. import { Texture } from "babylonjs/Materials/Textures/texture";
  72021. /**
  72022. * Class used to host texture specific utilities
  72023. */
  72024. export class TextureTools {
  72025. /**
  72026. * Uses the GPU to create a copy texture rescaled at a given size
  72027. * @param texture Texture to copy from
  72028. * @param width defines the desired width
  72029. * @param height defines the desired height
  72030. * @param useBilinearMode defines if bilinear mode has to be used
  72031. * @return the generated texture
  72032. */
  72033. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72034. }
  72035. }
  72036. declare module "babylonjs/Misc/videoRecorder" {
  72037. import { Nullable } from "babylonjs/types";
  72038. import { Engine } from "babylonjs/Engines/engine";
  72039. /**
  72040. * This represents the different options available for the video capture.
  72041. */
  72042. export interface VideoRecorderOptions {
  72043. /** Defines the mime type of the video. */
  72044. mimeType: string;
  72045. /** Defines the FPS the video should be recorded at. */
  72046. fps: number;
  72047. /** Defines the chunk size for the recording data. */
  72048. recordChunckSize: number;
  72049. /** The audio tracks to attach to the recording. */
  72050. audioTracks?: MediaStreamTrack[];
  72051. }
  72052. /**
  72053. * This can help with recording videos from BabylonJS.
  72054. * This is based on the available WebRTC functionalities of the browser.
  72055. *
  72056. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72057. */
  72058. export class VideoRecorder {
  72059. private static readonly _defaultOptions;
  72060. /**
  72061. * Returns whether or not the VideoRecorder is available in your browser.
  72062. * @param engine Defines the Babylon Engine.
  72063. * @returns true if supported otherwise false.
  72064. */
  72065. static IsSupported(engine: Engine): boolean;
  72066. private readonly _options;
  72067. private _canvas;
  72068. private _mediaRecorder;
  72069. private _recordedChunks;
  72070. private _fileName;
  72071. private _resolve;
  72072. private _reject;
  72073. /**
  72074. * True when a recording is already in progress.
  72075. */
  72076. get isRecording(): boolean;
  72077. /**
  72078. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72079. * @param engine Defines the BabylonJS Engine you wish to record.
  72080. * @param options Defines options that can be used to customize the capture.
  72081. */
  72082. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72083. /**
  72084. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72085. */
  72086. stopRecording(): void;
  72087. /**
  72088. * Starts recording the canvas for a max duration specified in parameters.
  72089. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72090. * If null no automatic download will start and you can rely on the promise to get the data back.
  72091. * @param maxDuration Defines the maximum recording time in seconds.
  72092. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72093. * @return A promise callback at the end of the recording with the video data in Blob.
  72094. */
  72095. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72096. /**
  72097. * Releases internal resources used during the recording.
  72098. */
  72099. dispose(): void;
  72100. private _handleDataAvailable;
  72101. private _handleError;
  72102. private _handleStop;
  72103. }
  72104. }
  72105. declare module "babylonjs/Misc/screenshotTools" {
  72106. import { Camera } from "babylonjs/Cameras/camera";
  72107. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72108. import { Engine } from "babylonjs/Engines/engine";
  72109. /**
  72110. * Class containing a set of static utilities functions for screenshots
  72111. */
  72112. export class ScreenshotTools {
  72113. /**
  72114. * Captures a screenshot of the current rendering
  72115. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72116. * @param engine defines the rendering engine
  72117. * @param camera defines the source camera
  72118. * @param size This parameter can be set to a single number or to an object with the
  72119. * following (optional) properties: precision, width, height. If a single number is passed,
  72120. * it will be used for both width and height. If an object is passed, the screenshot size
  72121. * will be derived from the parameters. The precision property is a multiplier allowing
  72122. * rendering at a higher or lower resolution
  72123. * @param successCallback defines the callback receives a single parameter which contains the
  72124. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72125. * src parameter of an <img> to display it
  72126. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72127. * Check your browser for supported MIME types
  72128. */
  72129. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72130. /**
  72131. * Captures a screenshot of the current rendering
  72132. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72133. * @param engine defines the rendering engine
  72134. * @param camera defines the source camera
  72135. * @param size This parameter can be set to a single number or to an object with the
  72136. * following (optional) properties: precision, width, height. If a single number is passed,
  72137. * it will be used for both width and height. If an object is passed, the screenshot size
  72138. * will be derived from the parameters. The precision property is a multiplier allowing
  72139. * rendering at a higher or lower resolution
  72140. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72141. * Check your browser for supported MIME types
  72142. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72143. * to the src parameter of an <img> to display it
  72144. */
  72145. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72146. /**
  72147. * Generates an image screenshot from the specified camera.
  72148. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72149. * @param engine The engine to use for rendering
  72150. * @param camera The camera to use for rendering
  72151. * @param size This parameter can be set to a single number or to an object with the
  72152. * following (optional) properties: precision, width, height. If a single number is passed,
  72153. * it will be used for both width and height. If an object is passed, the screenshot size
  72154. * will be derived from the parameters. The precision property is a multiplier allowing
  72155. * rendering at a higher or lower resolution
  72156. * @param successCallback The callback receives a single parameter which contains the
  72157. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72158. * src parameter of an <img> to display it
  72159. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72160. * Check your browser for supported MIME types
  72161. * @param samples Texture samples (default: 1)
  72162. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72163. * @param fileName A name for for the downloaded file.
  72164. */
  72165. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  72166. /**
  72167. * Generates an image screenshot from the specified camera.
  72168. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72169. * @param engine The engine to use for rendering
  72170. * @param camera The camera to use for rendering
  72171. * @param size This parameter can be set to a single number or to an object with the
  72172. * following (optional) properties: precision, width, height. If a single number is passed,
  72173. * it will be used for both width and height. If an object is passed, the screenshot size
  72174. * will be derived from the parameters. The precision property is a multiplier allowing
  72175. * rendering at a higher or lower resolution
  72176. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72177. * Check your browser for supported MIME types
  72178. * @param samples Texture samples (default: 1)
  72179. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72180. * @param fileName A name for for the downloaded file.
  72181. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72182. * to the src parameter of an <img> to display it
  72183. */
  72184. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  72185. /**
  72186. * Gets height and width for screenshot size
  72187. * @private
  72188. */
  72189. private static _getScreenshotSize;
  72190. }
  72191. }
  72192. declare module "babylonjs/Misc/dataReader" {
  72193. /**
  72194. * Interface for a data buffer
  72195. */
  72196. export interface IDataBuffer {
  72197. /**
  72198. * Reads bytes from the data buffer.
  72199. * @param byteOffset The byte offset to read
  72200. * @param byteLength The byte length to read
  72201. * @returns A promise that resolves when the bytes are read
  72202. */
  72203. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72204. /**
  72205. * The byte length of the buffer.
  72206. */
  72207. readonly byteLength: number;
  72208. }
  72209. /**
  72210. * Utility class for reading from a data buffer
  72211. */
  72212. export class DataReader {
  72213. /**
  72214. * The data buffer associated with this data reader.
  72215. */
  72216. readonly buffer: IDataBuffer;
  72217. /**
  72218. * The current byte offset from the beginning of the data buffer.
  72219. */
  72220. byteOffset: number;
  72221. private _dataView;
  72222. private _dataByteOffset;
  72223. /**
  72224. * Constructor
  72225. * @param buffer The buffer to read
  72226. */
  72227. constructor(buffer: IDataBuffer);
  72228. /**
  72229. * Loads the given byte length.
  72230. * @param byteLength The byte length to load
  72231. * @returns A promise that resolves when the load is complete
  72232. */
  72233. loadAsync(byteLength: number): Promise<void>;
  72234. /**
  72235. * Read a unsigned 32-bit integer from the currently loaded data range.
  72236. * @returns The 32-bit integer read
  72237. */
  72238. readUint32(): number;
  72239. /**
  72240. * Read a byte array from the currently loaded data range.
  72241. * @param byteLength The byte length to read
  72242. * @returns The byte array read
  72243. */
  72244. readUint8Array(byteLength: number): Uint8Array;
  72245. /**
  72246. * Read a string from the currently loaded data range.
  72247. * @param byteLength The byte length to read
  72248. * @returns The string read
  72249. */
  72250. readString(byteLength: number): string;
  72251. /**
  72252. * Skips the given byte length the currently loaded data range.
  72253. * @param byteLength The byte length to skip
  72254. */
  72255. skipBytes(byteLength: number): void;
  72256. }
  72257. }
  72258. declare module "babylonjs/Misc/index" {
  72259. export * from "babylonjs/Misc/andOrNotEvaluator";
  72260. export * from "babylonjs/Misc/assetsManager";
  72261. export * from "babylonjs/Misc/basis";
  72262. export * from "babylonjs/Misc/dds";
  72263. export * from "babylonjs/Misc/decorators";
  72264. export * from "babylonjs/Misc/deferred";
  72265. export * from "babylonjs/Misc/environmentTextureTools";
  72266. export * from "babylonjs/Misc/meshExploder";
  72267. export * from "babylonjs/Misc/filesInput";
  72268. export * from "babylonjs/Misc/HighDynamicRange/index";
  72269. export * from "babylonjs/Misc/khronosTextureContainer";
  72270. export * from "babylonjs/Misc/observable";
  72271. export * from "babylonjs/Misc/performanceMonitor";
  72272. export * from "babylonjs/Misc/promise";
  72273. export * from "babylonjs/Misc/sceneOptimizer";
  72274. export * from "babylonjs/Misc/sceneSerializer";
  72275. export * from "babylonjs/Misc/smartArray";
  72276. export * from "babylonjs/Misc/stringDictionary";
  72277. export * from "babylonjs/Misc/tags";
  72278. export * from "babylonjs/Misc/textureTools";
  72279. export * from "babylonjs/Misc/tga";
  72280. export * from "babylonjs/Misc/tools";
  72281. export * from "babylonjs/Misc/videoRecorder";
  72282. export * from "babylonjs/Misc/virtualJoystick";
  72283. export * from "babylonjs/Misc/workerPool";
  72284. export * from "babylonjs/Misc/logger";
  72285. export * from "babylonjs/Misc/typeStore";
  72286. export * from "babylonjs/Misc/filesInputStore";
  72287. export * from "babylonjs/Misc/deepCopier";
  72288. export * from "babylonjs/Misc/pivotTools";
  72289. export * from "babylonjs/Misc/precisionDate";
  72290. export * from "babylonjs/Misc/screenshotTools";
  72291. export * from "babylonjs/Misc/typeStore";
  72292. export * from "babylonjs/Misc/webRequest";
  72293. export * from "babylonjs/Misc/iInspectable";
  72294. export * from "babylonjs/Misc/brdfTextureTools";
  72295. export * from "babylonjs/Misc/rgbdTextureTools";
  72296. export * from "babylonjs/Misc/gradients";
  72297. export * from "babylonjs/Misc/perfCounter";
  72298. export * from "babylonjs/Misc/fileRequest";
  72299. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72300. export * from "babylonjs/Misc/retryStrategy";
  72301. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72302. export * from "babylonjs/Misc/canvasGenerator";
  72303. export * from "babylonjs/Misc/fileTools";
  72304. export * from "babylonjs/Misc/stringTools";
  72305. export * from "babylonjs/Misc/dataReader";
  72306. export * from "babylonjs/Misc/minMaxReducer";
  72307. export * from "babylonjs/Misc/depthReducer";
  72308. }
  72309. declare module "babylonjs/index" {
  72310. export * from "babylonjs/abstractScene";
  72311. export * from "babylonjs/Actions/index";
  72312. export * from "babylonjs/Animations/index";
  72313. export * from "babylonjs/assetContainer";
  72314. export * from "babylonjs/Audio/index";
  72315. export * from "babylonjs/Behaviors/index";
  72316. export * from "babylonjs/Bones/index";
  72317. export * from "babylonjs/Cameras/index";
  72318. export * from "babylonjs/Collisions/index";
  72319. export * from "babylonjs/Culling/index";
  72320. export * from "babylonjs/Debug/index";
  72321. export * from "babylonjs/Engines/index";
  72322. export * from "babylonjs/Events/index";
  72323. export * from "babylonjs/Gamepads/index";
  72324. export * from "babylonjs/Gizmos/index";
  72325. export * from "babylonjs/Helpers/index";
  72326. export * from "babylonjs/Instrumentation/index";
  72327. export * from "babylonjs/Layers/index";
  72328. export * from "babylonjs/LensFlares/index";
  72329. export * from "babylonjs/Lights/index";
  72330. export * from "babylonjs/Loading/index";
  72331. export * from "babylonjs/Materials/index";
  72332. export * from "babylonjs/Maths/index";
  72333. export * from "babylonjs/Meshes/index";
  72334. export * from "babylonjs/Morph/index";
  72335. export * from "babylonjs/Navigation/index";
  72336. export * from "babylonjs/node";
  72337. export * from "babylonjs/Offline/index";
  72338. export * from "babylonjs/Particles/index";
  72339. export * from "babylonjs/Physics/index";
  72340. export * from "babylonjs/PostProcesses/index";
  72341. export * from "babylonjs/Probes/index";
  72342. export * from "babylonjs/Rendering/index";
  72343. export * from "babylonjs/scene";
  72344. export * from "babylonjs/sceneComponent";
  72345. export * from "babylonjs/Sprites/index";
  72346. export * from "babylonjs/States/index";
  72347. export * from "babylonjs/Misc/index";
  72348. export * from "babylonjs/types";
  72349. }
  72350. declare module "babylonjs/Animations/pathCursor" {
  72351. import { Vector3 } from "babylonjs/Maths/math.vector";
  72352. import { Path2 } from "babylonjs/Maths/math.path";
  72353. /**
  72354. * A cursor which tracks a point on a path
  72355. */
  72356. export class PathCursor {
  72357. private path;
  72358. /**
  72359. * Stores path cursor callbacks for when an onchange event is triggered
  72360. */
  72361. private _onchange;
  72362. /**
  72363. * The value of the path cursor
  72364. */
  72365. value: number;
  72366. /**
  72367. * The animation array of the path cursor
  72368. */
  72369. animations: Animation[];
  72370. /**
  72371. * Initializes the path cursor
  72372. * @param path The path to track
  72373. */
  72374. constructor(path: Path2);
  72375. /**
  72376. * Gets the cursor point on the path
  72377. * @returns A point on the path cursor at the cursor location
  72378. */
  72379. getPoint(): Vector3;
  72380. /**
  72381. * Moves the cursor ahead by the step amount
  72382. * @param step The amount to move the cursor forward
  72383. * @returns This path cursor
  72384. */
  72385. moveAhead(step?: number): PathCursor;
  72386. /**
  72387. * Moves the cursor behind by the step amount
  72388. * @param step The amount to move the cursor back
  72389. * @returns This path cursor
  72390. */
  72391. moveBack(step?: number): PathCursor;
  72392. /**
  72393. * Moves the cursor by the step amount
  72394. * If the step amount is greater than one, an exception is thrown
  72395. * @param step The amount to move the cursor
  72396. * @returns This path cursor
  72397. */
  72398. move(step: number): PathCursor;
  72399. /**
  72400. * Ensures that the value is limited between zero and one
  72401. * @returns This path cursor
  72402. */
  72403. private ensureLimits;
  72404. /**
  72405. * Runs onchange callbacks on change (used by the animation engine)
  72406. * @returns This path cursor
  72407. */
  72408. private raiseOnChange;
  72409. /**
  72410. * Executes a function on change
  72411. * @param f A path cursor onchange callback
  72412. * @returns This path cursor
  72413. */
  72414. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72415. }
  72416. }
  72417. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  72418. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  72419. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  72420. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  72421. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  72422. }
  72423. declare module "babylonjs/Engines/Processors/Expressions/index" {
  72424. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  72425. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  72426. }
  72427. declare module "babylonjs/Engines/Processors/index" {
  72428. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  72429. export * from "babylonjs/Engines/Processors/Expressions/index";
  72430. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  72431. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  72432. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  72433. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  72434. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  72435. export * from "babylonjs/Engines/Processors/shaderProcessor";
  72436. }
  72437. declare module "babylonjs/Legacy/legacy" {
  72438. import * as Babylon from "babylonjs/index";
  72439. export * from "babylonjs/index";
  72440. }
  72441. declare module "babylonjs/Shaders/blur.fragment" {
  72442. /** @hidden */
  72443. export var blurPixelShader: {
  72444. name: string;
  72445. shader: string;
  72446. };
  72447. }
  72448. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  72449. /** @hidden */
  72450. export var pointCloudVertexDeclaration: {
  72451. name: string;
  72452. shader: string;
  72453. };
  72454. }
  72455. declare module "babylonjs" {
  72456. export * from "babylonjs/Legacy/legacy";
  72457. }
  72458. declare module BABYLON {
  72459. /** Alias type for value that can be null */
  72460. export type Nullable<T> = T | null;
  72461. /**
  72462. * Alias type for number that are floats
  72463. * @ignorenaming
  72464. */
  72465. export type float = number;
  72466. /**
  72467. * Alias type for number that are doubles.
  72468. * @ignorenaming
  72469. */
  72470. export type double = number;
  72471. /**
  72472. * Alias type for number that are integer
  72473. * @ignorenaming
  72474. */
  72475. export type int = number;
  72476. /** Alias type for number array or Float32Array */
  72477. export type FloatArray = number[] | Float32Array;
  72478. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  72479. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  72480. /**
  72481. * Alias for types that can be used by a Buffer or VertexBuffer.
  72482. */
  72483. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  72484. /**
  72485. * Alias type for primitive types
  72486. * @ignorenaming
  72487. */
  72488. type Primitive = undefined | null | boolean | string | number | Function;
  72489. /**
  72490. * Type modifier to make all the properties of an object Readonly
  72491. */
  72492. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  72493. /**
  72494. * Type modifier to make all the properties of an object Readonly recursively
  72495. */
  72496. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  72497. /**
  72498. * Type modifier to make object properties readonly.
  72499. */
  72500. export type DeepImmutableObject<T> = {
  72501. readonly [K in keyof T]: DeepImmutable<T[K]>;
  72502. };
  72503. /** @hidden */
  72504. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  72505. }
  72506. }
  72507. declare module BABYLON {
  72508. /**
  72509. * A class serves as a medium between the observable and its observers
  72510. */
  72511. export class EventState {
  72512. /**
  72513. * Create a new EventState
  72514. * @param mask defines the mask associated with this state
  72515. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72516. * @param target defines the original target of the state
  72517. * @param currentTarget defines the current target of the state
  72518. */
  72519. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  72520. /**
  72521. * Initialize the current event state
  72522. * @param mask defines the mask associated with this state
  72523. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72524. * @param target defines the original target of the state
  72525. * @param currentTarget defines the current target of the state
  72526. * @returns the current event state
  72527. */
  72528. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72529. /**
  72530. * An Observer can set this property to true to prevent subsequent observers of being notified
  72531. */
  72532. skipNextObservers: boolean;
  72533. /**
  72534. * Get the mask value that were used to trigger the event corresponding to this EventState object
  72535. */
  72536. mask: number;
  72537. /**
  72538. * The object that originally notified the event
  72539. */
  72540. target?: any;
  72541. /**
  72542. * The current object in the bubbling phase
  72543. */
  72544. currentTarget?: any;
  72545. /**
  72546. * This will be populated with the return value of the last function that was executed.
  72547. * If it is the first function in the callback chain it will be the event data.
  72548. */
  72549. lastReturnValue?: any;
  72550. }
  72551. /**
  72552. * Represent an Observer registered to a given Observable object.
  72553. */
  72554. export class Observer<T> {
  72555. /**
  72556. * Defines the callback to call when the observer is notified
  72557. */
  72558. callback: (eventData: T, eventState: EventState) => void;
  72559. /**
  72560. * Defines the mask of the observer (used to filter notifications)
  72561. */
  72562. mask: number;
  72563. /**
  72564. * Defines the current scope used to restore the JS context
  72565. */
  72566. scope: any;
  72567. /** @hidden */
  72568. _willBeUnregistered: boolean;
  72569. /**
  72570. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  72571. */
  72572. unregisterOnNextCall: boolean;
  72573. /**
  72574. * Creates a new observer
  72575. * @param callback defines the callback to call when the observer is notified
  72576. * @param mask defines the mask of the observer (used to filter notifications)
  72577. * @param scope defines the current scope used to restore the JS context
  72578. */
  72579. constructor(
  72580. /**
  72581. * Defines the callback to call when the observer is notified
  72582. */
  72583. callback: (eventData: T, eventState: EventState) => void,
  72584. /**
  72585. * Defines the mask of the observer (used to filter notifications)
  72586. */
  72587. mask: number,
  72588. /**
  72589. * Defines the current scope used to restore the JS context
  72590. */
  72591. scope?: any);
  72592. }
  72593. /**
  72594. * Represent a list of observers registered to multiple Observables object.
  72595. */
  72596. export class MultiObserver<T> {
  72597. private _observers;
  72598. private _observables;
  72599. /**
  72600. * Release associated resources
  72601. */
  72602. dispose(): void;
  72603. /**
  72604. * Raise a callback when one of the observable will notify
  72605. * @param observables defines a list of observables to watch
  72606. * @param callback defines the callback to call on notification
  72607. * @param mask defines the mask used to filter notifications
  72608. * @param scope defines the current scope used to restore the JS context
  72609. * @returns the new MultiObserver
  72610. */
  72611. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  72612. }
  72613. /**
  72614. * The Observable class is a simple implementation of the Observable pattern.
  72615. *
  72616. * 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.
  72617. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  72618. * 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).
  72619. * 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.
  72620. */
  72621. export class Observable<T> {
  72622. private _observers;
  72623. private _eventState;
  72624. private _onObserverAdded;
  72625. /**
  72626. * Gets the list of observers
  72627. */
  72628. get observers(): Array<Observer<T>>;
  72629. /**
  72630. * Creates a new observable
  72631. * @param onObserverAdded defines a callback to call when a new observer is added
  72632. */
  72633. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  72634. /**
  72635. * Create a new Observer with the specified callback
  72636. * @param callback the callback that will be executed for that Observer
  72637. * @param mask the mask used to filter observers
  72638. * @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.
  72639. * @param scope optional scope for the callback to be called from
  72640. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  72641. * @returns the new observer created for the callback
  72642. */
  72643. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  72644. /**
  72645. * Create a new Observer with the specified callback and unregisters after the next notification
  72646. * @param callback the callback that will be executed for that Observer
  72647. * @returns the new observer created for the callback
  72648. */
  72649. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  72650. /**
  72651. * Remove an Observer from the Observable object
  72652. * @param observer the instance of the Observer to remove
  72653. * @returns false if it doesn't belong to this Observable
  72654. */
  72655. remove(observer: Nullable<Observer<T>>): boolean;
  72656. /**
  72657. * Remove a callback from the Observable object
  72658. * @param callback the callback to remove
  72659. * @param scope optional scope. If used only the callbacks with this scope will be removed
  72660. * @returns false if it doesn't belong to this Observable
  72661. */
  72662. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  72663. private _deferUnregister;
  72664. private _remove;
  72665. /**
  72666. * Moves the observable to the top of the observer list making it get called first when notified
  72667. * @param observer the observer to move
  72668. */
  72669. makeObserverTopPriority(observer: Observer<T>): void;
  72670. /**
  72671. * Moves the observable to the bottom of the observer list making it get called last when notified
  72672. * @param observer the observer to move
  72673. */
  72674. makeObserverBottomPriority(observer: Observer<T>): void;
  72675. /**
  72676. * Notify all Observers by calling their respective callback with the given data
  72677. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  72678. * @param eventData defines the data to send to all observers
  72679. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  72680. * @param target defines the original target of the state
  72681. * @param currentTarget defines the current target of the state
  72682. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  72683. */
  72684. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  72685. /**
  72686. * Calling this will execute each callback, expecting it to be a promise or return a value.
  72687. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  72688. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  72689. * and it is crucial that all callbacks will be executed.
  72690. * The order of the callbacks is kept, callbacks are not executed parallel.
  72691. *
  72692. * @param eventData The data to be sent to each callback
  72693. * @param mask is used to filter observers defaults to -1
  72694. * @param target defines the callback target (see EventState)
  72695. * @param currentTarget defines he current object in the bubbling phase
  72696. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  72697. */
  72698. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  72699. /**
  72700. * Notify a specific observer
  72701. * @param observer defines the observer to notify
  72702. * @param eventData defines the data to be sent to each callback
  72703. * @param mask is used to filter observers defaults to -1
  72704. */
  72705. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  72706. /**
  72707. * Gets a boolean indicating if the observable has at least one observer
  72708. * @returns true is the Observable has at least one Observer registered
  72709. */
  72710. hasObservers(): boolean;
  72711. /**
  72712. * Clear the list of observers
  72713. */
  72714. clear(): void;
  72715. /**
  72716. * Clone the current observable
  72717. * @returns a new observable
  72718. */
  72719. clone(): Observable<T>;
  72720. /**
  72721. * Does this observable handles observer registered with a given mask
  72722. * @param mask defines the mask to be tested
  72723. * @return whether or not one observer registered with the given mask is handeled
  72724. **/
  72725. hasSpecificMask(mask?: number): boolean;
  72726. }
  72727. }
  72728. declare module BABYLON {
  72729. /**
  72730. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  72731. * Babylon.js
  72732. */
  72733. export class DomManagement {
  72734. /**
  72735. * Checks if the window object exists
  72736. * @returns true if the window object exists
  72737. */
  72738. static IsWindowObjectExist(): boolean;
  72739. /**
  72740. * Checks if the navigator object exists
  72741. * @returns true if the navigator object exists
  72742. */
  72743. static IsNavigatorAvailable(): boolean;
  72744. /**
  72745. * Extracts text content from a DOM element hierarchy
  72746. * @param element defines the root element
  72747. * @returns a string
  72748. */
  72749. static GetDOMTextContent(element: HTMLElement): string;
  72750. }
  72751. }
  72752. declare module BABYLON {
  72753. /**
  72754. * Logger used througouht the application to allow configuration of
  72755. * the log level required for the messages.
  72756. */
  72757. export class Logger {
  72758. /**
  72759. * No log
  72760. */
  72761. static readonly NoneLogLevel: number;
  72762. /**
  72763. * Only message logs
  72764. */
  72765. static readonly MessageLogLevel: number;
  72766. /**
  72767. * Only warning logs
  72768. */
  72769. static readonly WarningLogLevel: number;
  72770. /**
  72771. * Only error logs
  72772. */
  72773. static readonly ErrorLogLevel: number;
  72774. /**
  72775. * All logs
  72776. */
  72777. static readonly AllLogLevel: number;
  72778. private static _LogCache;
  72779. /**
  72780. * Gets a value indicating the number of loading errors
  72781. * @ignorenaming
  72782. */
  72783. static errorsCount: number;
  72784. /**
  72785. * Callback called when a new log is added
  72786. */
  72787. static OnNewCacheEntry: (entry: string) => void;
  72788. private static _AddLogEntry;
  72789. private static _FormatMessage;
  72790. private static _LogDisabled;
  72791. private static _LogEnabled;
  72792. private static _WarnDisabled;
  72793. private static _WarnEnabled;
  72794. private static _ErrorDisabled;
  72795. private static _ErrorEnabled;
  72796. /**
  72797. * Log a message to the console
  72798. */
  72799. static Log: (message: string) => void;
  72800. /**
  72801. * Write a warning message to the console
  72802. */
  72803. static Warn: (message: string) => void;
  72804. /**
  72805. * Write an error message to the console
  72806. */
  72807. static Error: (message: string) => void;
  72808. /**
  72809. * Gets current log cache (list of logs)
  72810. */
  72811. static get LogCache(): string;
  72812. /**
  72813. * Clears the log cache
  72814. */
  72815. static ClearLogCache(): void;
  72816. /**
  72817. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  72818. */
  72819. static set LogLevels(level: number);
  72820. }
  72821. }
  72822. declare module BABYLON {
  72823. /** @hidden */
  72824. export class _TypeStore {
  72825. /** @hidden */
  72826. static RegisteredTypes: {
  72827. [key: string]: Object;
  72828. };
  72829. /** @hidden */
  72830. static GetClass(fqdn: string): any;
  72831. }
  72832. }
  72833. declare module BABYLON {
  72834. /**
  72835. * Helper to manipulate strings
  72836. */
  72837. export class StringTools {
  72838. /**
  72839. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  72840. * @param str Source string
  72841. * @param suffix Suffix to search for in the source string
  72842. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  72843. */
  72844. static EndsWith(str: string, suffix: string): boolean;
  72845. /**
  72846. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  72847. * @param str Source string
  72848. * @param suffix Suffix to search for in the source string
  72849. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  72850. */
  72851. static StartsWith(str: string, suffix: string): boolean;
  72852. /**
  72853. * Decodes a buffer into a string
  72854. * @param buffer The buffer to decode
  72855. * @returns The decoded string
  72856. */
  72857. static Decode(buffer: Uint8Array | Uint16Array): string;
  72858. /**
  72859. * Encode a buffer to a base64 string
  72860. * @param buffer defines the buffer to encode
  72861. * @returns the encoded string
  72862. */
  72863. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  72864. }
  72865. }
  72866. declare module BABYLON {
  72867. /**
  72868. * Class containing a set of static utilities functions for deep copy.
  72869. */
  72870. export class DeepCopier {
  72871. /**
  72872. * Tries to copy an object by duplicating every property
  72873. * @param source defines the source object
  72874. * @param destination defines the target object
  72875. * @param doNotCopyList defines a list of properties to avoid
  72876. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  72877. */
  72878. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  72879. }
  72880. }
  72881. declare module BABYLON {
  72882. /**
  72883. * Class containing a set of static utilities functions for precision date
  72884. */
  72885. export class PrecisionDate {
  72886. /**
  72887. * Gets either window.performance.now() if supported or Date.now() else
  72888. */
  72889. static get Now(): number;
  72890. }
  72891. }
  72892. declare module BABYLON {
  72893. /** @hidden */
  72894. export class _DevTools {
  72895. static WarnImport(name: string): string;
  72896. }
  72897. }
  72898. declare module BABYLON {
  72899. /**
  72900. * Interface used to define the mechanism to get data from the network
  72901. */
  72902. export interface IWebRequest {
  72903. /**
  72904. * Returns client's response url
  72905. */
  72906. responseURL: string;
  72907. /**
  72908. * Returns client's status
  72909. */
  72910. status: number;
  72911. /**
  72912. * Returns client's status as a text
  72913. */
  72914. statusText: string;
  72915. }
  72916. }
  72917. declare module BABYLON {
  72918. /**
  72919. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  72920. */
  72921. export class WebRequest implements IWebRequest {
  72922. private _xhr;
  72923. /**
  72924. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  72925. * i.e. when loading files, where the server/service expects an Authorization header
  72926. */
  72927. static CustomRequestHeaders: {
  72928. [key: string]: string;
  72929. };
  72930. /**
  72931. * Add callback functions in this array to update all the requests before they get sent to the network
  72932. */
  72933. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  72934. private _injectCustomRequestHeaders;
  72935. /**
  72936. * Gets or sets a function to be called when loading progress changes
  72937. */
  72938. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  72939. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  72940. /**
  72941. * Returns client's state
  72942. */
  72943. get readyState(): number;
  72944. /**
  72945. * Returns client's status
  72946. */
  72947. get status(): number;
  72948. /**
  72949. * Returns client's status as a text
  72950. */
  72951. get statusText(): string;
  72952. /**
  72953. * Returns client's response
  72954. */
  72955. get response(): any;
  72956. /**
  72957. * Returns client's response url
  72958. */
  72959. get responseURL(): string;
  72960. /**
  72961. * Returns client's response as text
  72962. */
  72963. get responseText(): string;
  72964. /**
  72965. * Gets or sets the expected response type
  72966. */
  72967. get responseType(): XMLHttpRequestResponseType;
  72968. set responseType(value: XMLHttpRequestResponseType);
  72969. /** @hidden */
  72970. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  72971. /** @hidden */
  72972. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  72973. /**
  72974. * Cancels any network activity
  72975. */
  72976. abort(): void;
  72977. /**
  72978. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  72979. * @param body defines an optional request body
  72980. */
  72981. send(body?: Document | BodyInit | null): void;
  72982. /**
  72983. * Sets the request method, request URL
  72984. * @param method defines the method to use (GET, POST, etc..)
  72985. * @param url defines the url to connect with
  72986. */
  72987. open(method: string, url: string): void;
  72988. /**
  72989. * Sets the value of a request header.
  72990. * @param name The name of the header whose value is to be set
  72991. * @param value The value to set as the body of the header
  72992. */
  72993. setRequestHeader(name: string, value: string): void;
  72994. /**
  72995. * Get the string containing the text of a particular header's value.
  72996. * @param name The name of the header
  72997. * @returns The string containing the text of the given header name
  72998. */
  72999. getResponseHeader(name: string): Nullable<string>;
  73000. }
  73001. }
  73002. declare module BABYLON {
  73003. /**
  73004. * File request interface
  73005. */
  73006. export interface IFileRequest {
  73007. /**
  73008. * Raised when the request is complete (success or error).
  73009. */
  73010. onCompleteObservable: Observable<IFileRequest>;
  73011. /**
  73012. * Aborts the request for a file.
  73013. */
  73014. abort: () => void;
  73015. }
  73016. }
  73017. declare module BABYLON {
  73018. /**
  73019. * Define options used to create a render target texture
  73020. */
  73021. export class RenderTargetCreationOptions {
  73022. /**
  73023. * Specifies is mipmaps must be generated
  73024. */
  73025. generateMipMaps?: boolean;
  73026. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73027. generateDepthBuffer?: boolean;
  73028. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73029. generateStencilBuffer?: boolean;
  73030. /** Defines texture type (int by default) */
  73031. type?: number;
  73032. /** Defines sampling mode (trilinear by default) */
  73033. samplingMode?: number;
  73034. /** Defines format (RGBA by default) */
  73035. format?: number;
  73036. }
  73037. }
  73038. declare module BABYLON {
  73039. /**
  73040. * @hidden
  73041. **/
  73042. export class _TimeToken {
  73043. _startTimeQuery: Nullable<WebGLQuery>;
  73044. _endTimeQuery: Nullable<WebGLQuery>;
  73045. _timeElapsedQuery: Nullable<WebGLQuery>;
  73046. _timeElapsedQueryEnded: boolean;
  73047. }
  73048. }
  73049. declare module BABYLON {
  73050. /** Defines the cross module used constants to avoid circular dependncies */
  73051. export class Constants {
  73052. /** Defines that alpha blending is disabled */
  73053. static readonly ALPHA_DISABLE: number;
  73054. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73055. static readonly ALPHA_ADD: number;
  73056. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73057. static readonly ALPHA_COMBINE: number;
  73058. /** Defines that alpha blending is DEST - SRC * DEST */
  73059. static readonly ALPHA_SUBTRACT: number;
  73060. /** Defines that alpha blending is SRC * DEST */
  73061. static readonly ALPHA_MULTIPLY: number;
  73062. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73063. static readonly ALPHA_MAXIMIZED: number;
  73064. /** Defines that alpha blending is SRC + DEST */
  73065. static readonly ALPHA_ONEONE: number;
  73066. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73067. static readonly ALPHA_PREMULTIPLIED: number;
  73068. /**
  73069. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73070. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73071. */
  73072. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73073. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73074. static readonly ALPHA_INTERPOLATE: number;
  73075. /**
  73076. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73077. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73078. */
  73079. static readonly ALPHA_SCREENMODE: number;
  73080. /**
  73081. * Defines that alpha blending is SRC + DST
  73082. * Alpha will be set to SRC ALPHA + DST ALPHA
  73083. */
  73084. static readonly ALPHA_ONEONE_ONEONE: number;
  73085. /**
  73086. * Defines that alpha blending is SRC * DST ALPHA + DST
  73087. * Alpha will be set to 0
  73088. */
  73089. static readonly ALPHA_ALPHATOCOLOR: number;
  73090. /**
  73091. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73092. */
  73093. static readonly ALPHA_REVERSEONEMINUS: number;
  73094. /**
  73095. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73096. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73097. */
  73098. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73099. /**
  73100. * Defines that alpha blending is SRC + DST
  73101. * Alpha will be set to SRC ALPHA
  73102. */
  73103. static readonly ALPHA_ONEONE_ONEZERO: number;
  73104. /**
  73105. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73106. * Alpha will be set to DST ALPHA
  73107. */
  73108. static readonly ALPHA_EXCLUSION: number;
  73109. /** Defines that alpha blending equation a SUM */
  73110. static readonly ALPHA_EQUATION_ADD: number;
  73111. /** Defines that alpha blending equation a SUBSTRACTION */
  73112. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73113. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73114. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73115. /** Defines that alpha blending equation a MAX operation */
  73116. static readonly ALPHA_EQUATION_MAX: number;
  73117. /** Defines that alpha blending equation a MIN operation */
  73118. static readonly ALPHA_EQUATION_MIN: number;
  73119. /**
  73120. * Defines that alpha blending equation a DARKEN operation:
  73121. * It takes the min of the src and sums the alpha channels.
  73122. */
  73123. static readonly ALPHA_EQUATION_DARKEN: number;
  73124. /** Defines that the ressource is not delayed*/
  73125. static readonly DELAYLOADSTATE_NONE: number;
  73126. /** Defines that the ressource was successfully delay loaded */
  73127. static readonly DELAYLOADSTATE_LOADED: number;
  73128. /** Defines that the ressource is currently delay loading */
  73129. static readonly DELAYLOADSTATE_LOADING: number;
  73130. /** Defines that the ressource is delayed and has not started loading */
  73131. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73133. static readonly NEVER: number;
  73134. /** 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 */
  73135. static readonly ALWAYS: number;
  73136. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73137. static readonly LESS: number;
  73138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73139. static readonly EQUAL: number;
  73140. /** 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 */
  73141. static readonly LEQUAL: number;
  73142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73143. static readonly GREATER: number;
  73144. /** 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 */
  73145. static readonly GEQUAL: number;
  73146. /** 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 */
  73147. static readonly NOTEQUAL: number;
  73148. /** Passed to stencilOperation to specify that stencil value must be kept */
  73149. static readonly KEEP: number;
  73150. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73151. static readonly REPLACE: number;
  73152. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73153. static readonly INCR: number;
  73154. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73155. static readonly DECR: number;
  73156. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73157. static readonly INVERT: number;
  73158. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73159. static readonly INCR_WRAP: number;
  73160. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73161. static readonly DECR_WRAP: number;
  73162. /** Texture is not repeating outside of 0..1 UVs */
  73163. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73164. /** Texture is repeating outside of 0..1 UVs */
  73165. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73166. /** Texture is repeating and mirrored */
  73167. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73168. /** ALPHA */
  73169. static readonly TEXTUREFORMAT_ALPHA: number;
  73170. /** LUMINANCE */
  73171. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73172. /** LUMINANCE_ALPHA */
  73173. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73174. /** RGB */
  73175. static readonly TEXTUREFORMAT_RGB: number;
  73176. /** RGBA */
  73177. static readonly TEXTUREFORMAT_RGBA: number;
  73178. /** RED */
  73179. static readonly TEXTUREFORMAT_RED: number;
  73180. /** RED (2nd reference) */
  73181. static readonly TEXTUREFORMAT_R: number;
  73182. /** RG */
  73183. static readonly TEXTUREFORMAT_RG: number;
  73184. /** RED_INTEGER */
  73185. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73186. /** RED_INTEGER (2nd reference) */
  73187. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73188. /** RG_INTEGER */
  73189. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73190. /** RGB_INTEGER */
  73191. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73192. /** RGBA_INTEGER */
  73193. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73194. /** UNSIGNED_BYTE */
  73195. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73196. /** UNSIGNED_BYTE (2nd reference) */
  73197. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73198. /** FLOAT */
  73199. static readonly TEXTURETYPE_FLOAT: number;
  73200. /** HALF_FLOAT */
  73201. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73202. /** BYTE */
  73203. static readonly TEXTURETYPE_BYTE: number;
  73204. /** SHORT */
  73205. static readonly TEXTURETYPE_SHORT: number;
  73206. /** UNSIGNED_SHORT */
  73207. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73208. /** INT */
  73209. static readonly TEXTURETYPE_INT: number;
  73210. /** UNSIGNED_INT */
  73211. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73212. /** UNSIGNED_SHORT_4_4_4_4 */
  73213. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73214. /** UNSIGNED_SHORT_5_5_5_1 */
  73215. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73216. /** UNSIGNED_SHORT_5_6_5 */
  73217. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73218. /** UNSIGNED_INT_2_10_10_10_REV */
  73219. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73220. /** UNSIGNED_INT_24_8 */
  73221. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73222. /** UNSIGNED_INT_10F_11F_11F_REV */
  73223. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73224. /** UNSIGNED_INT_5_9_9_9_REV */
  73225. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73226. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73227. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73228. /** nearest is mag = nearest and min = nearest and no mip */
  73229. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73230. /** mag = nearest and min = nearest and mip = none */
  73231. static readonly TEXTURE_NEAREST_NEAREST: number;
  73232. /** Bilinear is mag = linear and min = linear and no mip */
  73233. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73234. /** mag = linear and min = linear and mip = none */
  73235. static readonly TEXTURE_LINEAR_LINEAR: number;
  73236. /** Trilinear is mag = linear and min = linear and mip = linear */
  73237. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73238. /** Trilinear is mag = linear and min = linear and mip = linear */
  73239. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  73240. /** mag = nearest and min = nearest and mip = nearest */
  73241. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  73242. /** mag = nearest and min = linear and mip = nearest */
  73243. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  73244. /** mag = nearest and min = linear and mip = linear */
  73245. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  73246. /** mag = nearest and min = linear and mip = none */
  73247. static readonly TEXTURE_NEAREST_LINEAR: number;
  73248. /** nearest is mag = nearest and min = nearest and mip = linear */
  73249. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  73250. /** mag = linear and min = nearest and mip = nearest */
  73251. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  73252. /** mag = linear and min = nearest and mip = linear */
  73253. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  73254. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73255. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  73256. /** mag = linear and min = nearest and mip = none */
  73257. static readonly TEXTURE_LINEAR_NEAREST: number;
  73258. /** Explicit coordinates mode */
  73259. static readonly TEXTURE_EXPLICIT_MODE: number;
  73260. /** Spherical coordinates mode */
  73261. static readonly TEXTURE_SPHERICAL_MODE: number;
  73262. /** Planar coordinates mode */
  73263. static readonly TEXTURE_PLANAR_MODE: number;
  73264. /** Cubic coordinates mode */
  73265. static readonly TEXTURE_CUBIC_MODE: number;
  73266. /** Projection coordinates mode */
  73267. static readonly TEXTURE_PROJECTION_MODE: number;
  73268. /** Skybox coordinates mode */
  73269. static readonly TEXTURE_SKYBOX_MODE: number;
  73270. /** Inverse Cubic coordinates mode */
  73271. static readonly TEXTURE_INVCUBIC_MODE: number;
  73272. /** Equirectangular coordinates mode */
  73273. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  73274. /** Equirectangular Fixed coordinates mode */
  73275. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  73276. /** Equirectangular Fixed Mirrored coordinates mode */
  73277. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73278. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  73279. static readonly SCALEMODE_FLOOR: number;
  73280. /** Defines that texture rescaling will look for the nearest power of 2 size */
  73281. static readonly SCALEMODE_NEAREST: number;
  73282. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  73283. static readonly SCALEMODE_CEILING: number;
  73284. /**
  73285. * The dirty texture flag value
  73286. */
  73287. static readonly MATERIAL_TextureDirtyFlag: number;
  73288. /**
  73289. * The dirty light flag value
  73290. */
  73291. static readonly MATERIAL_LightDirtyFlag: number;
  73292. /**
  73293. * The dirty fresnel flag value
  73294. */
  73295. static readonly MATERIAL_FresnelDirtyFlag: number;
  73296. /**
  73297. * The dirty attribute flag value
  73298. */
  73299. static readonly MATERIAL_AttributesDirtyFlag: number;
  73300. /**
  73301. * The dirty misc flag value
  73302. */
  73303. static readonly MATERIAL_MiscDirtyFlag: number;
  73304. /**
  73305. * The all dirty flag value
  73306. */
  73307. static readonly MATERIAL_AllDirtyFlag: number;
  73308. /**
  73309. * Returns the triangle fill mode
  73310. */
  73311. static readonly MATERIAL_TriangleFillMode: number;
  73312. /**
  73313. * Returns the wireframe mode
  73314. */
  73315. static readonly MATERIAL_WireFrameFillMode: number;
  73316. /**
  73317. * Returns the point fill mode
  73318. */
  73319. static readonly MATERIAL_PointFillMode: number;
  73320. /**
  73321. * Returns the point list draw mode
  73322. */
  73323. static readonly MATERIAL_PointListDrawMode: number;
  73324. /**
  73325. * Returns the line list draw mode
  73326. */
  73327. static readonly MATERIAL_LineListDrawMode: number;
  73328. /**
  73329. * Returns the line loop draw mode
  73330. */
  73331. static readonly MATERIAL_LineLoopDrawMode: number;
  73332. /**
  73333. * Returns the line strip draw mode
  73334. */
  73335. static readonly MATERIAL_LineStripDrawMode: number;
  73336. /**
  73337. * Returns the triangle strip draw mode
  73338. */
  73339. static readonly MATERIAL_TriangleStripDrawMode: number;
  73340. /**
  73341. * Returns the triangle fan draw mode
  73342. */
  73343. static readonly MATERIAL_TriangleFanDrawMode: number;
  73344. /**
  73345. * Stores the clock-wise side orientation
  73346. */
  73347. static readonly MATERIAL_ClockWiseSideOrientation: number;
  73348. /**
  73349. * Stores the counter clock-wise side orientation
  73350. */
  73351. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  73352. /**
  73353. * Nothing
  73354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73355. */
  73356. static readonly ACTION_NothingTrigger: number;
  73357. /**
  73358. * On pick
  73359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73360. */
  73361. static readonly ACTION_OnPickTrigger: number;
  73362. /**
  73363. * On left pick
  73364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73365. */
  73366. static readonly ACTION_OnLeftPickTrigger: number;
  73367. /**
  73368. * On right pick
  73369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73370. */
  73371. static readonly ACTION_OnRightPickTrigger: number;
  73372. /**
  73373. * On center pick
  73374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73375. */
  73376. static readonly ACTION_OnCenterPickTrigger: number;
  73377. /**
  73378. * On pick down
  73379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73380. */
  73381. static readonly ACTION_OnPickDownTrigger: number;
  73382. /**
  73383. * On double pick
  73384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73385. */
  73386. static readonly ACTION_OnDoublePickTrigger: number;
  73387. /**
  73388. * On pick up
  73389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73390. */
  73391. static readonly ACTION_OnPickUpTrigger: number;
  73392. /**
  73393. * On pick out.
  73394. * This trigger will only be raised if you also declared a OnPickDown
  73395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73396. */
  73397. static readonly ACTION_OnPickOutTrigger: number;
  73398. /**
  73399. * On long press
  73400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73401. */
  73402. static readonly ACTION_OnLongPressTrigger: number;
  73403. /**
  73404. * On pointer over
  73405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73406. */
  73407. static readonly ACTION_OnPointerOverTrigger: number;
  73408. /**
  73409. * On pointer out
  73410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73411. */
  73412. static readonly ACTION_OnPointerOutTrigger: number;
  73413. /**
  73414. * On every frame
  73415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73416. */
  73417. static readonly ACTION_OnEveryFrameTrigger: number;
  73418. /**
  73419. * On intersection enter
  73420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73421. */
  73422. static readonly ACTION_OnIntersectionEnterTrigger: number;
  73423. /**
  73424. * On intersection exit
  73425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73426. */
  73427. static readonly ACTION_OnIntersectionExitTrigger: number;
  73428. /**
  73429. * On key down
  73430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73431. */
  73432. static readonly ACTION_OnKeyDownTrigger: number;
  73433. /**
  73434. * On key up
  73435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73436. */
  73437. static readonly ACTION_OnKeyUpTrigger: number;
  73438. /**
  73439. * Billboard mode will only apply to Y axis
  73440. */
  73441. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  73442. /**
  73443. * Billboard mode will apply to all axes
  73444. */
  73445. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  73446. /**
  73447. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73448. */
  73449. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  73450. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  73451. * Test order :
  73452. * Is the bounding sphere outside the frustum ?
  73453. * If not, are the bounding box vertices outside the frustum ?
  73454. * It not, then the cullable object is in the frustum.
  73455. */
  73456. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  73457. /** Culling strategy : Bounding Sphere Only.
  73458. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  73459. * It's also less accurate than the standard because some not visible objects can still be selected.
  73460. * Test : is the bounding sphere outside the frustum ?
  73461. * If not, then the cullable object is in the frustum.
  73462. */
  73463. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  73464. /** Culling strategy : Optimistic Inclusion.
  73465. * This in an inclusion test first, then the standard exclusion test.
  73466. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  73467. * 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.
  73468. * Anyway, it's as accurate as the standard strategy.
  73469. * Test :
  73470. * Is the cullable object bounding sphere center in the frustum ?
  73471. * If not, apply the default culling strategy.
  73472. */
  73473. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  73474. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  73475. * This in an inclusion test first, then the bounding sphere only exclusion test.
  73476. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  73477. * 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.
  73478. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  73479. * Test :
  73480. * Is the cullable object bounding sphere center in the frustum ?
  73481. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  73482. */
  73483. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  73484. /**
  73485. * No logging while loading
  73486. */
  73487. static readonly SCENELOADER_NO_LOGGING: number;
  73488. /**
  73489. * Minimal logging while loading
  73490. */
  73491. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  73492. /**
  73493. * Summary logging while loading
  73494. */
  73495. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  73496. /**
  73497. * Detailled logging while loading
  73498. */
  73499. static readonly SCENELOADER_DETAILED_LOGGING: number;
  73500. }
  73501. }
  73502. declare module BABYLON {
  73503. /**
  73504. * This represents the required contract to create a new type of texture loader.
  73505. */
  73506. export interface IInternalTextureLoader {
  73507. /**
  73508. * Defines wether the loader supports cascade loading the different faces.
  73509. */
  73510. supportCascades: boolean;
  73511. /**
  73512. * This returns if the loader support the current file information.
  73513. * @param extension defines the file extension of the file being loaded
  73514. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73515. * @param fallback defines the fallback internal texture if any
  73516. * @param isBase64 defines whether the texture is encoded as a base64
  73517. * @param isBuffer defines whether the texture data are stored as a buffer
  73518. * @returns true if the loader can load the specified file
  73519. */
  73520. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73521. /**
  73522. * Transform the url before loading if required.
  73523. * @param rootUrl the url of the texture
  73524. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73525. * @returns the transformed texture
  73526. */
  73527. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73528. /**
  73529. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73530. * @param rootUrl the url of the texture
  73531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73532. * @returns the fallback texture
  73533. */
  73534. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73535. /**
  73536. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73537. * @param data contains the texture data
  73538. * @param texture defines the BabylonJS internal texture
  73539. * @param createPolynomials will be true if polynomials have been requested
  73540. * @param onLoad defines the callback to trigger once the texture is ready
  73541. * @param onError defines the callback to trigger in case of error
  73542. */
  73543. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73544. /**
  73545. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73546. * @param data contains the texture data
  73547. * @param texture defines the BabylonJS internal texture
  73548. * @param callback defines the method to call once ready to upload
  73549. */
  73550. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73551. }
  73552. }
  73553. declare module BABYLON {
  73554. /**
  73555. * Class used to store and describe the pipeline context associated with an effect
  73556. */
  73557. export interface IPipelineContext {
  73558. /**
  73559. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  73560. */
  73561. isAsync: boolean;
  73562. /**
  73563. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  73564. */
  73565. isReady: boolean;
  73566. /** @hidden */
  73567. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  73568. }
  73569. }
  73570. declare module BABYLON {
  73571. /**
  73572. * Class used to store gfx data (like WebGLBuffer)
  73573. */
  73574. export class DataBuffer {
  73575. /**
  73576. * Gets or sets the number of objects referencing this buffer
  73577. */
  73578. references: number;
  73579. /** Gets or sets the size of the underlying buffer */
  73580. capacity: number;
  73581. /**
  73582. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  73583. */
  73584. is32Bits: boolean;
  73585. /**
  73586. * Gets the underlying buffer
  73587. */
  73588. get underlyingResource(): any;
  73589. }
  73590. }
  73591. declare module BABYLON {
  73592. /** @hidden */
  73593. export interface IShaderProcessor {
  73594. attributeProcessor?: (attribute: string) => string;
  73595. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  73596. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  73597. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  73598. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  73599. lineProcessor?: (line: string, isFragment: boolean) => string;
  73600. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73601. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73602. }
  73603. }
  73604. declare module BABYLON {
  73605. /** @hidden */
  73606. export interface ProcessingOptions {
  73607. defines: string[];
  73608. indexParameters: any;
  73609. isFragment: boolean;
  73610. shouldUseHighPrecisionShader: boolean;
  73611. supportsUniformBuffers: boolean;
  73612. shadersRepository: string;
  73613. includesShadersStore: {
  73614. [key: string]: string;
  73615. };
  73616. processor?: IShaderProcessor;
  73617. version: string;
  73618. platformName: string;
  73619. lookForClosingBracketForUniformBuffer?: boolean;
  73620. }
  73621. }
  73622. declare module BABYLON {
  73623. /** @hidden */
  73624. export class ShaderCodeNode {
  73625. line: string;
  73626. children: ShaderCodeNode[];
  73627. additionalDefineKey?: string;
  73628. additionalDefineValue?: string;
  73629. isValid(preprocessors: {
  73630. [key: string]: string;
  73631. }): boolean;
  73632. process(preprocessors: {
  73633. [key: string]: string;
  73634. }, options: ProcessingOptions): string;
  73635. }
  73636. }
  73637. declare module BABYLON {
  73638. /** @hidden */
  73639. export class ShaderCodeCursor {
  73640. private _lines;
  73641. lineIndex: number;
  73642. get currentLine(): string;
  73643. get canRead(): boolean;
  73644. set lines(value: string[]);
  73645. }
  73646. }
  73647. declare module BABYLON {
  73648. /** @hidden */
  73649. export class ShaderCodeConditionNode extends ShaderCodeNode {
  73650. process(preprocessors: {
  73651. [key: string]: string;
  73652. }, options: ProcessingOptions): string;
  73653. }
  73654. }
  73655. declare module BABYLON {
  73656. /** @hidden */
  73657. export class ShaderDefineExpression {
  73658. isTrue(preprocessors: {
  73659. [key: string]: string;
  73660. }): boolean;
  73661. }
  73662. }
  73663. declare module BABYLON {
  73664. /** @hidden */
  73665. export class ShaderCodeTestNode extends ShaderCodeNode {
  73666. testExpression: ShaderDefineExpression;
  73667. isValid(preprocessors: {
  73668. [key: string]: string;
  73669. }): boolean;
  73670. }
  73671. }
  73672. declare module BABYLON {
  73673. /** @hidden */
  73674. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  73675. define: string;
  73676. not: boolean;
  73677. constructor(define: string, not?: boolean);
  73678. isTrue(preprocessors: {
  73679. [key: string]: string;
  73680. }): boolean;
  73681. }
  73682. }
  73683. declare module BABYLON {
  73684. /** @hidden */
  73685. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  73686. leftOperand: ShaderDefineExpression;
  73687. rightOperand: ShaderDefineExpression;
  73688. isTrue(preprocessors: {
  73689. [key: string]: string;
  73690. }): boolean;
  73691. }
  73692. }
  73693. declare module BABYLON {
  73694. /** @hidden */
  73695. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  73696. leftOperand: ShaderDefineExpression;
  73697. rightOperand: ShaderDefineExpression;
  73698. isTrue(preprocessors: {
  73699. [key: string]: string;
  73700. }): boolean;
  73701. }
  73702. }
  73703. declare module BABYLON {
  73704. /** @hidden */
  73705. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  73706. define: string;
  73707. operand: string;
  73708. testValue: string;
  73709. constructor(define: string, operand: string, testValue: string);
  73710. isTrue(preprocessors: {
  73711. [key: string]: string;
  73712. }): boolean;
  73713. }
  73714. }
  73715. declare module BABYLON {
  73716. /**
  73717. * Class used to enable access to offline support
  73718. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  73719. */
  73720. export interface IOfflineProvider {
  73721. /**
  73722. * Gets a boolean indicating if scene must be saved in the database
  73723. */
  73724. enableSceneOffline: boolean;
  73725. /**
  73726. * Gets a boolean indicating if textures must be saved in the database
  73727. */
  73728. enableTexturesOffline: boolean;
  73729. /**
  73730. * Open the offline support and make it available
  73731. * @param successCallback defines the callback to call on success
  73732. * @param errorCallback defines the callback to call on error
  73733. */
  73734. open(successCallback: () => void, errorCallback: () => void): void;
  73735. /**
  73736. * Loads an image from the offline support
  73737. * @param url defines the url to load from
  73738. * @param image defines the target DOM image
  73739. */
  73740. loadImage(url: string, image: HTMLImageElement): void;
  73741. /**
  73742. * Loads a file from offline support
  73743. * @param url defines the URL to load from
  73744. * @param sceneLoaded defines a callback to call on success
  73745. * @param progressCallBack defines a callback to call when progress changed
  73746. * @param errorCallback defines a callback to call on error
  73747. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  73748. */
  73749. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  73750. }
  73751. }
  73752. declare module BABYLON {
  73753. /**
  73754. * Class used to help managing file picking and drag'n'drop
  73755. * File Storage
  73756. */
  73757. export class FilesInputStore {
  73758. /**
  73759. * List of files ready to be loaded
  73760. */
  73761. static FilesToLoad: {
  73762. [key: string]: File;
  73763. };
  73764. }
  73765. }
  73766. declare module BABYLON {
  73767. /**
  73768. * Class used to define a retry strategy when error happens while loading assets
  73769. */
  73770. export class RetryStrategy {
  73771. /**
  73772. * Function used to defines an exponential back off strategy
  73773. * @param maxRetries defines the maximum number of retries (3 by default)
  73774. * @param baseInterval defines the interval between retries
  73775. * @returns the strategy function to use
  73776. */
  73777. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  73778. }
  73779. }
  73780. declare module BABYLON {
  73781. /**
  73782. * @ignore
  73783. * Application error to support additional information when loading a file
  73784. */
  73785. export abstract class BaseError extends Error {
  73786. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  73787. }
  73788. }
  73789. declare module BABYLON {
  73790. /** @ignore */
  73791. export class LoadFileError extends BaseError {
  73792. request?: WebRequest;
  73793. file?: File;
  73794. /**
  73795. * Creates a new LoadFileError
  73796. * @param message defines the message of the error
  73797. * @param request defines the optional web request
  73798. * @param file defines the optional file
  73799. */
  73800. constructor(message: string, object?: WebRequest | File);
  73801. }
  73802. /** @ignore */
  73803. export class RequestFileError extends BaseError {
  73804. request: WebRequest;
  73805. /**
  73806. * Creates a new LoadFileError
  73807. * @param message defines the message of the error
  73808. * @param request defines the optional web request
  73809. */
  73810. constructor(message: string, request: WebRequest);
  73811. }
  73812. /** @ignore */
  73813. export class ReadFileError extends BaseError {
  73814. file: File;
  73815. /**
  73816. * Creates a new ReadFileError
  73817. * @param message defines the message of the error
  73818. * @param file defines the optional file
  73819. */
  73820. constructor(message: string, file: File);
  73821. }
  73822. /**
  73823. * @hidden
  73824. */
  73825. export class FileTools {
  73826. /**
  73827. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  73828. */
  73829. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  73830. /**
  73831. * Gets or sets the base URL to use to load assets
  73832. */
  73833. static BaseUrl: string;
  73834. /**
  73835. * Default behaviour for cors in the application.
  73836. * It can be a string if the expected behavior is identical in the entire app.
  73837. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  73838. */
  73839. static CorsBehavior: string | ((url: string | string[]) => string);
  73840. /**
  73841. * Gets or sets a function used to pre-process url before using them to load assets
  73842. */
  73843. static PreprocessUrl: (url: string) => string;
  73844. /**
  73845. * Removes unwanted characters from an url
  73846. * @param url defines the url to clean
  73847. * @returns the cleaned url
  73848. */
  73849. private static _CleanUrl;
  73850. /**
  73851. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  73852. * @param url define the url we are trying
  73853. * @param element define the dom element where to configure the cors policy
  73854. */
  73855. static SetCorsBehavior(url: string | string[], element: {
  73856. crossOrigin: string | null;
  73857. }): void;
  73858. /**
  73859. * Loads an image as an HTMLImageElement.
  73860. * @param input url string, ArrayBuffer, or Blob to load
  73861. * @param onLoad callback called when the image successfully loads
  73862. * @param onError callback called when the image fails to load
  73863. * @param offlineProvider offline provider for caching
  73864. * @param mimeType optional mime type
  73865. * @returns the HTMLImageElement of the loaded image
  73866. */
  73867. 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>;
  73868. /**
  73869. * Reads a file from a File object
  73870. * @param file defines the file to load
  73871. * @param onSuccess defines the callback to call when data is loaded
  73872. * @param onProgress defines the callback to call during loading process
  73873. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  73874. * @param onError defines the callback to call when an error occurs
  73875. * @returns a file request object
  73876. */
  73877. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  73878. /**
  73879. * Loads a file from a url
  73880. * @param url url to load
  73881. * @param onSuccess callback called when the file successfully loads
  73882. * @param onProgress callback called while file is loading (if the server supports this mode)
  73883. * @param offlineProvider defines the offline provider for caching
  73884. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  73885. * @param onError callback called when the file fails to load
  73886. * @returns a file request object
  73887. */
  73888. 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;
  73889. /**
  73890. * Loads a file
  73891. * @param url url to load
  73892. * @param onSuccess callback called when the file successfully loads
  73893. * @param onProgress callback called while file is loading (if the server supports this mode)
  73894. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  73895. * @param onError callback called when the file fails to load
  73896. * @param onOpened callback called when the web request is opened
  73897. * @returns a file request object
  73898. */
  73899. 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;
  73900. /**
  73901. * Checks if the loaded document was accessed via `file:`-Protocol.
  73902. * @returns boolean
  73903. */
  73904. static IsFileURL(): boolean;
  73905. }
  73906. }
  73907. declare module BABYLON {
  73908. /** @hidden */
  73909. export class ShaderProcessor {
  73910. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  73911. private static _ProcessPrecision;
  73912. private static _ExtractOperation;
  73913. private static _BuildSubExpression;
  73914. private static _BuildExpression;
  73915. private static _MoveCursorWithinIf;
  73916. private static _MoveCursor;
  73917. private static _EvaluatePreProcessors;
  73918. private static _PreparePreProcessors;
  73919. private static _ProcessShaderConversion;
  73920. private static _ProcessIncludes;
  73921. /**
  73922. * Loads a file from a url
  73923. * @param url url to load
  73924. * @param onSuccess callback called when the file successfully loads
  73925. * @param onProgress callback called while file is loading (if the server supports this mode)
  73926. * @param offlineProvider defines the offline provider for caching
  73927. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  73928. * @param onError callback called when the file fails to load
  73929. * @returns a file request object
  73930. * @hidden
  73931. */
  73932. 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;
  73933. }
  73934. }
  73935. declare module BABYLON {
  73936. /**
  73937. * @hidden
  73938. */
  73939. export interface IColor4Like {
  73940. r: float;
  73941. g: float;
  73942. b: float;
  73943. a: float;
  73944. }
  73945. /**
  73946. * @hidden
  73947. */
  73948. export interface IColor3Like {
  73949. r: float;
  73950. g: float;
  73951. b: float;
  73952. }
  73953. /**
  73954. * @hidden
  73955. */
  73956. export interface IVector4Like {
  73957. x: float;
  73958. y: float;
  73959. z: float;
  73960. w: float;
  73961. }
  73962. /**
  73963. * @hidden
  73964. */
  73965. export interface IVector3Like {
  73966. x: float;
  73967. y: float;
  73968. z: float;
  73969. }
  73970. /**
  73971. * @hidden
  73972. */
  73973. export interface IVector2Like {
  73974. x: float;
  73975. y: float;
  73976. }
  73977. /**
  73978. * @hidden
  73979. */
  73980. export interface IMatrixLike {
  73981. toArray(): DeepImmutable<Float32Array>;
  73982. updateFlag: int;
  73983. }
  73984. /**
  73985. * @hidden
  73986. */
  73987. export interface IViewportLike {
  73988. x: float;
  73989. y: float;
  73990. width: float;
  73991. height: float;
  73992. }
  73993. /**
  73994. * @hidden
  73995. */
  73996. export interface IPlaneLike {
  73997. normal: IVector3Like;
  73998. d: float;
  73999. normalize(): void;
  74000. }
  74001. }
  74002. declare module BABYLON {
  74003. /**
  74004. * Interface used to define common properties for effect fallbacks
  74005. */
  74006. export interface IEffectFallbacks {
  74007. /**
  74008. * Removes the defines that should be removed when falling back.
  74009. * @param currentDefines defines the current define statements for the shader.
  74010. * @param effect defines the current effect we try to compile
  74011. * @returns The resulting defines with defines of the current rank removed.
  74012. */
  74013. reduce(currentDefines: string, effect: Effect): string;
  74014. /**
  74015. * Removes the fallback from the bound mesh.
  74016. */
  74017. unBindMesh(): void;
  74018. /**
  74019. * Checks to see if more fallbacks are still availible.
  74020. */
  74021. hasMoreFallbacks: boolean;
  74022. }
  74023. }
  74024. declare module BABYLON {
  74025. /**
  74026. * Class used to evalaute queries containing `and` and `or` operators
  74027. */
  74028. export class AndOrNotEvaluator {
  74029. /**
  74030. * Evaluate a query
  74031. * @param query defines the query to evaluate
  74032. * @param evaluateCallback defines the callback used to filter result
  74033. * @returns true if the query matches
  74034. */
  74035. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74036. private static _HandleParenthesisContent;
  74037. private static _SimplifyNegation;
  74038. }
  74039. }
  74040. declare module BABYLON {
  74041. /**
  74042. * Class used to store custom tags
  74043. */
  74044. export class Tags {
  74045. /**
  74046. * Adds support for tags on the given object
  74047. * @param obj defines the object to use
  74048. */
  74049. static EnableFor(obj: any): void;
  74050. /**
  74051. * Removes tags support
  74052. * @param obj defines the object to use
  74053. */
  74054. static DisableFor(obj: any): void;
  74055. /**
  74056. * Gets a boolean indicating if the given object has tags
  74057. * @param obj defines the object to use
  74058. * @returns a boolean
  74059. */
  74060. static HasTags(obj: any): boolean;
  74061. /**
  74062. * Gets the tags available on a given object
  74063. * @param obj defines the object to use
  74064. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74065. * @returns the tags
  74066. */
  74067. static GetTags(obj: any, asString?: boolean): any;
  74068. /**
  74069. * Adds tags to an object
  74070. * @param obj defines the object to use
  74071. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74072. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74073. */
  74074. static AddTagsTo(obj: any, tagsString: string): void;
  74075. /**
  74076. * @hidden
  74077. */
  74078. static _AddTagTo(obj: any, tag: string): void;
  74079. /**
  74080. * Removes specific tags from a specific object
  74081. * @param obj defines the object to use
  74082. * @param tagsString defines the tags to remove
  74083. */
  74084. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74085. /**
  74086. * @hidden
  74087. */
  74088. static _RemoveTagFrom(obj: any, tag: string): void;
  74089. /**
  74090. * Defines if tags hosted on an object match a given query
  74091. * @param obj defines the object to use
  74092. * @param tagsQuery defines the tag query
  74093. * @returns a boolean
  74094. */
  74095. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74096. }
  74097. }
  74098. declare module BABYLON {
  74099. /**
  74100. * Scalar computation library
  74101. */
  74102. export class Scalar {
  74103. /**
  74104. * Two pi constants convenient for computation.
  74105. */
  74106. static TwoPi: number;
  74107. /**
  74108. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74109. * @param a number
  74110. * @param b number
  74111. * @param epsilon (default = 1.401298E-45)
  74112. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74113. */
  74114. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74115. /**
  74116. * Returns a string : the upper case translation of the number i to hexadecimal.
  74117. * @param i number
  74118. * @returns the upper case translation of the number i to hexadecimal.
  74119. */
  74120. static ToHex(i: number): string;
  74121. /**
  74122. * Returns -1 if value is negative and +1 is value is positive.
  74123. * @param value the value
  74124. * @returns the value itself if it's equal to zero.
  74125. */
  74126. static Sign(value: number): number;
  74127. /**
  74128. * Returns the value itself if it's between min and max.
  74129. * Returns min if the value is lower than min.
  74130. * Returns max if the value is greater than max.
  74131. * @param value the value to clmap
  74132. * @param min the min value to clamp to (default: 0)
  74133. * @param max the max value to clamp to (default: 1)
  74134. * @returns the clamped value
  74135. */
  74136. static Clamp(value: number, min?: number, max?: number): number;
  74137. /**
  74138. * the log2 of value.
  74139. * @param value the value to compute log2 of
  74140. * @returns the log2 of value.
  74141. */
  74142. static Log2(value: number): number;
  74143. /**
  74144. * Loops the value, so that it is never larger than length and never smaller than 0.
  74145. *
  74146. * This is similar to the modulo operator but it works with floating point numbers.
  74147. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74148. * With t = 5 and length = 2.5, the result would be 0.0.
  74149. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74150. * @param value the value
  74151. * @param length the length
  74152. * @returns the looped value
  74153. */
  74154. static Repeat(value: number, length: number): number;
  74155. /**
  74156. * Normalize the value between 0.0 and 1.0 using min and max values
  74157. * @param value value to normalize
  74158. * @param min max to normalize between
  74159. * @param max min to normalize between
  74160. * @returns the normalized value
  74161. */
  74162. static Normalize(value: number, min: number, max: number): number;
  74163. /**
  74164. * Denormalize the value from 0.0 and 1.0 using min and max values
  74165. * @param normalized value to denormalize
  74166. * @param min max to denormalize between
  74167. * @param max min to denormalize between
  74168. * @returns the denormalized value
  74169. */
  74170. static Denormalize(normalized: number, min: number, max: number): number;
  74171. /**
  74172. * Calculates the shortest difference between two given angles given in degrees.
  74173. * @param current current angle in degrees
  74174. * @param target target angle in degrees
  74175. * @returns the delta
  74176. */
  74177. static DeltaAngle(current: number, target: number): number;
  74178. /**
  74179. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74180. * @param tx value
  74181. * @param length length
  74182. * @returns The returned value will move back and forth between 0 and length
  74183. */
  74184. static PingPong(tx: number, length: number): number;
  74185. /**
  74186. * Interpolates between min and max with smoothing at the limits.
  74187. *
  74188. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74189. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74190. * @param from from
  74191. * @param to to
  74192. * @param tx value
  74193. * @returns the smooth stepped value
  74194. */
  74195. static SmoothStep(from: number, to: number, tx: number): number;
  74196. /**
  74197. * Moves a value current towards target.
  74198. *
  74199. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74200. * Negative values of maxDelta pushes the value away from target.
  74201. * @param current current value
  74202. * @param target target value
  74203. * @param maxDelta max distance to move
  74204. * @returns resulting value
  74205. */
  74206. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74207. /**
  74208. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74209. *
  74210. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74211. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74212. * @param current current value
  74213. * @param target target value
  74214. * @param maxDelta max distance to move
  74215. * @returns resulting angle
  74216. */
  74217. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74218. /**
  74219. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74220. * @param start start value
  74221. * @param end target value
  74222. * @param amount amount to lerp between
  74223. * @returns the lerped value
  74224. */
  74225. static Lerp(start: number, end: number, amount: number): number;
  74226. /**
  74227. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74228. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74229. * @param start start value
  74230. * @param end target value
  74231. * @param amount amount to lerp between
  74232. * @returns the lerped value
  74233. */
  74234. static LerpAngle(start: number, end: number, amount: number): number;
  74235. /**
  74236. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74237. * @param a start value
  74238. * @param b target value
  74239. * @param value value between a and b
  74240. * @returns the inverseLerp value
  74241. */
  74242. static InverseLerp(a: number, b: number, value: number): number;
  74243. /**
  74244. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  74245. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  74246. * @param value1 spline value
  74247. * @param tangent1 spline value
  74248. * @param value2 spline value
  74249. * @param tangent2 spline value
  74250. * @param amount input value
  74251. * @returns hermite result
  74252. */
  74253. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  74254. /**
  74255. * Returns a random float number between and min and max values
  74256. * @param min min value of random
  74257. * @param max max value of random
  74258. * @returns random value
  74259. */
  74260. static RandomRange(min: number, max: number): number;
  74261. /**
  74262. * This function returns percentage of a number in a given range.
  74263. *
  74264. * RangeToPercent(40,20,60) will return 0.5 (50%)
  74265. * RangeToPercent(34,0,100) will return 0.34 (34%)
  74266. * @param number to convert to percentage
  74267. * @param min min range
  74268. * @param max max range
  74269. * @returns the percentage
  74270. */
  74271. static RangeToPercent(number: number, min: number, max: number): number;
  74272. /**
  74273. * This function returns number that corresponds to the percentage in a given range.
  74274. *
  74275. * PercentToRange(0.34,0,100) will return 34.
  74276. * @param percent to convert to number
  74277. * @param min min range
  74278. * @param max max range
  74279. * @returns the number
  74280. */
  74281. static PercentToRange(percent: number, min: number, max: number): number;
  74282. /**
  74283. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  74284. * @param angle The angle to normalize in radian.
  74285. * @return The converted angle.
  74286. */
  74287. static NormalizeRadians(angle: number): number;
  74288. }
  74289. }
  74290. declare module BABYLON {
  74291. /**
  74292. * Constant used to convert a value to gamma space
  74293. * @ignorenaming
  74294. */
  74295. export const ToGammaSpace: number;
  74296. /**
  74297. * Constant used to convert a value to linear space
  74298. * @ignorenaming
  74299. */
  74300. export const ToLinearSpace = 2.2;
  74301. /**
  74302. * Constant used to define the minimal number value in Babylon.js
  74303. * @ignorenaming
  74304. */
  74305. let Epsilon: number;
  74306. }
  74307. declare module BABYLON {
  74308. /**
  74309. * Class used to represent a viewport on screen
  74310. */
  74311. export class Viewport {
  74312. /** viewport left coordinate */
  74313. x: number;
  74314. /** viewport top coordinate */
  74315. y: number;
  74316. /**viewport width */
  74317. width: number;
  74318. /** viewport height */
  74319. height: number;
  74320. /**
  74321. * Creates a Viewport object located at (x, y) and sized (width, height)
  74322. * @param x defines viewport left coordinate
  74323. * @param y defines viewport top coordinate
  74324. * @param width defines the viewport width
  74325. * @param height defines the viewport height
  74326. */
  74327. constructor(
  74328. /** viewport left coordinate */
  74329. x: number,
  74330. /** viewport top coordinate */
  74331. y: number,
  74332. /**viewport width */
  74333. width: number,
  74334. /** viewport height */
  74335. height: number);
  74336. /**
  74337. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  74338. * @param renderWidth defines the rendering width
  74339. * @param renderHeight defines the rendering height
  74340. * @returns a new Viewport
  74341. */
  74342. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  74343. /**
  74344. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  74345. * @param renderWidth defines the rendering width
  74346. * @param renderHeight defines the rendering height
  74347. * @param ref defines the target viewport
  74348. * @returns the current viewport
  74349. */
  74350. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  74351. /**
  74352. * Returns a new Viewport copied from the current one
  74353. * @returns a new Viewport
  74354. */
  74355. clone(): Viewport;
  74356. }
  74357. }
  74358. declare module BABYLON {
  74359. /**
  74360. * Class containing a set of static utilities functions for arrays.
  74361. */
  74362. export class ArrayTools {
  74363. /**
  74364. * Returns an array of the given size filled with element built from the given constructor and the paramters
  74365. * @param size the number of element to construct and put in the array
  74366. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  74367. * @returns a new array filled with new objects
  74368. */
  74369. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  74370. }
  74371. }
  74372. declare module BABYLON {
  74373. /**
  74374. * Class representing a vector containing 2 coordinates
  74375. */
  74376. export class Vector2 {
  74377. /** defines the first coordinate */
  74378. x: number;
  74379. /** defines the second coordinate */
  74380. y: number;
  74381. /**
  74382. * Creates a new Vector2 from the given x and y coordinates
  74383. * @param x defines the first coordinate
  74384. * @param y defines the second coordinate
  74385. */
  74386. constructor(
  74387. /** defines the first coordinate */
  74388. x?: number,
  74389. /** defines the second coordinate */
  74390. y?: number);
  74391. /**
  74392. * Gets a string with the Vector2 coordinates
  74393. * @returns a string with the Vector2 coordinates
  74394. */
  74395. toString(): string;
  74396. /**
  74397. * Gets class name
  74398. * @returns the string "Vector2"
  74399. */
  74400. getClassName(): string;
  74401. /**
  74402. * Gets current vector hash code
  74403. * @returns the Vector2 hash code as a number
  74404. */
  74405. getHashCode(): number;
  74406. /**
  74407. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  74408. * @param array defines the source array
  74409. * @param index defines the offset in source array
  74410. * @returns the current Vector2
  74411. */
  74412. toArray(array: FloatArray, index?: number): Vector2;
  74413. /**
  74414. * Copy the current vector to an array
  74415. * @returns a new array with 2 elements: the Vector2 coordinates.
  74416. */
  74417. asArray(): number[];
  74418. /**
  74419. * Sets the Vector2 coordinates with the given Vector2 coordinates
  74420. * @param source defines the source Vector2
  74421. * @returns the current updated Vector2
  74422. */
  74423. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  74424. /**
  74425. * Sets the Vector2 coordinates with the given floats
  74426. * @param x defines the first coordinate
  74427. * @param y defines the second coordinate
  74428. * @returns the current updated Vector2
  74429. */
  74430. copyFromFloats(x: number, y: number): Vector2;
  74431. /**
  74432. * Sets the Vector2 coordinates with the given floats
  74433. * @param x defines the first coordinate
  74434. * @param y defines the second coordinate
  74435. * @returns the current updated Vector2
  74436. */
  74437. set(x: number, y: number): Vector2;
  74438. /**
  74439. * Add another vector with the current one
  74440. * @param otherVector defines the other vector
  74441. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  74442. */
  74443. add(otherVector: DeepImmutable<Vector2>): Vector2;
  74444. /**
  74445. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  74446. * @param otherVector defines the other vector
  74447. * @param result defines the target vector
  74448. * @returns the unmodified current Vector2
  74449. */
  74450. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74451. /**
  74452. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  74453. * @param otherVector defines the other vector
  74454. * @returns the current updated Vector2
  74455. */
  74456. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74457. /**
  74458. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  74459. * @param otherVector defines the other vector
  74460. * @returns a new Vector2
  74461. */
  74462. addVector3(otherVector: Vector3): Vector2;
  74463. /**
  74464. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  74465. * @param otherVector defines the other vector
  74466. * @returns a new Vector2
  74467. */
  74468. subtract(otherVector: Vector2): Vector2;
  74469. /**
  74470. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  74471. * @param otherVector defines the other vector
  74472. * @param result defines the target vector
  74473. * @returns the unmodified current Vector2
  74474. */
  74475. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74476. /**
  74477. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  74478. * @param otherVector defines the other vector
  74479. * @returns the current updated Vector2
  74480. */
  74481. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74482. /**
  74483. * Multiplies in place the current Vector2 coordinates by the given ones
  74484. * @param otherVector defines the other vector
  74485. * @returns the current updated Vector2
  74486. */
  74487. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74488. /**
  74489. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  74490. * @param otherVector defines the other vector
  74491. * @returns a new Vector2
  74492. */
  74493. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  74494. /**
  74495. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  74496. * @param otherVector defines the other vector
  74497. * @param result defines the target vector
  74498. * @returns the unmodified current Vector2
  74499. */
  74500. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74501. /**
  74502. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  74503. * @param x defines the first coordinate
  74504. * @param y defines the second coordinate
  74505. * @returns a new Vector2
  74506. */
  74507. multiplyByFloats(x: number, y: number): Vector2;
  74508. /**
  74509. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  74510. * @param otherVector defines the other vector
  74511. * @returns a new Vector2
  74512. */
  74513. divide(otherVector: Vector2): Vector2;
  74514. /**
  74515. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  74516. * @param otherVector defines the other vector
  74517. * @param result defines the target vector
  74518. * @returns the unmodified current Vector2
  74519. */
  74520. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74521. /**
  74522. * Divides the current Vector2 coordinates by the given ones
  74523. * @param otherVector defines the other vector
  74524. * @returns the current updated Vector2
  74525. */
  74526. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74527. /**
  74528. * Gets a new Vector2 with current Vector2 negated coordinates
  74529. * @returns a new Vector2
  74530. */
  74531. negate(): Vector2;
  74532. /**
  74533. * Multiply the Vector2 coordinates by scale
  74534. * @param scale defines the scaling factor
  74535. * @returns the current updated Vector2
  74536. */
  74537. scaleInPlace(scale: number): Vector2;
  74538. /**
  74539. * Returns a new Vector2 scaled by "scale" from the current Vector2
  74540. * @param scale defines the scaling factor
  74541. * @returns a new Vector2
  74542. */
  74543. scale(scale: number): Vector2;
  74544. /**
  74545. * Scale the current Vector2 values by a factor to a given Vector2
  74546. * @param scale defines the scale factor
  74547. * @param result defines the Vector2 object where to store the result
  74548. * @returns the unmodified current Vector2
  74549. */
  74550. scaleToRef(scale: number, result: Vector2): Vector2;
  74551. /**
  74552. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  74553. * @param scale defines the scale factor
  74554. * @param result defines the Vector2 object where to store the result
  74555. * @returns the unmodified current Vector2
  74556. */
  74557. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  74558. /**
  74559. * Gets a boolean if two vectors are equals
  74560. * @param otherVector defines the other vector
  74561. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  74562. */
  74563. equals(otherVector: DeepImmutable<Vector2>): boolean;
  74564. /**
  74565. * Gets a boolean if two vectors are equals (using an epsilon value)
  74566. * @param otherVector defines the other vector
  74567. * @param epsilon defines the minimal distance to consider equality
  74568. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  74569. */
  74570. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  74571. /**
  74572. * Gets a new Vector2 from current Vector2 floored values
  74573. * @returns a new Vector2
  74574. */
  74575. floor(): Vector2;
  74576. /**
  74577. * Gets a new Vector2 from current Vector2 floored values
  74578. * @returns a new Vector2
  74579. */
  74580. fract(): Vector2;
  74581. /**
  74582. * Gets the length of the vector
  74583. * @returns the vector length (float)
  74584. */
  74585. length(): number;
  74586. /**
  74587. * Gets the vector squared length
  74588. * @returns the vector squared length (float)
  74589. */
  74590. lengthSquared(): number;
  74591. /**
  74592. * Normalize the vector
  74593. * @returns the current updated Vector2
  74594. */
  74595. normalize(): Vector2;
  74596. /**
  74597. * Gets a new Vector2 copied from the Vector2
  74598. * @returns a new Vector2
  74599. */
  74600. clone(): Vector2;
  74601. /**
  74602. * Gets a new Vector2(0, 0)
  74603. * @returns a new Vector2
  74604. */
  74605. static Zero(): Vector2;
  74606. /**
  74607. * Gets a new Vector2(1, 1)
  74608. * @returns a new Vector2
  74609. */
  74610. static One(): Vector2;
  74611. /**
  74612. * Gets a new Vector2 set from the given index element of the given array
  74613. * @param array defines the data source
  74614. * @param offset defines the offset in the data source
  74615. * @returns a new Vector2
  74616. */
  74617. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  74618. /**
  74619. * Sets "result" from the given index element of the given array
  74620. * @param array defines the data source
  74621. * @param offset defines the offset in the data source
  74622. * @param result defines the target vector
  74623. */
  74624. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  74625. /**
  74626. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  74627. * @param value1 defines 1st point of control
  74628. * @param value2 defines 2nd point of control
  74629. * @param value3 defines 3rd point of control
  74630. * @param value4 defines 4th point of control
  74631. * @param amount defines the interpolation factor
  74632. * @returns a new Vector2
  74633. */
  74634. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  74635. /**
  74636. * 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".
  74637. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  74638. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  74639. * @param value defines the value to clamp
  74640. * @param min defines the lower limit
  74641. * @param max defines the upper limit
  74642. * @returns a new Vector2
  74643. */
  74644. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  74645. /**
  74646. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  74647. * @param value1 defines the 1st control point
  74648. * @param tangent1 defines the outgoing tangent
  74649. * @param value2 defines the 2nd control point
  74650. * @param tangent2 defines the incoming tangent
  74651. * @param amount defines the interpolation factor
  74652. * @returns a new Vector2
  74653. */
  74654. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  74655. /**
  74656. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  74657. * @param start defines the start vector
  74658. * @param end defines the end vector
  74659. * @param amount defines the interpolation factor
  74660. * @returns a new Vector2
  74661. */
  74662. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  74663. /**
  74664. * Gets the dot product of the vector "left" and the vector "right"
  74665. * @param left defines first vector
  74666. * @param right defines second vector
  74667. * @returns the dot product (float)
  74668. */
  74669. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  74670. /**
  74671. * Returns a new Vector2 equal to the normalized given vector
  74672. * @param vector defines the vector to normalize
  74673. * @returns a new Vector2
  74674. */
  74675. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  74676. /**
  74677. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  74678. * @param left defines 1st vector
  74679. * @param right defines 2nd vector
  74680. * @returns a new Vector2
  74681. */
  74682. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  74683. /**
  74684. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  74685. * @param left defines 1st vector
  74686. * @param right defines 2nd vector
  74687. * @returns a new Vector2
  74688. */
  74689. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  74690. /**
  74691. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  74692. * @param vector defines the vector to transform
  74693. * @param transformation defines the matrix to apply
  74694. * @returns a new Vector2
  74695. */
  74696. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  74697. /**
  74698. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  74699. * @param vector defines the vector to transform
  74700. * @param transformation defines the matrix to apply
  74701. * @param result defines the target vector
  74702. */
  74703. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  74704. /**
  74705. * Determines if a given vector is included in a triangle
  74706. * @param p defines the vector to test
  74707. * @param p0 defines 1st triangle point
  74708. * @param p1 defines 2nd triangle point
  74709. * @param p2 defines 3rd triangle point
  74710. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  74711. */
  74712. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  74713. /**
  74714. * Gets the distance between the vectors "value1" and "value2"
  74715. * @param value1 defines first vector
  74716. * @param value2 defines second vector
  74717. * @returns the distance between vectors
  74718. */
  74719. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  74720. /**
  74721. * Returns the squared distance between the vectors "value1" and "value2"
  74722. * @param value1 defines first vector
  74723. * @param value2 defines second vector
  74724. * @returns the squared distance between vectors
  74725. */
  74726. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  74727. /**
  74728. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  74729. * @param value1 defines first vector
  74730. * @param value2 defines second vector
  74731. * @returns a new Vector2
  74732. */
  74733. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  74734. /**
  74735. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  74736. * @param p defines the middle point
  74737. * @param segA defines one point of the segment
  74738. * @param segB defines the other point of the segment
  74739. * @returns the shortest distance
  74740. */
  74741. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  74742. }
  74743. /**
  74744. * Class used to store (x,y,z) vector representation
  74745. * A Vector3 is the main object used in 3D geometry
  74746. * It can represent etiher the coordinates of a point the space, either a direction
  74747. * Reminder: js uses a left handed forward facing system
  74748. */
  74749. export class Vector3 {
  74750. /**
  74751. * Defines the first coordinates (on X axis)
  74752. */
  74753. x: number;
  74754. /**
  74755. * Defines the second coordinates (on Y axis)
  74756. */
  74757. y: number;
  74758. /**
  74759. * Defines the third coordinates (on Z axis)
  74760. */
  74761. z: number;
  74762. private static _UpReadOnly;
  74763. private static _ZeroReadOnly;
  74764. /**
  74765. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  74766. * @param x defines the first coordinates (on X axis)
  74767. * @param y defines the second coordinates (on Y axis)
  74768. * @param z defines the third coordinates (on Z axis)
  74769. */
  74770. constructor(
  74771. /**
  74772. * Defines the first coordinates (on X axis)
  74773. */
  74774. x?: number,
  74775. /**
  74776. * Defines the second coordinates (on Y axis)
  74777. */
  74778. y?: number,
  74779. /**
  74780. * Defines the third coordinates (on Z axis)
  74781. */
  74782. z?: number);
  74783. /**
  74784. * Creates a string representation of the Vector3
  74785. * @returns a string with the Vector3 coordinates.
  74786. */
  74787. toString(): string;
  74788. /**
  74789. * Gets the class name
  74790. * @returns the string "Vector3"
  74791. */
  74792. getClassName(): string;
  74793. /**
  74794. * Creates the Vector3 hash code
  74795. * @returns a number which tends to be unique between Vector3 instances
  74796. */
  74797. getHashCode(): number;
  74798. /**
  74799. * Creates an array containing three elements : the coordinates of the Vector3
  74800. * @returns a new array of numbers
  74801. */
  74802. asArray(): number[];
  74803. /**
  74804. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  74805. * @param array defines the destination array
  74806. * @param index defines the offset in the destination array
  74807. * @returns the current Vector3
  74808. */
  74809. toArray(array: FloatArray, index?: number): Vector3;
  74810. /**
  74811. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  74812. * @returns a new Quaternion object, computed from the Vector3 coordinates
  74813. */
  74814. toQuaternion(): Quaternion;
  74815. /**
  74816. * Adds the given vector to the current Vector3
  74817. * @param otherVector defines the second operand
  74818. * @returns the current updated Vector3
  74819. */
  74820. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  74821. /**
  74822. * Adds the given coordinates to the current Vector3
  74823. * @param x defines the x coordinate of the operand
  74824. * @param y defines the y coordinate of the operand
  74825. * @param z defines the z coordinate of the operand
  74826. * @returns the current updated Vector3
  74827. */
  74828. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  74829. /**
  74830. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  74831. * @param otherVector defines the second operand
  74832. * @returns the resulting Vector3
  74833. */
  74834. add(otherVector: DeepImmutable<Vector3>): Vector3;
  74835. /**
  74836. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  74837. * @param otherVector defines the second operand
  74838. * @param result defines the Vector3 object where to store the result
  74839. * @returns the current Vector3
  74840. */
  74841. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74842. /**
  74843. * Subtract the given vector from the current Vector3
  74844. * @param otherVector defines the second operand
  74845. * @returns the current updated Vector3
  74846. */
  74847. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  74848. /**
  74849. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  74850. * @param otherVector defines the second operand
  74851. * @returns the resulting Vector3
  74852. */
  74853. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  74854. /**
  74855. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  74856. * @param otherVector defines the second operand
  74857. * @param result defines the Vector3 object where to store the result
  74858. * @returns the current Vector3
  74859. */
  74860. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74861. /**
  74862. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  74863. * @param x defines the x coordinate of the operand
  74864. * @param y defines the y coordinate of the operand
  74865. * @param z defines the z coordinate of the operand
  74866. * @returns the resulting Vector3
  74867. */
  74868. subtractFromFloats(x: number, y: number, z: number): Vector3;
  74869. /**
  74870. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  74871. * @param x defines the x coordinate of the operand
  74872. * @param y defines the y coordinate of the operand
  74873. * @param z defines the z coordinate of the operand
  74874. * @param result defines the Vector3 object where to store the result
  74875. * @returns the current Vector3
  74876. */
  74877. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  74878. /**
  74879. * Gets a new Vector3 set with the current Vector3 negated coordinates
  74880. * @returns a new Vector3
  74881. */
  74882. negate(): Vector3;
  74883. /**
  74884. * Negate this vector in place
  74885. * @returns this
  74886. */
  74887. negateInPlace(): Vector3;
  74888. /**
  74889. * Multiplies the Vector3 coordinates by the float "scale"
  74890. * @param scale defines the multiplier factor
  74891. * @returns the current updated Vector3
  74892. */
  74893. scaleInPlace(scale: number): Vector3;
  74894. /**
  74895. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  74896. * @param scale defines the multiplier factor
  74897. * @returns a new Vector3
  74898. */
  74899. scale(scale: number): Vector3;
  74900. /**
  74901. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  74902. * @param scale defines the multiplier factor
  74903. * @param result defines the Vector3 object where to store the result
  74904. * @returns the current Vector3
  74905. */
  74906. scaleToRef(scale: number, result: Vector3): Vector3;
  74907. /**
  74908. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  74909. * @param scale defines the scale factor
  74910. * @param result defines the Vector3 object where to store the result
  74911. * @returns the unmodified current Vector3
  74912. */
  74913. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  74914. /**
  74915. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  74916. * @param otherVector defines the second operand
  74917. * @returns true if both vectors are equals
  74918. */
  74919. equals(otherVector: DeepImmutable<Vector3>): boolean;
  74920. /**
  74921. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  74922. * @param otherVector defines the second operand
  74923. * @param epsilon defines the minimal distance to define values as equals
  74924. * @returns true if both vectors are distant less than epsilon
  74925. */
  74926. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  74927. /**
  74928. * Returns true if the current Vector3 coordinates equals the given floats
  74929. * @param x defines the x coordinate of the operand
  74930. * @param y defines the y coordinate of the operand
  74931. * @param z defines the z coordinate of the operand
  74932. * @returns true if both vectors are equals
  74933. */
  74934. equalsToFloats(x: number, y: number, z: number): boolean;
  74935. /**
  74936. * Multiplies the current Vector3 coordinates by the given ones
  74937. * @param otherVector defines the second operand
  74938. * @returns the current updated Vector3
  74939. */
  74940. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  74941. /**
  74942. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  74943. * @param otherVector defines the second operand
  74944. * @returns the new Vector3
  74945. */
  74946. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  74947. /**
  74948. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  74949. * @param otherVector defines the second operand
  74950. * @param result defines the Vector3 object where to store the result
  74951. * @returns the current Vector3
  74952. */
  74953. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74954. /**
  74955. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  74956. * @param x defines the x coordinate of the operand
  74957. * @param y defines the y coordinate of the operand
  74958. * @param z defines the z coordinate of the operand
  74959. * @returns the new Vector3
  74960. */
  74961. multiplyByFloats(x: number, y: number, z: number): Vector3;
  74962. /**
  74963. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  74964. * @param otherVector defines the second operand
  74965. * @returns the new Vector3
  74966. */
  74967. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  74968. /**
  74969. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  74970. * @param otherVector defines the second operand
  74971. * @param result defines the Vector3 object where to store the result
  74972. * @returns the current Vector3
  74973. */
  74974. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  74975. /**
  74976. * Divides the current Vector3 coordinates by the given ones.
  74977. * @param otherVector defines the second operand
  74978. * @returns the current updated Vector3
  74979. */
  74980. divideInPlace(otherVector: Vector3): Vector3;
  74981. /**
  74982. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  74983. * @param other defines the second operand
  74984. * @returns the current updated Vector3
  74985. */
  74986. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  74987. /**
  74988. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  74989. * @param other defines the second operand
  74990. * @returns the current updated Vector3
  74991. */
  74992. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  74993. /**
  74994. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  74995. * @param x defines the x coordinate of the operand
  74996. * @param y defines the y coordinate of the operand
  74997. * @param z defines the z coordinate of the operand
  74998. * @returns the current updated Vector3
  74999. */
  75000. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75001. /**
  75002. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75003. * @param x defines the x coordinate of the operand
  75004. * @param y defines the y coordinate of the operand
  75005. * @param z defines the z coordinate of the operand
  75006. * @returns the current updated Vector3
  75007. */
  75008. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75009. /**
  75010. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75011. * Check if is non uniform within a certain amount of decimal places to account for this
  75012. * @param epsilon the amount the values can differ
  75013. * @returns if the the vector is non uniform to a certain number of decimal places
  75014. */
  75015. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75016. /**
  75017. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75018. */
  75019. get isNonUniform(): boolean;
  75020. /**
  75021. * Gets a new Vector3 from current Vector3 floored values
  75022. * @returns a new Vector3
  75023. */
  75024. floor(): Vector3;
  75025. /**
  75026. * Gets a new Vector3 from current Vector3 floored values
  75027. * @returns a new Vector3
  75028. */
  75029. fract(): Vector3;
  75030. /**
  75031. * Gets the length of the Vector3
  75032. * @returns the length of the Vector3
  75033. */
  75034. length(): number;
  75035. /**
  75036. * Gets the squared length of the Vector3
  75037. * @returns squared length of the Vector3
  75038. */
  75039. lengthSquared(): number;
  75040. /**
  75041. * Normalize the current Vector3.
  75042. * Please note that this is an in place operation.
  75043. * @returns the current updated Vector3
  75044. */
  75045. normalize(): Vector3;
  75046. /**
  75047. * Reorders the x y z properties of the vector in place
  75048. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75049. * @returns the current updated vector
  75050. */
  75051. reorderInPlace(order: string): this;
  75052. /**
  75053. * Rotates the vector around 0,0,0 by a quaternion
  75054. * @param quaternion the rotation quaternion
  75055. * @param result vector to store the result
  75056. * @returns the resulting vector
  75057. */
  75058. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75059. /**
  75060. * Rotates a vector around a given point
  75061. * @param quaternion the rotation quaternion
  75062. * @param point the point to rotate around
  75063. * @param result vector to store the result
  75064. * @returns the resulting vector
  75065. */
  75066. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75067. /**
  75068. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75069. * The cross product is then orthogonal to both current and "other"
  75070. * @param other defines the right operand
  75071. * @returns the cross product
  75072. */
  75073. cross(other: Vector3): Vector3;
  75074. /**
  75075. * Normalize the current Vector3 with the given input length.
  75076. * Please note that this is an in place operation.
  75077. * @param len the length of the vector
  75078. * @returns the current updated Vector3
  75079. */
  75080. normalizeFromLength(len: number): Vector3;
  75081. /**
  75082. * Normalize the current Vector3 to a new vector
  75083. * @returns the new Vector3
  75084. */
  75085. normalizeToNew(): Vector3;
  75086. /**
  75087. * Normalize the current Vector3 to the reference
  75088. * @param reference define the Vector3 to update
  75089. * @returns the updated Vector3
  75090. */
  75091. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75092. /**
  75093. * Creates a new Vector3 copied from the current Vector3
  75094. * @returns the new Vector3
  75095. */
  75096. clone(): Vector3;
  75097. /**
  75098. * Copies the given vector coordinates to the current Vector3 ones
  75099. * @param source defines the source Vector3
  75100. * @returns the current updated Vector3
  75101. */
  75102. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75103. /**
  75104. * Copies the given floats to the current Vector3 coordinates
  75105. * @param x defines the x coordinate of the operand
  75106. * @param y defines the y coordinate of the operand
  75107. * @param z defines the z coordinate of the operand
  75108. * @returns the current updated Vector3
  75109. */
  75110. copyFromFloats(x: number, y: number, z: number): Vector3;
  75111. /**
  75112. * Copies the given floats to the current Vector3 coordinates
  75113. * @param x defines the x coordinate of the operand
  75114. * @param y defines the y coordinate of the operand
  75115. * @param z defines the z coordinate of the operand
  75116. * @returns the current updated Vector3
  75117. */
  75118. set(x: number, y: number, z: number): Vector3;
  75119. /**
  75120. * Copies the given float to the current Vector3 coordinates
  75121. * @param v defines the x, y and z coordinates of the operand
  75122. * @returns the current updated Vector3
  75123. */
  75124. setAll(v: number): Vector3;
  75125. /**
  75126. * Get the clip factor between two vectors
  75127. * @param vector0 defines the first operand
  75128. * @param vector1 defines the second operand
  75129. * @param axis defines the axis to use
  75130. * @param size defines the size along the axis
  75131. * @returns the clip factor
  75132. */
  75133. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75134. /**
  75135. * Get angle between two vectors
  75136. * @param vector0 angle between vector0 and vector1
  75137. * @param vector1 angle between vector0 and vector1
  75138. * @param normal direction of the normal
  75139. * @return the angle between vector0 and vector1
  75140. */
  75141. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75142. /**
  75143. * Returns a new Vector3 set from the index "offset" of the given array
  75144. * @param array defines the source array
  75145. * @param offset defines the offset in the source array
  75146. * @returns the new Vector3
  75147. */
  75148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75149. /**
  75150. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75151. * @param array defines the source array
  75152. * @param offset defines the offset in the source array
  75153. * @returns the new Vector3
  75154. * @deprecated Please use FromArray instead.
  75155. */
  75156. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75157. /**
  75158. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75159. * @param array defines the source array
  75160. * @param offset defines the offset in the source array
  75161. * @param result defines the Vector3 where to store the result
  75162. */
  75163. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75164. /**
  75165. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75166. * @param array defines the source array
  75167. * @param offset defines the offset in the source array
  75168. * @param result defines the Vector3 where to store the result
  75169. * @deprecated Please use FromArrayToRef instead.
  75170. */
  75171. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75172. /**
  75173. * Sets the given vector "result" with the given floats.
  75174. * @param x defines the x coordinate of the source
  75175. * @param y defines the y coordinate of the source
  75176. * @param z defines the z coordinate of the source
  75177. * @param result defines the Vector3 where to store the result
  75178. */
  75179. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75180. /**
  75181. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75182. * @returns a new empty Vector3
  75183. */
  75184. static Zero(): Vector3;
  75185. /**
  75186. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75187. * @returns a new unit Vector3
  75188. */
  75189. static One(): Vector3;
  75190. /**
  75191. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75192. * @returns a new up Vector3
  75193. */
  75194. static Up(): Vector3;
  75195. /**
  75196. * Gets a up Vector3 that must not be updated
  75197. */
  75198. static get UpReadOnly(): DeepImmutable<Vector3>;
  75199. /**
  75200. * Gets a zero Vector3 that must not be updated
  75201. */
  75202. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75203. /**
  75204. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75205. * @returns a new down Vector3
  75206. */
  75207. static Down(): Vector3;
  75208. /**
  75209. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75210. * @returns a new forward Vector3
  75211. */
  75212. static Forward(): Vector3;
  75213. /**
  75214. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75215. * @returns a new forward Vector3
  75216. */
  75217. static Backward(): Vector3;
  75218. /**
  75219. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75220. * @returns a new right Vector3
  75221. */
  75222. static Right(): Vector3;
  75223. /**
  75224. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75225. * @returns a new left Vector3
  75226. */
  75227. static Left(): Vector3;
  75228. /**
  75229. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  75230. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75231. * @param vector defines the Vector3 to transform
  75232. * @param transformation defines the transformation matrix
  75233. * @returns the transformed Vector3
  75234. */
  75235. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75236. /**
  75237. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  75238. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75239. * @param vector defines the Vector3 to transform
  75240. * @param transformation defines the transformation matrix
  75241. * @param result defines the Vector3 where to store the result
  75242. */
  75243. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75244. /**
  75245. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  75246. * This method computes tranformed coordinates only, not transformed direction vectors
  75247. * @param x define the x coordinate of the source vector
  75248. * @param y define the y coordinate of the source vector
  75249. * @param z define the z coordinate of the source vector
  75250. * @param transformation defines the transformation matrix
  75251. * @param result defines the Vector3 where to store the result
  75252. */
  75253. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75254. /**
  75255. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  75256. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75257. * @param vector defines the Vector3 to transform
  75258. * @param transformation defines the transformation matrix
  75259. * @returns the new Vector3
  75260. */
  75261. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75262. /**
  75263. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  75264. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75265. * @param vector defines the Vector3 to transform
  75266. * @param transformation defines the transformation matrix
  75267. * @param result defines the Vector3 where to store the result
  75268. */
  75269. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75270. /**
  75271. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  75272. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75273. * @param x define the x coordinate of the source vector
  75274. * @param y define the y coordinate of the source vector
  75275. * @param z define the z coordinate of the source vector
  75276. * @param transformation defines the transformation matrix
  75277. * @param result defines the Vector3 where to store the result
  75278. */
  75279. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75280. /**
  75281. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  75282. * @param value1 defines the first control point
  75283. * @param value2 defines the second control point
  75284. * @param value3 defines the third control point
  75285. * @param value4 defines the fourth control point
  75286. * @param amount defines the amount on the spline to use
  75287. * @returns the new Vector3
  75288. */
  75289. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  75290. /**
  75291. * 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"
  75292. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75293. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75294. * @param value defines the current value
  75295. * @param min defines the lower range value
  75296. * @param max defines the upper range value
  75297. * @returns the new Vector3
  75298. */
  75299. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  75300. /**
  75301. * 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"
  75302. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75303. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75304. * @param value defines the current value
  75305. * @param min defines the lower range value
  75306. * @param max defines the upper range value
  75307. * @param result defines the Vector3 where to store the result
  75308. */
  75309. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  75310. /**
  75311. * Checks if a given vector is inside a specific range
  75312. * @param v defines the vector to test
  75313. * @param min defines the minimum range
  75314. * @param max defines the maximum range
  75315. */
  75316. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  75317. /**
  75318. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  75319. * @param value1 defines the first control point
  75320. * @param tangent1 defines the first tangent vector
  75321. * @param value2 defines the second control point
  75322. * @param tangent2 defines the second tangent vector
  75323. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  75324. * @returns the new Vector3
  75325. */
  75326. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  75327. /**
  75328. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  75329. * @param start defines the start value
  75330. * @param end defines the end value
  75331. * @param amount max defines amount between both (between 0 and 1)
  75332. * @returns the new Vector3
  75333. */
  75334. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  75335. /**
  75336. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  75337. * @param start defines the start value
  75338. * @param end defines the end value
  75339. * @param amount max defines amount between both (between 0 and 1)
  75340. * @param result defines the Vector3 where to store the result
  75341. */
  75342. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  75343. /**
  75344. * Returns the dot product (float) between the vectors "left" and "right"
  75345. * @param left defines the left operand
  75346. * @param right defines the right operand
  75347. * @returns the dot product
  75348. */
  75349. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  75350. /**
  75351. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  75352. * The cross product is then orthogonal to both "left" and "right"
  75353. * @param left defines the left operand
  75354. * @param right defines the right operand
  75355. * @returns the cross product
  75356. */
  75357. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75358. /**
  75359. * Sets the given vector "result" with the cross product of "left" and "right"
  75360. * The cross product is then orthogonal to both "left" and "right"
  75361. * @param left defines the left operand
  75362. * @param right defines the right operand
  75363. * @param result defines the Vector3 where to store the result
  75364. */
  75365. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  75366. /**
  75367. * Returns a new Vector3 as the normalization of the given vector
  75368. * @param vector defines the Vector3 to normalize
  75369. * @returns the new Vector3
  75370. */
  75371. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  75372. /**
  75373. * Sets the given vector "result" with the normalization of the given first vector
  75374. * @param vector defines the Vector3 to normalize
  75375. * @param result defines the Vector3 where to store the result
  75376. */
  75377. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  75378. /**
  75379. * Project a Vector3 onto screen space
  75380. * @param vector defines the Vector3 to project
  75381. * @param world defines the world matrix to use
  75382. * @param transform defines the transform (view x projection) matrix to use
  75383. * @param viewport defines the screen viewport to use
  75384. * @returns the new Vector3
  75385. */
  75386. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  75387. /** @hidden */
  75388. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  75389. /**
  75390. * Unproject from screen space to object space
  75391. * @param source defines the screen space Vector3 to use
  75392. * @param viewportWidth defines the current width of the viewport
  75393. * @param viewportHeight defines the current height of the viewport
  75394. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75395. * @param transform defines the transform (view x projection) matrix to use
  75396. * @returns the new Vector3
  75397. */
  75398. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  75399. /**
  75400. * Unproject from screen space to object space
  75401. * @param source defines the screen space Vector3 to use
  75402. * @param viewportWidth defines the current width of the viewport
  75403. * @param viewportHeight defines the current height of the viewport
  75404. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75405. * @param view defines the view matrix to use
  75406. * @param projection defines the projection matrix to use
  75407. * @returns the new Vector3
  75408. */
  75409. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  75410. /**
  75411. * Unproject from screen space to object space
  75412. * @param source defines the screen space Vector3 to use
  75413. * @param viewportWidth defines the current width of the viewport
  75414. * @param viewportHeight defines the current height of the viewport
  75415. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75416. * @param view defines the view matrix to use
  75417. * @param projection defines the projection matrix to use
  75418. * @param result defines the Vector3 where to store the result
  75419. */
  75420. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75421. /**
  75422. * Unproject from screen space to object space
  75423. * @param sourceX defines the screen space x coordinate to use
  75424. * @param sourceY defines the screen space y coordinate to use
  75425. * @param sourceZ defines the screen space z coordinate to use
  75426. * @param viewportWidth defines the current width of the viewport
  75427. * @param viewportHeight defines the current height of the viewport
  75428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75429. * @param view defines the view matrix to use
  75430. * @param projection defines the projection matrix to use
  75431. * @param result defines the Vector3 where to store the result
  75432. */
  75433. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75434. /**
  75435. * Gets the minimal coordinate values between two Vector3
  75436. * @param left defines the first operand
  75437. * @param right defines the second operand
  75438. * @returns the new Vector3
  75439. */
  75440. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75441. /**
  75442. * Gets the maximal coordinate values between two Vector3
  75443. * @param left defines the first operand
  75444. * @param right defines the second operand
  75445. * @returns the new Vector3
  75446. */
  75447. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75448. /**
  75449. * Returns the distance between the vectors "value1" and "value2"
  75450. * @param value1 defines the first operand
  75451. * @param value2 defines the second operand
  75452. * @returns the distance
  75453. */
  75454. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75455. /**
  75456. * Returns the squared distance between the vectors "value1" and "value2"
  75457. * @param value1 defines the first operand
  75458. * @param value2 defines the second operand
  75459. * @returns the squared distance
  75460. */
  75461. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75462. /**
  75463. * Returns a new Vector3 located at the center between "value1" and "value2"
  75464. * @param value1 defines the first operand
  75465. * @param value2 defines the second operand
  75466. * @returns the new Vector3
  75467. */
  75468. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  75469. /**
  75470. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  75471. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  75472. * to something in order to rotate it from its local system to the given target system
  75473. * Note: axis1, axis2 and axis3 are normalized during this operation
  75474. * @param axis1 defines the first axis
  75475. * @param axis2 defines the second axis
  75476. * @param axis3 defines the third axis
  75477. * @returns a new Vector3
  75478. */
  75479. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  75480. /**
  75481. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  75482. * @param axis1 defines the first axis
  75483. * @param axis2 defines the second axis
  75484. * @param axis3 defines the third axis
  75485. * @param ref defines the Vector3 where to store the result
  75486. */
  75487. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  75488. }
  75489. /**
  75490. * Vector4 class created for EulerAngle class conversion to Quaternion
  75491. */
  75492. export class Vector4 {
  75493. /** x value of the vector */
  75494. x: number;
  75495. /** y value of the vector */
  75496. y: number;
  75497. /** z value of the vector */
  75498. z: number;
  75499. /** w value of the vector */
  75500. w: number;
  75501. /**
  75502. * Creates a Vector4 object from the given floats.
  75503. * @param x x value of the vector
  75504. * @param y y value of the vector
  75505. * @param z z value of the vector
  75506. * @param w w value of the vector
  75507. */
  75508. constructor(
  75509. /** x value of the vector */
  75510. x: number,
  75511. /** y value of the vector */
  75512. y: number,
  75513. /** z value of the vector */
  75514. z: number,
  75515. /** w value of the vector */
  75516. w: number);
  75517. /**
  75518. * Returns the string with the Vector4 coordinates.
  75519. * @returns a string containing all the vector values
  75520. */
  75521. toString(): string;
  75522. /**
  75523. * Returns the string "Vector4".
  75524. * @returns "Vector4"
  75525. */
  75526. getClassName(): string;
  75527. /**
  75528. * Returns the Vector4 hash code.
  75529. * @returns a unique hash code
  75530. */
  75531. getHashCode(): number;
  75532. /**
  75533. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  75534. * @returns the resulting array
  75535. */
  75536. asArray(): number[];
  75537. /**
  75538. * Populates the given array from the given index with the Vector4 coordinates.
  75539. * @param array array to populate
  75540. * @param index index of the array to start at (default: 0)
  75541. * @returns the Vector4.
  75542. */
  75543. toArray(array: FloatArray, index?: number): Vector4;
  75544. /**
  75545. * Adds the given vector to the current Vector4.
  75546. * @param otherVector the vector to add
  75547. * @returns the updated Vector4.
  75548. */
  75549. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75550. /**
  75551. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  75552. * @param otherVector the vector to add
  75553. * @returns the resulting vector
  75554. */
  75555. add(otherVector: DeepImmutable<Vector4>): Vector4;
  75556. /**
  75557. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  75558. * @param otherVector the vector to add
  75559. * @param result the vector to store the result
  75560. * @returns the current Vector4.
  75561. */
  75562. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75563. /**
  75564. * Subtract in place the given vector from the current Vector4.
  75565. * @param otherVector the vector to subtract
  75566. * @returns the updated Vector4.
  75567. */
  75568. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75569. /**
  75570. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  75571. * @param otherVector the vector to add
  75572. * @returns the new vector with the result
  75573. */
  75574. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  75575. /**
  75576. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  75577. * @param otherVector the vector to subtract
  75578. * @param result the vector to store the result
  75579. * @returns the current Vector4.
  75580. */
  75581. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75582. /**
  75583. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75584. */
  75585. /**
  75586. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75587. * @param x value to subtract
  75588. * @param y value to subtract
  75589. * @param z value to subtract
  75590. * @param w value to subtract
  75591. * @returns new vector containing the result
  75592. */
  75593. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  75594. /**
  75595. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75596. * @param x value to subtract
  75597. * @param y value to subtract
  75598. * @param z value to subtract
  75599. * @param w value to subtract
  75600. * @param result the vector to store the result in
  75601. * @returns the current Vector4.
  75602. */
  75603. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  75604. /**
  75605. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  75606. * @returns a new vector with the negated values
  75607. */
  75608. negate(): Vector4;
  75609. /**
  75610. * Multiplies the current Vector4 coordinates by scale (float).
  75611. * @param scale the number to scale with
  75612. * @returns the updated Vector4.
  75613. */
  75614. scaleInPlace(scale: number): Vector4;
  75615. /**
  75616. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  75617. * @param scale the number to scale with
  75618. * @returns a new vector with the result
  75619. */
  75620. scale(scale: number): Vector4;
  75621. /**
  75622. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  75623. * @param scale the number to scale with
  75624. * @param result a vector to store the result in
  75625. * @returns the current Vector4.
  75626. */
  75627. scaleToRef(scale: number, result: Vector4): Vector4;
  75628. /**
  75629. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  75630. * @param scale defines the scale factor
  75631. * @param result defines the Vector4 object where to store the result
  75632. * @returns the unmodified current Vector4
  75633. */
  75634. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  75635. /**
  75636. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  75637. * @param otherVector the vector to compare against
  75638. * @returns true if they are equal
  75639. */
  75640. equals(otherVector: DeepImmutable<Vector4>): boolean;
  75641. /**
  75642. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  75643. * @param otherVector vector to compare against
  75644. * @param epsilon (Default: very small number)
  75645. * @returns true if they are equal
  75646. */
  75647. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  75648. /**
  75649. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  75650. * @param x x value to compare against
  75651. * @param y y value to compare against
  75652. * @param z z value to compare against
  75653. * @param w w value to compare against
  75654. * @returns true if equal
  75655. */
  75656. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  75657. /**
  75658. * Multiplies in place the current Vector4 by the given one.
  75659. * @param otherVector vector to multiple with
  75660. * @returns the updated Vector4.
  75661. */
  75662. multiplyInPlace(otherVector: Vector4): Vector4;
  75663. /**
  75664. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  75665. * @param otherVector vector to multiple with
  75666. * @returns resulting new vector
  75667. */
  75668. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  75669. /**
  75670. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  75671. * @param otherVector vector to multiple with
  75672. * @param result vector to store the result
  75673. * @returns the current Vector4.
  75674. */
  75675. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75676. /**
  75677. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  75678. * @param x x value multiply with
  75679. * @param y y value multiply with
  75680. * @param z z value multiply with
  75681. * @param w w value multiply with
  75682. * @returns resulting new vector
  75683. */
  75684. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  75685. /**
  75686. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  75687. * @param otherVector vector to devide with
  75688. * @returns resulting new vector
  75689. */
  75690. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  75691. /**
  75692. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  75693. * @param otherVector vector to devide with
  75694. * @param result vector to store the result
  75695. * @returns the current Vector4.
  75696. */
  75697. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75698. /**
  75699. * Divides the current Vector3 coordinates by the given ones.
  75700. * @param otherVector vector to devide with
  75701. * @returns the updated Vector3.
  75702. */
  75703. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75704. /**
  75705. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  75706. * @param other defines the second operand
  75707. * @returns the current updated Vector4
  75708. */
  75709. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  75710. /**
  75711. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  75712. * @param other defines the second operand
  75713. * @returns the current updated Vector4
  75714. */
  75715. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  75716. /**
  75717. * Gets a new Vector4 from current Vector4 floored values
  75718. * @returns a new Vector4
  75719. */
  75720. floor(): Vector4;
  75721. /**
  75722. * Gets a new Vector4 from current Vector3 floored values
  75723. * @returns a new Vector4
  75724. */
  75725. fract(): Vector4;
  75726. /**
  75727. * Returns the Vector4 length (float).
  75728. * @returns the length
  75729. */
  75730. length(): number;
  75731. /**
  75732. * Returns the Vector4 squared length (float).
  75733. * @returns the length squared
  75734. */
  75735. lengthSquared(): number;
  75736. /**
  75737. * Normalizes in place the Vector4.
  75738. * @returns the updated Vector4.
  75739. */
  75740. normalize(): Vector4;
  75741. /**
  75742. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  75743. * @returns this converted to a new vector3
  75744. */
  75745. toVector3(): Vector3;
  75746. /**
  75747. * Returns a new Vector4 copied from the current one.
  75748. * @returns the new cloned vector
  75749. */
  75750. clone(): Vector4;
  75751. /**
  75752. * Updates the current Vector4 with the given one coordinates.
  75753. * @param source the source vector to copy from
  75754. * @returns the updated Vector4.
  75755. */
  75756. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  75757. /**
  75758. * Updates the current Vector4 coordinates with the given floats.
  75759. * @param x float to copy from
  75760. * @param y float to copy from
  75761. * @param z float to copy from
  75762. * @param w float to copy from
  75763. * @returns the updated Vector4.
  75764. */
  75765. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  75766. /**
  75767. * Updates the current Vector4 coordinates with the given floats.
  75768. * @param x float to set from
  75769. * @param y float to set from
  75770. * @param z float to set from
  75771. * @param w float to set from
  75772. * @returns the updated Vector4.
  75773. */
  75774. set(x: number, y: number, z: number, w: number): Vector4;
  75775. /**
  75776. * Copies the given float to the current Vector3 coordinates
  75777. * @param v defines the x, y, z and w coordinates of the operand
  75778. * @returns the current updated Vector3
  75779. */
  75780. setAll(v: number): Vector4;
  75781. /**
  75782. * Returns a new Vector4 set from the starting index of the given array.
  75783. * @param array the array to pull values from
  75784. * @param offset the offset into the array to start at
  75785. * @returns the new vector
  75786. */
  75787. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  75788. /**
  75789. * Updates the given vector "result" from the starting index of the given array.
  75790. * @param array the array to pull values from
  75791. * @param offset the offset into the array to start at
  75792. * @param result the vector to store the result in
  75793. */
  75794. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  75795. /**
  75796. * Updates the given vector "result" from the starting index of the given Float32Array.
  75797. * @param array the array to pull values from
  75798. * @param offset the offset into the array to start at
  75799. * @param result the vector to store the result in
  75800. */
  75801. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  75802. /**
  75803. * Updates the given vector "result" coordinates from the given floats.
  75804. * @param x float to set from
  75805. * @param y float to set from
  75806. * @param z float to set from
  75807. * @param w float to set from
  75808. * @param result the vector to the floats in
  75809. */
  75810. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  75811. /**
  75812. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  75813. * @returns the new vector
  75814. */
  75815. static Zero(): Vector4;
  75816. /**
  75817. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  75818. * @returns the new vector
  75819. */
  75820. static One(): Vector4;
  75821. /**
  75822. * Returns a new normalized Vector4 from the given one.
  75823. * @param vector the vector to normalize
  75824. * @returns the vector
  75825. */
  75826. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  75827. /**
  75828. * Updates the given vector "result" from the normalization of the given one.
  75829. * @param vector the vector to normalize
  75830. * @param result the vector to store the result in
  75831. */
  75832. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  75833. /**
  75834. * Returns a vector with the minimum values from the left and right vectors
  75835. * @param left left vector to minimize
  75836. * @param right right vector to minimize
  75837. * @returns a new vector with the minimum of the left and right vector values
  75838. */
  75839. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  75840. /**
  75841. * Returns a vector with the maximum values from the left and right vectors
  75842. * @param left left vector to maximize
  75843. * @param right right vector to maximize
  75844. * @returns a new vector with the maximum of the left and right vector values
  75845. */
  75846. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  75847. /**
  75848. * Returns the distance (float) between the vectors "value1" and "value2".
  75849. * @param value1 value to calulate the distance between
  75850. * @param value2 value to calulate the distance between
  75851. * @return the distance between the two vectors
  75852. */
  75853. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  75854. /**
  75855. * Returns the squared distance (float) between the vectors "value1" and "value2".
  75856. * @param value1 value to calulate the distance between
  75857. * @param value2 value to calulate the distance between
  75858. * @return the distance between the two vectors squared
  75859. */
  75860. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  75861. /**
  75862. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  75863. * @param value1 value to calulate the center between
  75864. * @param value2 value to calulate the center between
  75865. * @return the center between the two vectors
  75866. */
  75867. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  75868. /**
  75869. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  75870. * This methods computes transformed normalized direction vectors only.
  75871. * @param vector the vector to transform
  75872. * @param transformation the transformation matrix to apply
  75873. * @returns the new vector
  75874. */
  75875. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  75876. /**
  75877. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  75878. * This methods computes transformed normalized direction vectors only.
  75879. * @param vector the vector to transform
  75880. * @param transformation the transformation matrix to apply
  75881. * @param result the vector to store the result in
  75882. */
  75883. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  75884. /**
  75885. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  75886. * This methods computes transformed normalized direction vectors only.
  75887. * @param x value to transform
  75888. * @param y value to transform
  75889. * @param z value to transform
  75890. * @param w value to transform
  75891. * @param transformation the transformation matrix to apply
  75892. * @param result the vector to store the results in
  75893. */
  75894. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  75895. /**
  75896. * Creates a new Vector4 from a Vector3
  75897. * @param source defines the source data
  75898. * @param w defines the 4th component (default is 0)
  75899. * @returns a new Vector4
  75900. */
  75901. static FromVector3(source: Vector3, w?: number): Vector4;
  75902. }
  75903. /**
  75904. * Class used to store quaternion data
  75905. * @see https://en.wikipedia.org/wiki/Quaternion
  75906. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  75907. */
  75908. export class Quaternion {
  75909. /** defines the first component (0 by default) */
  75910. x: number;
  75911. /** defines the second component (0 by default) */
  75912. y: number;
  75913. /** defines the third component (0 by default) */
  75914. z: number;
  75915. /** defines the fourth component (1.0 by default) */
  75916. w: number;
  75917. /**
  75918. * Creates a new Quaternion from the given floats
  75919. * @param x defines the first component (0 by default)
  75920. * @param y defines the second component (0 by default)
  75921. * @param z defines the third component (0 by default)
  75922. * @param w defines the fourth component (1.0 by default)
  75923. */
  75924. constructor(
  75925. /** defines the first component (0 by default) */
  75926. x?: number,
  75927. /** defines the second component (0 by default) */
  75928. y?: number,
  75929. /** defines the third component (0 by default) */
  75930. z?: number,
  75931. /** defines the fourth component (1.0 by default) */
  75932. w?: number);
  75933. /**
  75934. * Gets a string representation for the current quaternion
  75935. * @returns a string with the Quaternion coordinates
  75936. */
  75937. toString(): string;
  75938. /**
  75939. * Gets the class name of the quaternion
  75940. * @returns the string "Quaternion"
  75941. */
  75942. getClassName(): string;
  75943. /**
  75944. * Gets a hash code for this quaternion
  75945. * @returns the quaternion hash code
  75946. */
  75947. getHashCode(): number;
  75948. /**
  75949. * Copy the quaternion to an array
  75950. * @returns a new array populated with 4 elements from the quaternion coordinates
  75951. */
  75952. asArray(): number[];
  75953. /**
  75954. * Check if two quaternions are equals
  75955. * @param otherQuaternion defines the second operand
  75956. * @return true if the current quaternion and the given one coordinates are strictly equals
  75957. */
  75958. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  75959. /**
  75960. * Gets a boolean if two quaternions are equals (using an epsilon value)
  75961. * @param otherQuaternion defines the other quaternion
  75962. * @param epsilon defines the minimal distance to consider equality
  75963. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  75964. */
  75965. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  75966. /**
  75967. * Clone the current quaternion
  75968. * @returns a new quaternion copied from the current one
  75969. */
  75970. clone(): Quaternion;
  75971. /**
  75972. * Copy a quaternion to the current one
  75973. * @param other defines the other quaternion
  75974. * @returns the updated current quaternion
  75975. */
  75976. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  75977. /**
  75978. * Updates the current quaternion with the given float coordinates
  75979. * @param x defines the x coordinate
  75980. * @param y defines the y coordinate
  75981. * @param z defines the z coordinate
  75982. * @param w defines the w coordinate
  75983. * @returns the updated current quaternion
  75984. */
  75985. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  75986. /**
  75987. * Updates the current quaternion from the given float coordinates
  75988. * @param x defines the x coordinate
  75989. * @param y defines the y coordinate
  75990. * @param z defines the z coordinate
  75991. * @param w defines the w coordinate
  75992. * @returns the updated current quaternion
  75993. */
  75994. set(x: number, y: number, z: number, w: number): Quaternion;
  75995. /**
  75996. * Adds two quaternions
  75997. * @param other defines the second operand
  75998. * @returns a new quaternion as the addition result of the given one and the current quaternion
  75999. */
  76000. add(other: DeepImmutable<Quaternion>): Quaternion;
  76001. /**
  76002. * Add a quaternion to the current one
  76003. * @param other defines the quaternion to add
  76004. * @returns the current quaternion
  76005. */
  76006. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76007. /**
  76008. * Subtract two quaternions
  76009. * @param other defines the second operand
  76010. * @returns a new quaternion as the subtraction result of the given one from the current one
  76011. */
  76012. subtract(other: Quaternion): Quaternion;
  76013. /**
  76014. * Multiplies the current quaternion by a scale factor
  76015. * @param value defines the scale factor
  76016. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76017. */
  76018. scale(value: number): Quaternion;
  76019. /**
  76020. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76021. * @param scale defines the scale factor
  76022. * @param result defines the Quaternion object where to store the result
  76023. * @returns the unmodified current quaternion
  76024. */
  76025. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76026. /**
  76027. * Multiplies in place the current quaternion by a scale factor
  76028. * @param value defines the scale factor
  76029. * @returns the current modified quaternion
  76030. */
  76031. scaleInPlace(value: number): Quaternion;
  76032. /**
  76033. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76034. * @param scale defines the scale factor
  76035. * @param result defines the Quaternion object where to store the result
  76036. * @returns the unmodified current quaternion
  76037. */
  76038. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76039. /**
  76040. * Multiplies two quaternions
  76041. * @param q1 defines the second operand
  76042. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76043. */
  76044. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76045. /**
  76046. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76047. * @param q1 defines the second operand
  76048. * @param result defines the target quaternion
  76049. * @returns the current quaternion
  76050. */
  76051. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76052. /**
  76053. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76054. * @param q1 defines the second operand
  76055. * @returns the currentupdated quaternion
  76056. */
  76057. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76058. /**
  76059. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76060. * @param ref defines the target quaternion
  76061. * @returns the current quaternion
  76062. */
  76063. conjugateToRef(ref: Quaternion): Quaternion;
  76064. /**
  76065. * Conjugates in place (1-q) the current quaternion
  76066. * @returns the current updated quaternion
  76067. */
  76068. conjugateInPlace(): Quaternion;
  76069. /**
  76070. * Conjugates in place (1-q) the current quaternion
  76071. * @returns a new quaternion
  76072. */
  76073. conjugate(): Quaternion;
  76074. /**
  76075. * Gets length of current quaternion
  76076. * @returns the quaternion length (float)
  76077. */
  76078. length(): number;
  76079. /**
  76080. * Normalize in place the current quaternion
  76081. * @returns the current updated quaternion
  76082. */
  76083. normalize(): Quaternion;
  76084. /**
  76085. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76086. * @param order is a reserved parameter and is ignore for now
  76087. * @returns a new Vector3 containing the Euler angles
  76088. */
  76089. toEulerAngles(order?: string): Vector3;
  76090. /**
  76091. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76092. * @param result defines the vector which will be filled with the Euler angles
  76093. * @param order is a reserved parameter and is ignore for now
  76094. * @returns the current unchanged quaternion
  76095. */
  76096. toEulerAnglesToRef(result: Vector3): Quaternion;
  76097. /**
  76098. * Updates the given rotation matrix with the current quaternion values
  76099. * @param result defines the target matrix
  76100. * @returns the current unchanged quaternion
  76101. */
  76102. toRotationMatrix(result: Matrix): Quaternion;
  76103. /**
  76104. * Updates the current quaternion from the given rotation matrix values
  76105. * @param matrix defines the source matrix
  76106. * @returns the current updated quaternion
  76107. */
  76108. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76109. /**
  76110. * Creates a new quaternion from a rotation matrix
  76111. * @param matrix defines the source matrix
  76112. * @returns a new quaternion created from the given rotation matrix values
  76113. */
  76114. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76115. /**
  76116. * Updates the given quaternion with the given rotation matrix values
  76117. * @param matrix defines the source matrix
  76118. * @param result defines the target quaternion
  76119. */
  76120. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76121. /**
  76122. * Returns the dot product (float) between the quaternions "left" and "right"
  76123. * @param left defines the left operand
  76124. * @param right defines the right operand
  76125. * @returns the dot product
  76126. */
  76127. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76128. /**
  76129. * Checks if the two quaternions are close to each other
  76130. * @param quat0 defines the first quaternion to check
  76131. * @param quat1 defines the second quaternion to check
  76132. * @returns true if the two quaternions are close to each other
  76133. */
  76134. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76135. /**
  76136. * Creates an empty quaternion
  76137. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76138. */
  76139. static Zero(): Quaternion;
  76140. /**
  76141. * Inverse a given quaternion
  76142. * @param q defines the source quaternion
  76143. * @returns a new quaternion as the inverted current quaternion
  76144. */
  76145. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76146. /**
  76147. * Inverse a given quaternion
  76148. * @param q defines the source quaternion
  76149. * @param result the quaternion the result will be stored in
  76150. * @returns the result quaternion
  76151. */
  76152. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76153. /**
  76154. * Creates an identity quaternion
  76155. * @returns the identity quaternion
  76156. */
  76157. static Identity(): Quaternion;
  76158. /**
  76159. * Gets a boolean indicating if the given quaternion is identity
  76160. * @param quaternion defines the quaternion to check
  76161. * @returns true if the quaternion is identity
  76162. */
  76163. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76164. /**
  76165. * Creates a quaternion from a rotation around an axis
  76166. * @param axis defines the axis to use
  76167. * @param angle defines the angle to use
  76168. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76169. */
  76170. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76171. /**
  76172. * Creates a rotation around an axis and stores it into the given quaternion
  76173. * @param axis defines the axis to use
  76174. * @param angle defines the angle to use
  76175. * @param result defines the target quaternion
  76176. * @returns the target quaternion
  76177. */
  76178. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76179. /**
  76180. * Creates a new quaternion from data stored into an array
  76181. * @param array defines the data source
  76182. * @param offset defines the offset in the source array where the data starts
  76183. * @returns a new quaternion
  76184. */
  76185. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76186. /**
  76187. * Create a quaternion from Euler rotation angles
  76188. * @param x Pitch
  76189. * @param y Yaw
  76190. * @param z Roll
  76191. * @returns the new Quaternion
  76192. */
  76193. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76194. /**
  76195. * Updates a quaternion from Euler rotation angles
  76196. * @param x Pitch
  76197. * @param y Yaw
  76198. * @param z Roll
  76199. * @param result the quaternion to store the result
  76200. * @returns the updated quaternion
  76201. */
  76202. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76203. /**
  76204. * Create a quaternion from Euler rotation vector
  76205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76206. * @returns the new Quaternion
  76207. */
  76208. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76209. /**
  76210. * Updates a quaternion from Euler rotation vector
  76211. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76212. * @param result the quaternion to store the result
  76213. * @returns the updated quaternion
  76214. */
  76215. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76216. /**
  76217. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76218. * @param yaw defines the rotation around Y axis
  76219. * @param pitch defines the rotation around X axis
  76220. * @param roll defines the rotation around Z axis
  76221. * @returns the new quaternion
  76222. */
  76223. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  76224. /**
  76225. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76226. * @param yaw defines the rotation around Y axis
  76227. * @param pitch defines the rotation around X axis
  76228. * @param roll defines the rotation around Z axis
  76229. * @param result defines the target quaternion
  76230. */
  76231. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  76232. /**
  76233. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  76234. * @param alpha defines the rotation around first axis
  76235. * @param beta defines the rotation around second axis
  76236. * @param gamma defines the rotation around third axis
  76237. * @returns the new quaternion
  76238. */
  76239. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  76240. /**
  76241. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  76242. * @param alpha defines the rotation around first axis
  76243. * @param beta defines the rotation around second axis
  76244. * @param gamma defines the rotation around third axis
  76245. * @param result defines the target quaternion
  76246. */
  76247. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  76248. /**
  76249. * 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)
  76250. * @param axis1 defines the first axis
  76251. * @param axis2 defines the second axis
  76252. * @param axis3 defines the third axis
  76253. * @returns the new quaternion
  76254. */
  76255. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  76256. /**
  76257. * 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
  76258. * @param axis1 defines the first axis
  76259. * @param axis2 defines the second axis
  76260. * @param axis3 defines the third axis
  76261. * @param ref defines the target quaternion
  76262. */
  76263. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  76264. /**
  76265. * Interpolates between two quaternions
  76266. * @param left defines first quaternion
  76267. * @param right defines second quaternion
  76268. * @param amount defines the gradient to use
  76269. * @returns the new interpolated quaternion
  76270. */
  76271. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76272. /**
  76273. * Interpolates between two quaternions and stores it into a target quaternion
  76274. * @param left defines first quaternion
  76275. * @param right defines second quaternion
  76276. * @param amount defines the gradient to use
  76277. * @param result defines the target quaternion
  76278. */
  76279. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  76280. /**
  76281. * Interpolate between two quaternions using Hermite interpolation
  76282. * @param value1 defines first quaternion
  76283. * @param tangent1 defines the incoming tangent
  76284. * @param value2 defines second quaternion
  76285. * @param tangent2 defines the outgoing tangent
  76286. * @param amount defines the target quaternion
  76287. * @returns the new interpolated quaternion
  76288. */
  76289. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76290. }
  76291. /**
  76292. * Class used to store matrix data (4x4)
  76293. */
  76294. export class Matrix {
  76295. private static _updateFlagSeed;
  76296. private static _identityReadOnly;
  76297. private _isIdentity;
  76298. private _isIdentityDirty;
  76299. private _isIdentity3x2;
  76300. private _isIdentity3x2Dirty;
  76301. /**
  76302. * Gets the update flag of the matrix which is an unique number for the matrix.
  76303. * It will be incremented every time the matrix data change.
  76304. * You can use it to speed the comparison between two versions of the same matrix.
  76305. */
  76306. updateFlag: number;
  76307. private readonly _m;
  76308. /**
  76309. * Gets the internal data of the matrix
  76310. */
  76311. get m(): DeepImmutable<Float32Array>;
  76312. /** @hidden */
  76313. _markAsUpdated(): void;
  76314. /** @hidden */
  76315. private _updateIdentityStatus;
  76316. /**
  76317. * Creates an empty matrix (filled with zeros)
  76318. */
  76319. constructor();
  76320. /**
  76321. * Check if the current matrix is identity
  76322. * @returns true is the matrix is the identity matrix
  76323. */
  76324. isIdentity(): boolean;
  76325. /**
  76326. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  76327. * @returns true is the matrix is the identity matrix
  76328. */
  76329. isIdentityAs3x2(): boolean;
  76330. /**
  76331. * Gets the determinant of the matrix
  76332. * @returns the matrix determinant
  76333. */
  76334. determinant(): number;
  76335. /**
  76336. * Returns the matrix as a Float32Array
  76337. * @returns the matrix underlying array
  76338. */
  76339. toArray(): DeepImmutable<Float32Array>;
  76340. /**
  76341. * Returns the matrix as a Float32Array
  76342. * @returns the matrix underlying array.
  76343. */
  76344. asArray(): DeepImmutable<Float32Array>;
  76345. /**
  76346. * Inverts the current matrix in place
  76347. * @returns the current inverted matrix
  76348. */
  76349. invert(): Matrix;
  76350. /**
  76351. * Sets all the matrix elements to zero
  76352. * @returns the current matrix
  76353. */
  76354. reset(): Matrix;
  76355. /**
  76356. * Adds the current matrix with a second one
  76357. * @param other defines the matrix to add
  76358. * @returns a new matrix as the addition of the current matrix and the given one
  76359. */
  76360. add(other: DeepImmutable<Matrix>): Matrix;
  76361. /**
  76362. * Sets the given matrix "result" to the addition of the current matrix and the given one
  76363. * @param other defines the matrix to add
  76364. * @param result defines the target matrix
  76365. * @returns the current matrix
  76366. */
  76367. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76368. /**
  76369. * Adds in place the given matrix to the current matrix
  76370. * @param other defines the second operand
  76371. * @returns the current updated matrix
  76372. */
  76373. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  76374. /**
  76375. * Sets the given matrix to the current inverted Matrix
  76376. * @param other defines the target matrix
  76377. * @returns the unmodified current matrix
  76378. */
  76379. invertToRef(other: Matrix): Matrix;
  76380. /**
  76381. * add a value at the specified position in the current Matrix
  76382. * @param index the index of the value within the matrix. between 0 and 15.
  76383. * @param value the value to be added
  76384. * @returns the current updated matrix
  76385. */
  76386. addAtIndex(index: number, value: number): Matrix;
  76387. /**
  76388. * mutiply the specified position in the current Matrix by a value
  76389. * @param index the index of the value within the matrix. between 0 and 15.
  76390. * @param value the value to be added
  76391. * @returns the current updated matrix
  76392. */
  76393. multiplyAtIndex(index: number, value: number): Matrix;
  76394. /**
  76395. * Inserts the translation vector (using 3 floats) in the current matrix
  76396. * @param x defines the 1st component of the translation
  76397. * @param y defines the 2nd component of the translation
  76398. * @param z defines the 3rd component of the translation
  76399. * @returns the current updated matrix
  76400. */
  76401. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76402. /**
  76403. * Adds the translation vector (using 3 floats) in the current matrix
  76404. * @param x defines the 1st component of the translation
  76405. * @param y defines the 2nd component of the translation
  76406. * @param z defines the 3rd component of the translation
  76407. * @returns the current updated matrix
  76408. */
  76409. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76410. /**
  76411. * Inserts the translation vector in the current matrix
  76412. * @param vector3 defines the translation to insert
  76413. * @returns the current updated matrix
  76414. */
  76415. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  76416. /**
  76417. * Gets the translation value of the current matrix
  76418. * @returns a new Vector3 as the extracted translation from the matrix
  76419. */
  76420. getTranslation(): Vector3;
  76421. /**
  76422. * Fill a Vector3 with the extracted translation from the matrix
  76423. * @param result defines the Vector3 where to store the translation
  76424. * @returns the current matrix
  76425. */
  76426. getTranslationToRef(result: Vector3): Matrix;
  76427. /**
  76428. * Remove rotation and scaling part from the matrix
  76429. * @returns the updated matrix
  76430. */
  76431. removeRotationAndScaling(): Matrix;
  76432. /**
  76433. * Multiply two matrices
  76434. * @param other defines the second operand
  76435. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  76436. */
  76437. multiply(other: DeepImmutable<Matrix>): Matrix;
  76438. /**
  76439. * Copy the current matrix from the given one
  76440. * @param other defines the source matrix
  76441. * @returns the current updated matrix
  76442. */
  76443. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  76444. /**
  76445. * Populates the given array from the starting index with the current matrix values
  76446. * @param array defines the target array
  76447. * @param offset defines the offset in the target array where to start storing values
  76448. * @returns the current matrix
  76449. */
  76450. copyToArray(array: Float32Array, offset?: number): Matrix;
  76451. /**
  76452. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  76453. * @param other defines the second operand
  76454. * @param result defines the matrix where to store the multiplication
  76455. * @returns the current matrix
  76456. */
  76457. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76458. /**
  76459. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  76460. * @param other defines the second operand
  76461. * @param result defines the array where to store the multiplication
  76462. * @param offset defines the offset in the target array where to start storing values
  76463. * @returns the current matrix
  76464. */
  76465. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  76466. /**
  76467. * Check equality between this matrix and a second one
  76468. * @param value defines the second matrix to compare
  76469. * @returns true is the current matrix and the given one values are strictly equal
  76470. */
  76471. equals(value: DeepImmutable<Matrix>): boolean;
  76472. /**
  76473. * Clone the current matrix
  76474. * @returns a new matrix from the current matrix
  76475. */
  76476. clone(): Matrix;
  76477. /**
  76478. * Returns the name of the current matrix class
  76479. * @returns the string "Matrix"
  76480. */
  76481. getClassName(): string;
  76482. /**
  76483. * Gets the hash code of the current matrix
  76484. * @returns the hash code
  76485. */
  76486. getHashCode(): number;
  76487. /**
  76488. * Decomposes the current Matrix into a translation, rotation and scaling components
  76489. * @param scale defines the scale vector3 given as a reference to update
  76490. * @param rotation defines the rotation quaternion given as a reference to update
  76491. * @param translation defines the translation vector3 given as a reference to update
  76492. * @returns true if operation was successful
  76493. */
  76494. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  76495. /**
  76496. * Gets specific row of the matrix
  76497. * @param index defines the number of the row to get
  76498. * @returns the index-th row of the current matrix as a new Vector4
  76499. */
  76500. getRow(index: number): Nullable<Vector4>;
  76501. /**
  76502. * Sets the index-th row of the current matrix to the vector4 values
  76503. * @param index defines the number of the row to set
  76504. * @param row defines the target vector4
  76505. * @returns the updated current matrix
  76506. */
  76507. setRow(index: number, row: Vector4): Matrix;
  76508. /**
  76509. * Compute the transpose of the matrix
  76510. * @returns the new transposed matrix
  76511. */
  76512. transpose(): Matrix;
  76513. /**
  76514. * Compute the transpose of the matrix and store it in a given matrix
  76515. * @param result defines the target matrix
  76516. * @returns the current matrix
  76517. */
  76518. transposeToRef(result: Matrix): Matrix;
  76519. /**
  76520. * Sets the index-th row of the current matrix with the given 4 x float values
  76521. * @param index defines the row index
  76522. * @param x defines the x component to set
  76523. * @param y defines the y component to set
  76524. * @param z defines the z component to set
  76525. * @param w defines the w component to set
  76526. * @returns the updated current matrix
  76527. */
  76528. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  76529. /**
  76530. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  76531. * @param scale defines the scale factor
  76532. * @returns a new matrix
  76533. */
  76534. scale(scale: number): Matrix;
  76535. /**
  76536. * Scale the current matrix values by a factor to a given result matrix
  76537. * @param scale defines the scale factor
  76538. * @param result defines the matrix to store the result
  76539. * @returns the current matrix
  76540. */
  76541. scaleToRef(scale: number, result: Matrix): Matrix;
  76542. /**
  76543. * Scale the current matrix values by a factor and add the result to a given matrix
  76544. * @param scale defines the scale factor
  76545. * @param result defines the Matrix to store the result
  76546. * @returns the current matrix
  76547. */
  76548. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  76549. /**
  76550. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  76551. * @param ref matrix to store the result
  76552. */
  76553. toNormalMatrix(ref: Matrix): void;
  76554. /**
  76555. * Gets only rotation part of the current matrix
  76556. * @returns a new matrix sets to the extracted rotation matrix from the current one
  76557. */
  76558. getRotationMatrix(): Matrix;
  76559. /**
  76560. * Extracts the rotation matrix from the current one and sets it as the given "result"
  76561. * @param result defines the target matrix to store data to
  76562. * @returns the current matrix
  76563. */
  76564. getRotationMatrixToRef(result: Matrix): Matrix;
  76565. /**
  76566. * Toggles model matrix from being right handed to left handed in place and vice versa
  76567. */
  76568. toggleModelMatrixHandInPlace(): void;
  76569. /**
  76570. * Toggles projection matrix from being right handed to left handed in place and vice versa
  76571. */
  76572. toggleProjectionMatrixHandInPlace(): void;
  76573. /**
  76574. * Creates a matrix from an array
  76575. * @param array defines the source array
  76576. * @param offset defines an offset in the source array
  76577. * @returns a new Matrix set from the starting index of the given array
  76578. */
  76579. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  76580. /**
  76581. * Copy the content of an array into a given matrix
  76582. * @param array defines the source array
  76583. * @param offset defines an offset in the source array
  76584. * @param result defines the target matrix
  76585. */
  76586. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  76587. /**
  76588. * Stores an array into a matrix after having multiplied each component by a given factor
  76589. * @param array defines the source array
  76590. * @param offset defines the offset in the source array
  76591. * @param scale defines the scaling factor
  76592. * @param result defines the target matrix
  76593. */
  76594. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  76595. /**
  76596. * Gets an identity matrix that must not be updated
  76597. */
  76598. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  76599. /**
  76600. * Stores a list of values (16) inside a given matrix
  76601. * @param initialM11 defines 1st value of 1st row
  76602. * @param initialM12 defines 2nd value of 1st row
  76603. * @param initialM13 defines 3rd value of 1st row
  76604. * @param initialM14 defines 4th value of 1st row
  76605. * @param initialM21 defines 1st value of 2nd row
  76606. * @param initialM22 defines 2nd value of 2nd row
  76607. * @param initialM23 defines 3rd value of 2nd row
  76608. * @param initialM24 defines 4th value of 2nd row
  76609. * @param initialM31 defines 1st value of 3rd row
  76610. * @param initialM32 defines 2nd value of 3rd row
  76611. * @param initialM33 defines 3rd value of 3rd row
  76612. * @param initialM34 defines 4th value of 3rd row
  76613. * @param initialM41 defines 1st value of 4th row
  76614. * @param initialM42 defines 2nd value of 4th row
  76615. * @param initialM43 defines 3rd value of 4th row
  76616. * @param initialM44 defines 4th value of 4th row
  76617. * @param result defines the target matrix
  76618. */
  76619. 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;
  76620. /**
  76621. * Creates new matrix from a list of values (16)
  76622. * @param initialM11 defines 1st value of 1st row
  76623. * @param initialM12 defines 2nd value of 1st row
  76624. * @param initialM13 defines 3rd value of 1st row
  76625. * @param initialM14 defines 4th value of 1st row
  76626. * @param initialM21 defines 1st value of 2nd row
  76627. * @param initialM22 defines 2nd value of 2nd row
  76628. * @param initialM23 defines 3rd value of 2nd row
  76629. * @param initialM24 defines 4th value of 2nd row
  76630. * @param initialM31 defines 1st value of 3rd row
  76631. * @param initialM32 defines 2nd value of 3rd row
  76632. * @param initialM33 defines 3rd value of 3rd row
  76633. * @param initialM34 defines 4th value of 3rd row
  76634. * @param initialM41 defines 1st value of 4th row
  76635. * @param initialM42 defines 2nd value of 4th row
  76636. * @param initialM43 defines 3rd value of 4th row
  76637. * @param initialM44 defines 4th value of 4th row
  76638. * @returns the new matrix
  76639. */
  76640. 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;
  76641. /**
  76642. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76643. * @param scale defines the scale vector3
  76644. * @param rotation defines the rotation quaternion
  76645. * @param translation defines the translation vector3
  76646. * @returns a new matrix
  76647. */
  76648. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  76649. /**
  76650. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76651. * @param scale defines the scale vector3
  76652. * @param rotation defines the rotation quaternion
  76653. * @param translation defines the translation vector3
  76654. * @param result defines the target matrix
  76655. */
  76656. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  76657. /**
  76658. * Creates a new identity matrix
  76659. * @returns a new identity matrix
  76660. */
  76661. static Identity(): Matrix;
  76662. /**
  76663. * Creates a new identity matrix and stores the result in a given matrix
  76664. * @param result defines the target matrix
  76665. */
  76666. static IdentityToRef(result: Matrix): void;
  76667. /**
  76668. * Creates a new zero matrix
  76669. * @returns a new zero matrix
  76670. */
  76671. static Zero(): Matrix;
  76672. /**
  76673. * Creates a new rotation matrix for "angle" radians around the X axis
  76674. * @param angle defines the angle (in radians) to use
  76675. * @return the new matrix
  76676. */
  76677. static RotationX(angle: number): Matrix;
  76678. /**
  76679. * Creates a new matrix as the invert of a given matrix
  76680. * @param source defines the source matrix
  76681. * @returns the new matrix
  76682. */
  76683. static Invert(source: DeepImmutable<Matrix>): Matrix;
  76684. /**
  76685. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  76686. * @param angle defines the angle (in radians) to use
  76687. * @param result defines the target matrix
  76688. */
  76689. static RotationXToRef(angle: number, result: Matrix): void;
  76690. /**
  76691. * Creates a new rotation matrix for "angle" radians around the Y axis
  76692. * @param angle defines the angle (in radians) to use
  76693. * @return the new matrix
  76694. */
  76695. static RotationY(angle: number): Matrix;
  76696. /**
  76697. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  76698. * @param angle defines the angle (in radians) to use
  76699. * @param result defines the target matrix
  76700. */
  76701. static RotationYToRef(angle: number, result: Matrix): void;
  76702. /**
  76703. * Creates a new rotation matrix for "angle" radians around the Z axis
  76704. * @param angle defines the angle (in radians) to use
  76705. * @return the new matrix
  76706. */
  76707. static RotationZ(angle: number): Matrix;
  76708. /**
  76709. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  76710. * @param angle defines the angle (in radians) to use
  76711. * @param result defines the target matrix
  76712. */
  76713. static RotationZToRef(angle: number, result: Matrix): void;
  76714. /**
  76715. * Creates a new rotation matrix for "angle" radians around the given axis
  76716. * @param axis defines the axis to use
  76717. * @param angle defines the angle (in radians) to use
  76718. * @return the new matrix
  76719. */
  76720. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  76721. /**
  76722. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  76723. * @param axis defines the axis to use
  76724. * @param angle defines the angle (in radians) to use
  76725. * @param result defines the target matrix
  76726. */
  76727. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  76728. /**
  76729. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  76730. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  76731. * @param from defines the vector to align
  76732. * @param to defines the vector to align to
  76733. * @param result defines the target matrix
  76734. */
  76735. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  76736. /**
  76737. * Creates a rotation matrix
  76738. * @param yaw defines the yaw angle in radians (Y axis)
  76739. * @param pitch defines the pitch angle in radians (X axis)
  76740. * @param roll defines the roll angle in radians (X axis)
  76741. * @returns the new rotation matrix
  76742. */
  76743. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  76744. /**
  76745. * Creates a rotation matrix and stores it in a given matrix
  76746. * @param yaw defines the yaw angle in radians (Y axis)
  76747. * @param pitch defines the pitch angle in radians (X axis)
  76748. * @param roll defines the roll angle in radians (X axis)
  76749. * @param result defines the target matrix
  76750. */
  76751. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  76752. /**
  76753. * Creates a scaling matrix
  76754. * @param x defines the scale factor on X axis
  76755. * @param y defines the scale factor on Y axis
  76756. * @param z defines the scale factor on Z axis
  76757. * @returns the new matrix
  76758. */
  76759. static Scaling(x: number, y: number, z: number): Matrix;
  76760. /**
  76761. * Creates a scaling matrix and stores it in a given matrix
  76762. * @param x defines the scale factor on X axis
  76763. * @param y defines the scale factor on Y axis
  76764. * @param z defines the scale factor on Z axis
  76765. * @param result defines the target matrix
  76766. */
  76767. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  76768. /**
  76769. * Creates a translation matrix
  76770. * @param x defines the translation on X axis
  76771. * @param y defines the translation on Y axis
  76772. * @param z defines the translationon Z axis
  76773. * @returns the new matrix
  76774. */
  76775. static Translation(x: number, y: number, z: number): Matrix;
  76776. /**
  76777. * Creates a translation matrix and stores it in a given matrix
  76778. * @param x defines the translation on X axis
  76779. * @param y defines the translation on Y axis
  76780. * @param z defines the translationon Z axis
  76781. * @param result defines the target matrix
  76782. */
  76783. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  76784. /**
  76785. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76786. * @param startValue defines the start value
  76787. * @param endValue defines the end value
  76788. * @param gradient defines the gradient factor
  76789. * @returns the new matrix
  76790. */
  76791. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  76792. /**
  76793. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76794. * @param startValue defines the start value
  76795. * @param endValue defines the end value
  76796. * @param gradient defines the gradient factor
  76797. * @param result defines the Matrix object where to store data
  76798. */
  76799. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  76800. /**
  76801. * Builds a new matrix whose values are computed by:
  76802. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76803. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76804. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76805. * @param startValue defines the first matrix
  76806. * @param endValue defines the second matrix
  76807. * @param gradient defines the gradient between the two matrices
  76808. * @returns the new matrix
  76809. */
  76810. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  76811. /**
  76812. * Update a matrix to values which are computed by:
  76813. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76814. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76815. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76816. * @param startValue defines the first matrix
  76817. * @param endValue defines the second matrix
  76818. * @param gradient defines the gradient between the two matrices
  76819. * @param result defines the target matrix
  76820. */
  76821. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  76822. /**
  76823. * 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"
  76824. * This function works in left handed mode
  76825. * @param eye defines the final position of the entity
  76826. * @param target defines where the entity should look at
  76827. * @param up defines the up vector for the entity
  76828. * @returns the new matrix
  76829. */
  76830. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  76831. /**
  76832. * 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".
  76833. * This function works in left handed mode
  76834. * @param eye defines the final position of the entity
  76835. * @param target defines where the entity should look at
  76836. * @param up defines the up vector for the entity
  76837. * @param result defines the target matrix
  76838. */
  76839. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  76840. /**
  76841. * 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"
  76842. * This function works in right handed mode
  76843. * @param eye defines the final position of the entity
  76844. * @param target defines where the entity should look at
  76845. * @param up defines the up vector for the entity
  76846. * @returns the new matrix
  76847. */
  76848. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  76849. /**
  76850. * 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".
  76851. * This function works in right handed mode
  76852. * @param eye defines the final position of the entity
  76853. * @param target defines where the entity should look at
  76854. * @param up defines the up vector for the entity
  76855. * @param result defines the target matrix
  76856. */
  76857. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  76858. /**
  76859. * Create a left-handed orthographic projection matrix
  76860. * @param width defines the viewport width
  76861. * @param height defines the viewport height
  76862. * @param znear defines the near clip plane
  76863. * @param zfar defines the far clip plane
  76864. * @returns a new matrix as a left-handed orthographic projection matrix
  76865. */
  76866. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  76867. /**
  76868. * Store a left-handed orthographic projection to a given matrix
  76869. * @param width defines the viewport width
  76870. * @param height defines the viewport height
  76871. * @param znear defines the near clip plane
  76872. * @param zfar defines the far clip plane
  76873. * @param result defines the target matrix
  76874. */
  76875. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  76876. /**
  76877. * Create a left-handed orthographic projection matrix
  76878. * @param left defines the viewport left coordinate
  76879. * @param right defines the viewport right coordinate
  76880. * @param bottom defines the viewport bottom coordinate
  76881. * @param top defines the viewport top coordinate
  76882. * @param znear defines the near clip plane
  76883. * @param zfar defines the far clip plane
  76884. * @returns a new matrix as a left-handed orthographic projection matrix
  76885. */
  76886. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  76887. /**
  76888. * Stores a left-handed orthographic projection into a given matrix
  76889. * @param left defines the viewport left coordinate
  76890. * @param right defines the viewport right coordinate
  76891. * @param bottom defines the viewport bottom coordinate
  76892. * @param top defines the viewport top coordinate
  76893. * @param znear defines the near clip plane
  76894. * @param zfar defines the far clip plane
  76895. * @param result defines the target matrix
  76896. */
  76897. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  76898. /**
  76899. * Creates a right-handed orthographic projection matrix
  76900. * @param left defines the viewport left coordinate
  76901. * @param right defines the viewport right coordinate
  76902. * @param bottom defines the viewport bottom coordinate
  76903. * @param top defines the viewport top coordinate
  76904. * @param znear defines the near clip plane
  76905. * @param zfar defines the far clip plane
  76906. * @returns a new matrix as a right-handed orthographic projection matrix
  76907. */
  76908. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  76909. /**
  76910. * Stores a right-handed orthographic projection into a given matrix
  76911. * @param left defines the viewport left coordinate
  76912. * @param right defines the viewport right coordinate
  76913. * @param bottom defines the viewport bottom coordinate
  76914. * @param top defines the viewport top coordinate
  76915. * @param znear defines the near clip plane
  76916. * @param zfar defines the far clip plane
  76917. * @param result defines the target matrix
  76918. */
  76919. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  76920. /**
  76921. * Creates a left-handed perspective projection matrix
  76922. * @param width defines the viewport width
  76923. * @param height defines the viewport height
  76924. * @param znear defines the near clip plane
  76925. * @param zfar defines the far clip plane
  76926. * @returns a new matrix as a left-handed perspective projection matrix
  76927. */
  76928. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  76929. /**
  76930. * Creates a left-handed perspective projection matrix
  76931. * @param fov defines the horizontal field of view
  76932. * @param aspect defines the aspect ratio
  76933. * @param znear defines the near clip plane
  76934. * @param zfar defines the far clip plane
  76935. * @returns a new matrix as a left-handed perspective projection matrix
  76936. */
  76937. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  76938. /**
  76939. * Stores a left-handed perspective projection into a given matrix
  76940. * @param fov defines the horizontal field of view
  76941. * @param aspect defines the aspect ratio
  76942. * @param znear defines the near clip plane
  76943. * @param zfar defines the far clip plane
  76944. * @param result defines the target matrix
  76945. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76946. */
  76947. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76948. /**
  76949. * Stores a left-handed perspective projection into a given matrix with depth reversed
  76950. * @param fov defines the horizontal field of view
  76951. * @param aspect defines the aspect ratio
  76952. * @param znear defines the near clip plane
  76953. * @param zfar not used as infinity is used as far clip
  76954. * @param result defines the target matrix
  76955. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76956. */
  76957. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76958. /**
  76959. * Creates a right-handed perspective projection matrix
  76960. * @param fov defines the horizontal field of view
  76961. * @param aspect defines the aspect ratio
  76962. * @param znear defines the near clip plane
  76963. * @param zfar defines the far clip plane
  76964. * @returns a new matrix as a right-handed perspective projection matrix
  76965. */
  76966. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  76967. /**
  76968. * Stores a right-handed perspective projection into a given matrix
  76969. * @param fov defines the horizontal field of view
  76970. * @param aspect defines the aspect ratio
  76971. * @param znear defines the near clip plane
  76972. * @param zfar defines the far clip plane
  76973. * @param result defines the target matrix
  76974. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76975. */
  76976. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76977. /**
  76978. * Stores a right-handed perspective projection into a given matrix
  76979. * @param fov defines the horizontal field of view
  76980. * @param aspect defines the aspect ratio
  76981. * @param znear defines the near clip plane
  76982. * @param zfar not used as infinity is used as far clip
  76983. * @param result defines the target matrix
  76984. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76985. */
  76986. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  76987. /**
  76988. * Stores a perspective projection for WebVR info a given matrix
  76989. * @param fov defines the field of view
  76990. * @param znear defines the near clip plane
  76991. * @param zfar defines the far clip plane
  76992. * @param result defines the target matrix
  76993. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  76994. */
  76995. static PerspectiveFovWebVRToRef(fov: {
  76996. upDegrees: number;
  76997. downDegrees: number;
  76998. leftDegrees: number;
  76999. rightDegrees: number;
  77000. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77001. /**
  77002. * Computes a complete transformation matrix
  77003. * @param viewport defines the viewport to use
  77004. * @param world defines the world matrix
  77005. * @param view defines the view matrix
  77006. * @param projection defines the projection matrix
  77007. * @param zmin defines the near clip plane
  77008. * @param zmax defines the far clip plane
  77009. * @returns the transformation matrix
  77010. */
  77011. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77012. /**
  77013. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77014. * @param matrix defines the matrix to use
  77015. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77016. */
  77017. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77018. /**
  77019. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77020. * @param matrix defines the matrix to use
  77021. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77022. */
  77023. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77024. /**
  77025. * Compute the transpose of a given matrix
  77026. * @param matrix defines the matrix to transpose
  77027. * @returns the new matrix
  77028. */
  77029. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77030. /**
  77031. * Compute the transpose of a matrix and store it in a target matrix
  77032. * @param matrix defines the matrix to transpose
  77033. * @param result defines the target matrix
  77034. */
  77035. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77036. /**
  77037. * Computes a reflection matrix from a plane
  77038. * @param plane defines the reflection plane
  77039. * @returns a new matrix
  77040. */
  77041. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77042. /**
  77043. * Computes a reflection matrix from a plane
  77044. * @param plane defines the reflection plane
  77045. * @param result defines the target matrix
  77046. */
  77047. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77048. /**
  77049. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77050. * @param xaxis defines the value of the 1st axis
  77051. * @param yaxis defines the value of the 2nd axis
  77052. * @param zaxis defines the value of the 3rd axis
  77053. * @param result defines the target matrix
  77054. */
  77055. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77056. /**
  77057. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77058. * @param quat defines the quaternion to use
  77059. * @param result defines the target matrix
  77060. */
  77061. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77062. }
  77063. /**
  77064. * @hidden
  77065. */
  77066. export class TmpVectors {
  77067. static Vector2: Vector2[];
  77068. static Vector3: Vector3[];
  77069. static Vector4: Vector4[];
  77070. static Quaternion: Quaternion[];
  77071. static Matrix: Matrix[];
  77072. }
  77073. }
  77074. declare module BABYLON {
  77075. /**
  77076. * Defines potential orientation for back face culling
  77077. */
  77078. export enum Orientation {
  77079. /**
  77080. * Clockwise
  77081. */
  77082. CW = 0,
  77083. /** Counter clockwise */
  77084. CCW = 1
  77085. }
  77086. /** Class used to represent a Bezier curve */
  77087. export class BezierCurve {
  77088. /**
  77089. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77090. * @param t defines the time
  77091. * @param x1 defines the left coordinate on X axis
  77092. * @param y1 defines the left coordinate on Y axis
  77093. * @param x2 defines the right coordinate on X axis
  77094. * @param y2 defines the right coordinate on Y axis
  77095. * @returns the interpolated value
  77096. */
  77097. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77098. }
  77099. /**
  77100. * Defines angle representation
  77101. */
  77102. export class Angle {
  77103. private _radians;
  77104. /**
  77105. * Creates an Angle object of "radians" radians (float).
  77106. * @param radians the angle in radians
  77107. */
  77108. constructor(radians: number);
  77109. /**
  77110. * Get value in degrees
  77111. * @returns the Angle value in degrees (float)
  77112. */
  77113. degrees(): number;
  77114. /**
  77115. * Get value in radians
  77116. * @returns the Angle value in radians (float)
  77117. */
  77118. radians(): number;
  77119. /**
  77120. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77121. * @param a defines first vector
  77122. * @param b defines second vector
  77123. * @returns a new Angle
  77124. */
  77125. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77126. /**
  77127. * Gets a new Angle object from the given float in radians
  77128. * @param radians defines the angle value in radians
  77129. * @returns a new Angle
  77130. */
  77131. static FromRadians(radians: number): Angle;
  77132. /**
  77133. * Gets a new Angle object from the given float in degrees
  77134. * @param degrees defines the angle value in degrees
  77135. * @returns a new Angle
  77136. */
  77137. static FromDegrees(degrees: number): Angle;
  77138. }
  77139. /**
  77140. * This represents an arc in a 2d space.
  77141. */
  77142. export class Arc2 {
  77143. /** Defines the start point of the arc */
  77144. startPoint: Vector2;
  77145. /** Defines the mid point of the arc */
  77146. midPoint: Vector2;
  77147. /** Defines the end point of the arc */
  77148. endPoint: Vector2;
  77149. /**
  77150. * Defines the center point of the arc.
  77151. */
  77152. centerPoint: Vector2;
  77153. /**
  77154. * Defines the radius of the arc.
  77155. */
  77156. radius: number;
  77157. /**
  77158. * Defines the angle of the arc (from mid point to end point).
  77159. */
  77160. angle: Angle;
  77161. /**
  77162. * Defines the start angle of the arc (from start point to middle point).
  77163. */
  77164. startAngle: Angle;
  77165. /**
  77166. * Defines the orientation of the arc (clock wise/counter clock wise).
  77167. */
  77168. orientation: Orientation;
  77169. /**
  77170. * Creates an Arc object from the three given points : start, middle and end.
  77171. * @param startPoint Defines the start point of the arc
  77172. * @param midPoint Defines the midlle point of the arc
  77173. * @param endPoint Defines the end point of the arc
  77174. */
  77175. constructor(
  77176. /** Defines the start point of the arc */
  77177. startPoint: Vector2,
  77178. /** Defines the mid point of the arc */
  77179. midPoint: Vector2,
  77180. /** Defines the end point of the arc */
  77181. endPoint: Vector2);
  77182. }
  77183. /**
  77184. * Represents a 2D path made up of multiple 2D points
  77185. */
  77186. export class Path2 {
  77187. private _points;
  77188. private _length;
  77189. /**
  77190. * If the path start and end point are the same
  77191. */
  77192. closed: boolean;
  77193. /**
  77194. * Creates a Path2 object from the starting 2D coordinates x and y.
  77195. * @param x the starting points x value
  77196. * @param y the starting points y value
  77197. */
  77198. constructor(x: number, y: number);
  77199. /**
  77200. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77201. * @param x the added points x value
  77202. * @param y the added points y value
  77203. * @returns the updated Path2.
  77204. */
  77205. addLineTo(x: number, y: number): Path2;
  77206. /**
  77207. * 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.
  77208. * @param midX middle point x value
  77209. * @param midY middle point y value
  77210. * @param endX end point x value
  77211. * @param endY end point y value
  77212. * @param numberOfSegments (default: 36)
  77213. * @returns the updated Path2.
  77214. */
  77215. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77216. /**
  77217. * Closes the Path2.
  77218. * @returns the Path2.
  77219. */
  77220. close(): Path2;
  77221. /**
  77222. * Gets the sum of the distance between each sequential point in the path
  77223. * @returns the Path2 total length (float).
  77224. */
  77225. length(): number;
  77226. /**
  77227. * Gets the points which construct the path
  77228. * @returns the Path2 internal array of points.
  77229. */
  77230. getPoints(): Vector2[];
  77231. /**
  77232. * Retreives the point at the distance aways from the starting point
  77233. * @param normalizedLengthPosition the length along the path to retreive the point from
  77234. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  77235. */
  77236. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  77237. /**
  77238. * Creates a new path starting from an x and y position
  77239. * @param x starting x value
  77240. * @param y starting y value
  77241. * @returns a new Path2 starting at the coordinates (x, y).
  77242. */
  77243. static StartingAt(x: number, y: number): Path2;
  77244. }
  77245. /**
  77246. * Represents a 3D path made up of multiple 3D points
  77247. */
  77248. export class Path3D {
  77249. /**
  77250. * an array of Vector3, the curve axis of the Path3D
  77251. */
  77252. path: Vector3[];
  77253. private _curve;
  77254. private _distances;
  77255. private _tangents;
  77256. private _normals;
  77257. private _binormals;
  77258. private _raw;
  77259. private _alignTangentsWithPath;
  77260. private readonly _pointAtData;
  77261. /**
  77262. * new Path3D(path, normal, raw)
  77263. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  77264. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  77265. * @param path an array of Vector3, the curve axis of the Path3D
  77266. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  77267. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  77268. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  77269. */
  77270. constructor(
  77271. /**
  77272. * an array of Vector3, the curve axis of the Path3D
  77273. */
  77274. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  77275. /**
  77276. * Returns the Path3D array of successive Vector3 designing its curve.
  77277. * @returns the Path3D array of successive Vector3 designing its curve.
  77278. */
  77279. getCurve(): Vector3[];
  77280. /**
  77281. * Returns the Path3D array of successive Vector3 designing its curve.
  77282. * @returns the Path3D array of successive Vector3 designing its curve.
  77283. */
  77284. getPoints(): Vector3[];
  77285. /**
  77286. * @returns the computed length (float) of the path.
  77287. */
  77288. length(): number;
  77289. /**
  77290. * Returns an array populated with tangent vectors on each Path3D curve point.
  77291. * @returns an array populated with tangent vectors on each Path3D curve point.
  77292. */
  77293. getTangents(): Vector3[];
  77294. /**
  77295. * Returns an array populated with normal vectors on each Path3D curve point.
  77296. * @returns an array populated with normal vectors on each Path3D curve point.
  77297. */
  77298. getNormals(): Vector3[];
  77299. /**
  77300. * Returns an array populated with binormal vectors on each Path3D curve point.
  77301. * @returns an array populated with binormal vectors on each Path3D curve point.
  77302. */
  77303. getBinormals(): Vector3[];
  77304. /**
  77305. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  77306. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  77307. */
  77308. getDistances(): number[];
  77309. /**
  77310. * Returns an interpolated point along this path
  77311. * @param position the position of the point along this path, from 0.0 to 1.0
  77312. * @returns a new Vector3 as the point
  77313. */
  77314. getPointAt(position: number): Vector3;
  77315. /**
  77316. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77317. * @param position the position of the point along this path, from 0.0 to 1.0
  77318. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  77319. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  77320. */
  77321. getTangentAt(position: number, interpolated?: boolean): Vector3;
  77322. /**
  77323. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77324. * @param position the position of the point along this path, from 0.0 to 1.0
  77325. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  77326. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  77327. */
  77328. getNormalAt(position: number, interpolated?: boolean): Vector3;
  77329. /**
  77330. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  77331. * @param position the position of the point along this path, from 0.0 to 1.0
  77332. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  77333. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  77334. */
  77335. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  77336. /**
  77337. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  77338. * @param position the position of the point along this path, from 0.0 to 1.0
  77339. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  77340. */
  77341. getDistanceAt(position: number): number;
  77342. /**
  77343. * Returns the array index of the previous point of an interpolated point along this path
  77344. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77345. * @returns the array index
  77346. */
  77347. getPreviousPointIndexAt(position: number): number;
  77348. /**
  77349. * 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)
  77350. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77351. * @returns the sub position
  77352. */
  77353. getSubPositionAt(position: number): number;
  77354. /**
  77355. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  77356. * @param target the vector of which to get the closest position to
  77357. * @returns the position of the closest virtual point on this path to the target vector
  77358. */
  77359. getClosestPositionTo(target: Vector3): number;
  77360. /**
  77361. * Returns a sub path (slice) of this path
  77362. * @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
  77363. * @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
  77364. * @returns a sub path (slice) of this path
  77365. */
  77366. slice(start?: number, end?: number): Path3D;
  77367. /**
  77368. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  77369. * @param path path which all values are copied into the curves points
  77370. * @param firstNormal which should be projected onto the curve
  77371. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  77372. * @returns the same object updated.
  77373. */
  77374. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  77375. private _compute;
  77376. private _getFirstNonNullVector;
  77377. private _getLastNonNullVector;
  77378. private _normalVector;
  77379. /**
  77380. * Updates the point at data for an interpolated point along this curve
  77381. * @param position the position of the point along this curve, from 0.0 to 1.0
  77382. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  77383. * @returns the (updated) point at data
  77384. */
  77385. private _updatePointAtData;
  77386. /**
  77387. * Updates the point at data from the specified parameters
  77388. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  77389. * @param point the interpolated point
  77390. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  77391. */
  77392. private _setPointAtData;
  77393. /**
  77394. * Updates the point at interpolation matrix for the tangents, normals and binormals
  77395. */
  77396. private _updateInterpolationMatrix;
  77397. }
  77398. /**
  77399. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77400. * A Curve3 is designed from a series of successive Vector3.
  77401. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77402. */
  77403. export class Curve3 {
  77404. private _points;
  77405. private _length;
  77406. /**
  77407. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77408. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77409. * @param v1 (Vector3) the control point
  77410. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77411. * @param nbPoints (integer) the wanted number of points in the curve
  77412. * @returns the created Curve3
  77413. */
  77414. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77415. /**
  77416. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77417. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77418. * @param v1 (Vector3) the first control point
  77419. * @param v2 (Vector3) the second control point
  77420. * @param v3 (Vector3) the end point of the Cubic Bezier
  77421. * @param nbPoints (integer) the wanted number of points in the curve
  77422. * @returns the created Curve3
  77423. */
  77424. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77425. /**
  77426. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77427. * @param p1 (Vector3) the origin point of the Hermite Spline
  77428. * @param t1 (Vector3) the tangent vector at the origin point
  77429. * @param p2 (Vector3) the end point of the Hermite Spline
  77430. * @param t2 (Vector3) the tangent vector at the end point
  77431. * @param nbPoints (integer) the wanted number of points in the curve
  77432. * @returns the created Curve3
  77433. */
  77434. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77435. /**
  77436. * Returns a Curve3 object along a CatmullRom Spline curve :
  77437. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77438. * @param nbPoints (integer) the wanted number of points between each curve control points
  77439. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77440. * @returns the created Curve3
  77441. */
  77442. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  77443. /**
  77444. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77445. * A Curve3 is designed from a series of successive Vector3.
  77446. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77447. * @param points points which make up the curve
  77448. */
  77449. constructor(points: Vector3[]);
  77450. /**
  77451. * @returns the Curve3 stored array of successive Vector3
  77452. */
  77453. getPoints(): Vector3[];
  77454. /**
  77455. * @returns the computed length (float) of the curve.
  77456. */
  77457. length(): number;
  77458. /**
  77459. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  77460. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  77461. * curveA and curveB keep unchanged.
  77462. * @param curve the curve to continue from this curve
  77463. * @returns the newly constructed curve
  77464. */
  77465. continue(curve: DeepImmutable<Curve3>): Curve3;
  77466. private _computeLength;
  77467. }
  77468. }
  77469. declare module BABYLON {
  77470. /**
  77471. * This represents the main contract an easing function should follow.
  77472. * Easing functions are used throughout the animation system.
  77473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77474. */
  77475. export interface IEasingFunction {
  77476. /**
  77477. * Given an input gradient between 0 and 1, this returns the corrseponding value
  77478. * of the easing function.
  77479. * The link below provides some of the most common examples of easing functions.
  77480. * @see https://easings.net/
  77481. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77482. * @returns the corresponding value on the curve defined by the easing function
  77483. */
  77484. ease(gradient: number): number;
  77485. }
  77486. /**
  77487. * Base class used for every default easing function.
  77488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77489. */
  77490. export class EasingFunction implements IEasingFunction {
  77491. /**
  77492. * Interpolation follows the mathematical formula associated with the easing function.
  77493. */
  77494. static readonly EASINGMODE_EASEIN: number;
  77495. /**
  77496. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  77497. */
  77498. static readonly EASINGMODE_EASEOUT: number;
  77499. /**
  77500. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  77501. */
  77502. static readonly EASINGMODE_EASEINOUT: number;
  77503. private _easingMode;
  77504. /**
  77505. * Sets the easing mode of the current function.
  77506. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  77507. */
  77508. setEasingMode(easingMode: number): void;
  77509. /**
  77510. * Gets the current easing mode.
  77511. * @returns the easing mode
  77512. */
  77513. getEasingMode(): number;
  77514. /**
  77515. * @hidden
  77516. */
  77517. easeInCore(gradient: number): number;
  77518. /**
  77519. * Given an input gradient between 0 and 1, this returns the corresponding value
  77520. * of the easing function.
  77521. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77522. * @returns the corresponding value on the curve defined by the easing function
  77523. */
  77524. ease(gradient: number): number;
  77525. }
  77526. /**
  77527. * Easing function with a circle shape (see link below).
  77528. * @see https://easings.net/#easeInCirc
  77529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77530. */
  77531. export class CircleEase extends EasingFunction implements IEasingFunction {
  77532. /** @hidden */
  77533. easeInCore(gradient: number): number;
  77534. }
  77535. /**
  77536. * Easing function with a ease back shape (see link below).
  77537. * @see https://easings.net/#easeInBack
  77538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77539. */
  77540. export class BackEase extends EasingFunction implements IEasingFunction {
  77541. /** Defines the amplitude of the function */
  77542. amplitude: number;
  77543. /**
  77544. * Instantiates a back ease easing
  77545. * @see https://easings.net/#easeInBack
  77546. * @param amplitude Defines the amplitude of the function
  77547. */
  77548. constructor(
  77549. /** Defines the amplitude of the function */
  77550. amplitude?: number);
  77551. /** @hidden */
  77552. easeInCore(gradient: number): number;
  77553. }
  77554. /**
  77555. * Easing function with a bouncing shape (see link below).
  77556. * @see https://easings.net/#easeInBounce
  77557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77558. */
  77559. export class BounceEase extends EasingFunction implements IEasingFunction {
  77560. /** Defines the number of bounces */
  77561. bounces: number;
  77562. /** Defines the amplitude of the bounce */
  77563. bounciness: number;
  77564. /**
  77565. * Instantiates a bounce easing
  77566. * @see https://easings.net/#easeInBounce
  77567. * @param bounces Defines the number of bounces
  77568. * @param bounciness Defines the amplitude of the bounce
  77569. */
  77570. constructor(
  77571. /** Defines the number of bounces */
  77572. bounces?: number,
  77573. /** Defines the amplitude of the bounce */
  77574. bounciness?: number);
  77575. /** @hidden */
  77576. easeInCore(gradient: number): number;
  77577. }
  77578. /**
  77579. * Easing function with a power of 3 shape (see link below).
  77580. * @see https://easings.net/#easeInCubic
  77581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77582. */
  77583. export class CubicEase extends EasingFunction implements IEasingFunction {
  77584. /** @hidden */
  77585. easeInCore(gradient: number): number;
  77586. }
  77587. /**
  77588. * Easing function with an elastic shape (see link below).
  77589. * @see https://easings.net/#easeInElastic
  77590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77591. */
  77592. export class ElasticEase extends EasingFunction implements IEasingFunction {
  77593. /** Defines the number of oscillations*/
  77594. oscillations: number;
  77595. /** Defines the amplitude of the oscillations*/
  77596. springiness: number;
  77597. /**
  77598. * Instantiates an elastic easing function
  77599. * @see https://easings.net/#easeInElastic
  77600. * @param oscillations Defines the number of oscillations
  77601. * @param springiness Defines the amplitude of the oscillations
  77602. */
  77603. constructor(
  77604. /** Defines the number of oscillations*/
  77605. oscillations?: number,
  77606. /** Defines the amplitude of the oscillations*/
  77607. springiness?: number);
  77608. /** @hidden */
  77609. easeInCore(gradient: number): number;
  77610. }
  77611. /**
  77612. * Easing function with an exponential shape (see link below).
  77613. * @see https://easings.net/#easeInExpo
  77614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77615. */
  77616. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  77617. /** Defines the exponent of the function */
  77618. exponent: number;
  77619. /**
  77620. * Instantiates an exponential easing function
  77621. * @see https://easings.net/#easeInExpo
  77622. * @param exponent Defines the exponent of the function
  77623. */
  77624. constructor(
  77625. /** Defines the exponent of the function */
  77626. exponent?: number);
  77627. /** @hidden */
  77628. easeInCore(gradient: number): number;
  77629. }
  77630. /**
  77631. * Easing function with a power shape (see link below).
  77632. * @see https://easings.net/#easeInQuad
  77633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77634. */
  77635. export class PowerEase extends EasingFunction implements IEasingFunction {
  77636. /** Defines the power of the function */
  77637. power: number;
  77638. /**
  77639. * Instantiates an power base easing function
  77640. * @see https://easings.net/#easeInQuad
  77641. * @param power Defines the power of the function
  77642. */
  77643. constructor(
  77644. /** Defines the power of the function */
  77645. power?: number);
  77646. /** @hidden */
  77647. easeInCore(gradient: number): number;
  77648. }
  77649. /**
  77650. * Easing function with a power of 2 shape (see link below).
  77651. * @see https://easings.net/#easeInQuad
  77652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77653. */
  77654. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  77655. /** @hidden */
  77656. easeInCore(gradient: number): number;
  77657. }
  77658. /**
  77659. * Easing function with a power of 4 shape (see link below).
  77660. * @see https://easings.net/#easeInQuart
  77661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77662. */
  77663. export class QuarticEase extends EasingFunction implements IEasingFunction {
  77664. /** @hidden */
  77665. easeInCore(gradient: number): number;
  77666. }
  77667. /**
  77668. * Easing function with a power of 5 shape (see link below).
  77669. * @see https://easings.net/#easeInQuint
  77670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77671. */
  77672. export class QuinticEase extends EasingFunction implements IEasingFunction {
  77673. /** @hidden */
  77674. easeInCore(gradient: number): number;
  77675. }
  77676. /**
  77677. * Easing function with a sin shape (see link below).
  77678. * @see https://easings.net/#easeInSine
  77679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77680. */
  77681. export class SineEase extends EasingFunction implements IEasingFunction {
  77682. /** @hidden */
  77683. easeInCore(gradient: number): number;
  77684. }
  77685. /**
  77686. * Easing function with a bezier shape (see link below).
  77687. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  77688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77689. */
  77690. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  77691. /** Defines the x component of the start tangent in the bezier curve */
  77692. x1: number;
  77693. /** Defines the y component of the start tangent in the bezier curve */
  77694. y1: number;
  77695. /** Defines the x component of the end tangent in the bezier curve */
  77696. x2: number;
  77697. /** Defines the y component of the end tangent in the bezier curve */
  77698. y2: number;
  77699. /**
  77700. * Instantiates a bezier function
  77701. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  77702. * @param x1 Defines the x component of the start tangent in the bezier curve
  77703. * @param y1 Defines the y component of the start tangent in the bezier curve
  77704. * @param x2 Defines the x component of the end tangent in the bezier curve
  77705. * @param y2 Defines the y component of the end tangent in the bezier curve
  77706. */
  77707. constructor(
  77708. /** Defines the x component of the start tangent in the bezier curve */
  77709. x1?: number,
  77710. /** Defines the y component of the start tangent in the bezier curve */
  77711. y1?: number,
  77712. /** Defines the x component of the end tangent in the bezier curve */
  77713. x2?: number,
  77714. /** Defines the y component of the end tangent in the bezier curve */
  77715. y2?: number);
  77716. /** @hidden */
  77717. easeInCore(gradient: number): number;
  77718. }
  77719. }
  77720. declare module BABYLON {
  77721. /**
  77722. * Class used to hold a RBG color
  77723. */
  77724. export class Color3 {
  77725. /**
  77726. * Defines the red component (between 0 and 1, default is 0)
  77727. */
  77728. r: number;
  77729. /**
  77730. * Defines the green component (between 0 and 1, default is 0)
  77731. */
  77732. g: number;
  77733. /**
  77734. * Defines the blue component (between 0 and 1, default is 0)
  77735. */
  77736. b: number;
  77737. /**
  77738. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  77739. * @param r defines the red component (between 0 and 1, default is 0)
  77740. * @param g defines the green component (between 0 and 1, default is 0)
  77741. * @param b defines the blue component (between 0 and 1, default is 0)
  77742. */
  77743. constructor(
  77744. /**
  77745. * Defines the red component (between 0 and 1, default is 0)
  77746. */
  77747. r?: number,
  77748. /**
  77749. * Defines the green component (between 0 and 1, default is 0)
  77750. */
  77751. g?: number,
  77752. /**
  77753. * Defines the blue component (between 0 and 1, default is 0)
  77754. */
  77755. b?: number);
  77756. /**
  77757. * Creates a string with the Color3 current values
  77758. * @returns the string representation of the Color3 object
  77759. */
  77760. toString(): string;
  77761. /**
  77762. * Returns the string "Color3"
  77763. * @returns "Color3"
  77764. */
  77765. getClassName(): string;
  77766. /**
  77767. * Compute the Color3 hash code
  77768. * @returns an unique number that can be used to hash Color3 objects
  77769. */
  77770. getHashCode(): number;
  77771. /**
  77772. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  77773. * @param array defines the array where to store the r,g,b components
  77774. * @param index defines an optional index in the target array to define where to start storing values
  77775. * @returns the current Color3 object
  77776. */
  77777. toArray(array: FloatArray, index?: number): Color3;
  77778. /**
  77779. * Returns a new Color4 object from the current Color3 and the given alpha
  77780. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  77781. * @returns a new Color4 object
  77782. */
  77783. toColor4(alpha?: number): Color4;
  77784. /**
  77785. * Returns a new array populated with 3 numeric elements : red, green and blue values
  77786. * @returns the new array
  77787. */
  77788. asArray(): number[];
  77789. /**
  77790. * Returns the luminance value
  77791. * @returns a float value
  77792. */
  77793. toLuminance(): number;
  77794. /**
  77795. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  77796. * @param otherColor defines the second operand
  77797. * @returns the new Color3 object
  77798. */
  77799. multiply(otherColor: DeepImmutable<Color3>): Color3;
  77800. /**
  77801. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  77802. * @param otherColor defines the second operand
  77803. * @param result defines the Color3 object where to store the result
  77804. * @returns the current Color3
  77805. */
  77806. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  77807. /**
  77808. * Determines equality between Color3 objects
  77809. * @param otherColor defines the second operand
  77810. * @returns true if the rgb values are equal to the given ones
  77811. */
  77812. equals(otherColor: DeepImmutable<Color3>): boolean;
  77813. /**
  77814. * Determines equality between the current Color3 object and a set of r,b,g values
  77815. * @param r defines the red component to check
  77816. * @param g defines the green component to check
  77817. * @param b defines the blue component to check
  77818. * @returns true if the rgb values are equal to the given ones
  77819. */
  77820. equalsFloats(r: number, g: number, b: number): boolean;
  77821. /**
  77822. * Multiplies in place each rgb value by scale
  77823. * @param scale defines the scaling factor
  77824. * @returns the updated Color3
  77825. */
  77826. scale(scale: number): Color3;
  77827. /**
  77828. * Multiplies the rgb values by scale and stores the result into "result"
  77829. * @param scale defines the scaling factor
  77830. * @param result defines the Color3 object where to store the result
  77831. * @returns the unmodified current Color3
  77832. */
  77833. scaleToRef(scale: number, result: Color3): Color3;
  77834. /**
  77835. * Scale the current Color3 values by a factor and add the result to a given Color3
  77836. * @param scale defines the scale factor
  77837. * @param result defines color to store the result into
  77838. * @returns the unmodified current Color3
  77839. */
  77840. scaleAndAddToRef(scale: number, result: Color3): Color3;
  77841. /**
  77842. * Clamps the rgb values by the min and max values and stores the result into "result"
  77843. * @param min defines minimum clamping value (default is 0)
  77844. * @param max defines maximum clamping value (default is 1)
  77845. * @param result defines color to store the result into
  77846. * @returns the original Color3
  77847. */
  77848. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  77849. /**
  77850. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  77851. * @param otherColor defines the second operand
  77852. * @returns the new Color3
  77853. */
  77854. add(otherColor: DeepImmutable<Color3>): Color3;
  77855. /**
  77856. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  77857. * @param otherColor defines the second operand
  77858. * @param result defines Color3 object to store the result into
  77859. * @returns the unmodified current Color3
  77860. */
  77861. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  77862. /**
  77863. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  77864. * @param otherColor defines the second operand
  77865. * @returns the new Color3
  77866. */
  77867. subtract(otherColor: DeepImmutable<Color3>): Color3;
  77868. /**
  77869. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  77870. * @param otherColor defines the second operand
  77871. * @param result defines Color3 object to store the result into
  77872. * @returns the unmodified current Color3
  77873. */
  77874. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  77875. /**
  77876. * Copy the current object
  77877. * @returns a new Color3 copied the current one
  77878. */
  77879. clone(): Color3;
  77880. /**
  77881. * Copies the rgb values from the source in the current Color3
  77882. * @param source defines the source Color3 object
  77883. * @returns the updated Color3 object
  77884. */
  77885. copyFrom(source: DeepImmutable<Color3>): Color3;
  77886. /**
  77887. * Updates the Color3 rgb values from the given floats
  77888. * @param r defines the red component to read from
  77889. * @param g defines the green component to read from
  77890. * @param b defines the blue component to read from
  77891. * @returns the current Color3 object
  77892. */
  77893. copyFromFloats(r: number, g: number, b: number): Color3;
  77894. /**
  77895. * Updates the Color3 rgb values from the given floats
  77896. * @param r defines the red component to read from
  77897. * @param g defines the green component to read from
  77898. * @param b defines the blue component to read from
  77899. * @returns the current Color3 object
  77900. */
  77901. set(r: number, g: number, b: number): Color3;
  77902. /**
  77903. * Compute the Color3 hexadecimal code as a string
  77904. * @returns a string containing the hexadecimal representation of the Color3 object
  77905. */
  77906. toHexString(): string;
  77907. /**
  77908. * Computes a new Color3 converted from the current one to linear space
  77909. * @returns a new Color3 object
  77910. */
  77911. toLinearSpace(): Color3;
  77912. /**
  77913. * Converts current color in rgb space to HSV values
  77914. * @returns a new color3 representing the HSV values
  77915. */
  77916. toHSV(): Color3;
  77917. /**
  77918. * Converts current color in rgb space to HSV values
  77919. * @param result defines the Color3 where to store the HSV values
  77920. */
  77921. toHSVToRef(result: Color3): void;
  77922. /**
  77923. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  77924. * @param convertedColor defines the Color3 object where to store the linear space version
  77925. * @returns the unmodified Color3
  77926. */
  77927. toLinearSpaceToRef(convertedColor: Color3): Color3;
  77928. /**
  77929. * Computes a new Color3 converted from the current one to gamma space
  77930. * @returns a new Color3 object
  77931. */
  77932. toGammaSpace(): Color3;
  77933. /**
  77934. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  77935. * @param convertedColor defines the Color3 object where to store the gamma space version
  77936. * @returns the unmodified Color3
  77937. */
  77938. toGammaSpaceToRef(convertedColor: Color3): Color3;
  77939. private static _BlackReadOnly;
  77940. /**
  77941. * Convert Hue, saturation and value to a Color3 (RGB)
  77942. * @param hue defines the hue
  77943. * @param saturation defines the saturation
  77944. * @param value defines the value
  77945. * @param result defines the Color3 where to store the RGB values
  77946. */
  77947. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  77948. /**
  77949. * Creates a new Color3 from the string containing valid hexadecimal values
  77950. * @param hex defines a string containing valid hexadecimal values
  77951. * @returns a new Color3 object
  77952. */
  77953. static FromHexString(hex: string): Color3;
  77954. /**
  77955. * Creates a new Color3 from the starting index of the given array
  77956. * @param array defines the source array
  77957. * @param offset defines an offset in the source array
  77958. * @returns a new Color3 object
  77959. */
  77960. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  77961. /**
  77962. * Creates a new Color3 from integer values (< 256)
  77963. * @param r defines the red component to read from (value between 0 and 255)
  77964. * @param g defines the green component to read from (value between 0 and 255)
  77965. * @param b defines the blue component to read from (value between 0 and 255)
  77966. * @returns a new Color3 object
  77967. */
  77968. static FromInts(r: number, g: number, b: number): Color3;
  77969. /**
  77970. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  77971. * @param start defines the start Color3 value
  77972. * @param end defines the end Color3 value
  77973. * @param amount defines the gradient value between start and end
  77974. * @returns a new Color3 object
  77975. */
  77976. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  77977. /**
  77978. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  77979. * @param left defines the start value
  77980. * @param right defines the end value
  77981. * @param amount defines the gradient factor
  77982. * @param result defines the Color3 object where to store the result
  77983. */
  77984. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  77985. /**
  77986. * Returns a Color3 value containing a red color
  77987. * @returns a new Color3 object
  77988. */
  77989. static Red(): Color3;
  77990. /**
  77991. * Returns a Color3 value containing a green color
  77992. * @returns a new Color3 object
  77993. */
  77994. static Green(): Color3;
  77995. /**
  77996. * Returns a Color3 value containing a blue color
  77997. * @returns a new Color3 object
  77998. */
  77999. static Blue(): Color3;
  78000. /**
  78001. * Returns a Color3 value containing a black color
  78002. * @returns a new Color3 object
  78003. */
  78004. static Black(): Color3;
  78005. /**
  78006. * Gets a Color3 value containing a black color that must not be updated
  78007. */
  78008. static get BlackReadOnly(): DeepImmutable<Color3>;
  78009. /**
  78010. * Returns a Color3 value containing a white color
  78011. * @returns a new Color3 object
  78012. */
  78013. static White(): Color3;
  78014. /**
  78015. * Returns a Color3 value containing a purple color
  78016. * @returns a new Color3 object
  78017. */
  78018. static Purple(): Color3;
  78019. /**
  78020. * Returns a Color3 value containing a magenta color
  78021. * @returns a new Color3 object
  78022. */
  78023. static Magenta(): Color3;
  78024. /**
  78025. * Returns a Color3 value containing a yellow color
  78026. * @returns a new Color3 object
  78027. */
  78028. static Yellow(): Color3;
  78029. /**
  78030. * Returns a Color3 value containing a gray color
  78031. * @returns a new Color3 object
  78032. */
  78033. static Gray(): Color3;
  78034. /**
  78035. * Returns a Color3 value containing a teal color
  78036. * @returns a new Color3 object
  78037. */
  78038. static Teal(): Color3;
  78039. /**
  78040. * Returns a Color3 value containing a random color
  78041. * @returns a new Color3 object
  78042. */
  78043. static Random(): Color3;
  78044. }
  78045. /**
  78046. * Class used to hold a RBGA color
  78047. */
  78048. export class Color4 {
  78049. /**
  78050. * Defines the red component (between 0 and 1, default is 0)
  78051. */
  78052. r: number;
  78053. /**
  78054. * Defines the green component (between 0 and 1, default is 0)
  78055. */
  78056. g: number;
  78057. /**
  78058. * Defines the blue component (between 0 and 1, default is 0)
  78059. */
  78060. b: number;
  78061. /**
  78062. * Defines the alpha component (between 0 and 1, default is 1)
  78063. */
  78064. a: number;
  78065. /**
  78066. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78067. * @param r defines the red component (between 0 and 1, default is 0)
  78068. * @param g defines the green component (between 0 and 1, default is 0)
  78069. * @param b defines the blue component (between 0 and 1, default is 0)
  78070. * @param a defines the alpha component (between 0 and 1, default is 1)
  78071. */
  78072. constructor(
  78073. /**
  78074. * Defines the red component (between 0 and 1, default is 0)
  78075. */
  78076. r?: number,
  78077. /**
  78078. * Defines the green component (between 0 and 1, default is 0)
  78079. */
  78080. g?: number,
  78081. /**
  78082. * Defines the blue component (between 0 and 1, default is 0)
  78083. */
  78084. b?: number,
  78085. /**
  78086. * Defines the alpha component (between 0 and 1, default is 1)
  78087. */
  78088. a?: number);
  78089. /**
  78090. * Adds in place the given Color4 values to the current Color4 object
  78091. * @param right defines the second operand
  78092. * @returns the current updated Color4 object
  78093. */
  78094. addInPlace(right: DeepImmutable<Color4>): Color4;
  78095. /**
  78096. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78097. * @returns the new array
  78098. */
  78099. asArray(): number[];
  78100. /**
  78101. * Stores from the starting index in the given array the Color4 successive values
  78102. * @param array defines the array where to store the r,g,b components
  78103. * @param index defines an optional index in the target array to define where to start storing values
  78104. * @returns the current Color4 object
  78105. */
  78106. toArray(array: number[], index?: number): Color4;
  78107. /**
  78108. * Determines equality between Color4 objects
  78109. * @param otherColor defines the second operand
  78110. * @returns true if the rgba values are equal to the given ones
  78111. */
  78112. equals(otherColor: DeepImmutable<Color4>): boolean;
  78113. /**
  78114. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78115. * @param right defines the second operand
  78116. * @returns a new Color4 object
  78117. */
  78118. add(right: DeepImmutable<Color4>): Color4;
  78119. /**
  78120. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78121. * @param right defines the second operand
  78122. * @returns a new Color4 object
  78123. */
  78124. subtract(right: DeepImmutable<Color4>): Color4;
  78125. /**
  78126. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78127. * @param right defines the second operand
  78128. * @param result defines the Color4 object where to store the result
  78129. * @returns the current Color4 object
  78130. */
  78131. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78132. /**
  78133. * Creates a new Color4 with the current Color4 values multiplied by scale
  78134. * @param scale defines the scaling factor to apply
  78135. * @returns a new Color4 object
  78136. */
  78137. scale(scale: number): Color4;
  78138. /**
  78139. * Multiplies the current Color4 values by scale and stores the result in "result"
  78140. * @param scale defines the scaling factor to apply
  78141. * @param result defines the Color4 object where to store the result
  78142. * @returns the current unmodified Color4
  78143. */
  78144. scaleToRef(scale: number, result: Color4): Color4;
  78145. /**
  78146. * Scale the current Color4 values by a factor and add the result to a given Color4
  78147. * @param scale defines the scale factor
  78148. * @param result defines the Color4 object where to store the result
  78149. * @returns the unmodified current Color4
  78150. */
  78151. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78152. /**
  78153. * Clamps the rgb values by the min and max values and stores the result into "result"
  78154. * @param min defines minimum clamping value (default is 0)
  78155. * @param max defines maximum clamping value (default is 1)
  78156. * @param result defines color to store the result into.
  78157. * @returns the cuurent Color4
  78158. */
  78159. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78160. /**
  78161. * Multipy an Color4 value by another and return a new Color4 object
  78162. * @param color defines the Color4 value to multiply by
  78163. * @returns a new Color4 object
  78164. */
  78165. multiply(color: Color4): Color4;
  78166. /**
  78167. * Multipy a Color4 value by another and push the result in a reference value
  78168. * @param color defines the Color4 value to multiply by
  78169. * @param result defines the Color4 to fill the result in
  78170. * @returns the result Color4
  78171. */
  78172. multiplyToRef(color: Color4, result: Color4): Color4;
  78173. /**
  78174. * Creates a string with the Color4 current values
  78175. * @returns the string representation of the Color4 object
  78176. */
  78177. toString(): string;
  78178. /**
  78179. * Returns the string "Color4"
  78180. * @returns "Color4"
  78181. */
  78182. getClassName(): string;
  78183. /**
  78184. * Compute the Color4 hash code
  78185. * @returns an unique number that can be used to hash Color4 objects
  78186. */
  78187. getHashCode(): number;
  78188. /**
  78189. * Creates a new Color4 copied from the current one
  78190. * @returns a new Color4 object
  78191. */
  78192. clone(): Color4;
  78193. /**
  78194. * Copies the given Color4 values into the current one
  78195. * @param source defines the source Color4 object
  78196. * @returns the current updated Color4 object
  78197. */
  78198. copyFrom(source: Color4): Color4;
  78199. /**
  78200. * Copies the given float values into the current one
  78201. * @param r defines the red component to read from
  78202. * @param g defines the green component to read from
  78203. * @param b defines the blue component to read from
  78204. * @param a defines the alpha component to read from
  78205. * @returns the current updated Color4 object
  78206. */
  78207. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78208. /**
  78209. * Copies the given float values into the current one
  78210. * @param r defines the red component to read from
  78211. * @param g defines the green component to read from
  78212. * @param b defines the blue component to read from
  78213. * @param a defines the alpha component to read from
  78214. * @returns the current updated Color4 object
  78215. */
  78216. set(r: number, g: number, b: number, a: number): Color4;
  78217. /**
  78218. * Compute the Color4 hexadecimal code as a string
  78219. * @returns a string containing the hexadecimal representation of the Color4 object
  78220. */
  78221. toHexString(): string;
  78222. /**
  78223. * Computes a new Color4 converted from the current one to linear space
  78224. * @returns a new Color4 object
  78225. */
  78226. toLinearSpace(): Color4;
  78227. /**
  78228. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  78229. * @param convertedColor defines the Color4 object where to store the linear space version
  78230. * @returns the unmodified Color4
  78231. */
  78232. toLinearSpaceToRef(convertedColor: Color4): Color4;
  78233. /**
  78234. * Computes a new Color4 converted from the current one to gamma space
  78235. * @returns a new Color4 object
  78236. */
  78237. toGammaSpace(): Color4;
  78238. /**
  78239. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  78240. * @param convertedColor defines the Color4 object where to store the gamma space version
  78241. * @returns the unmodified Color4
  78242. */
  78243. toGammaSpaceToRef(convertedColor: Color4): Color4;
  78244. /**
  78245. * Creates a new Color4 from the string containing valid hexadecimal values
  78246. * @param hex defines a string containing valid hexadecimal values
  78247. * @returns a new Color4 object
  78248. */
  78249. static FromHexString(hex: string): Color4;
  78250. /**
  78251. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78252. * @param left defines the start value
  78253. * @param right defines the end value
  78254. * @param amount defines the gradient factor
  78255. * @returns a new Color4 object
  78256. */
  78257. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  78258. /**
  78259. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78260. * @param left defines the start value
  78261. * @param right defines the end value
  78262. * @param amount defines the gradient factor
  78263. * @param result defines the Color4 object where to store data
  78264. */
  78265. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  78266. /**
  78267. * Creates a new Color4 from a Color3 and an alpha value
  78268. * @param color3 defines the source Color3 to read from
  78269. * @param alpha defines the alpha component (1.0 by default)
  78270. * @returns a new Color4 object
  78271. */
  78272. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  78273. /**
  78274. * Creates a new Color4 from the starting index element of the given array
  78275. * @param array defines the source array to read from
  78276. * @param offset defines the offset in the source array
  78277. * @returns a new Color4 object
  78278. */
  78279. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  78280. /**
  78281. * Creates a new Color3 from integer values (< 256)
  78282. * @param r defines the red component to read from (value between 0 and 255)
  78283. * @param g defines the green component to read from (value between 0 and 255)
  78284. * @param b defines the blue component to read from (value between 0 and 255)
  78285. * @param a defines the alpha component to read from (value between 0 and 255)
  78286. * @returns a new Color3 object
  78287. */
  78288. static FromInts(r: number, g: number, b: number, a: number): Color4;
  78289. /**
  78290. * Check the content of a given array and convert it to an array containing RGBA data
  78291. * If the original array was already containing count * 4 values then it is returned directly
  78292. * @param colors defines the array to check
  78293. * @param count defines the number of RGBA data to expect
  78294. * @returns an array containing count * 4 values (RGBA)
  78295. */
  78296. static CheckColors4(colors: number[], count: number): number[];
  78297. }
  78298. /**
  78299. * @hidden
  78300. */
  78301. export class TmpColors {
  78302. static Color3: Color3[];
  78303. static Color4: Color4[];
  78304. }
  78305. }
  78306. declare module BABYLON {
  78307. /**
  78308. * Defines an interface which represents an animation key frame
  78309. */
  78310. export interface IAnimationKey {
  78311. /**
  78312. * Frame of the key frame
  78313. */
  78314. frame: number;
  78315. /**
  78316. * Value at the specifies key frame
  78317. */
  78318. value: any;
  78319. /**
  78320. * The input tangent for the cubic hermite spline
  78321. */
  78322. inTangent?: any;
  78323. /**
  78324. * The output tangent for the cubic hermite spline
  78325. */
  78326. outTangent?: any;
  78327. /**
  78328. * The animation interpolation type
  78329. */
  78330. interpolation?: AnimationKeyInterpolation;
  78331. }
  78332. /**
  78333. * Enum for the animation key frame interpolation type
  78334. */
  78335. export enum AnimationKeyInterpolation {
  78336. /**
  78337. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  78338. */
  78339. STEP = 1
  78340. }
  78341. }
  78342. declare module BABYLON {
  78343. /**
  78344. * Represents the range of an animation
  78345. */
  78346. export class AnimationRange {
  78347. /**The name of the animation range**/
  78348. name: string;
  78349. /**The starting frame of the animation */
  78350. from: number;
  78351. /**The ending frame of the animation*/
  78352. to: number;
  78353. /**
  78354. * Initializes the range of an animation
  78355. * @param name The name of the animation range
  78356. * @param from The starting frame of the animation
  78357. * @param to The ending frame of the animation
  78358. */
  78359. constructor(
  78360. /**The name of the animation range**/
  78361. name: string,
  78362. /**The starting frame of the animation */
  78363. from: number,
  78364. /**The ending frame of the animation*/
  78365. to: number);
  78366. /**
  78367. * Makes a copy of the animation range
  78368. * @returns A copy of the animation range
  78369. */
  78370. clone(): AnimationRange;
  78371. }
  78372. }
  78373. declare module BABYLON {
  78374. /**
  78375. * Composed of a frame, and an action function
  78376. */
  78377. export class AnimationEvent {
  78378. /** The frame for which the event is triggered **/
  78379. frame: number;
  78380. /** The event to perform when triggered **/
  78381. action: (currentFrame: number) => void;
  78382. /** Specifies if the event should be triggered only once**/
  78383. onlyOnce?: boolean | undefined;
  78384. /**
  78385. * Specifies if the animation event is done
  78386. */
  78387. isDone: boolean;
  78388. /**
  78389. * Initializes the animation event
  78390. * @param frame The frame for which the event is triggered
  78391. * @param action The event to perform when triggered
  78392. * @param onlyOnce Specifies if the event should be triggered only once
  78393. */
  78394. constructor(
  78395. /** The frame for which the event is triggered **/
  78396. frame: number,
  78397. /** The event to perform when triggered **/
  78398. action: (currentFrame: number) => void,
  78399. /** Specifies if the event should be triggered only once**/
  78400. onlyOnce?: boolean | undefined);
  78401. /** @hidden */
  78402. _clone(): AnimationEvent;
  78403. }
  78404. }
  78405. declare module BABYLON {
  78406. /**
  78407. * Interface used to define a behavior
  78408. */
  78409. export interface Behavior<T> {
  78410. /** gets or sets behavior's name */
  78411. name: string;
  78412. /**
  78413. * Function called when the behavior needs to be initialized (after attaching it to a target)
  78414. */
  78415. init(): void;
  78416. /**
  78417. * Called when the behavior is attached to a target
  78418. * @param target defines the target where the behavior is attached to
  78419. */
  78420. attach(target: T): void;
  78421. /**
  78422. * Called when the behavior is detached from its target
  78423. */
  78424. detach(): void;
  78425. }
  78426. /**
  78427. * Interface implemented by classes supporting behaviors
  78428. */
  78429. export interface IBehaviorAware<T> {
  78430. /**
  78431. * Attach a behavior
  78432. * @param behavior defines the behavior to attach
  78433. * @returns the current host
  78434. */
  78435. addBehavior(behavior: Behavior<T>): T;
  78436. /**
  78437. * Remove a behavior from the current object
  78438. * @param behavior defines the behavior to detach
  78439. * @returns the current host
  78440. */
  78441. removeBehavior(behavior: Behavior<T>): T;
  78442. /**
  78443. * Gets a behavior using its name to search
  78444. * @param name defines the name to search
  78445. * @returns the behavior or null if not found
  78446. */
  78447. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  78448. }
  78449. }
  78450. declare module BABYLON {
  78451. /**
  78452. * Defines an array and its length.
  78453. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  78454. */
  78455. export interface ISmartArrayLike<T> {
  78456. /**
  78457. * The data of the array.
  78458. */
  78459. data: Array<T>;
  78460. /**
  78461. * The active length of the array.
  78462. */
  78463. length: number;
  78464. }
  78465. /**
  78466. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78467. */
  78468. export class SmartArray<T> implements ISmartArrayLike<T> {
  78469. /**
  78470. * The full set of data from the array.
  78471. */
  78472. data: Array<T>;
  78473. /**
  78474. * The active length of the array.
  78475. */
  78476. length: number;
  78477. protected _id: number;
  78478. /**
  78479. * Instantiates a Smart Array.
  78480. * @param capacity defines the default capacity of the array.
  78481. */
  78482. constructor(capacity: number);
  78483. /**
  78484. * Pushes a value at the end of the active data.
  78485. * @param value defines the object to push in the array.
  78486. */
  78487. push(value: T): void;
  78488. /**
  78489. * Iterates over the active data and apply the lambda to them.
  78490. * @param func defines the action to apply on each value.
  78491. */
  78492. forEach(func: (content: T) => void): void;
  78493. /**
  78494. * Sorts the full sets of data.
  78495. * @param compareFn defines the comparison function to apply.
  78496. */
  78497. sort(compareFn: (a: T, b: T) => number): void;
  78498. /**
  78499. * Resets the active data to an empty array.
  78500. */
  78501. reset(): void;
  78502. /**
  78503. * Releases all the data from the array as well as the array.
  78504. */
  78505. dispose(): void;
  78506. /**
  78507. * Concats the active data with a given array.
  78508. * @param array defines the data to concatenate with.
  78509. */
  78510. concat(array: any): void;
  78511. /**
  78512. * Returns the position of a value in the active data.
  78513. * @param value defines the value to find the index for
  78514. * @returns the index if found in the active data otherwise -1
  78515. */
  78516. indexOf(value: T): number;
  78517. /**
  78518. * Returns whether an element is part of the active data.
  78519. * @param value defines the value to look for
  78520. * @returns true if found in the active data otherwise false
  78521. */
  78522. contains(value: T): boolean;
  78523. private static _GlobalId;
  78524. }
  78525. /**
  78526. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78527. * The data in this array can only be present once
  78528. */
  78529. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  78530. private _duplicateId;
  78531. /**
  78532. * Pushes a value at the end of the active data.
  78533. * THIS DOES NOT PREVENT DUPPLICATE DATA
  78534. * @param value defines the object to push in the array.
  78535. */
  78536. push(value: T): void;
  78537. /**
  78538. * Pushes a value at the end of the active data.
  78539. * If the data is already present, it won t be added again
  78540. * @param value defines the object to push in the array.
  78541. * @returns true if added false if it was already present
  78542. */
  78543. pushNoDuplicate(value: T): boolean;
  78544. /**
  78545. * Resets the active data to an empty array.
  78546. */
  78547. reset(): void;
  78548. /**
  78549. * Concats the active data with a given array.
  78550. * This ensures no dupplicate will be present in the result.
  78551. * @param array defines the data to concatenate with.
  78552. */
  78553. concatWithNoDuplicate(array: any): void;
  78554. }
  78555. }
  78556. declare module BABYLON {
  78557. /**
  78558. * @ignore
  78559. * This is a list of all the different input types that are available in the application.
  78560. * Fo instance: ArcRotateCameraGamepadInput...
  78561. */
  78562. export var CameraInputTypes: {};
  78563. /**
  78564. * This is the contract to implement in order to create a new input class.
  78565. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  78566. */
  78567. export interface ICameraInput<TCamera extends Camera> {
  78568. /**
  78569. * Defines the camera the input is attached to.
  78570. */
  78571. camera: Nullable<TCamera>;
  78572. /**
  78573. * Gets the class name of the current intput.
  78574. * @returns the class name
  78575. */
  78576. getClassName(): string;
  78577. /**
  78578. * Get the friendly name associated with the input class.
  78579. * @returns the input friendly name
  78580. */
  78581. getSimpleName(): string;
  78582. /**
  78583. * Attach the input controls to a specific dom element to get the input from.
  78584. * @param element Defines the element the controls should be listened from
  78585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78586. */
  78587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78588. /**
  78589. * Detach the current controls from the specified dom element.
  78590. * @param element Defines the element to stop listening the inputs from
  78591. */
  78592. detachControl(element: Nullable<HTMLElement>): void;
  78593. /**
  78594. * Update the current camera state depending on the inputs that have been used this frame.
  78595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78596. */
  78597. checkInputs?: () => void;
  78598. }
  78599. /**
  78600. * Represents a map of input types to input instance or input index to input instance.
  78601. */
  78602. export interface CameraInputsMap<TCamera extends Camera> {
  78603. /**
  78604. * Accessor to the input by input type.
  78605. */
  78606. [name: string]: ICameraInput<TCamera>;
  78607. /**
  78608. * Accessor to the input by input index.
  78609. */
  78610. [idx: number]: ICameraInput<TCamera>;
  78611. }
  78612. /**
  78613. * This represents the input manager used within a camera.
  78614. * It helps dealing with all the different kind of input attached to a camera.
  78615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78616. */
  78617. export class CameraInputsManager<TCamera extends Camera> {
  78618. /**
  78619. * Defines the list of inputs attahed to the camera.
  78620. */
  78621. attached: CameraInputsMap<TCamera>;
  78622. /**
  78623. * Defines the dom element the camera is collecting inputs from.
  78624. * This is null if the controls have not been attached.
  78625. */
  78626. attachedElement: Nullable<HTMLElement>;
  78627. /**
  78628. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78629. */
  78630. noPreventDefault: boolean;
  78631. /**
  78632. * Defined the camera the input manager belongs to.
  78633. */
  78634. camera: TCamera;
  78635. /**
  78636. * Update the current camera state depending on the inputs that have been used this frame.
  78637. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78638. */
  78639. checkInputs: () => void;
  78640. /**
  78641. * Instantiate a new Camera Input Manager.
  78642. * @param camera Defines the camera the input manager blongs to
  78643. */
  78644. constructor(camera: TCamera);
  78645. /**
  78646. * Add an input method to a camera
  78647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78648. * @param input camera input method
  78649. */
  78650. add(input: ICameraInput<TCamera>): void;
  78651. /**
  78652. * Remove a specific input method from a camera
  78653. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  78654. * @param inputToRemove camera input method
  78655. */
  78656. remove(inputToRemove: ICameraInput<TCamera>): void;
  78657. /**
  78658. * Remove a specific input type from a camera
  78659. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  78660. * @param inputType the type of the input to remove
  78661. */
  78662. removeByType(inputType: string): void;
  78663. private _addCheckInputs;
  78664. /**
  78665. * Attach the input controls to the currently attached dom element to listen the events from.
  78666. * @param input Defines the input to attach
  78667. */
  78668. attachInput(input: ICameraInput<TCamera>): void;
  78669. /**
  78670. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  78671. * @param element Defines the dom element to collect the events from
  78672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78673. */
  78674. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  78675. /**
  78676. * Detach the current manager inputs controls from a specific dom element.
  78677. * @param element Defines the dom element to collect the events from
  78678. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  78679. */
  78680. detachElement(element: HTMLElement, disconnect?: boolean): void;
  78681. /**
  78682. * Rebuild the dynamic inputCheck function from the current list of
  78683. * defined inputs in the manager.
  78684. */
  78685. rebuildInputCheck(): void;
  78686. /**
  78687. * Remove all attached input methods from a camera
  78688. */
  78689. clear(): void;
  78690. /**
  78691. * Serialize the current input manager attached to a camera.
  78692. * This ensures than once parsed,
  78693. * the input associated to the camera will be identical to the current ones
  78694. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  78695. */
  78696. serialize(serializedCamera: any): void;
  78697. /**
  78698. * Parses an input manager serialized JSON to restore the previous list of inputs
  78699. * and states associated to a camera.
  78700. * @param parsedCamera Defines the JSON to parse
  78701. */
  78702. parse(parsedCamera: any): void;
  78703. }
  78704. }
  78705. declare module BABYLON {
  78706. /**
  78707. * Class used to store data that will be store in GPU memory
  78708. */
  78709. export class Buffer {
  78710. private _engine;
  78711. private _buffer;
  78712. /** @hidden */
  78713. _data: Nullable<DataArray>;
  78714. private _updatable;
  78715. private _instanced;
  78716. private _divisor;
  78717. /**
  78718. * Gets the byte stride.
  78719. */
  78720. readonly byteStride: number;
  78721. /**
  78722. * Constructor
  78723. * @param engine the engine
  78724. * @param data the data to use for this buffer
  78725. * @param updatable whether the data is updatable
  78726. * @param stride the stride (optional)
  78727. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  78728. * @param instanced whether the buffer is instanced (optional)
  78729. * @param useBytes set to true if the stride in in bytes (optional)
  78730. * @param divisor sets an optional divisor for instances (1 by default)
  78731. */
  78732. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  78733. /**
  78734. * Create a new VertexBuffer based on the current buffer
  78735. * @param kind defines the vertex buffer kind (position, normal, etc.)
  78736. * @param offset defines offset in the buffer (0 by default)
  78737. * @param size defines the size in floats of attributes (position is 3 for instance)
  78738. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  78739. * @param instanced defines if the vertex buffer contains indexed data
  78740. * @param useBytes defines if the offset and stride are in bytes *
  78741. * @param divisor sets an optional divisor for instances (1 by default)
  78742. * @returns the new vertex buffer
  78743. */
  78744. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  78745. /**
  78746. * Gets a boolean indicating if the Buffer is updatable?
  78747. * @returns true if the buffer is updatable
  78748. */
  78749. isUpdatable(): boolean;
  78750. /**
  78751. * Gets current buffer's data
  78752. * @returns a DataArray or null
  78753. */
  78754. getData(): Nullable<DataArray>;
  78755. /**
  78756. * Gets underlying native buffer
  78757. * @returns underlying native buffer
  78758. */
  78759. getBuffer(): Nullable<DataBuffer>;
  78760. /**
  78761. * Gets the stride in float32 units (i.e. byte stride / 4).
  78762. * May not be an integer if the byte stride is not divisible by 4.
  78763. * @returns the stride in float32 units
  78764. * @deprecated Please use byteStride instead.
  78765. */
  78766. getStrideSize(): number;
  78767. /**
  78768. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  78769. * @param data defines the data to store
  78770. */
  78771. create(data?: Nullable<DataArray>): void;
  78772. /** @hidden */
  78773. _rebuild(): void;
  78774. /**
  78775. * Update current buffer data
  78776. * @param data defines the data to store
  78777. */
  78778. update(data: DataArray): void;
  78779. /**
  78780. * Updates the data directly.
  78781. * @param data the new data
  78782. * @param offset the new offset
  78783. * @param vertexCount the vertex count (optional)
  78784. * @param useBytes set to true if the offset is in bytes
  78785. */
  78786. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  78787. /**
  78788. * Release all resources
  78789. */
  78790. dispose(): void;
  78791. }
  78792. /**
  78793. * Specialized buffer used to store vertex data
  78794. */
  78795. export class VertexBuffer {
  78796. /** @hidden */
  78797. _buffer: Buffer;
  78798. private _kind;
  78799. private _size;
  78800. private _ownsBuffer;
  78801. private _instanced;
  78802. private _instanceDivisor;
  78803. /**
  78804. * The byte type.
  78805. */
  78806. static readonly BYTE: number;
  78807. /**
  78808. * The unsigned byte type.
  78809. */
  78810. static readonly UNSIGNED_BYTE: number;
  78811. /**
  78812. * The short type.
  78813. */
  78814. static readonly SHORT: number;
  78815. /**
  78816. * The unsigned short type.
  78817. */
  78818. static readonly UNSIGNED_SHORT: number;
  78819. /**
  78820. * The integer type.
  78821. */
  78822. static readonly INT: number;
  78823. /**
  78824. * The unsigned integer type.
  78825. */
  78826. static readonly UNSIGNED_INT: number;
  78827. /**
  78828. * The float type.
  78829. */
  78830. static readonly FLOAT: number;
  78831. /**
  78832. * Gets or sets the instance divisor when in instanced mode
  78833. */
  78834. get instanceDivisor(): number;
  78835. set instanceDivisor(value: number);
  78836. /**
  78837. * Gets the byte stride.
  78838. */
  78839. readonly byteStride: number;
  78840. /**
  78841. * Gets the byte offset.
  78842. */
  78843. readonly byteOffset: number;
  78844. /**
  78845. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  78846. */
  78847. readonly normalized: boolean;
  78848. /**
  78849. * Gets the data type of each component in the array.
  78850. */
  78851. readonly type: number;
  78852. /**
  78853. * Constructor
  78854. * @param engine the engine
  78855. * @param data the data to use for this vertex buffer
  78856. * @param kind the vertex buffer kind
  78857. * @param updatable whether the data is updatable
  78858. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  78859. * @param stride the stride (optional)
  78860. * @param instanced whether the buffer is instanced (optional)
  78861. * @param offset the offset of the data (optional)
  78862. * @param size the number of components (optional)
  78863. * @param type the type of the component (optional)
  78864. * @param normalized whether the data contains normalized data (optional)
  78865. * @param useBytes set to true if stride and offset are in bytes (optional)
  78866. * @param divisor defines the instance divisor to use (1 by default)
  78867. */
  78868. 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);
  78869. /** @hidden */
  78870. _rebuild(): void;
  78871. /**
  78872. * Returns the kind of the VertexBuffer (string)
  78873. * @returns a string
  78874. */
  78875. getKind(): string;
  78876. /**
  78877. * Gets a boolean indicating if the VertexBuffer is updatable?
  78878. * @returns true if the buffer is updatable
  78879. */
  78880. isUpdatable(): boolean;
  78881. /**
  78882. * Gets current buffer's data
  78883. * @returns a DataArray or null
  78884. */
  78885. getData(): Nullable<DataArray>;
  78886. /**
  78887. * Gets underlying native buffer
  78888. * @returns underlying native buffer
  78889. */
  78890. getBuffer(): Nullable<DataBuffer>;
  78891. /**
  78892. * Gets the stride in float32 units (i.e. byte stride / 4).
  78893. * May not be an integer if the byte stride is not divisible by 4.
  78894. * @returns the stride in float32 units
  78895. * @deprecated Please use byteStride instead.
  78896. */
  78897. getStrideSize(): number;
  78898. /**
  78899. * Returns the offset as a multiple of the type byte length.
  78900. * @returns the offset in bytes
  78901. * @deprecated Please use byteOffset instead.
  78902. */
  78903. getOffset(): number;
  78904. /**
  78905. * Returns the number of components per vertex attribute (integer)
  78906. * @returns the size in float
  78907. */
  78908. getSize(): number;
  78909. /**
  78910. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  78911. * @returns true if this buffer is instanced
  78912. */
  78913. getIsInstanced(): boolean;
  78914. /**
  78915. * Returns the instancing divisor, zero for non-instanced (integer).
  78916. * @returns a number
  78917. */
  78918. getInstanceDivisor(): number;
  78919. /**
  78920. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  78921. * @param data defines the data to store
  78922. */
  78923. create(data?: DataArray): void;
  78924. /**
  78925. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  78926. * This function will create a new buffer if the current one is not updatable
  78927. * @param data defines the data to store
  78928. */
  78929. update(data: DataArray): void;
  78930. /**
  78931. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  78932. * Returns the directly updated WebGLBuffer.
  78933. * @param data the new data
  78934. * @param offset the new offset
  78935. * @param useBytes set to true if the offset is in bytes
  78936. */
  78937. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  78938. /**
  78939. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  78940. */
  78941. dispose(): void;
  78942. /**
  78943. * Enumerates each value of this vertex buffer as numbers.
  78944. * @param count the number of values to enumerate
  78945. * @param callback the callback function called for each value
  78946. */
  78947. forEach(count: number, callback: (value: number, index: number) => void): void;
  78948. /**
  78949. * Positions
  78950. */
  78951. static readonly PositionKind: string;
  78952. /**
  78953. * Normals
  78954. */
  78955. static readonly NormalKind: string;
  78956. /**
  78957. * Tangents
  78958. */
  78959. static readonly TangentKind: string;
  78960. /**
  78961. * Texture coordinates
  78962. */
  78963. static readonly UVKind: string;
  78964. /**
  78965. * Texture coordinates 2
  78966. */
  78967. static readonly UV2Kind: string;
  78968. /**
  78969. * Texture coordinates 3
  78970. */
  78971. static readonly UV3Kind: string;
  78972. /**
  78973. * Texture coordinates 4
  78974. */
  78975. static readonly UV4Kind: string;
  78976. /**
  78977. * Texture coordinates 5
  78978. */
  78979. static readonly UV5Kind: string;
  78980. /**
  78981. * Texture coordinates 6
  78982. */
  78983. static readonly UV6Kind: string;
  78984. /**
  78985. * Colors
  78986. */
  78987. static readonly ColorKind: string;
  78988. /**
  78989. * Matrix indices (for bones)
  78990. */
  78991. static readonly MatricesIndicesKind: string;
  78992. /**
  78993. * Matrix weights (for bones)
  78994. */
  78995. static readonly MatricesWeightsKind: string;
  78996. /**
  78997. * Additional matrix indices (for bones)
  78998. */
  78999. static readonly MatricesIndicesExtraKind: string;
  79000. /**
  79001. * Additional matrix weights (for bones)
  79002. */
  79003. static readonly MatricesWeightsExtraKind: string;
  79004. /**
  79005. * Deduces the stride given a kind.
  79006. * @param kind The kind string to deduce
  79007. * @returns The deduced stride
  79008. */
  79009. static DeduceStride(kind: string): number;
  79010. /**
  79011. * Gets the byte length of the given type.
  79012. * @param type the type
  79013. * @returns the number of bytes
  79014. */
  79015. static GetTypeByteLength(type: number): number;
  79016. /**
  79017. * Enumerates each value of the given parameters as numbers.
  79018. * @param data the data to enumerate
  79019. * @param byteOffset the byte offset of the data
  79020. * @param byteStride the byte stride of the data
  79021. * @param componentCount the number of components per element
  79022. * @param componentType the type of the component
  79023. * @param count the number of values to enumerate
  79024. * @param normalized whether the data is normalized
  79025. * @param callback the callback function called for each value
  79026. */
  79027. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79028. private static _GetFloatValue;
  79029. }
  79030. }
  79031. declare module BABYLON {
  79032. /**
  79033. * @hidden
  79034. */
  79035. export class IntersectionInfo {
  79036. bu: Nullable<number>;
  79037. bv: Nullable<number>;
  79038. distance: number;
  79039. faceId: number;
  79040. subMeshId: number;
  79041. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79042. }
  79043. }
  79044. declare module BABYLON {
  79045. /**
  79046. * Represens a plane by the equation ax + by + cz + d = 0
  79047. */
  79048. export class Plane {
  79049. private static _TmpMatrix;
  79050. /**
  79051. * Normal of the plane (a,b,c)
  79052. */
  79053. normal: Vector3;
  79054. /**
  79055. * d component of the plane
  79056. */
  79057. d: number;
  79058. /**
  79059. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79060. * @param a a component of the plane
  79061. * @param b b component of the plane
  79062. * @param c c component of the plane
  79063. * @param d d component of the plane
  79064. */
  79065. constructor(a: number, b: number, c: number, d: number);
  79066. /**
  79067. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79068. */
  79069. asArray(): number[];
  79070. /**
  79071. * @returns a new plane copied from the current Plane.
  79072. */
  79073. clone(): Plane;
  79074. /**
  79075. * @returns the string "Plane".
  79076. */
  79077. getClassName(): string;
  79078. /**
  79079. * @returns the Plane hash code.
  79080. */
  79081. getHashCode(): number;
  79082. /**
  79083. * Normalize the current Plane in place.
  79084. * @returns the updated Plane.
  79085. */
  79086. normalize(): Plane;
  79087. /**
  79088. * Applies a transformation the plane and returns the result
  79089. * @param transformation the transformation matrix to be applied to the plane
  79090. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79091. */
  79092. transform(transformation: DeepImmutable<Matrix>): Plane;
  79093. /**
  79094. * Calcualtte the dot product between the point and the plane normal
  79095. * @param point point to calculate the dot product with
  79096. * @returns the dot product (float) of the point coordinates and the plane normal.
  79097. */
  79098. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79099. /**
  79100. * Updates the current Plane from the plane defined by the three given points.
  79101. * @param point1 one of the points used to contruct the plane
  79102. * @param point2 one of the points used to contruct the plane
  79103. * @param point3 one of the points used to contruct the plane
  79104. * @returns the updated Plane.
  79105. */
  79106. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79107. /**
  79108. * Checks if the plane is facing a given direction
  79109. * @param direction the direction to check if the plane is facing
  79110. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79111. * @returns True is the vector "direction" is the same side than the plane normal.
  79112. */
  79113. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79114. /**
  79115. * Calculates the distance to a point
  79116. * @param point point to calculate distance to
  79117. * @returns the signed distance (float) from the given point to the Plane.
  79118. */
  79119. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79120. /**
  79121. * Creates a plane from an array
  79122. * @param array the array to create a plane from
  79123. * @returns a new Plane from the given array.
  79124. */
  79125. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79126. /**
  79127. * Creates a plane from three points
  79128. * @param point1 point used to create the plane
  79129. * @param point2 point used to create the plane
  79130. * @param point3 point used to create the plane
  79131. * @returns a new Plane defined by the three given points.
  79132. */
  79133. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79134. /**
  79135. * Creates a plane from an origin point and a normal
  79136. * @param origin origin of the plane to be constructed
  79137. * @param normal normal of the plane to be constructed
  79138. * @returns a new Plane the normal vector to this plane at the given origin point.
  79139. * Note : the vector "normal" is updated because normalized.
  79140. */
  79141. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79142. /**
  79143. * Calculates the distance from a plane and a point
  79144. * @param origin origin of the plane to be constructed
  79145. * @param normal normal of the plane to be constructed
  79146. * @param point point to calculate distance to
  79147. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79148. */
  79149. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79150. }
  79151. }
  79152. declare module BABYLON {
  79153. /**
  79154. * Class used to store bounding sphere information
  79155. */
  79156. export class BoundingSphere {
  79157. /**
  79158. * Gets the center of the bounding sphere in local space
  79159. */
  79160. readonly center: Vector3;
  79161. /**
  79162. * Radius of the bounding sphere in local space
  79163. */
  79164. radius: number;
  79165. /**
  79166. * Gets the center of the bounding sphere in world space
  79167. */
  79168. readonly centerWorld: Vector3;
  79169. /**
  79170. * Radius of the bounding sphere in world space
  79171. */
  79172. radiusWorld: number;
  79173. /**
  79174. * Gets the minimum vector in local space
  79175. */
  79176. readonly minimum: Vector3;
  79177. /**
  79178. * Gets the maximum vector in local space
  79179. */
  79180. readonly maximum: Vector3;
  79181. private _worldMatrix;
  79182. private static readonly TmpVector3;
  79183. /**
  79184. * Creates a new bounding sphere
  79185. * @param min defines the minimum vector (in local space)
  79186. * @param max defines the maximum vector (in local space)
  79187. * @param worldMatrix defines the new world matrix
  79188. */
  79189. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79190. /**
  79191. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79192. * @param min defines the new minimum vector (in local space)
  79193. * @param max defines the new maximum vector (in local space)
  79194. * @param worldMatrix defines the new world matrix
  79195. */
  79196. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79197. /**
  79198. * Scale the current bounding sphere by applying a scale factor
  79199. * @param factor defines the scale factor to apply
  79200. * @returns the current bounding box
  79201. */
  79202. scale(factor: number): BoundingSphere;
  79203. /**
  79204. * Gets the world matrix of the bounding box
  79205. * @returns a matrix
  79206. */
  79207. getWorldMatrix(): DeepImmutable<Matrix>;
  79208. /** @hidden */
  79209. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79210. /**
  79211. * Tests if the bounding sphere is intersecting the frustum planes
  79212. * @param frustumPlanes defines the frustum planes to test
  79213. * @returns true if there is an intersection
  79214. */
  79215. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79216. /**
  79217. * Tests if the bounding sphere center is in between the frustum planes.
  79218. * Used for optimistic fast inclusion.
  79219. * @param frustumPlanes defines the frustum planes to test
  79220. * @returns true if the sphere center is in between the frustum planes
  79221. */
  79222. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79223. /**
  79224. * Tests if a point is inside the bounding sphere
  79225. * @param point defines the point to test
  79226. * @returns true if the point is inside the bounding sphere
  79227. */
  79228. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79229. /**
  79230. * Checks if two sphere intersct
  79231. * @param sphere0 sphere 0
  79232. * @param sphere1 sphere 1
  79233. * @returns true if the speres intersect
  79234. */
  79235. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  79236. }
  79237. }
  79238. declare module BABYLON {
  79239. /**
  79240. * Class used to store bounding box information
  79241. */
  79242. export class BoundingBox implements ICullable {
  79243. /**
  79244. * Gets the 8 vectors representing the bounding box in local space
  79245. */
  79246. readonly vectors: Vector3[];
  79247. /**
  79248. * Gets the center of the bounding box in local space
  79249. */
  79250. readonly center: Vector3;
  79251. /**
  79252. * Gets the center of the bounding box in world space
  79253. */
  79254. readonly centerWorld: Vector3;
  79255. /**
  79256. * Gets the extend size in local space
  79257. */
  79258. readonly extendSize: Vector3;
  79259. /**
  79260. * Gets the extend size in world space
  79261. */
  79262. readonly extendSizeWorld: Vector3;
  79263. /**
  79264. * Gets the OBB (object bounding box) directions
  79265. */
  79266. readonly directions: Vector3[];
  79267. /**
  79268. * Gets the 8 vectors representing the bounding box in world space
  79269. */
  79270. readonly vectorsWorld: Vector3[];
  79271. /**
  79272. * Gets the minimum vector in world space
  79273. */
  79274. readonly minimumWorld: Vector3;
  79275. /**
  79276. * Gets the maximum vector in world space
  79277. */
  79278. readonly maximumWorld: Vector3;
  79279. /**
  79280. * Gets the minimum vector in local space
  79281. */
  79282. readonly minimum: Vector3;
  79283. /**
  79284. * Gets the maximum vector in local space
  79285. */
  79286. readonly maximum: Vector3;
  79287. private _worldMatrix;
  79288. private static readonly TmpVector3;
  79289. /**
  79290. * @hidden
  79291. */
  79292. _tag: number;
  79293. /**
  79294. * Creates a new bounding box
  79295. * @param min defines the minimum vector (in local space)
  79296. * @param max defines the maximum vector (in local space)
  79297. * @param worldMatrix defines the new world matrix
  79298. */
  79299. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79300. /**
  79301. * Recreates the entire bounding box from scratch as if we call the constructor in place
  79302. * @param min defines the new minimum vector (in local space)
  79303. * @param max defines the new maximum vector (in local space)
  79304. * @param worldMatrix defines the new world matrix
  79305. */
  79306. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79307. /**
  79308. * Scale the current bounding box by applying a scale factor
  79309. * @param factor defines the scale factor to apply
  79310. * @returns the current bounding box
  79311. */
  79312. scale(factor: number): BoundingBox;
  79313. /**
  79314. * Gets the world matrix of the bounding box
  79315. * @returns a matrix
  79316. */
  79317. getWorldMatrix(): DeepImmutable<Matrix>;
  79318. /** @hidden */
  79319. _update(world: DeepImmutable<Matrix>): void;
  79320. /**
  79321. * Tests if the bounding box is intersecting the frustum planes
  79322. * @param frustumPlanes defines the frustum planes to test
  79323. * @returns true if there is an intersection
  79324. */
  79325. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79326. /**
  79327. * Tests if the bounding box is entirely inside the frustum planes
  79328. * @param frustumPlanes defines the frustum planes to test
  79329. * @returns true if there is an inclusion
  79330. */
  79331. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79332. /**
  79333. * Tests if a point is inside the bounding box
  79334. * @param point defines the point to test
  79335. * @returns true if the point is inside the bounding box
  79336. */
  79337. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79338. /**
  79339. * Tests if the bounding box intersects with a bounding sphere
  79340. * @param sphere defines the sphere to test
  79341. * @returns true if there is an intersection
  79342. */
  79343. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  79344. /**
  79345. * Tests if the bounding box intersects with a box defined by a min and max vectors
  79346. * @param min defines the min vector to use
  79347. * @param max defines the max vector to use
  79348. * @returns true if there is an intersection
  79349. */
  79350. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  79351. /**
  79352. * Tests if two bounding boxes are intersections
  79353. * @param box0 defines the first box to test
  79354. * @param box1 defines the second box to test
  79355. * @returns true if there is an intersection
  79356. */
  79357. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  79358. /**
  79359. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  79360. * @param minPoint defines the minimum vector of the bounding box
  79361. * @param maxPoint defines the maximum vector of the bounding box
  79362. * @param sphereCenter defines the sphere center
  79363. * @param sphereRadius defines the sphere radius
  79364. * @returns true if there is an intersection
  79365. */
  79366. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  79367. /**
  79368. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  79369. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79370. * @param frustumPlanes defines the frustum planes to test
  79371. * @return true if there is an inclusion
  79372. */
  79373. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79374. /**
  79375. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  79376. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79377. * @param frustumPlanes defines the frustum planes to test
  79378. * @return true if there is an intersection
  79379. */
  79380. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79381. }
  79382. }
  79383. declare module BABYLON {
  79384. /** @hidden */
  79385. export class Collider {
  79386. /** Define if a collision was found */
  79387. collisionFound: boolean;
  79388. /**
  79389. * Define last intersection point in local space
  79390. */
  79391. intersectionPoint: Vector3;
  79392. /**
  79393. * Define last collided mesh
  79394. */
  79395. collidedMesh: Nullable<AbstractMesh>;
  79396. private _collisionPoint;
  79397. private _planeIntersectionPoint;
  79398. private _tempVector;
  79399. private _tempVector2;
  79400. private _tempVector3;
  79401. private _tempVector4;
  79402. private _edge;
  79403. private _baseToVertex;
  79404. private _destinationPoint;
  79405. private _slidePlaneNormal;
  79406. private _displacementVector;
  79407. /** @hidden */
  79408. _radius: Vector3;
  79409. /** @hidden */
  79410. _retry: number;
  79411. private _velocity;
  79412. private _basePoint;
  79413. private _epsilon;
  79414. /** @hidden */
  79415. _velocityWorldLength: number;
  79416. /** @hidden */
  79417. _basePointWorld: Vector3;
  79418. private _velocityWorld;
  79419. private _normalizedVelocity;
  79420. /** @hidden */
  79421. _initialVelocity: Vector3;
  79422. /** @hidden */
  79423. _initialPosition: Vector3;
  79424. private _nearestDistance;
  79425. private _collisionMask;
  79426. get collisionMask(): number;
  79427. set collisionMask(mask: number);
  79428. /**
  79429. * Gets the plane normal used to compute the sliding response (in local space)
  79430. */
  79431. get slidePlaneNormal(): Vector3;
  79432. /** @hidden */
  79433. _initialize(source: Vector3, dir: Vector3, e: number): void;
  79434. /** @hidden */
  79435. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  79436. /** @hidden */
  79437. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  79438. /** @hidden */
  79439. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79440. /** @hidden */
  79441. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79442. /** @hidden */
  79443. _getResponse(pos: Vector3, vel: Vector3): void;
  79444. }
  79445. }
  79446. declare module BABYLON {
  79447. /**
  79448. * Interface for cullable objects
  79449. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  79450. */
  79451. export interface ICullable {
  79452. /**
  79453. * Checks if the object or part of the object is in the frustum
  79454. * @param frustumPlanes Camera near/planes
  79455. * @returns true if the object is in frustum otherwise false
  79456. */
  79457. isInFrustum(frustumPlanes: Plane[]): boolean;
  79458. /**
  79459. * Checks if a cullable object (mesh...) is in the camera frustum
  79460. * Unlike isInFrustum this cheks the full bounding box
  79461. * @param frustumPlanes Camera near/planes
  79462. * @returns true if the object is in frustum otherwise false
  79463. */
  79464. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79465. }
  79466. /**
  79467. * Info for a bounding data of a mesh
  79468. */
  79469. export class BoundingInfo implements ICullable {
  79470. /**
  79471. * Bounding box for the mesh
  79472. */
  79473. readonly boundingBox: BoundingBox;
  79474. /**
  79475. * Bounding sphere for the mesh
  79476. */
  79477. readonly boundingSphere: BoundingSphere;
  79478. private _isLocked;
  79479. private static readonly TmpVector3;
  79480. /**
  79481. * Constructs bounding info
  79482. * @param minimum min vector of the bounding box/sphere
  79483. * @param maximum max vector of the bounding box/sphere
  79484. * @param worldMatrix defines the new world matrix
  79485. */
  79486. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79487. /**
  79488. * Recreates the entire bounding info from scratch as if we call the constructor in place
  79489. * @param min defines the new minimum vector (in local space)
  79490. * @param max defines the new maximum vector (in local space)
  79491. * @param worldMatrix defines the new world matrix
  79492. */
  79493. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79494. /**
  79495. * min vector of the bounding box/sphere
  79496. */
  79497. get minimum(): Vector3;
  79498. /**
  79499. * max vector of the bounding box/sphere
  79500. */
  79501. get maximum(): Vector3;
  79502. /**
  79503. * If the info is locked and won't be updated to avoid perf overhead
  79504. */
  79505. get isLocked(): boolean;
  79506. set isLocked(value: boolean);
  79507. /**
  79508. * Updates the bounding sphere and box
  79509. * @param world world matrix to be used to update
  79510. */
  79511. update(world: DeepImmutable<Matrix>): void;
  79512. /**
  79513. * Recreate the bounding info to be centered around a specific point given a specific extend.
  79514. * @param center New center of the bounding info
  79515. * @param extend New extend of the bounding info
  79516. * @returns the current bounding info
  79517. */
  79518. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  79519. /**
  79520. * Scale the current bounding info by applying a scale factor
  79521. * @param factor defines the scale factor to apply
  79522. * @returns the current bounding info
  79523. */
  79524. scale(factor: number): BoundingInfo;
  79525. /**
  79526. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  79527. * @param frustumPlanes defines the frustum to test
  79528. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  79529. * @returns true if the bounding info is in the frustum planes
  79530. */
  79531. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  79532. /**
  79533. * Gets the world distance between the min and max points of the bounding box
  79534. */
  79535. get diagonalLength(): number;
  79536. /**
  79537. * Checks if a cullable object (mesh...) is in the camera frustum
  79538. * Unlike isInFrustum this cheks the full bounding box
  79539. * @param frustumPlanes Camera near/planes
  79540. * @returns true if the object is in frustum otherwise false
  79541. */
  79542. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79543. /** @hidden */
  79544. _checkCollision(collider: Collider): boolean;
  79545. /**
  79546. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  79547. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79548. * @param point the point to check intersection with
  79549. * @returns if the point intersects
  79550. */
  79551. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79552. /**
  79553. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  79554. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79555. * @param boundingInfo the bounding info to check intersection with
  79556. * @param precise if the intersection should be done using OBB
  79557. * @returns if the bounding info intersects
  79558. */
  79559. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  79560. }
  79561. }
  79562. declare module BABYLON {
  79563. /**
  79564. * Extracts minimum and maximum values from a list of indexed positions
  79565. * @param positions defines the positions to use
  79566. * @param indices defines the indices to the positions
  79567. * @param indexStart defines the start index
  79568. * @param indexCount defines the end index
  79569. * @param bias defines bias value to add to the result
  79570. * @return minimum and maximum values
  79571. */
  79572. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  79573. minimum: Vector3;
  79574. maximum: Vector3;
  79575. };
  79576. /**
  79577. * Extracts minimum and maximum values from a list of positions
  79578. * @param positions defines the positions to use
  79579. * @param start defines the start index in the positions array
  79580. * @param count defines the number of positions to handle
  79581. * @param bias defines bias value to add to the result
  79582. * @param stride defines the stride size to use (distance between two positions in the positions array)
  79583. * @return minimum and maximum values
  79584. */
  79585. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  79586. minimum: Vector3;
  79587. maximum: Vector3;
  79588. };
  79589. }
  79590. declare module BABYLON {
  79591. /** @hidden */
  79592. export class WebGLDataBuffer extends DataBuffer {
  79593. private _buffer;
  79594. constructor(resource: WebGLBuffer);
  79595. get underlyingResource(): any;
  79596. }
  79597. }
  79598. declare module BABYLON {
  79599. /** @hidden */
  79600. export class WebGLPipelineContext implements IPipelineContext {
  79601. engine: ThinEngine;
  79602. program: Nullable<WebGLProgram>;
  79603. context?: WebGLRenderingContext;
  79604. vertexShader?: WebGLShader;
  79605. fragmentShader?: WebGLShader;
  79606. isParallelCompiled: boolean;
  79607. onCompiled?: () => void;
  79608. transformFeedback?: WebGLTransformFeedback | null;
  79609. vertexCompilationError: Nullable<string>;
  79610. fragmentCompilationError: Nullable<string>;
  79611. programLinkError: Nullable<string>;
  79612. programValidationError: Nullable<string>;
  79613. get isAsync(): boolean;
  79614. get isReady(): boolean;
  79615. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  79616. }
  79617. }
  79618. declare module BABYLON {
  79619. interface ThinEngine {
  79620. /**
  79621. * Create an uniform buffer
  79622. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79623. * @param elements defines the content of the uniform buffer
  79624. * @returns the webGL uniform buffer
  79625. */
  79626. createUniformBuffer(elements: FloatArray): DataBuffer;
  79627. /**
  79628. * Create a dynamic uniform buffer
  79629. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79630. * @param elements defines the content of the uniform buffer
  79631. * @returns the webGL uniform buffer
  79632. */
  79633. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  79634. /**
  79635. * Update an existing uniform buffer
  79636. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  79637. * @param uniformBuffer defines the target uniform buffer
  79638. * @param elements defines the content to update
  79639. * @param offset defines the offset in the uniform buffer where update should start
  79640. * @param count defines the size of the data to update
  79641. */
  79642. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  79643. /**
  79644. * Bind an uniform buffer to the current webGL context
  79645. * @param buffer defines the buffer to bind
  79646. */
  79647. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  79648. /**
  79649. * Bind a buffer to the current webGL context at a given location
  79650. * @param buffer defines the buffer to bind
  79651. * @param location defines the index where to bind the buffer
  79652. */
  79653. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  79654. /**
  79655. * Bind a specific block at a given index in a specific shader program
  79656. * @param pipelineContext defines the pipeline context to use
  79657. * @param blockName defines the block name
  79658. * @param index defines the index where to bind the block
  79659. */
  79660. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  79661. }
  79662. }
  79663. declare module BABYLON {
  79664. /**
  79665. * Uniform buffer objects.
  79666. *
  79667. * Handles blocks of uniform on the GPU.
  79668. *
  79669. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79670. *
  79671. * For more information, please refer to :
  79672. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79673. */
  79674. export class UniformBuffer {
  79675. private _engine;
  79676. private _buffer;
  79677. private _data;
  79678. private _bufferData;
  79679. private _dynamic?;
  79680. private _uniformLocations;
  79681. private _uniformSizes;
  79682. private _uniformLocationPointer;
  79683. private _needSync;
  79684. private _noUBO;
  79685. private _currentEffect;
  79686. /** @hidden */
  79687. _alreadyBound: boolean;
  79688. private static _MAX_UNIFORM_SIZE;
  79689. private static _tempBuffer;
  79690. /**
  79691. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  79692. * This is dynamic to allow compat with webgl 1 and 2.
  79693. * You will need to pass the name of the uniform as well as the value.
  79694. */
  79695. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  79696. /**
  79697. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  79698. * This is dynamic to allow compat with webgl 1 and 2.
  79699. * You will need to pass the name of the uniform as well as the value.
  79700. */
  79701. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  79702. /**
  79703. * Lambda to Update a single float in a uniform buffer.
  79704. * This is dynamic to allow compat with webgl 1 and 2.
  79705. * You will need to pass the name of the uniform as well as the value.
  79706. */
  79707. updateFloat: (name: string, x: number) => void;
  79708. /**
  79709. * Lambda to Update a vec2 of float in a uniform buffer.
  79710. * This is dynamic to allow compat with webgl 1 and 2.
  79711. * You will need to pass the name of the uniform as well as the value.
  79712. */
  79713. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  79714. /**
  79715. * Lambda to Update a vec3 of float in a uniform buffer.
  79716. * This is dynamic to allow compat with webgl 1 and 2.
  79717. * You will need to pass the name of the uniform as well as the value.
  79718. */
  79719. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  79720. /**
  79721. * Lambda to Update a vec4 of float in a uniform buffer.
  79722. * This is dynamic to allow compat with webgl 1 and 2.
  79723. * You will need to pass the name of the uniform as well as the value.
  79724. */
  79725. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  79726. /**
  79727. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  79728. * This is dynamic to allow compat with webgl 1 and 2.
  79729. * You will need to pass the name of the uniform as well as the value.
  79730. */
  79731. updateMatrix: (name: string, mat: Matrix) => void;
  79732. /**
  79733. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  79734. * This is dynamic to allow compat with webgl 1 and 2.
  79735. * You will need to pass the name of the uniform as well as the value.
  79736. */
  79737. updateVector3: (name: string, vector: Vector3) => void;
  79738. /**
  79739. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  79740. * This is dynamic to allow compat with webgl 1 and 2.
  79741. * You will need to pass the name of the uniform as well as the value.
  79742. */
  79743. updateVector4: (name: string, vector: Vector4) => void;
  79744. /**
  79745. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  79746. * This is dynamic to allow compat with webgl 1 and 2.
  79747. * You will need to pass the name of the uniform as well as the value.
  79748. */
  79749. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  79750. /**
  79751. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  79752. * This is dynamic to allow compat with webgl 1 and 2.
  79753. * You will need to pass the name of the uniform as well as the value.
  79754. */
  79755. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  79756. /**
  79757. * Instantiates a new Uniform buffer objects.
  79758. *
  79759. * Handles blocks of uniform on the GPU.
  79760. *
  79761. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  79762. *
  79763. * For more information, please refer to :
  79764. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  79765. * @param engine Define the engine the buffer is associated with
  79766. * @param data Define the data contained in the buffer
  79767. * @param dynamic Define if the buffer is updatable
  79768. */
  79769. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  79770. /**
  79771. * Indicates if the buffer is using the WebGL2 UBO implementation,
  79772. * or just falling back on setUniformXXX calls.
  79773. */
  79774. get useUbo(): boolean;
  79775. /**
  79776. * Indicates if the WebGL underlying uniform buffer is in sync
  79777. * with the javascript cache data.
  79778. */
  79779. get isSync(): boolean;
  79780. /**
  79781. * Indicates if the WebGL underlying uniform buffer is dynamic.
  79782. * Also, a dynamic UniformBuffer will disable cache verification and always
  79783. * update the underlying WebGL uniform buffer to the GPU.
  79784. * @returns if Dynamic, otherwise false
  79785. */
  79786. isDynamic(): boolean;
  79787. /**
  79788. * The data cache on JS side.
  79789. * @returns the underlying data as a float array
  79790. */
  79791. getData(): Float32Array;
  79792. /**
  79793. * The underlying WebGL Uniform buffer.
  79794. * @returns the webgl buffer
  79795. */
  79796. getBuffer(): Nullable<DataBuffer>;
  79797. /**
  79798. * std140 layout specifies how to align data within an UBO structure.
  79799. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  79800. * for specs.
  79801. */
  79802. private _fillAlignment;
  79803. /**
  79804. * Adds an uniform in the buffer.
  79805. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  79806. * for the layout to be correct !
  79807. * @param name Name of the uniform, as used in the uniform block in the shader.
  79808. * @param size Data size, or data directly.
  79809. */
  79810. addUniform(name: string, size: number | number[]): void;
  79811. /**
  79812. * Adds a Matrix 4x4 to the uniform buffer.
  79813. * @param name Name of the uniform, as used in the uniform block in the shader.
  79814. * @param mat A 4x4 matrix.
  79815. */
  79816. addMatrix(name: string, mat: Matrix): void;
  79817. /**
  79818. * Adds a vec2 to the uniform buffer.
  79819. * @param name Name of the uniform, as used in the uniform block in the shader.
  79820. * @param x Define the x component value of the vec2
  79821. * @param y Define the y component value of the vec2
  79822. */
  79823. addFloat2(name: string, x: number, y: number): void;
  79824. /**
  79825. * Adds a vec3 to the uniform buffer.
  79826. * @param name Name of the uniform, as used in the uniform block in the shader.
  79827. * @param x Define the x component value of the vec3
  79828. * @param y Define the y component value of the vec3
  79829. * @param z Define the z component value of the vec3
  79830. */
  79831. addFloat3(name: string, x: number, y: number, z: number): void;
  79832. /**
  79833. * Adds a vec3 to the uniform buffer.
  79834. * @param name Name of the uniform, as used in the uniform block in the shader.
  79835. * @param color Define the vec3 from a Color
  79836. */
  79837. addColor3(name: string, color: Color3): void;
  79838. /**
  79839. * Adds a vec4 to the uniform buffer.
  79840. * @param name Name of the uniform, as used in the uniform block in the shader.
  79841. * @param color Define the rgb components from a Color
  79842. * @param alpha Define the a component of the vec4
  79843. */
  79844. addColor4(name: string, color: Color3, alpha: number): void;
  79845. /**
  79846. * Adds a vec3 to the uniform buffer.
  79847. * @param name Name of the uniform, as used in the uniform block in the shader.
  79848. * @param vector Define the vec3 components from a Vector
  79849. */
  79850. addVector3(name: string, vector: Vector3): void;
  79851. /**
  79852. * Adds a Matrix 3x3 to the uniform buffer.
  79853. * @param name Name of the uniform, as used in the uniform block in the shader.
  79854. */
  79855. addMatrix3x3(name: string): void;
  79856. /**
  79857. * Adds a Matrix 2x2 to the uniform buffer.
  79858. * @param name Name of the uniform, as used in the uniform block in the shader.
  79859. */
  79860. addMatrix2x2(name: string): void;
  79861. /**
  79862. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  79863. */
  79864. create(): void;
  79865. /** @hidden */
  79866. _rebuild(): void;
  79867. /**
  79868. * Updates the WebGL Uniform Buffer on the GPU.
  79869. * If the `dynamic` flag is set to true, no cache comparison is done.
  79870. * Otherwise, the buffer will be updated only if the cache differs.
  79871. */
  79872. update(): void;
  79873. /**
  79874. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  79875. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  79876. * @param data Define the flattened data
  79877. * @param size Define the size of the data.
  79878. */
  79879. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  79880. private _valueCache;
  79881. private _cacheMatrix;
  79882. private _updateMatrix3x3ForUniform;
  79883. private _updateMatrix3x3ForEffect;
  79884. private _updateMatrix2x2ForEffect;
  79885. private _updateMatrix2x2ForUniform;
  79886. private _updateFloatForEffect;
  79887. private _updateFloatForUniform;
  79888. private _updateFloat2ForEffect;
  79889. private _updateFloat2ForUniform;
  79890. private _updateFloat3ForEffect;
  79891. private _updateFloat3ForUniform;
  79892. private _updateFloat4ForEffect;
  79893. private _updateFloat4ForUniform;
  79894. private _updateMatrixForEffect;
  79895. private _updateMatrixForUniform;
  79896. private _updateVector3ForEffect;
  79897. private _updateVector3ForUniform;
  79898. private _updateVector4ForEffect;
  79899. private _updateVector4ForUniform;
  79900. private _updateColor3ForEffect;
  79901. private _updateColor3ForUniform;
  79902. private _updateColor4ForEffect;
  79903. private _updateColor4ForUniform;
  79904. /**
  79905. * Sets a sampler uniform on the effect.
  79906. * @param name Define the name of the sampler.
  79907. * @param texture Define the texture to set in the sampler
  79908. */
  79909. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  79910. /**
  79911. * Directly updates the value of the uniform in the cache AND on the GPU.
  79912. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  79913. * @param data Define the flattened data
  79914. */
  79915. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  79916. /**
  79917. * Binds this uniform buffer to an effect.
  79918. * @param effect Define the effect to bind the buffer to
  79919. * @param name Name of the uniform block in the shader.
  79920. */
  79921. bindToEffect(effect: Effect, name: string): void;
  79922. /**
  79923. * Disposes the uniform buffer.
  79924. */
  79925. dispose(): void;
  79926. }
  79927. }
  79928. declare module BABYLON {
  79929. /**
  79930. * Enum that determines the text-wrapping mode to use.
  79931. */
  79932. export enum InspectableType {
  79933. /**
  79934. * Checkbox for booleans
  79935. */
  79936. Checkbox = 0,
  79937. /**
  79938. * Sliders for numbers
  79939. */
  79940. Slider = 1,
  79941. /**
  79942. * Vector3
  79943. */
  79944. Vector3 = 2,
  79945. /**
  79946. * Quaternions
  79947. */
  79948. Quaternion = 3,
  79949. /**
  79950. * Color3
  79951. */
  79952. Color3 = 4,
  79953. /**
  79954. * String
  79955. */
  79956. String = 5
  79957. }
  79958. /**
  79959. * Interface used to define custom inspectable properties.
  79960. * This interface is used by the inspector to display custom property grids
  79961. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79962. */
  79963. export interface IInspectable {
  79964. /**
  79965. * Gets the label to display
  79966. */
  79967. label: string;
  79968. /**
  79969. * Gets the name of the property to edit
  79970. */
  79971. propertyName: string;
  79972. /**
  79973. * Gets the type of the editor to use
  79974. */
  79975. type: InspectableType;
  79976. /**
  79977. * Gets the minimum value of the property when using in "slider" mode
  79978. */
  79979. min?: number;
  79980. /**
  79981. * Gets the maximum value of the property when using in "slider" mode
  79982. */
  79983. max?: number;
  79984. /**
  79985. * Gets the setp to use when using in "slider" mode
  79986. */
  79987. step?: number;
  79988. }
  79989. }
  79990. declare module BABYLON {
  79991. /**
  79992. * Class used to provide helper for timing
  79993. */
  79994. export class TimingTools {
  79995. /**
  79996. * Polyfill for setImmediate
  79997. * @param action defines the action to execute after the current execution block
  79998. */
  79999. static SetImmediate(action: () => void): void;
  80000. }
  80001. }
  80002. declare module BABYLON {
  80003. /**
  80004. * Class used to enable instatition of objects by class name
  80005. */
  80006. export class InstantiationTools {
  80007. /**
  80008. * Use this object to register external classes like custom textures or material
  80009. * to allow the laoders to instantiate them
  80010. */
  80011. static RegisteredExternalClasses: {
  80012. [key: string]: Object;
  80013. };
  80014. /**
  80015. * Tries to instantiate a new object from a given class name
  80016. * @param className defines the class name to instantiate
  80017. * @returns the new object or null if the system was not able to do the instantiation
  80018. */
  80019. static Instantiate(className: string): any;
  80020. }
  80021. }
  80022. declare module BABYLON {
  80023. /**
  80024. * Define options used to create a depth texture
  80025. */
  80026. export class DepthTextureCreationOptions {
  80027. /** Specifies whether or not a stencil should be allocated in the texture */
  80028. generateStencil?: boolean;
  80029. /** Specifies whether or not bilinear filtering is enable on the texture */
  80030. bilinearFiltering?: boolean;
  80031. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80032. comparisonFunction?: number;
  80033. /** Specifies if the created texture is a cube texture */
  80034. isCube?: boolean;
  80035. }
  80036. }
  80037. declare module BABYLON {
  80038. interface ThinEngine {
  80039. /**
  80040. * Creates a depth stencil cube texture.
  80041. * This is only available in WebGL 2.
  80042. * @param size The size of face edge in the cube texture.
  80043. * @param options The options defining the cube texture.
  80044. * @returns The cube texture
  80045. */
  80046. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80047. /**
  80048. * Creates a cube texture
  80049. * @param rootUrl defines the url where the files to load is located
  80050. * @param scene defines the current scene
  80051. * @param files defines the list of files to load (1 per face)
  80052. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80053. * @param onLoad defines an optional callback raised when the texture is loaded
  80054. * @param onError defines an optional callback raised if there is an issue to load the texture
  80055. * @param format defines the format of the data
  80056. * @param forcedExtension defines the extension to use to pick the right loader
  80057. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80058. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80059. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80060. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80061. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80062. * @returns the cube texture as an InternalTexture
  80063. */
  80064. 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;
  80065. /**
  80066. * Creates a cube texture
  80067. * @param rootUrl defines the url where the files to load is located
  80068. * @param scene defines the current scene
  80069. * @param files defines the list of files to load (1 per face)
  80070. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80071. * @param onLoad defines an optional callback raised when the texture is loaded
  80072. * @param onError defines an optional callback raised if there is an issue to load the texture
  80073. * @param format defines the format of the data
  80074. * @param forcedExtension defines the extension to use to pick the right loader
  80075. * @returns the cube texture as an InternalTexture
  80076. */
  80077. 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;
  80078. /**
  80079. * Creates a cube texture
  80080. * @param rootUrl defines the url where the files to load is located
  80081. * @param scene defines the current scene
  80082. * @param files defines the list of files to load (1 per face)
  80083. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80084. * @param onLoad defines an optional callback raised when the texture is loaded
  80085. * @param onError defines an optional callback raised if there is an issue to load the texture
  80086. * @param format defines the format of the data
  80087. * @param forcedExtension defines the extension to use to pick the right loader
  80088. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80089. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80090. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80091. * @returns the cube texture as an InternalTexture
  80092. */
  80093. 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;
  80094. /** @hidden */
  80095. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80096. /** @hidden */
  80097. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80098. /** @hidden */
  80099. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80100. /** @hidden */
  80101. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80102. /**
  80103. * @hidden
  80104. */
  80105. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80106. }
  80107. }
  80108. declare module BABYLON {
  80109. /**
  80110. * Class for creating a cube texture
  80111. */
  80112. export class CubeTexture extends BaseTexture {
  80113. private _delayedOnLoad;
  80114. /**
  80115. * The url of the texture
  80116. */
  80117. url: string;
  80118. /**
  80119. * Gets or sets the center of the bounding box associated with the cube texture.
  80120. * It must define where the camera used to render the texture was set
  80121. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80122. */
  80123. boundingBoxPosition: Vector3;
  80124. private _boundingBoxSize;
  80125. /**
  80126. * Gets or sets the size of the bounding box associated with the cube texture
  80127. * When defined, the cubemap will switch to local mode
  80128. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80129. * @example https://www.babylonjs-playground.com/#RNASML
  80130. */
  80131. set boundingBoxSize(value: Vector3);
  80132. /**
  80133. * Returns the bounding box size
  80134. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80135. */
  80136. get boundingBoxSize(): Vector3;
  80137. protected _rotationY: number;
  80138. /**
  80139. * Sets texture matrix rotation angle around Y axis in radians.
  80140. */
  80141. set rotationY(value: number);
  80142. /**
  80143. * Gets texture matrix rotation angle around Y axis radians.
  80144. */
  80145. get rotationY(): number;
  80146. /**
  80147. * Are mip maps generated for this texture or not.
  80148. */
  80149. get noMipmap(): boolean;
  80150. private _noMipmap;
  80151. private _files;
  80152. protected _forcedExtension: Nullable<string>;
  80153. private _extensions;
  80154. private _textureMatrix;
  80155. private _format;
  80156. private _createPolynomials;
  80157. /** @hidden */
  80158. _prefiltered: boolean;
  80159. /**
  80160. * Creates a cube texture from an array of image urls
  80161. * @param files defines an array of image urls
  80162. * @param scene defines the hosting scene
  80163. * @param noMipmap specifies if mip maps are not used
  80164. * @returns a cube texture
  80165. */
  80166. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80167. /**
  80168. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80169. * @param url defines the url of the prefiltered texture
  80170. * @param scene defines the scene the texture is attached to
  80171. * @param forcedExtension defines the extension of the file if different from the url
  80172. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80173. * @return the prefiltered texture
  80174. */
  80175. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80176. /**
  80177. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80178. * as prefiltered data.
  80179. * @param rootUrl defines the url of the texture or the root name of the six images
  80180. * @param scene defines the scene the texture is attached to
  80181. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80182. * @param noMipmap defines if mipmaps should be created or not
  80183. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80184. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80185. * @param onError defines a callback triggered in case of error during load
  80186. * @param format defines the internal format to use for the texture once loaded
  80187. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80188. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80189. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80190. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80191. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80192. * @return the cube texture
  80193. */
  80194. 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);
  80195. /**
  80196. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80197. */
  80198. get isPrefiltered(): boolean;
  80199. /**
  80200. * Get the current class name of the texture useful for serialization or dynamic coding.
  80201. * @returns "CubeTexture"
  80202. */
  80203. getClassName(): string;
  80204. /**
  80205. * Update the url (and optional buffer) of this texture if url was null during construction.
  80206. * @param url the url of the texture
  80207. * @param forcedExtension defines the extension to use
  80208. * @param onLoad callback called when the texture is loaded (defaults to null)
  80209. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80210. */
  80211. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80212. /**
  80213. * Delays loading of the cube texture
  80214. * @param forcedExtension defines the extension to use
  80215. */
  80216. delayLoad(forcedExtension?: string): void;
  80217. /**
  80218. * Returns the reflection texture matrix
  80219. * @returns the reflection texture matrix
  80220. */
  80221. getReflectionTextureMatrix(): Matrix;
  80222. /**
  80223. * Sets the reflection texture matrix
  80224. * @param value Reflection texture matrix
  80225. */
  80226. setReflectionTextureMatrix(value: Matrix): void;
  80227. /**
  80228. * Parses text to create a cube texture
  80229. * @param parsedTexture define the serialized text to read from
  80230. * @param scene defines the hosting scene
  80231. * @param rootUrl defines the root url of the cube texture
  80232. * @returns a cube texture
  80233. */
  80234. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  80235. /**
  80236. * Makes a clone, or deep copy, of the cube texture
  80237. * @returns a new cube texture
  80238. */
  80239. clone(): CubeTexture;
  80240. }
  80241. }
  80242. declare module BABYLON {
  80243. /**
  80244. * Manages the defines for the Material
  80245. */
  80246. export class MaterialDefines {
  80247. /** @hidden */
  80248. protected _keys: string[];
  80249. private _isDirty;
  80250. /** @hidden */
  80251. _renderId: number;
  80252. /** @hidden */
  80253. _areLightsDirty: boolean;
  80254. /** @hidden */
  80255. _areLightsDisposed: boolean;
  80256. /** @hidden */
  80257. _areAttributesDirty: boolean;
  80258. /** @hidden */
  80259. _areTexturesDirty: boolean;
  80260. /** @hidden */
  80261. _areFresnelDirty: boolean;
  80262. /** @hidden */
  80263. _areMiscDirty: boolean;
  80264. /** @hidden */
  80265. _areImageProcessingDirty: boolean;
  80266. /** @hidden */
  80267. _normals: boolean;
  80268. /** @hidden */
  80269. _uvs: boolean;
  80270. /** @hidden */
  80271. _needNormals: boolean;
  80272. /** @hidden */
  80273. _needUVs: boolean;
  80274. [id: string]: any;
  80275. /**
  80276. * Specifies if the material needs to be re-calculated
  80277. */
  80278. get isDirty(): boolean;
  80279. /**
  80280. * Marks the material to indicate that it has been re-calculated
  80281. */
  80282. markAsProcessed(): void;
  80283. /**
  80284. * Marks the material to indicate that it needs to be re-calculated
  80285. */
  80286. markAsUnprocessed(): void;
  80287. /**
  80288. * Marks the material to indicate all of its defines need to be re-calculated
  80289. */
  80290. markAllAsDirty(): void;
  80291. /**
  80292. * Marks the material to indicate that image processing needs to be re-calculated
  80293. */
  80294. markAsImageProcessingDirty(): void;
  80295. /**
  80296. * Marks the material to indicate the lights need to be re-calculated
  80297. * @param disposed Defines whether the light is dirty due to dispose or not
  80298. */
  80299. markAsLightDirty(disposed?: boolean): void;
  80300. /**
  80301. * Marks the attribute state as changed
  80302. */
  80303. markAsAttributesDirty(): void;
  80304. /**
  80305. * Marks the texture state as changed
  80306. */
  80307. markAsTexturesDirty(): void;
  80308. /**
  80309. * Marks the fresnel state as changed
  80310. */
  80311. markAsFresnelDirty(): void;
  80312. /**
  80313. * Marks the misc state as changed
  80314. */
  80315. markAsMiscDirty(): void;
  80316. /**
  80317. * Rebuilds the material defines
  80318. */
  80319. rebuild(): void;
  80320. /**
  80321. * Specifies if two material defines are equal
  80322. * @param other - A material define instance to compare to
  80323. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  80324. */
  80325. isEqual(other: MaterialDefines): boolean;
  80326. /**
  80327. * Clones this instance's defines to another instance
  80328. * @param other - material defines to clone values to
  80329. */
  80330. cloneTo(other: MaterialDefines): void;
  80331. /**
  80332. * Resets the material define values
  80333. */
  80334. reset(): void;
  80335. /**
  80336. * Converts the material define values to a string
  80337. * @returns - String of material define information
  80338. */
  80339. toString(): string;
  80340. }
  80341. }
  80342. declare module BABYLON {
  80343. /**
  80344. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  80345. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  80346. * 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;
  80347. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  80348. */
  80349. export class ColorCurves {
  80350. private _dirty;
  80351. private _tempColor;
  80352. private _globalCurve;
  80353. private _highlightsCurve;
  80354. private _midtonesCurve;
  80355. private _shadowsCurve;
  80356. private _positiveCurve;
  80357. private _negativeCurve;
  80358. private _globalHue;
  80359. private _globalDensity;
  80360. private _globalSaturation;
  80361. private _globalExposure;
  80362. /**
  80363. * Gets the global Hue value.
  80364. * 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).
  80365. */
  80366. get globalHue(): number;
  80367. /**
  80368. * Sets the global Hue value.
  80369. * 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).
  80370. */
  80371. set globalHue(value: number);
  80372. /**
  80373. * Gets the global Density value.
  80374. * 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.
  80375. * Values less than zero provide a filter of opposite hue.
  80376. */
  80377. get globalDensity(): number;
  80378. /**
  80379. * Sets the global Density value.
  80380. * 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.
  80381. * Values less than zero provide a filter of opposite hue.
  80382. */
  80383. set globalDensity(value: number);
  80384. /**
  80385. * Gets the global Saturation value.
  80386. * 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.
  80387. */
  80388. get globalSaturation(): number;
  80389. /**
  80390. * Sets the global Saturation value.
  80391. * 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.
  80392. */
  80393. set globalSaturation(value: number);
  80394. /**
  80395. * Gets the global Exposure value.
  80396. * 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.
  80397. */
  80398. get globalExposure(): number;
  80399. /**
  80400. * Sets the global Exposure value.
  80401. * 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.
  80402. */
  80403. set globalExposure(value: number);
  80404. private _highlightsHue;
  80405. private _highlightsDensity;
  80406. private _highlightsSaturation;
  80407. private _highlightsExposure;
  80408. /**
  80409. * Gets the highlights Hue value.
  80410. * 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).
  80411. */
  80412. get highlightsHue(): number;
  80413. /**
  80414. * Sets the highlights Hue value.
  80415. * 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).
  80416. */
  80417. set highlightsHue(value: number);
  80418. /**
  80419. * Gets the highlights Density value.
  80420. * 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.
  80421. * Values less than zero provide a filter of opposite hue.
  80422. */
  80423. get highlightsDensity(): number;
  80424. /**
  80425. * Sets the highlights Density value.
  80426. * 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.
  80427. * Values less than zero provide a filter of opposite hue.
  80428. */
  80429. set highlightsDensity(value: number);
  80430. /**
  80431. * Gets the highlights Saturation value.
  80432. * 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.
  80433. */
  80434. get highlightsSaturation(): number;
  80435. /**
  80436. * Sets the highlights Saturation value.
  80437. * 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.
  80438. */
  80439. set highlightsSaturation(value: number);
  80440. /**
  80441. * Gets the highlights Exposure value.
  80442. * 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.
  80443. */
  80444. get highlightsExposure(): number;
  80445. /**
  80446. * Sets the highlights Exposure value.
  80447. * 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.
  80448. */
  80449. set highlightsExposure(value: number);
  80450. private _midtonesHue;
  80451. private _midtonesDensity;
  80452. private _midtonesSaturation;
  80453. private _midtonesExposure;
  80454. /**
  80455. * Gets the midtones Hue value.
  80456. * 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).
  80457. */
  80458. get midtonesHue(): number;
  80459. /**
  80460. * Sets the midtones Hue value.
  80461. * 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).
  80462. */
  80463. set midtonesHue(value: number);
  80464. /**
  80465. * Gets the midtones Density value.
  80466. * 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.
  80467. * Values less than zero provide a filter of opposite hue.
  80468. */
  80469. get midtonesDensity(): number;
  80470. /**
  80471. * Sets the midtones Density value.
  80472. * 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.
  80473. * Values less than zero provide a filter of opposite hue.
  80474. */
  80475. set midtonesDensity(value: number);
  80476. /**
  80477. * Gets the midtones Saturation value.
  80478. * 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.
  80479. */
  80480. get midtonesSaturation(): number;
  80481. /**
  80482. * Sets the midtones Saturation value.
  80483. * 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.
  80484. */
  80485. set midtonesSaturation(value: number);
  80486. /**
  80487. * Gets the midtones Exposure value.
  80488. * 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.
  80489. */
  80490. get midtonesExposure(): number;
  80491. /**
  80492. * Sets the midtones Exposure value.
  80493. * 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.
  80494. */
  80495. set midtonesExposure(value: number);
  80496. private _shadowsHue;
  80497. private _shadowsDensity;
  80498. private _shadowsSaturation;
  80499. private _shadowsExposure;
  80500. /**
  80501. * Gets the shadows Hue value.
  80502. * 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).
  80503. */
  80504. get shadowsHue(): number;
  80505. /**
  80506. * Sets the shadows Hue value.
  80507. * 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).
  80508. */
  80509. set shadowsHue(value: number);
  80510. /**
  80511. * Gets the shadows Density value.
  80512. * 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.
  80513. * Values less than zero provide a filter of opposite hue.
  80514. */
  80515. get shadowsDensity(): number;
  80516. /**
  80517. * Sets the shadows Density value.
  80518. * 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.
  80519. * Values less than zero provide a filter of opposite hue.
  80520. */
  80521. set shadowsDensity(value: number);
  80522. /**
  80523. * Gets the shadows Saturation value.
  80524. * 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.
  80525. */
  80526. get shadowsSaturation(): number;
  80527. /**
  80528. * Sets the shadows Saturation value.
  80529. * 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.
  80530. */
  80531. set shadowsSaturation(value: number);
  80532. /**
  80533. * Gets the shadows Exposure value.
  80534. * 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.
  80535. */
  80536. get shadowsExposure(): number;
  80537. /**
  80538. * Sets the shadows Exposure value.
  80539. * 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.
  80540. */
  80541. set shadowsExposure(value: number);
  80542. /**
  80543. * Returns the class name
  80544. * @returns The class name
  80545. */
  80546. getClassName(): string;
  80547. /**
  80548. * Binds the color curves to the shader.
  80549. * @param colorCurves The color curve to bind
  80550. * @param effect The effect to bind to
  80551. * @param positiveUniform The positive uniform shader parameter
  80552. * @param neutralUniform The neutral uniform shader parameter
  80553. * @param negativeUniform The negative uniform shader parameter
  80554. */
  80555. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  80556. /**
  80557. * Prepare the list of uniforms associated with the ColorCurves effects.
  80558. * @param uniformsList The list of uniforms used in the effect
  80559. */
  80560. static PrepareUniforms(uniformsList: string[]): void;
  80561. /**
  80562. * Returns color grading data based on a hue, density, saturation and exposure value.
  80563. * @param filterHue The hue of the color filter.
  80564. * @param filterDensity The density of the color filter.
  80565. * @param saturation The saturation.
  80566. * @param exposure The exposure.
  80567. * @param result The result data container.
  80568. */
  80569. private getColorGradingDataToRef;
  80570. /**
  80571. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  80572. * @param value The input slider value in range [-100,100].
  80573. * @returns Adjusted value.
  80574. */
  80575. private static applyColorGradingSliderNonlinear;
  80576. /**
  80577. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  80578. * @param hue The hue (H) input.
  80579. * @param saturation The saturation (S) input.
  80580. * @param brightness The brightness (B) input.
  80581. * @result An RGBA color represented as Vector4.
  80582. */
  80583. private static fromHSBToRef;
  80584. /**
  80585. * Returns a value clamped between min and max
  80586. * @param value The value to clamp
  80587. * @param min The minimum of value
  80588. * @param max The maximum of value
  80589. * @returns The clamped value.
  80590. */
  80591. private static clamp;
  80592. /**
  80593. * Clones the current color curve instance.
  80594. * @return The cloned curves
  80595. */
  80596. clone(): ColorCurves;
  80597. /**
  80598. * Serializes the current color curve instance to a json representation.
  80599. * @return a JSON representation
  80600. */
  80601. serialize(): any;
  80602. /**
  80603. * Parses the color curve from a json representation.
  80604. * @param source the JSON source to parse
  80605. * @return The parsed curves
  80606. */
  80607. static Parse(source: any): ColorCurves;
  80608. }
  80609. }
  80610. declare module BABYLON {
  80611. /**
  80612. * Interface to follow in your material defines to integrate easily the
  80613. * Image proccessing functions.
  80614. * @hidden
  80615. */
  80616. export interface IImageProcessingConfigurationDefines {
  80617. IMAGEPROCESSING: boolean;
  80618. VIGNETTE: boolean;
  80619. VIGNETTEBLENDMODEMULTIPLY: boolean;
  80620. VIGNETTEBLENDMODEOPAQUE: boolean;
  80621. TONEMAPPING: boolean;
  80622. TONEMAPPING_ACES: boolean;
  80623. CONTRAST: boolean;
  80624. EXPOSURE: boolean;
  80625. COLORCURVES: boolean;
  80626. COLORGRADING: boolean;
  80627. COLORGRADING3D: boolean;
  80628. SAMPLER3DGREENDEPTH: boolean;
  80629. SAMPLER3DBGRMAP: boolean;
  80630. IMAGEPROCESSINGPOSTPROCESS: boolean;
  80631. }
  80632. /**
  80633. * @hidden
  80634. */
  80635. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  80636. IMAGEPROCESSING: boolean;
  80637. VIGNETTE: boolean;
  80638. VIGNETTEBLENDMODEMULTIPLY: boolean;
  80639. VIGNETTEBLENDMODEOPAQUE: boolean;
  80640. TONEMAPPING: boolean;
  80641. TONEMAPPING_ACES: boolean;
  80642. CONTRAST: boolean;
  80643. COLORCURVES: boolean;
  80644. COLORGRADING: boolean;
  80645. COLORGRADING3D: boolean;
  80646. SAMPLER3DGREENDEPTH: boolean;
  80647. SAMPLER3DBGRMAP: boolean;
  80648. IMAGEPROCESSINGPOSTPROCESS: boolean;
  80649. EXPOSURE: boolean;
  80650. constructor();
  80651. }
  80652. /**
  80653. * This groups together the common properties used for image processing either in direct forward pass
  80654. * or through post processing effect depending on the use of the image processing pipeline in your scene
  80655. * or not.
  80656. */
  80657. export class ImageProcessingConfiguration {
  80658. /**
  80659. * Default tone mapping applied in BabylonJS.
  80660. */
  80661. static readonly TONEMAPPING_STANDARD: number;
  80662. /**
  80663. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  80664. * to other engines rendering to increase portability.
  80665. */
  80666. static readonly TONEMAPPING_ACES: number;
  80667. /**
  80668. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  80669. */
  80670. colorCurves: Nullable<ColorCurves>;
  80671. private _colorCurvesEnabled;
  80672. /**
  80673. * Gets wether the color curves effect is enabled.
  80674. */
  80675. get colorCurvesEnabled(): boolean;
  80676. /**
  80677. * Sets wether the color curves effect is enabled.
  80678. */
  80679. set colorCurvesEnabled(value: boolean);
  80680. private _colorGradingTexture;
  80681. /**
  80682. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  80683. */
  80684. get colorGradingTexture(): Nullable<BaseTexture>;
  80685. /**
  80686. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  80687. */
  80688. set colorGradingTexture(value: Nullable<BaseTexture>);
  80689. private _colorGradingEnabled;
  80690. /**
  80691. * Gets wether the color grading effect is enabled.
  80692. */
  80693. get colorGradingEnabled(): boolean;
  80694. /**
  80695. * Sets wether the color grading effect is enabled.
  80696. */
  80697. set colorGradingEnabled(value: boolean);
  80698. private _colorGradingWithGreenDepth;
  80699. /**
  80700. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  80701. */
  80702. get colorGradingWithGreenDepth(): boolean;
  80703. /**
  80704. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  80705. */
  80706. set colorGradingWithGreenDepth(value: boolean);
  80707. private _colorGradingBGR;
  80708. /**
  80709. * Gets wether the color grading texture contains BGR values.
  80710. */
  80711. get colorGradingBGR(): boolean;
  80712. /**
  80713. * Sets wether the color grading texture contains BGR values.
  80714. */
  80715. set colorGradingBGR(value: boolean);
  80716. /** @hidden */
  80717. _exposure: number;
  80718. /**
  80719. * Gets the Exposure used in the effect.
  80720. */
  80721. get exposure(): number;
  80722. /**
  80723. * Sets the Exposure used in the effect.
  80724. */
  80725. set exposure(value: number);
  80726. private _toneMappingEnabled;
  80727. /**
  80728. * Gets wether the tone mapping effect is enabled.
  80729. */
  80730. get toneMappingEnabled(): boolean;
  80731. /**
  80732. * Sets wether the tone mapping effect is enabled.
  80733. */
  80734. set toneMappingEnabled(value: boolean);
  80735. private _toneMappingType;
  80736. /**
  80737. * Gets the type of tone mapping effect.
  80738. */
  80739. get toneMappingType(): number;
  80740. /**
  80741. * Sets the type of tone mapping effect used in BabylonJS.
  80742. */
  80743. set toneMappingType(value: number);
  80744. protected _contrast: number;
  80745. /**
  80746. * Gets the contrast used in the effect.
  80747. */
  80748. get contrast(): number;
  80749. /**
  80750. * Sets the contrast used in the effect.
  80751. */
  80752. set contrast(value: number);
  80753. /**
  80754. * Vignette stretch size.
  80755. */
  80756. vignetteStretch: number;
  80757. /**
  80758. * Vignette centre X Offset.
  80759. */
  80760. vignetteCentreX: number;
  80761. /**
  80762. * Vignette centre Y Offset.
  80763. */
  80764. vignetteCentreY: number;
  80765. /**
  80766. * Vignette weight or intensity of the vignette effect.
  80767. */
  80768. vignetteWeight: number;
  80769. /**
  80770. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  80771. * if vignetteEnabled is set to true.
  80772. */
  80773. vignetteColor: Color4;
  80774. /**
  80775. * Camera field of view used by the Vignette effect.
  80776. */
  80777. vignetteCameraFov: number;
  80778. private _vignetteBlendMode;
  80779. /**
  80780. * Gets the vignette blend mode allowing different kind of effect.
  80781. */
  80782. get vignetteBlendMode(): number;
  80783. /**
  80784. * Sets the vignette blend mode allowing different kind of effect.
  80785. */
  80786. set vignetteBlendMode(value: number);
  80787. private _vignetteEnabled;
  80788. /**
  80789. * Gets wether the vignette effect is enabled.
  80790. */
  80791. get vignetteEnabled(): boolean;
  80792. /**
  80793. * Sets wether the vignette effect is enabled.
  80794. */
  80795. set vignetteEnabled(value: boolean);
  80796. private _applyByPostProcess;
  80797. /**
  80798. * Gets wether the image processing is applied through a post process or not.
  80799. */
  80800. get applyByPostProcess(): boolean;
  80801. /**
  80802. * Sets wether the image processing is applied through a post process or not.
  80803. */
  80804. set applyByPostProcess(value: boolean);
  80805. private _isEnabled;
  80806. /**
  80807. * Gets wether the image processing is enabled or not.
  80808. */
  80809. get isEnabled(): boolean;
  80810. /**
  80811. * Sets wether the image processing is enabled or not.
  80812. */
  80813. set isEnabled(value: boolean);
  80814. /**
  80815. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  80816. */
  80817. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  80818. /**
  80819. * Method called each time the image processing information changes requires to recompile the effect.
  80820. */
  80821. protected _updateParameters(): void;
  80822. /**
  80823. * Gets the current class name.
  80824. * @return "ImageProcessingConfiguration"
  80825. */
  80826. getClassName(): string;
  80827. /**
  80828. * Prepare the list of uniforms associated with the Image Processing effects.
  80829. * @param uniforms The list of uniforms used in the effect
  80830. * @param defines the list of defines currently in use
  80831. */
  80832. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  80833. /**
  80834. * Prepare the list of samplers associated with the Image Processing effects.
  80835. * @param samplersList The list of uniforms used in the effect
  80836. * @param defines the list of defines currently in use
  80837. */
  80838. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  80839. /**
  80840. * Prepare the list of defines associated to the shader.
  80841. * @param defines the list of defines to complete
  80842. * @param forPostProcess Define if we are currently in post process mode or not
  80843. */
  80844. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  80845. /**
  80846. * Returns true if all the image processing information are ready.
  80847. * @returns True if ready, otherwise, false
  80848. */
  80849. isReady(): boolean;
  80850. /**
  80851. * Binds the image processing to the shader.
  80852. * @param effect The effect to bind to
  80853. * @param overrideAspectRatio Override the aspect ratio of the effect
  80854. */
  80855. bind(effect: Effect, overrideAspectRatio?: number): void;
  80856. /**
  80857. * Clones the current image processing instance.
  80858. * @return The cloned image processing
  80859. */
  80860. clone(): ImageProcessingConfiguration;
  80861. /**
  80862. * Serializes the current image processing instance to a json representation.
  80863. * @return a JSON representation
  80864. */
  80865. serialize(): any;
  80866. /**
  80867. * Parses the image processing from a json representation.
  80868. * @param source the JSON source to parse
  80869. * @return The parsed image processing
  80870. */
  80871. static Parse(source: any): ImageProcessingConfiguration;
  80872. private static _VIGNETTEMODE_MULTIPLY;
  80873. private static _VIGNETTEMODE_OPAQUE;
  80874. /**
  80875. * Used to apply the vignette as a mix with the pixel color.
  80876. */
  80877. static get VIGNETTEMODE_MULTIPLY(): number;
  80878. /**
  80879. * Used to apply the vignette as a replacement of the pixel color.
  80880. */
  80881. static get VIGNETTEMODE_OPAQUE(): number;
  80882. }
  80883. }
  80884. declare module BABYLON {
  80885. /** @hidden */
  80886. export var postprocessVertexShader: {
  80887. name: string;
  80888. shader: string;
  80889. };
  80890. }
  80891. declare module BABYLON {
  80892. interface ThinEngine {
  80893. /**
  80894. * Creates a new render target texture
  80895. * @param size defines the size of the texture
  80896. * @param options defines the options used to create the texture
  80897. * @returns a new render target texture stored in an InternalTexture
  80898. */
  80899. createRenderTargetTexture(size: number | {
  80900. width: number;
  80901. height: number;
  80902. layers?: number;
  80903. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  80904. /**
  80905. * Creates a depth stencil texture.
  80906. * This is only available in WebGL 2 or with the depth texture extension available.
  80907. * @param size The size of face edge in the texture.
  80908. * @param options The options defining the texture.
  80909. * @returns The texture
  80910. */
  80911. createDepthStencilTexture(size: number | {
  80912. width: number;
  80913. height: number;
  80914. layers?: number;
  80915. }, options: DepthTextureCreationOptions): InternalTexture;
  80916. /** @hidden */
  80917. _createDepthStencilTexture(size: number | {
  80918. width: number;
  80919. height: number;
  80920. layers?: number;
  80921. }, options: DepthTextureCreationOptions): InternalTexture;
  80922. }
  80923. }
  80924. declare module BABYLON {
  80925. /** Defines supported spaces */
  80926. export enum Space {
  80927. /** Local (object) space */
  80928. LOCAL = 0,
  80929. /** World space */
  80930. WORLD = 1,
  80931. /** Bone space */
  80932. BONE = 2
  80933. }
  80934. /** Defines the 3 main axes */
  80935. export class Axis {
  80936. /** X axis */
  80937. static X: Vector3;
  80938. /** Y axis */
  80939. static Y: Vector3;
  80940. /** Z axis */
  80941. static Z: Vector3;
  80942. }
  80943. }
  80944. declare module BABYLON {
  80945. /**
  80946. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  80947. * This is the base of the follow, arc rotate cameras and Free camera
  80948. * @see http://doc.babylonjs.com/features/cameras
  80949. */
  80950. export class TargetCamera extends Camera {
  80951. private static _RigCamTransformMatrix;
  80952. private static _TargetTransformMatrix;
  80953. private static _TargetFocalPoint;
  80954. /**
  80955. * Define the current direction the camera is moving to
  80956. */
  80957. cameraDirection: Vector3;
  80958. /**
  80959. * Define the current rotation the camera is rotating to
  80960. */
  80961. cameraRotation: Vector2;
  80962. /**
  80963. * When set, the up vector of the camera will be updated by the rotation of the camera
  80964. */
  80965. updateUpVectorFromRotation: boolean;
  80966. private _tmpQuaternion;
  80967. /**
  80968. * Define the current rotation of the camera
  80969. */
  80970. rotation: Vector3;
  80971. /**
  80972. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  80973. */
  80974. rotationQuaternion: Quaternion;
  80975. /**
  80976. * Define the current speed of the camera
  80977. */
  80978. speed: number;
  80979. /**
  80980. * Add constraint to the camera to prevent it to move freely in all directions and
  80981. * around all axis.
  80982. */
  80983. noRotationConstraint: boolean;
  80984. /**
  80985. * Define the current target of the camera as an object or a position.
  80986. */
  80987. lockedTarget: any;
  80988. /** @hidden */
  80989. _currentTarget: Vector3;
  80990. /** @hidden */
  80991. _initialFocalDistance: number;
  80992. /** @hidden */
  80993. _viewMatrix: Matrix;
  80994. /** @hidden */
  80995. _camMatrix: Matrix;
  80996. /** @hidden */
  80997. _cameraTransformMatrix: Matrix;
  80998. /** @hidden */
  80999. _cameraRotationMatrix: Matrix;
  81000. /** @hidden */
  81001. _referencePoint: Vector3;
  81002. /** @hidden */
  81003. _transformedReferencePoint: Vector3;
  81004. protected _globalCurrentTarget: Vector3;
  81005. protected _globalCurrentUpVector: Vector3;
  81006. /** @hidden */
  81007. _reset: () => void;
  81008. private _defaultUp;
  81009. /**
  81010. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81011. * This is the base of the follow, arc rotate cameras and Free camera
  81012. * @see http://doc.babylonjs.com/features/cameras
  81013. * @param name Defines the name of the camera in the scene
  81014. * @param position Defines the start position of the camera in the scene
  81015. * @param scene Defines the scene the camera belongs to
  81016. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81017. */
  81018. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81019. /**
  81020. * Gets the position in front of the camera at a given distance.
  81021. * @param distance The distance from the camera we want the position to be
  81022. * @returns the position
  81023. */
  81024. getFrontPosition(distance: number): Vector3;
  81025. /** @hidden */
  81026. _getLockedTargetPosition(): Nullable<Vector3>;
  81027. private _storedPosition;
  81028. private _storedRotation;
  81029. private _storedRotationQuaternion;
  81030. /**
  81031. * Store current camera state of the camera (fov, position, rotation, etc..)
  81032. * @returns the camera
  81033. */
  81034. storeState(): Camera;
  81035. /**
  81036. * Restored camera state. You must call storeState() first
  81037. * @returns whether it was successful or not
  81038. * @hidden
  81039. */
  81040. _restoreStateValues(): boolean;
  81041. /** @hidden */
  81042. _initCache(): void;
  81043. /** @hidden */
  81044. _updateCache(ignoreParentClass?: boolean): void;
  81045. /** @hidden */
  81046. _isSynchronizedViewMatrix(): boolean;
  81047. /** @hidden */
  81048. _computeLocalCameraSpeed(): number;
  81049. /**
  81050. * Defines the target the camera should look at.
  81051. * @param target Defines the new target as a Vector or a mesh
  81052. */
  81053. setTarget(target: Vector3): void;
  81054. /**
  81055. * Return the current target position of the camera. This value is expressed in local space.
  81056. * @returns the target position
  81057. */
  81058. getTarget(): Vector3;
  81059. /** @hidden */
  81060. _decideIfNeedsToMove(): boolean;
  81061. /** @hidden */
  81062. _updatePosition(): void;
  81063. /** @hidden */
  81064. _checkInputs(): void;
  81065. protected _updateCameraRotationMatrix(): void;
  81066. /**
  81067. * 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)
  81068. * @returns the current camera
  81069. */
  81070. private _rotateUpVectorWithCameraRotationMatrix;
  81071. private _cachedRotationZ;
  81072. private _cachedQuaternionRotationZ;
  81073. /** @hidden */
  81074. _getViewMatrix(): Matrix;
  81075. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81076. /**
  81077. * @hidden
  81078. */
  81079. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81080. /**
  81081. * @hidden
  81082. */
  81083. _updateRigCameras(): void;
  81084. private _getRigCamPositionAndTarget;
  81085. /**
  81086. * Gets the current object class name.
  81087. * @return the class name
  81088. */
  81089. getClassName(): string;
  81090. }
  81091. }
  81092. declare module BABYLON {
  81093. /**
  81094. * Gather the list of keyboard event types as constants.
  81095. */
  81096. export class KeyboardEventTypes {
  81097. /**
  81098. * The keydown event is fired when a key becomes active (pressed).
  81099. */
  81100. static readonly KEYDOWN: number;
  81101. /**
  81102. * The keyup event is fired when a key has been released.
  81103. */
  81104. static readonly KEYUP: number;
  81105. }
  81106. /**
  81107. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81108. */
  81109. export class KeyboardInfo {
  81110. /**
  81111. * Defines the type of event (KeyboardEventTypes)
  81112. */
  81113. type: number;
  81114. /**
  81115. * Defines the related dom event
  81116. */
  81117. event: KeyboardEvent;
  81118. /**
  81119. * Instantiates a new keyboard info.
  81120. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81121. * @param type Defines the type of event (KeyboardEventTypes)
  81122. * @param event Defines the related dom event
  81123. */
  81124. constructor(
  81125. /**
  81126. * Defines the type of event (KeyboardEventTypes)
  81127. */
  81128. type: number,
  81129. /**
  81130. * Defines the related dom event
  81131. */
  81132. event: KeyboardEvent);
  81133. }
  81134. /**
  81135. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81136. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81137. */
  81138. export class KeyboardInfoPre extends KeyboardInfo {
  81139. /**
  81140. * Defines the type of event (KeyboardEventTypes)
  81141. */
  81142. type: number;
  81143. /**
  81144. * Defines the related dom event
  81145. */
  81146. event: KeyboardEvent;
  81147. /**
  81148. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81149. */
  81150. skipOnPointerObservable: boolean;
  81151. /**
  81152. * Instantiates a new keyboard pre info.
  81153. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81154. * @param type Defines the type of event (KeyboardEventTypes)
  81155. * @param event Defines the related dom event
  81156. */
  81157. constructor(
  81158. /**
  81159. * Defines the type of event (KeyboardEventTypes)
  81160. */
  81161. type: number,
  81162. /**
  81163. * Defines the related dom event
  81164. */
  81165. event: KeyboardEvent);
  81166. }
  81167. }
  81168. declare module BABYLON {
  81169. /**
  81170. * Manage the keyboard inputs to control the movement of a free camera.
  81171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81172. */
  81173. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81174. /**
  81175. * Defines the camera the input is attached to.
  81176. */
  81177. camera: FreeCamera;
  81178. /**
  81179. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81180. */
  81181. keysUp: number[];
  81182. /**
  81183. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81184. */
  81185. keysDown: number[];
  81186. /**
  81187. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81188. */
  81189. keysLeft: number[];
  81190. /**
  81191. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81192. */
  81193. keysRight: number[];
  81194. private _keys;
  81195. private _onCanvasBlurObserver;
  81196. private _onKeyboardObserver;
  81197. private _engine;
  81198. private _scene;
  81199. /**
  81200. * Attach the input controls to a specific dom element to get the input from.
  81201. * @param element Defines the element the controls should be listened from
  81202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81203. */
  81204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81205. /**
  81206. * Detach the current controls from the specified dom element.
  81207. * @param element Defines the element to stop listening the inputs from
  81208. */
  81209. detachControl(element: Nullable<HTMLElement>): void;
  81210. /**
  81211. * Update the current camera state depending on the inputs that have been used this frame.
  81212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81213. */
  81214. checkInputs(): void;
  81215. /**
  81216. * Gets the class name of the current intput.
  81217. * @returns the class name
  81218. */
  81219. getClassName(): string;
  81220. /** @hidden */
  81221. _onLostFocus(): void;
  81222. /**
  81223. * Get the friendly name associated with the input class.
  81224. * @returns the input friendly name
  81225. */
  81226. getSimpleName(): string;
  81227. }
  81228. }
  81229. declare module BABYLON {
  81230. /**
  81231. * Interface describing all the common properties and methods a shadow light needs to implement.
  81232. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  81233. * as well as binding the different shadow properties to the effects.
  81234. */
  81235. export interface IShadowLight extends Light {
  81236. /**
  81237. * The light id in the scene (used in scene.findLighById for instance)
  81238. */
  81239. id: string;
  81240. /**
  81241. * The position the shdow will be casted from.
  81242. */
  81243. position: Vector3;
  81244. /**
  81245. * In 2d mode (needCube being false), the direction used to cast the shadow.
  81246. */
  81247. direction: Vector3;
  81248. /**
  81249. * The transformed position. Position of the light in world space taking parenting in account.
  81250. */
  81251. transformedPosition: Vector3;
  81252. /**
  81253. * The transformed direction. Direction of the light in world space taking parenting in account.
  81254. */
  81255. transformedDirection: Vector3;
  81256. /**
  81257. * The friendly name of the light in the scene.
  81258. */
  81259. name: string;
  81260. /**
  81261. * Defines the shadow projection clipping minimum z value.
  81262. */
  81263. shadowMinZ: number;
  81264. /**
  81265. * Defines the shadow projection clipping maximum z value.
  81266. */
  81267. shadowMaxZ: number;
  81268. /**
  81269. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81270. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81271. */
  81272. computeTransformedInformation(): boolean;
  81273. /**
  81274. * Gets the scene the light belongs to.
  81275. * @returns The scene
  81276. */
  81277. getScene(): Scene;
  81278. /**
  81279. * Callback defining a custom Projection Matrix Builder.
  81280. * This can be used to override the default projection matrix computation.
  81281. */
  81282. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81283. /**
  81284. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81285. * @param matrix The materix to updated with the projection information
  81286. * @param viewMatrix The transform matrix of the light
  81287. * @param renderList The list of mesh to render in the map
  81288. * @returns The current light
  81289. */
  81290. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81291. /**
  81292. * Gets the current depth scale used in ESM.
  81293. * @returns The scale
  81294. */
  81295. getDepthScale(): number;
  81296. /**
  81297. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81298. * @returns true if a cube texture needs to be use
  81299. */
  81300. needCube(): boolean;
  81301. /**
  81302. * Detects if the projection matrix requires to be recomputed this frame.
  81303. * @returns true if it requires to be recomputed otherwise, false.
  81304. */
  81305. needProjectionMatrixCompute(): boolean;
  81306. /**
  81307. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81308. */
  81309. forceProjectionMatrixCompute(): void;
  81310. /**
  81311. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81312. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81313. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81314. */
  81315. getShadowDirection(faceIndex?: number): Vector3;
  81316. /**
  81317. * Gets the minZ used for shadow according to both the scene and the light.
  81318. * @param activeCamera The camera we are returning the min for
  81319. * @returns the depth min z
  81320. */
  81321. getDepthMinZ(activeCamera: Camera): number;
  81322. /**
  81323. * Gets the maxZ used for shadow according to both the scene and the light.
  81324. * @param activeCamera The camera we are returning the max for
  81325. * @returns the depth max z
  81326. */
  81327. getDepthMaxZ(activeCamera: Camera): number;
  81328. }
  81329. /**
  81330. * Base implementation IShadowLight
  81331. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  81332. */
  81333. export abstract class ShadowLight extends Light implements IShadowLight {
  81334. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  81335. protected _position: Vector3;
  81336. protected _setPosition(value: Vector3): void;
  81337. /**
  81338. * Sets the position the shadow will be casted from. Also use as the light position for both
  81339. * point and spot lights.
  81340. */
  81341. get position(): Vector3;
  81342. /**
  81343. * Sets the position the shadow will be casted from. Also use as the light position for both
  81344. * point and spot lights.
  81345. */
  81346. set position(value: Vector3);
  81347. protected _direction: Vector3;
  81348. protected _setDirection(value: Vector3): void;
  81349. /**
  81350. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  81351. * Also use as the light direction on spot and directional lights.
  81352. */
  81353. get direction(): Vector3;
  81354. /**
  81355. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  81356. * Also use as the light direction on spot and directional lights.
  81357. */
  81358. set direction(value: Vector3);
  81359. protected _shadowMinZ: number;
  81360. /**
  81361. * Gets the shadow projection clipping minimum z value.
  81362. */
  81363. get shadowMinZ(): number;
  81364. /**
  81365. * Sets the shadow projection clipping minimum z value.
  81366. */
  81367. set shadowMinZ(value: number);
  81368. protected _shadowMaxZ: number;
  81369. /**
  81370. * Sets the shadow projection clipping maximum z value.
  81371. */
  81372. get shadowMaxZ(): number;
  81373. /**
  81374. * Gets the shadow projection clipping maximum z value.
  81375. */
  81376. set shadowMaxZ(value: number);
  81377. /**
  81378. * Callback defining a custom Projection Matrix Builder.
  81379. * This can be used to override the default projection matrix computation.
  81380. */
  81381. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81382. /**
  81383. * The transformed position. Position of the light in world space taking parenting in account.
  81384. */
  81385. transformedPosition: Vector3;
  81386. /**
  81387. * The transformed direction. Direction of the light in world space taking parenting in account.
  81388. */
  81389. transformedDirection: Vector3;
  81390. private _needProjectionMatrixCompute;
  81391. /**
  81392. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81393. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81394. */
  81395. computeTransformedInformation(): boolean;
  81396. /**
  81397. * Return the depth scale used for the shadow map.
  81398. * @returns the depth scale.
  81399. */
  81400. getDepthScale(): number;
  81401. /**
  81402. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81403. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81404. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81405. */
  81406. getShadowDirection(faceIndex?: number): Vector3;
  81407. /**
  81408. * Returns the ShadowLight absolute position in the World.
  81409. * @returns the position vector in world space
  81410. */
  81411. getAbsolutePosition(): Vector3;
  81412. /**
  81413. * Sets the ShadowLight direction toward the passed target.
  81414. * @param target The point to target in local space
  81415. * @returns the updated ShadowLight direction
  81416. */
  81417. setDirectionToTarget(target: Vector3): Vector3;
  81418. /**
  81419. * Returns the light rotation in euler definition.
  81420. * @returns the x y z rotation in local space.
  81421. */
  81422. getRotation(): Vector3;
  81423. /**
  81424. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81425. * @returns true if a cube texture needs to be use
  81426. */
  81427. needCube(): boolean;
  81428. /**
  81429. * Detects if the projection matrix requires to be recomputed this frame.
  81430. * @returns true if it requires to be recomputed otherwise, false.
  81431. */
  81432. needProjectionMatrixCompute(): boolean;
  81433. /**
  81434. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81435. */
  81436. forceProjectionMatrixCompute(): void;
  81437. /** @hidden */
  81438. _initCache(): void;
  81439. /** @hidden */
  81440. _isSynchronized(): boolean;
  81441. /**
  81442. * Computes the world matrix of the node
  81443. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81444. * @returns the world matrix
  81445. */
  81446. computeWorldMatrix(force?: boolean): Matrix;
  81447. /**
  81448. * Gets the minZ used for shadow according to both the scene and the light.
  81449. * @param activeCamera The camera we are returning the min for
  81450. * @returns the depth min z
  81451. */
  81452. getDepthMinZ(activeCamera: Camera): number;
  81453. /**
  81454. * Gets the maxZ used for shadow according to both the scene and the light.
  81455. * @param activeCamera The camera we are returning the max for
  81456. * @returns the depth max z
  81457. */
  81458. getDepthMaxZ(activeCamera: Camera): number;
  81459. /**
  81460. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81461. * @param matrix The materix to updated with the projection information
  81462. * @param viewMatrix The transform matrix of the light
  81463. * @param renderList The list of mesh to render in the map
  81464. * @returns The current light
  81465. */
  81466. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81467. }
  81468. }
  81469. declare module BABYLON {
  81470. /**
  81471. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  81472. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  81473. */
  81474. export class EffectFallbacks implements IEffectFallbacks {
  81475. private _defines;
  81476. private _currentRank;
  81477. private _maxRank;
  81478. private _mesh;
  81479. /**
  81480. * Removes the fallback from the bound mesh.
  81481. */
  81482. unBindMesh(): void;
  81483. /**
  81484. * Adds a fallback on the specified property.
  81485. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81486. * @param define The name of the define in the shader
  81487. */
  81488. addFallback(rank: number, define: string): void;
  81489. /**
  81490. * Sets the mesh to use CPU skinning when needing to fallback.
  81491. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81492. * @param mesh The mesh to use the fallbacks.
  81493. */
  81494. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  81495. /**
  81496. * Checks to see if more fallbacks are still availible.
  81497. */
  81498. get hasMoreFallbacks(): boolean;
  81499. /**
  81500. * Removes the defines that should be removed when falling back.
  81501. * @param currentDefines defines the current define statements for the shader.
  81502. * @param effect defines the current effect we try to compile
  81503. * @returns The resulting defines with defines of the current rank removed.
  81504. */
  81505. reduce(currentDefines: string, effect: Effect): string;
  81506. }
  81507. }
  81508. declare module BABYLON {
  81509. /**
  81510. * "Static Class" containing the most commonly used helper while dealing with material for
  81511. * rendering purpose.
  81512. *
  81513. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  81514. *
  81515. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  81516. */
  81517. export class MaterialHelper {
  81518. /**
  81519. * Bind the current view position to an effect.
  81520. * @param effect The effect to be bound
  81521. * @param scene The scene the eyes position is used from
  81522. */
  81523. static BindEyePosition(effect: Effect, scene: Scene): void;
  81524. /**
  81525. * Helps preparing the defines values about the UVs in used in the effect.
  81526. * UVs are shared as much as we can accross channels in the shaders.
  81527. * @param texture The texture we are preparing the UVs for
  81528. * @param defines The defines to update
  81529. * @param key The channel key "diffuse", "specular"... used in the shader
  81530. */
  81531. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  81532. /**
  81533. * Binds a texture matrix value to its corrsponding uniform
  81534. * @param texture The texture to bind the matrix for
  81535. * @param uniformBuffer The uniform buffer receivin the data
  81536. * @param key The channel key "diffuse", "specular"... used in the shader
  81537. */
  81538. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  81539. /**
  81540. * Gets the current status of the fog (should it be enabled?)
  81541. * @param mesh defines the mesh to evaluate for fog support
  81542. * @param scene defines the hosting scene
  81543. * @returns true if fog must be enabled
  81544. */
  81545. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  81546. /**
  81547. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  81548. * @param mesh defines the current mesh
  81549. * @param scene defines the current scene
  81550. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  81551. * @param pointsCloud defines if point cloud rendering has to be turned on
  81552. * @param fogEnabled defines if fog has to be turned on
  81553. * @param alphaTest defines if alpha testing has to be turned on
  81554. * @param defines defines the current list of defines
  81555. */
  81556. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  81557. /**
  81558. * Helper used to prepare the list of defines associated with frame values for shader compilation
  81559. * @param scene defines the current scene
  81560. * @param engine defines the current engine
  81561. * @param defines specifies the list of active defines
  81562. * @param useInstances defines if instances have to be turned on
  81563. * @param useClipPlane defines if clip plane have to be turned on
  81564. */
  81565. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  81566. /**
  81567. * Prepares the defines for bones
  81568. * @param mesh The mesh containing the geometry data we will draw
  81569. * @param defines The defines to update
  81570. */
  81571. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  81572. /**
  81573. * Prepares the defines for morph targets
  81574. * @param mesh The mesh containing the geometry data we will draw
  81575. * @param defines The defines to update
  81576. */
  81577. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  81578. /**
  81579. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  81580. * @param mesh The mesh containing the geometry data we will draw
  81581. * @param defines The defines to update
  81582. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  81583. * @param useBones Precise whether bones should be used or not (override mesh info)
  81584. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  81585. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  81586. * @returns false if defines are considered not dirty and have not been checked
  81587. */
  81588. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  81589. /**
  81590. * Prepares the defines related to multiview
  81591. * @param scene The scene we are intending to draw
  81592. * @param defines The defines to update
  81593. */
  81594. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  81595. /**
  81596. * Prepares the defines related to the light information passed in parameter
  81597. * @param scene The scene we are intending to draw
  81598. * @param mesh The mesh the effect is compiling for
  81599. * @param light The light the effect is compiling for
  81600. * @param lightIndex The index of the light
  81601. * @param defines The defines to update
  81602. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  81603. * @param state Defines the current state regarding what is needed (normals, etc...)
  81604. */
  81605. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  81606. needNormals: boolean;
  81607. needRebuild: boolean;
  81608. shadowEnabled: boolean;
  81609. specularEnabled: boolean;
  81610. lightmapMode: boolean;
  81611. }): void;
  81612. /**
  81613. * Prepares the defines related to the light information passed in parameter
  81614. * @param scene The scene we are intending to draw
  81615. * @param mesh The mesh the effect is compiling for
  81616. * @param defines The defines to update
  81617. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  81618. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  81619. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  81620. * @returns true if normals will be required for the rest of the effect
  81621. */
  81622. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  81623. /**
  81624. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  81625. * @param lightIndex defines the light index
  81626. * @param uniformsList The uniform list
  81627. * @param samplersList The sampler list
  81628. * @param projectedLightTexture defines if projected texture must be used
  81629. * @param uniformBuffersList defines an optional list of uniform buffers
  81630. */
  81631. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  81632. /**
  81633. * Prepares the uniforms and samplers list to be used in the effect
  81634. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  81635. * @param samplersList The sampler list
  81636. * @param defines The defines helping in the list generation
  81637. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  81638. */
  81639. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  81640. /**
  81641. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  81642. * @param defines The defines to update while falling back
  81643. * @param fallbacks The authorized effect fallbacks
  81644. * @param maxSimultaneousLights The maximum number of lights allowed
  81645. * @param rank the current rank of the Effect
  81646. * @returns The newly affected rank
  81647. */
  81648. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  81649. private static _TmpMorphInfluencers;
  81650. /**
  81651. * Prepares the list of attributes required for morph targets according to the effect defines.
  81652. * @param attribs The current list of supported attribs
  81653. * @param mesh The mesh to prepare the morph targets attributes for
  81654. * @param influencers The number of influencers
  81655. */
  81656. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  81657. /**
  81658. * Prepares the list of attributes required for morph targets according to the effect defines.
  81659. * @param attribs The current list of supported attribs
  81660. * @param mesh The mesh to prepare the morph targets attributes for
  81661. * @param defines The current Defines of the effect
  81662. */
  81663. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  81664. /**
  81665. * Prepares the list of attributes required for bones according to the effect defines.
  81666. * @param attribs The current list of supported attribs
  81667. * @param mesh The mesh to prepare the bones attributes for
  81668. * @param defines The current Defines of the effect
  81669. * @param fallbacks The current efffect fallback strategy
  81670. */
  81671. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  81672. /**
  81673. * Check and prepare the list of attributes required for instances according to the effect defines.
  81674. * @param attribs The current list of supported attribs
  81675. * @param defines The current MaterialDefines of the effect
  81676. */
  81677. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  81678. /**
  81679. * Add the list of attributes required for instances to the attribs array.
  81680. * @param attribs The current list of supported attribs
  81681. */
  81682. static PushAttributesForInstances(attribs: string[]): void;
  81683. /**
  81684. * Binds the light information to the effect.
  81685. * @param light The light containing the generator
  81686. * @param effect The effect we are binding the data to
  81687. * @param lightIndex The light index in the effect used to render
  81688. */
  81689. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  81690. /**
  81691. * Binds the lights information from the scene to the effect for the given mesh.
  81692. * @param light Light to bind
  81693. * @param lightIndex Light index
  81694. * @param scene The scene where the light belongs to
  81695. * @param effect The effect we are binding the data to
  81696. * @param useSpecular Defines if specular is supported
  81697. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81698. */
  81699. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  81700. /**
  81701. * Binds the lights information from the scene to the effect for the given mesh.
  81702. * @param scene The scene the lights belongs to
  81703. * @param mesh The mesh we are binding the information to render
  81704. * @param effect The effect we are binding the data to
  81705. * @param defines The generated defines for the effect
  81706. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  81707. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81708. */
  81709. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  81710. private static _tempFogColor;
  81711. /**
  81712. * Binds the fog information from the scene to the effect for the given mesh.
  81713. * @param scene The scene the lights belongs to
  81714. * @param mesh The mesh we are binding the information to render
  81715. * @param effect The effect we are binding the data to
  81716. * @param linearSpace Defines if the fog effect is applied in linear space
  81717. */
  81718. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  81719. /**
  81720. * Binds the bones information from the mesh to the effect.
  81721. * @param mesh The mesh we are binding the information to render
  81722. * @param effect The effect we are binding the data to
  81723. */
  81724. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  81725. /**
  81726. * Binds the morph targets information from the mesh to the effect.
  81727. * @param abstractMesh The mesh we are binding the information to render
  81728. * @param effect The effect we are binding the data to
  81729. */
  81730. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  81731. /**
  81732. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  81733. * @param defines The generated defines used in the effect
  81734. * @param effect The effect we are binding the data to
  81735. * @param scene The scene we are willing to render with logarithmic scale for
  81736. */
  81737. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  81738. /**
  81739. * Binds the clip plane information from the scene to the effect.
  81740. * @param scene The scene the clip plane information are extracted from
  81741. * @param effect The effect we are binding the data to
  81742. */
  81743. static BindClipPlane(effect: Effect, scene: Scene): void;
  81744. }
  81745. }
  81746. declare module BABYLON {
  81747. /** @hidden */
  81748. export var packingFunctions: {
  81749. name: string;
  81750. shader: string;
  81751. };
  81752. }
  81753. declare module BABYLON {
  81754. /** @hidden */
  81755. export var shadowMapPixelShader: {
  81756. name: string;
  81757. shader: string;
  81758. };
  81759. }
  81760. declare module BABYLON {
  81761. /** @hidden */
  81762. export var bonesDeclaration: {
  81763. name: string;
  81764. shader: string;
  81765. };
  81766. }
  81767. declare module BABYLON {
  81768. /** @hidden */
  81769. export var morphTargetsVertexGlobalDeclaration: {
  81770. name: string;
  81771. shader: string;
  81772. };
  81773. }
  81774. declare module BABYLON {
  81775. /** @hidden */
  81776. export var morphTargetsVertexDeclaration: {
  81777. name: string;
  81778. shader: string;
  81779. };
  81780. }
  81781. declare module BABYLON {
  81782. /** @hidden */
  81783. export var instancesDeclaration: {
  81784. name: string;
  81785. shader: string;
  81786. };
  81787. }
  81788. declare module BABYLON {
  81789. /** @hidden */
  81790. export var helperFunctions: {
  81791. name: string;
  81792. shader: string;
  81793. };
  81794. }
  81795. declare module BABYLON {
  81796. /** @hidden */
  81797. export var morphTargetsVertex: {
  81798. name: string;
  81799. shader: string;
  81800. };
  81801. }
  81802. declare module BABYLON {
  81803. /** @hidden */
  81804. export var instancesVertex: {
  81805. name: string;
  81806. shader: string;
  81807. };
  81808. }
  81809. declare module BABYLON {
  81810. /** @hidden */
  81811. export var bonesVertex: {
  81812. name: string;
  81813. shader: string;
  81814. };
  81815. }
  81816. declare module BABYLON {
  81817. /** @hidden */
  81818. export var shadowMapVertexShader: {
  81819. name: string;
  81820. shader: string;
  81821. };
  81822. }
  81823. declare module BABYLON {
  81824. /** @hidden */
  81825. export var depthBoxBlurPixelShader: {
  81826. name: string;
  81827. shader: string;
  81828. };
  81829. }
  81830. declare module BABYLON {
  81831. /**
  81832. * Defines the options associated with the creation of a custom shader for a shadow generator.
  81833. */
  81834. export interface ICustomShaderOptions {
  81835. /**
  81836. * Gets or sets the custom shader name to use
  81837. */
  81838. shaderName: string;
  81839. /**
  81840. * The list of attribute names used in the shader
  81841. */
  81842. attributes?: string[];
  81843. /**
  81844. * The list of unifrom names used in the shader
  81845. */
  81846. uniforms?: string[];
  81847. /**
  81848. * The list of sampler names used in the shader
  81849. */
  81850. samplers?: string[];
  81851. /**
  81852. * The list of defines used in the shader
  81853. */
  81854. defines?: string[];
  81855. }
  81856. /**
  81857. * Interface to implement to create a shadow generator compatible with BJS.
  81858. */
  81859. export interface IShadowGenerator {
  81860. /**
  81861. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  81862. * @returns The render target texture if present otherwise, null
  81863. */
  81864. getShadowMap(): Nullable<RenderTargetTexture>;
  81865. /**
  81866. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  81867. * @param subMesh The submesh we want to render in the shadow map
  81868. * @param useInstances Defines wether will draw in the map using instances
  81869. * @returns true if ready otherwise, false
  81870. */
  81871. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  81872. /**
  81873. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  81874. * @param defines Defines of the material we want to update
  81875. * @param lightIndex Index of the light in the enabled light list of the material
  81876. */
  81877. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  81878. /**
  81879. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  81880. * defined in the generator but impacting the effect).
  81881. * It implies the unifroms available on the materials are the standard BJS ones.
  81882. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  81883. * @param effect The effect we are binfing the information for
  81884. */
  81885. bindShadowLight(lightIndex: string, effect: Effect): void;
  81886. /**
  81887. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  81888. * (eq to shadow prjection matrix * light transform matrix)
  81889. * @returns The transform matrix used to create the shadow map
  81890. */
  81891. getTransformMatrix(): Matrix;
  81892. /**
  81893. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  81894. * Cube and 2D textures for instance.
  81895. */
  81896. recreateShadowMap(): void;
  81897. /**
  81898. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81899. * @param onCompiled Callback triggered at the and of the effects compilation
  81900. * @param options Sets of optional options forcing the compilation with different modes
  81901. */
  81902. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  81903. useInstances: boolean;
  81904. }>): void;
  81905. /**
  81906. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81907. * @param options Sets of optional options forcing the compilation with different modes
  81908. * @returns A promise that resolves when the compilation completes
  81909. */
  81910. forceCompilationAsync(options?: Partial<{
  81911. useInstances: boolean;
  81912. }>): Promise<void>;
  81913. /**
  81914. * Serializes the shadow generator setup to a json object.
  81915. * @returns The serialized JSON object
  81916. */
  81917. serialize(): any;
  81918. /**
  81919. * Disposes the Shadow map and related Textures and effects.
  81920. */
  81921. dispose(): void;
  81922. }
  81923. /**
  81924. * Default implementation IShadowGenerator.
  81925. * This is the main object responsible of generating shadows in the framework.
  81926. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  81927. */
  81928. export class ShadowGenerator implements IShadowGenerator {
  81929. /**
  81930. * Name of the shadow generator class
  81931. */
  81932. static CLASSNAME: string;
  81933. /**
  81934. * Shadow generator mode None: no filtering applied.
  81935. */
  81936. static readonly FILTER_NONE: number;
  81937. /**
  81938. * Shadow generator mode ESM: Exponential Shadow Mapping.
  81939. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81940. */
  81941. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  81942. /**
  81943. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  81944. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  81945. */
  81946. static readonly FILTER_POISSONSAMPLING: number;
  81947. /**
  81948. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  81949. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81950. */
  81951. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  81952. /**
  81953. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  81954. * edge artifacts on steep falloff.
  81955. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81956. */
  81957. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  81958. /**
  81959. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  81960. * edge artifacts on steep falloff.
  81961. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  81962. */
  81963. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  81964. /**
  81965. * Shadow generator mode PCF: Percentage Closer Filtering
  81966. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  81967. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  81968. */
  81969. static readonly FILTER_PCF: number;
  81970. /**
  81971. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  81972. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  81973. * Contact Hardening
  81974. */
  81975. static readonly FILTER_PCSS: number;
  81976. /**
  81977. * Reserved for PCF and PCSS
  81978. * Highest Quality.
  81979. *
  81980. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  81981. *
  81982. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  81983. */
  81984. static readonly QUALITY_HIGH: number;
  81985. /**
  81986. * Reserved for PCF and PCSS
  81987. * Good tradeoff for quality/perf cross devices
  81988. *
  81989. * Execute PCF on a 3*3 kernel.
  81990. *
  81991. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  81992. */
  81993. static readonly QUALITY_MEDIUM: number;
  81994. /**
  81995. * Reserved for PCF and PCSS
  81996. * The lowest quality but the fastest.
  81997. *
  81998. * Execute PCF on a 1*1 kernel.
  81999. *
  82000. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  82001. */
  82002. static readonly QUALITY_LOW: number;
  82003. /** Gets or sets the custom shader name to use */
  82004. customShaderOptions: ICustomShaderOptions;
  82005. /**
  82006. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  82007. */
  82008. onBeforeShadowMapRenderObservable: Observable<Effect>;
  82009. /**
  82010. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  82011. */
  82012. onAfterShadowMapRenderObservable: Observable<Effect>;
  82013. /**
  82014. * Observable triggered before a mesh is rendered in the shadow map.
  82015. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  82016. */
  82017. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  82018. /**
  82019. * Observable triggered after a mesh is rendered in the shadow map.
  82020. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  82021. */
  82022. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  82023. protected _bias: number;
  82024. /**
  82025. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  82026. */
  82027. get bias(): number;
  82028. /**
  82029. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  82030. */
  82031. set bias(bias: number);
  82032. protected _normalBias: number;
  82033. /**
  82034. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82035. */
  82036. get normalBias(): number;
  82037. /**
  82038. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82039. */
  82040. set normalBias(normalBias: number);
  82041. protected _blurBoxOffset: number;
  82042. /**
  82043. * Gets the blur box offset: offset applied during the blur pass.
  82044. * Only useful if useKernelBlur = false
  82045. */
  82046. get blurBoxOffset(): number;
  82047. /**
  82048. * Sets the blur box offset: offset applied during the blur pass.
  82049. * Only useful if useKernelBlur = false
  82050. */
  82051. set blurBoxOffset(value: number);
  82052. protected _blurScale: number;
  82053. /**
  82054. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  82055. * 2 means half of the size.
  82056. */
  82057. get blurScale(): number;
  82058. /**
  82059. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  82060. * 2 means half of the size.
  82061. */
  82062. set blurScale(value: number);
  82063. protected _blurKernel: number;
  82064. /**
  82065. * Gets the blur kernel: kernel size of the blur pass.
  82066. * Only useful if useKernelBlur = true
  82067. */
  82068. get blurKernel(): number;
  82069. /**
  82070. * Sets the blur kernel: kernel size of the blur pass.
  82071. * Only useful if useKernelBlur = true
  82072. */
  82073. set blurKernel(value: number);
  82074. protected _useKernelBlur: boolean;
  82075. /**
  82076. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  82077. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82078. */
  82079. get useKernelBlur(): boolean;
  82080. /**
  82081. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  82082. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82083. */
  82084. set useKernelBlur(value: boolean);
  82085. protected _depthScale: number;
  82086. /**
  82087. * Gets the depth scale used in ESM mode.
  82088. */
  82089. get depthScale(): number;
  82090. /**
  82091. * Sets the depth scale used in ESM mode.
  82092. * This can override the scale stored on the light.
  82093. */
  82094. set depthScale(value: number);
  82095. protected _validateFilter(filter: number): number;
  82096. protected _filter: number;
  82097. /**
  82098. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  82099. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82100. */
  82101. get filter(): number;
  82102. /**
  82103. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  82104. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82105. */
  82106. set filter(value: number);
  82107. /**
  82108. * Gets if the current filter is set to Poisson Sampling.
  82109. */
  82110. get usePoissonSampling(): boolean;
  82111. /**
  82112. * Sets the current filter to Poisson Sampling.
  82113. */
  82114. set usePoissonSampling(value: boolean);
  82115. /**
  82116. * Gets if the current filter is set to ESM.
  82117. */
  82118. get useExponentialShadowMap(): boolean;
  82119. /**
  82120. * Sets the current filter is to ESM.
  82121. */
  82122. set useExponentialShadowMap(value: boolean);
  82123. /**
  82124. * Gets if the current filter is set to filtered ESM.
  82125. */
  82126. get useBlurExponentialShadowMap(): boolean;
  82127. /**
  82128. * Gets if the current filter is set to filtered ESM.
  82129. */
  82130. set useBlurExponentialShadowMap(value: boolean);
  82131. /**
  82132. * Gets if the current filter is set to "close ESM" (using the inverse of the
  82133. * exponential to prevent steep falloff artifacts).
  82134. */
  82135. get useCloseExponentialShadowMap(): boolean;
  82136. /**
  82137. * Sets the current filter to "close ESM" (using the inverse of the
  82138. * exponential to prevent steep falloff artifacts).
  82139. */
  82140. set useCloseExponentialShadowMap(value: boolean);
  82141. /**
  82142. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  82143. * exponential to prevent steep falloff artifacts).
  82144. */
  82145. get useBlurCloseExponentialShadowMap(): boolean;
  82146. /**
  82147. * Sets the current filter to filtered "close ESM" (using the inverse of the
  82148. * exponential to prevent steep falloff artifacts).
  82149. */
  82150. set useBlurCloseExponentialShadowMap(value: boolean);
  82151. /**
  82152. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  82153. */
  82154. get usePercentageCloserFiltering(): boolean;
  82155. /**
  82156. * Sets the current filter to "PCF" (percentage closer filtering).
  82157. */
  82158. set usePercentageCloserFiltering(value: boolean);
  82159. protected _filteringQuality: number;
  82160. /**
  82161. * Gets the PCF or PCSS Quality.
  82162. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82163. */
  82164. get filteringQuality(): number;
  82165. /**
  82166. * Sets the PCF or PCSS Quality.
  82167. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82168. */
  82169. set filteringQuality(filteringQuality: number);
  82170. /**
  82171. * Gets if the current filter is set to "PCSS" (contact hardening).
  82172. */
  82173. get useContactHardeningShadow(): boolean;
  82174. /**
  82175. * Sets the current filter to "PCSS" (contact hardening).
  82176. */
  82177. set useContactHardeningShadow(value: boolean);
  82178. protected _contactHardeningLightSizeUVRatio: number;
  82179. /**
  82180. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82181. * Using a ratio helps keeping shape stability independently of the map size.
  82182. *
  82183. * It does not account for the light projection as it was having too much
  82184. * instability during the light setup or during light position changes.
  82185. *
  82186. * Only valid if useContactHardeningShadow is true.
  82187. */
  82188. get contactHardeningLightSizeUVRatio(): number;
  82189. /**
  82190. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82191. * Using a ratio helps keeping shape stability independently of the map size.
  82192. *
  82193. * It does not account for the light projection as it was having too much
  82194. * instability during the light setup or during light position changes.
  82195. *
  82196. * Only valid if useContactHardeningShadow is true.
  82197. */
  82198. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  82199. protected _darkness: number;
  82200. /** Gets or sets the actual darkness of a shadow */
  82201. get darkness(): number;
  82202. set darkness(value: number);
  82203. /**
  82204. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  82205. * 0 means strongest and 1 would means no shadow.
  82206. * @returns the darkness.
  82207. */
  82208. getDarkness(): number;
  82209. /**
  82210. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  82211. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  82212. * @returns the shadow generator allowing fluent coding.
  82213. */
  82214. setDarkness(darkness: number): ShadowGenerator;
  82215. protected _transparencyShadow: boolean;
  82216. /** Gets or sets the ability to have transparent shadow */
  82217. get transparencyShadow(): boolean;
  82218. set transparencyShadow(value: boolean);
  82219. /**
  82220. * Sets the ability to have transparent shadow (boolean).
  82221. * @param transparent True if transparent else False
  82222. * @returns the shadow generator allowing fluent coding
  82223. */
  82224. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  82225. protected _shadowMap: Nullable<RenderTargetTexture>;
  82226. protected _shadowMap2: Nullable<RenderTargetTexture>;
  82227. /**
  82228. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82229. * @returns The render target texture if present otherwise, null
  82230. */
  82231. getShadowMap(): Nullable<RenderTargetTexture>;
  82232. /**
  82233. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  82234. * @returns The render target texture if the shadow map is present otherwise, null
  82235. */
  82236. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  82237. /**
  82238. * Gets the class name of that object
  82239. * @returns "ShadowGenerator"
  82240. */
  82241. getClassName(): string;
  82242. /**
  82243. * Helper function to add a mesh and its descendants to the list of shadow casters.
  82244. * @param mesh Mesh to add
  82245. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  82246. * @returns the Shadow Generator itself
  82247. */
  82248. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82249. /**
  82250. * Helper function to remove a mesh and its descendants from the list of shadow casters
  82251. * @param mesh Mesh to remove
  82252. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  82253. * @returns the Shadow Generator itself
  82254. */
  82255. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82256. /**
  82257. * Controls the extent to which the shadows fade out at the edge of the frustum
  82258. */
  82259. frustumEdgeFalloff: number;
  82260. protected _light: IShadowLight;
  82261. /**
  82262. * Returns the associated light object.
  82263. * @returns the light generating the shadow
  82264. */
  82265. getLight(): IShadowLight;
  82266. /**
  82267. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  82268. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  82269. * It might on the other hand introduce peter panning.
  82270. */
  82271. forceBackFacesOnly: boolean;
  82272. protected _scene: Scene;
  82273. protected _lightDirection: Vector3;
  82274. protected _effect: Effect;
  82275. protected _viewMatrix: Matrix;
  82276. protected _projectionMatrix: Matrix;
  82277. protected _transformMatrix: Matrix;
  82278. protected _cachedPosition: Vector3;
  82279. protected _cachedDirection: Vector3;
  82280. protected _cachedDefines: string;
  82281. protected _currentRenderID: number;
  82282. protected _boxBlurPostprocess: Nullable<PostProcess>;
  82283. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  82284. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  82285. protected _blurPostProcesses: PostProcess[];
  82286. protected _mapSize: number;
  82287. protected _currentFaceIndex: number;
  82288. protected _currentFaceIndexCache: number;
  82289. protected _textureType: number;
  82290. protected _defaultTextureMatrix: Matrix;
  82291. protected _storedUniqueId: Nullable<number>;
  82292. /** @hidden */
  82293. static _SceneComponentInitialization: (scene: Scene) => void;
  82294. /**
  82295. * Creates a ShadowGenerator object.
  82296. * A ShadowGenerator is the required tool to use the shadows.
  82297. * Each light casting shadows needs to use its own ShadowGenerator.
  82298. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  82299. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  82300. * @param light The light object generating the shadows.
  82301. * @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.
  82302. */
  82303. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  82304. protected _initializeGenerator(): void;
  82305. protected _createTargetRenderTexture(): void;
  82306. protected _initializeShadowMap(): void;
  82307. protected _initializeBlurRTTAndPostProcesses(): void;
  82308. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  82309. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  82310. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  82311. protected _applyFilterValues(): void;
  82312. /**
  82313. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82314. * @param onCompiled Callback triggered at the and of the effects compilation
  82315. * @param options Sets of optional options forcing the compilation with different modes
  82316. */
  82317. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82318. useInstances: boolean;
  82319. }>): void;
  82320. /**
  82321. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82322. * @param options Sets of optional options forcing the compilation with different modes
  82323. * @returns A promise that resolves when the compilation completes
  82324. */
  82325. forceCompilationAsync(options?: Partial<{
  82326. useInstances: boolean;
  82327. }>): Promise<void>;
  82328. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  82329. /**
  82330. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82331. * @param subMesh The submesh we want to render in the shadow map
  82332. * @param useInstances Defines wether will draw in the map using instances
  82333. * @returns true if ready otherwise, false
  82334. */
  82335. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82336. /**
  82337. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82338. * @param defines Defines of the material we want to update
  82339. * @param lightIndex Index of the light in the enabled light list of the material
  82340. */
  82341. prepareDefines(defines: any, lightIndex: number): void;
  82342. /**
  82343. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82344. * defined in the generator but impacting the effect).
  82345. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82346. * @param effect The effect we are binfing the information for
  82347. */
  82348. bindShadowLight(lightIndex: string, effect: Effect): void;
  82349. /**
  82350. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82351. * (eq to shadow prjection matrix * light transform matrix)
  82352. * @returns The transform matrix used to create the shadow map
  82353. */
  82354. getTransformMatrix(): Matrix;
  82355. /**
  82356. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82357. * Cube and 2D textures for instance.
  82358. */
  82359. recreateShadowMap(): void;
  82360. protected _disposeBlurPostProcesses(): void;
  82361. protected _disposeRTTandPostProcesses(): void;
  82362. /**
  82363. * Disposes the ShadowGenerator.
  82364. * Returns nothing.
  82365. */
  82366. dispose(): void;
  82367. /**
  82368. * Serializes the shadow generator setup to a json object.
  82369. * @returns The serialized JSON object
  82370. */
  82371. serialize(): any;
  82372. /**
  82373. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  82374. * @param parsedShadowGenerator The JSON object to parse
  82375. * @param scene The scene to create the shadow map for
  82376. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  82377. * @returns The parsed shadow generator
  82378. */
  82379. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  82380. }
  82381. }
  82382. declare module BABYLON {
  82383. /**
  82384. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  82385. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  82386. * 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.
  82387. */
  82388. export abstract class Light extends Node {
  82389. /**
  82390. * Falloff Default: light is falling off following the material specification:
  82391. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  82392. */
  82393. static readonly FALLOFF_DEFAULT: number;
  82394. /**
  82395. * Falloff Physical: light is falling off following the inverse squared distance law.
  82396. */
  82397. static readonly FALLOFF_PHYSICAL: number;
  82398. /**
  82399. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  82400. * to enhance interoperability with other engines.
  82401. */
  82402. static readonly FALLOFF_GLTF: number;
  82403. /**
  82404. * Falloff Standard: light is falling off like in the standard material
  82405. * to enhance interoperability with other materials.
  82406. */
  82407. static readonly FALLOFF_STANDARD: number;
  82408. /**
  82409. * If every light affecting the material is in this lightmapMode,
  82410. * material.lightmapTexture adds or multiplies
  82411. * (depends on material.useLightmapAsShadowmap)
  82412. * after every other light calculations.
  82413. */
  82414. static readonly LIGHTMAP_DEFAULT: number;
  82415. /**
  82416. * material.lightmapTexture as only diffuse lighting from this light
  82417. * adds only specular lighting from this light
  82418. * adds dynamic shadows
  82419. */
  82420. static readonly LIGHTMAP_SPECULAR: number;
  82421. /**
  82422. * material.lightmapTexture as only lighting
  82423. * no light calculation from this light
  82424. * only adds dynamic shadows from this light
  82425. */
  82426. static readonly LIGHTMAP_SHADOWSONLY: number;
  82427. /**
  82428. * Each light type uses the default quantity according to its type:
  82429. * point/spot lights use luminous intensity
  82430. * directional lights use illuminance
  82431. */
  82432. static readonly INTENSITYMODE_AUTOMATIC: number;
  82433. /**
  82434. * lumen (lm)
  82435. */
  82436. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  82437. /**
  82438. * candela (lm/sr)
  82439. */
  82440. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  82441. /**
  82442. * lux (lm/m^2)
  82443. */
  82444. static readonly INTENSITYMODE_ILLUMINANCE: number;
  82445. /**
  82446. * nit (cd/m^2)
  82447. */
  82448. static readonly INTENSITYMODE_LUMINANCE: number;
  82449. /**
  82450. * Light type const id of the point light.
  82451. */
  82452. static readonly LIGHTTYPEID_POINTLIGHT: number;
  82453. /**
  82454. * Light type const id of the directional light.
  82455. */
  82456. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  82457. /**
  82458. * Light type const id of the spot light.
  82459. */
  82460. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  82461. /**
  82462. * Light type const id of the hemispheric light.
  82463. */
  82464. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  82465. /**
  82466. * Diffuse gives the basic color to an object.
  82467. */
  82468. diffuse: Color3;
  82469. /**
  82470. * Specular produces a highlight color on an object.
  82471. * Note: This is note affecting PBR materials.
  82472. */
  82473. specular: Color3;
  82474. /**
  82475. * Defines the falloff type for this light. This lets overrriding how punctual light are
  82476. * falling off base on range or angle.
  82477. * This can be set to any values in Light.FALLOFF_x.
  82478. *
  82479. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  82480. * other types of materials.
  82481. */
  82482. falloffType: number;
  82483. /**
  82484. * Strength of the light.
  82485. * Note: By default it is define in the framework own unit.
  82486. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  82487. */
  82488. intensity: number;
  82489. private _range;
  82490. protected _inverseSquaredRange: number;
  82491. /**
  82492. * Defines how far from the source the light is impacting in scene units.
  82493. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82494. */
  82495. get range(): number;
  82496. /**
  82497. * Defines how far from the source the light is impacting in scene units.
  82498. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82499. */
  82500. set range(value: number);
  82501. /**
  82502. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  82503. * of light.
  82504. */
  82505. private _photometricScale;
  82506. private _intensityMode;
  82507. /**
  82508. * Gets the photometric scale used to interpret the intensity.
  82509. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82510. */
  82511. get intensityMode(): number;
  82512. /**
  82513. * Sets the photometric scale used to interpret the intensity.
  82514. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82515. */
  82516. set intensityMode(value: number);
  82517. private _radius;
  82518. /**
  82519. * Gets the light radius used by PBR Materials to simulate soft area lights.
  82520. */
  82521. get radius(): number;
  82522. /**
  82523. * sets the light radius used by PBR Materials to simulate soft area lights.
  82524. */
  82525. set radius(value: number);
  82526. private _renderPriority;
  82527. /**
  82528. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  82529. * exceeding the number allowed of the materials.
  82530. */
  82531. renderPriority: number;
  82532. private _shadowEnabled;
  82533. /**
  82534. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82535. * the current shadow generator.
  82536. */
  82537. get shadowEnabled(): boolean;
  82538. /**
  82539. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82540. * the current shadow generator.
  82541. */
  82542. set shadowEnabled(value: boolean);
  82543. private _includedOnlyMeshes;
  82544. /**
  82545. * Gets the only meshes impacted by this light.
  82546. */
  82547. get includedOnlyMeshes(): AbstractMesh[];
  82548. /**
  82549. * Sets the only meshes impacted by this light.
  82550. */
  82551. set includedOnlyMeshes(value: AbstractMesh[]);
  82552. private _excludedMeshes;
  82553. /**
  82554. * Gets the meshes not impacted by this light.
  82555. */
  82556. get excludedMeshes(): AbstractMesh[];
  82557. /**
  82558. * Sets the meshes not impacted by this light.
  82559. */
  82560. set excludedMeshes(value: AbstractMesh[]);
  82561. private _excludeWithLayerMask;
  82562. /**
  82563. * Gets the layer id use to find what meshes are not impacted by the light.
  82564. * Inactive if 0
  82565. */
  82566. get excludeWithLayerMask(): number;
  82567. /**
  82568. * Sets the layer id use to find what meshes are not impacted by the light.
  82569. * Inactive if 0
  82570. */
  82571. set excludeWithLayerMask(value: number);
  82572. private _includeOnlyWithLayerMask;
  82573. /**
  82574. * Gets the layer id use to find what meshes are impacted by the light.
  82575. * Inactive if 0
  82576. */
  82577. get includeOnlyWithLayerMask(): number;
  82578. /**
  82579. * Sets the layer id use to find what meshes are impacted by the light.
  82580. * Inactive if 0
  82581. */
  82582. set includeOnlyWithLayerMask(value: number);
  82583. private _lightmapMode;
  82584. /**
  82585. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  82586. */
  82587. get lightmapMode(): number;
  82588. /**
  82589. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  82590. */
  82591. set lightmapMode(value: number);
  82592. /**
  82593. * Shadow generator associted to the light.
  82594. * @hidden Internal use only.
  82595. */
  82596. _shadowGenerator: Nullable<IShadowGenerator>;
  82597. /**
  82598. * @hidden Internal use only.
  82599. */
  82600. _excludedMeshesIds: string[];
  82601. /**
  82602. * @hidden Internal use only.
  82603. */
  82604. _includedOnlyMeshesIds: string[];
  82605. /**
  82606. * The current light unifom buffer.
  82607. * @hidden Internal use only.
  82608. */
  82609. _uniformBuffer: UniformBuffer;
  82610. /** @hidden */
  82611. _renderId: number;
  82612. /**
  82613. * Creates a Light object in the scene.
  82614. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82615. * @param name The firendly name of the light
  82616. * @param scene The scene the light belongs too
  82617. */
  82618. constructor(name: string, scene: Scene);
  82619. protected abstract _buildUniformLayout(): void;
  82620. /**
  82621. * Sets the passed Effect "effect" with the Light information.
  82622. * @param effect The effect to update
  82623. * @param lightIndex The index of the light in the effect to update
  82624. * @returns The light
  82625. */
  82626. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  82627. /**
  82628. * Sets the passed Effect "effect" with the Light textures.
  82629. * @param effect The effect to update
  82630. * @param lightIndex The index of the light in the effect to update
  82631. * @returns The light
  82632. */
  82633. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  82634. /**
  82635. * Binds the lights information from the scene to the effect for the given mesh.
  82636. * @param lightIndex Light index
  82637. * @param scene The scene where the light belongs to
  82638. * @param effect The effect we are binding the data to
  82639. * @param useSpecular Defines if specular is supported
  82640. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82641. */
  82642. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82643. /**
  82644. * Sets the passed Effect "effect" with the Light information.
  82645. * @param effect The effect to update
  82646. * @param lightDataUniformName The uniform used to store light data (position or direction)
  82647. * @returns The light
  82648. */
  82649. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  82650. /**
  82651. * Returns the string "Light".
  82652. * @returns the class name
  82653. */
  82654. getClassName(): string;
  82655. /** @hidden */
  82656. readonly _isLight: boolean;
  82657. /**
  82658. * Converts the light information to a readable string for debug purpose.
  82659. * @param fullDetails Supports for multiple levels of logging within scene loading
  82660. * @returns the human readable light info
  82661. */
  82662. toString(fullDetails?: boolean): string;
  82663. /** @hidden */
  82664. protected _syncParentEnabledState(): void;
  82665. /**
  82666. * Set the enabled state of this node.
  82667. * @param value - the new enabled state
  82668. */
  82669. setEnabled(value: boolean): void;
  82670. /**
  82671. * Returns the Light associated shadow generator if any.
  82672. * @return the associated shadow generator.
  82673. */
  82674. getShadowGenerator(): Nullable<IShadowGenerator>;
  82675. /**
  82676. * Returns a Vector3, the absolute light position in the World.
  82677. * @returns the world space position of the light
  82678. */
  82679. getAbsolutePosition(): Vector3;
  82680. /**
  82681. * Specifies if the light will affect the passed mesh.
  82682. * @param mesh The mesh to test against the light
  82683. * @return true the mesh is affected otherwise, false.
  82684. */
  82685. canAffectMesh(mesh: AbstractMesh): boolean;
  82686. /**
  82687. * Sort function to order lights for rendering.
  82688. * @param a First Light object to compare to second.
  82689. * @param b Second Light object to compare first.
  82690. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  82691. */
  82692. static CompareLightsPriority(a: Light, b: Light): number;
  82693. /**
  82694. * Releases resources associated with this node.
  82695. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82696. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82697. */
  82698. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82699. /**
  82700. * Returns the light type ID (integer).
  82701. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82702. */
  82703. getTypeID(): number;
  82704. /**
  82705. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  82706. * @returns the scaled intensity in intensity mode unit
  82707. */
  82708. getScaledIntensity(): number;
  82709. /**
  82710. * Returns a new Light object, named "name", from the current one.
  82711. * @param name The name of the cloned light
  82712. * @returns the new created light
  82713. */
  82714. clone(name: string): Nullable<Light>;
  82715. /**
  82716. * Serializes the current light into a Serialization object.
  82717. * @returns the serialized object.
  82718. */
  82719. serialize(): any;
  82720. /**
  82721. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  82722. * This new light is named "name" and added to the passed scene.
  82723. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  82724. * @param name The friendly name of the light
  82725. * @param scene The scene the new light will belong to
  82726. * @returns the constructor function
  82727. */
  82728. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  82729. /**
  82730. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  82731. * @param parsedLight The JSON representation of the light
  82732. * @param scene The scene to create the parsed light in
  82733. * @returns the created light after parsing
  82734. */
  82735. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  82736. private _hookArrayForExcluded;
  82737. private _hookArrayForIncludedOnly;
  82738. private _resyncMeshes;
  82739. /**
  82740. * Forces the meshes to update their light related information in their rendering used effects
  82741. * @hidden Internal Use Only
  82742. */
  82743. _markMeshesAsLightDirty(): void;
  82744. /**
  82745. * Recomputes the cached photometric scale if needed.
  82746. */
  82747. private _computePhotometricScale;
  82748. /**
  82749. * Returns the Photometric Scale according to the light type and intensity mode.
  82750. */
  82751. private _getPhotometricScale;
  82752. /**
  82753. * Reorder the light in the scene according to their defined priority.
  82754. * @hidden Internal Use Only
  82755. */
  82756. _reorderLightsInScene(): void;
  82757. /**
  82758. * Prepares the list of defines specific to the light type.
  82759. * @param defines the list of defines
  82760. * @param lightIndex defines the index of the light for the effect
  82761. */
  82762. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82763. }
  82764. }
  82765. declare module BABYLON {
  82766. /**
  82767. * Interface used to define Action
  82768. */
  82769. export interface IAction {
  82770. /**
  82771. * Trigger for the action
  82772. */
  82773. trigger: number;
  82774. /** Options of the trigger */
  82775. triggerOptions: any;
  82776. /**
  82777. * Gets the trigger parameters
  82778. * @returns the trigger parameters
  82779. */
  82780. getTriggerParameter(): any;
  82781. /**
  82782. * Internal only - executes current action event
  82783. * @hidden
  82784. */
  82785. _executeCurrent(evt?: ActionEvent): void;
  82786. /**
  82787. * Serialize placeholder for child classes
  82788. * @param parent of child
  82789. * @returns the serialized object
  82790. */
  82791. serialize(parent: any): any;
  82792. /**
  82793. * Internal only
  82794. * @hidden
  82795. */
  82796. _prepare(): void;
  82797. /**
  82798. * Internal only - manager for action
  82799. * @hidden
  82800. */
  82801. _actionManager: AbstractActionManager;
  82802. /**
  82803. * Adds action to chain of actions, may be a DoNothingAction
  82804. * @param action defines the next action to execute
  82805. * @returns The action passed in
  82806. * @see https://www.babylonjs-playground.com/#1T30HR#0
  82807. */
  82808. then(action: IAction): IAction;
  82809. }
  82810. /**
  82811. * The action to be carried out following a trigger
  82812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  82813. */
  82814. export class Action implements IAction {
  82815. /** the trigger, with or without parameters, for the action */
  82816. triggerOptions: any;
  82817. /**
  82818. * Trigger for the action
  82819. */
  82820. trigger: number;
  82821. /**
  82822. * Internal only - manager for action
  82823. * @hidden
  82824. */
  82825. _actionManager: ActionManager;
  82826. private _nextActiveAction;
  82827. private _child;
  82828. private _condition?;
  82829. private _triggerParameter;
  82830. /**
  82831. * An event triggered prior to action being executed.
  82832. */
  82833. onBeforeExecuteObservable: Observable<Action>;
  82834. /**
  82835. * Creates a new Action
  82836. * @param triggerOptions the trigger, with or without parameters, for the action
  82837. * @param condition an optional determinant of action
  82838. */
  82839. constructor(
  82840. /** the trigger, with or without parameters, for the action */
  82841. triggerOptions: any, condition?: Condition);
  82842. /**
  82843. * Internal only
  82844. * @hidden
  82845. */
  82846. _prepare(): void;
  82847. /**
  82848. * Gets the trigger parameters
  82849. * @returns the trigger parameters
  82850. */
  82851. getTriggerParameter(): any;
  82852. /**
  82853. * Internal only - executes current action event
  82854. * @hidden
  82855. */
  82856. _executeCurrent(evt?: ActionEvent): void;
  82857. /**
  82858. * Execute placeholder for child classes
  82859. * @param evt optional action event
  82860. */
  82861. execute(evt?: ActionEvent): void;
  82862. /**
  82863. * Skips to next active action
  82864. */
  82865. skipToNextActiveAction(): void;
  82866. /**
  82867. * Adds action to chain of actions, may be a DoNothingAction
  82868. * @param action defines the next action to execute
  82869. * @returns The action passed in
  82870. * @see https://www.babylonjs-playground.com/#1T30HR#0
  82871. */
  82872. then(action: Action): Action;
  82873. /**
  82874. * Internal only
  82875. * @hidden
  82876. */
  82877. _getProperty(propertyPath: string): string;
  82878. /**
  82879. * Internal only
  82880. * @hidden
  82881. */
  82882. _getEffectiveTarget(target: any, propertyPath: string): any;
  82883. /**
  82884. * Serialize placeholder for child classes
  82885. * @param parent of child
  82886. * @returns the serialized object
  82887. */
  82888. serialize(parent: any): any;
  82889. /**
  82890. * Internal only called by serialize
  82891. * @hidden
  82892. */
  82893. protected _serialize(serializedAction: any, parent?: any): any;
  82894. /**
  82895. * Internal only
  82896. * @hidden
  82897. */
  82898. static _SerializeValueAsString: (value: any) => string;
  82899. /**
  82900. * Internal only
  82901. * @hidden
  82902. */
  82903. static _GetTargetProperty: (target: Node | Scene) => {
  82904. name: string;
  82905. targetType: string;
  82906. value: string;
  82907. };
  82908. }
  82909. }
  82910. declare module BABYLON {
  82911. /**
  82912. * A Condition applied to an Action
  82913. */
  82914. export class Condition {
  82915. /**
  82916. * Internal only - manager for action
  82917. * @hidden
  82918. */
  82919. _actionManager: ActionManager;
  82920. /**
  82921. * Internal only
  82922. * @hidden
  82923. */
  82924. _evaluationId: number;
  82925. /**
  82926. * Internal only
  82927. * @hidden
  82928. */
  82929. _currentResult: boolean;
  82930. /**
  82931. * Creates a new Condition
  82932. * @param actionManager the manager of the action the condition is applied to
  82933. */
  82934. constructor(actionManager: ActionManager);
  82935. /**
  82936. * Check if the current condition is valid
  82937. * @returns a boolean
  82938. */
  82939. isValid(): boolean;
  82940. /**
  82941. * Internal only
  82942. * @hidden
  82943. */
  82944. _getProperty(propertyPath: string): string;
  82945. /**
  82946. * Internal only
  82947. * @hidden
  82948. */
  82949. _getEffectiveTarget(target: any, propertyPath: string): any;
  82950. /**
  82951. * Serialize placeholder for child classes
  82952. * @returns the serialized object
  82953. */
  82954. serialize(): any;
  82955. /**
  82956. * Internal only
  82957. * @hidden
  82958. */
  82959. protected _serialize(serializedCondition: any): any;
  82960. }
  82961. /**
  82962. * Defines specific conditional operators as extensions of Condition
  82963. */
  82964. export class ValueCondition extends Condition {
  82965. /** path to specify the property of the target the conditional operator uses */
  82966. propertyPath: string;
  82967. /** the value compared by the conditional operator against the current value of the property */
  82968. value: any;
  82969. /** the conditional operator, default ValueCondition.IsEqual */
  82970. operator: number;
  82971. /**
  82972. * Internal only
  82973. * @hidden
  82974. */
  82975. private static _IsEqual;
  82976. /**
  82977. * Internal only
  82978. * @hidden
  82979. */
  82980. private static _IsDifferent;
  82981. /**
  82982. * Internal only
  82983. * @hidden
  82984. */
  82985. private static _IsGreater;
  82986. /**
  82987. * Internal only
  82988. * @hidden
  82989. */
  82990. private static _IsLesser;
  82991. /**
  82992. * returns the number for IsEqual
  82993. */
  82994. static get IsEqual(): number;
  82995. /**
  82996. * Returns the number for IsDifferent
  82997. */
  82998. static get IsDifferent(): number;
  82999. /**
  83000. * Returns the number for IsGreater
  83001. */
  83002. static get IsGreater(): number;
  83003. /**
  83004. * Returns the number for IsLesser
  83005. */
  83006. static get IsLesser(): number;
  83007. /**
  83008. * Internal only The action manager for the condition
  83009. * @hidden
  83010. */
  83011. _actionManager: ActionManager;
  83012. /**
  83013. * Internal only
  83014. * @hidden
  83015. */
  83016. private _target;
  83017. /**
  83018. * Internal only
  83019. * @hidden
  83020. */
  83021. private _effectiveTarget;
  83022. /**
  83023. * Internal only
  83024. * @hidden
  83025. */
  83026. private _property;
  83027. /**
  83028. * Creates a new ValueCondition
  83029. * @param actionManager manager for the action the condition applies to
  83030. * @param target for the action
  83031. * @param propertyPath path to specify the property of the target the conditional operator uses
  83032. * @param value the value compared by the conditional operator against the current value of the property
  83033. * @param operator the conditional operator, default ValueCondition.IsEqual
  83034. */
  83035. constructor(actionManager: ActionManager, target: any,
  83036. /** path to specify the property of the target the conditional operator uses */
  83037. propertyPath: string,
  83038. /** the value compared by the conditional operator against the current value of the property */
  83039. value: any,
  83040. /** the conditional operator, default ValueCondition.IsEqual */
  83041. operator?: number);
  83042. /**
  83043. * Compares the given value with the property value for the specified conditional operator
  83044. * @returns the result of the comparison
  83045. */
  83046. isValid(): boolean;
  83047. /**
  83048. * Serialize the ValueCondition into a JSON compatible object
  83049. * @returns serialization object
  83050. */
  83051. serialize(): any;
  83052. /**
  83053. * Gets the name of the conditional operator for the ValueCondition
  83054. * @param operator the conditional operator
  83055. * @returns the name
  83056. */
  83057. static GetOperatorName(operator: number): string;
  83058. }
  83059. /**
  83060. * Defines a predicate condition as an extension of Condition
  83061. */
  83062. export class PredicateCondition extends Condition {
  83063. /** defines the predicate function used to validate the condition */
  83064. predicate: () => boolean;
  83065. /**
  83066. * Internal only - manager for action
  83067. * @hidden
  83068. */
  83069. _actionManager: ActionManager;
  83070. /**
  83071. * Creates a new PredicateCondition
  83072. * @param actionManager manager for the action the condition applies to
  83073. * @param predicate defines the predicate function used to validate the condition
  83074. */
  83075. constructor(actionManager: ActionManager,
  83076. /** defines the predicate function used to validate the condition */
  83077. predicate: () => boolean);
  83078. /**
  83079. * @returns the validity of the predicate condition
  83080. */
  83081. isValid(): boolean;
  83082. }
  83083. /**
  83084. * Defines a state condition as an extension of Condition
  83085. */
  83086. export class StateCondition extends Condition {
  83087. /** Value to compare with target state */
  83088. value: string;
  83089. /**
  83090. * Internal only - manager for action
  83091. * @hidden
  83092. */
  83093. _actionManager: ActionManager;
  83094. /**
  83095. * Internal only
  83096. * @hidden
  83097. */
  83098. private _target;
  83099. /**
  83100. * Creates a new StateCondition
  83101. * @param actionManager manager for the action the condition applies to
  83102. * @param target of the condition
  83103. * @param value to compare with target state
  83104. */
  83105. constructor(actionManager: ActionManager, target: any,
  83106. /** Value to compare with target state */
  83107. value: string);
  83108. /**
  83109. * Gets a boolean indicating if the current condition is met
  83110. * @returns the validity of the state
  83111. */
  83112. isValid(): boolean;
  83113. /**
  83114. * Serialize the StateCondition into a JSON compatible object
  83115. * @returns serialization object
  83116. */
  83117. serialize(): any;
  83118. }
  83119. }
  83120. declare module BABYLON {
  83121. /**
  83122. * This defines an action responsible to toggle a boolean once triggered.
  83123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83124. */
  83125. export class SwitchBooleanAction extends Action {
  83126. /**
  83127. * The path to the boolean property in the target object
  83128. */
  83129. propertyPath: string;
  83130. private _target;
  83131. private _effectiveTarget;
  83132. private _property;
  83133. /**
  83134. * Instantiate the action
  83135. * @param triggerOptions defines the trigger options
  83136. * @param target defines the object containing the boolean
  83137. * @param propertyPath defines the path to the boolean property in the target object
  83138. * @param condition defines the trigger related conditions
  83139. */
  83140. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  83141. /** @hidden */
  83142. _prepare(): void;
  83143. /**
  83144. * Execute the action toggle the boolean value.
  83145. */
  83146. execute(): void;
  83147. /**
  83148. * Serializes the actions and its related information.
  83149. * @param parent defines the object to serialize in
  83150. * @returns the serialized object
  83151. */
  83152. serialize(parent: any): any;
  83153. }
  83154. /**
  83155. * This defines an action responsible to set a the state field of the target
  83156. * to a desired value once triggered.
  83157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83158. */
  83159. export class SetStateAction extends Action {
  83160. /**
  83161. * The value to store in the state field.
  83162. */
  83163. value: string;
  83164. private _target;
  83165. /**
  83166. * Instantiate the action
  83167. * @param triggerOptions defines the trigger options
  83168. * @param target defines the object containing the state property
  83169. * @param value defines the value to store in the state field
  83170. * @param condition defines the trigger related conditions
  83171. */
  83172. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  83173. /**
  83174. * Execute the action and store the value on the target state property.
  83175. */
  83176. execute(): void;
  83177. /**
  83178. * Serializes the actions and its related information.
  83179. * @param parent defines the object to serialize in
  83180. * @returns the serialized object
  83181. */
  83182. serialize(parent: any): any;
  83183. }
  83184. /**
  83185. * This defines an action responsible to set a property of the target
  83186. * to a desired value once triggered.
  83187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83188. */
  83189. export class SetValueAction extends Action {
  83190. /**
  83191. * The path of the property to set in the target.
  83192. */
  83193. propertyPath: string;
  83194. /**
  83195. * The value to set in the property
  83196. */
  83197. value: any;
  83198. private _target;
  83199. private _effectiveTarget;
  83200. private _property;
  83201. /**
  83202. * Instantiate the action
  83203. * @param triggerOptions defines the trigger options
  83204. * @param target defines the object containing the property
  83205. * @param propertyPath defines the path of the property to set in the target
  83206. * @param value defines the value to set in the property
  83207. * @param condition defines the trigger related conditions
  83208. */
  83209. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83210. /** @hidden */
  83211. _prepare(): void;
  83212. /**
  83213. * Execute the action and set the targetted property to the desired value.
  83214. */
  83215. execute(): void;
  83216. /**
  83217. * Serializes the actions and its related information.
  83218. * @param parent defines the object to serialize in
  83219. * @returns the serialized object
  83220. */
  83221. serialize(parent: any): any;
  83222. }
  83223. /**
  83224. * This defines an action responsible to increment the target value
  83225. * to a desired value once triggered.
  83226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83227. */
  83228. export class IncrementValueAction extends Action {
  83229. /**
  83230. * The path of the property to increment in the target.
  83231. */
  83232. propertyPath: string;
  83233. /**
  83234. * The value we should increment the property by.
  83235. */
  83236. value: any;
  83237. private _target;
  83238. private _effectiveTarget;
  83239. private _property;
  83240. /**
  83241. * Instantiate the action
  83242. * @param triggerOptions defines the trigger options
  83243. * @param target defines the object containing the property
  83244. * @param propertyPath defines the path of the property to increment in the target
  83245. * @param value defines the value value we should increment the property by
  83246. * @param condition defines the trigger related conditions
  83247. */
  83248. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83249. /** @hidden */
  83250. _prepare(): void;
  83251. /**
  83252. * Execute the action and increment the target of the value amount.
  83253. */
  83254. execute(): void;
  83255. /**
  83256. * Serializes the actions and its related information.
  83257. * @param parent defines the object to serialize in
  83258. * @returns the serialized object
  83259. */
  83260. serialize(parent: any): any;
  83261. }
  83262. /**
  83263. * This defines an action responsible to start an animation once triggered.
  83264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83265. */
  83266. export class PlayAnimationAction extends Action {
  83267. /**
  83268. * Where the animation should start (animation frame)
  83269. */
  83270. from: number;
  83271. /**
  83272. * Where the animation should stop (animation frame)
  83273. */
  83274. to: number;
  83275. /**
  83276. * Define if the animation should loop or stop after the first play.
  83277. */
  83278. loop?: boolean;
  83279. private _target;
  83280. /**
  83281. * Instantiate the action
  83282. * @param triggerOptions defines the trigger options
  83283. * @param target defines the target animation or animation name
  83284. * @param from defines from where the animation should start (animation frame)
  83285. * @param end defines where the animation should stop (animation frame)
  83286. * @param loop defines if the animation should loop or stop after the first play
  83287. * @param condition defines the trigger related conditions
  83288. */
  83289. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  83290. /** @hidden */
  83291. _prepare(): void;
  83292. /**
  83293. * Execute the action and play the animation.
  83294. */
  83295. execute(): void;
  83296. /**
  83297. * Serializes the actions and its related information.
  83298. * @param parent defines the object to serialize in
  83299. * @returns the serialized object
  83300. */
  83301. serialize(parent: any): any;
  83302. }
  83303. /**
  83304. * This defines an action responsible to stop an animation once triggered.
  83305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83306. */
  83307. export class StopAnimationAction extends Action {
  83308. private _target;
  83309. /**
  83310. * Instantiate the action
  83311. * @param triggerOptions defines the trigger options
  83312. * @param target defines the target animation or animation name
  83313. * @param condition defines the trigger related conditions
  83314. */
  83315. constructor(triggerOptions: any, target: any, condition?: Condition);
  83316. /** @hidden */
  83317. _prepare(): void;
  83318. /**
  83319. * Execute the action and stop the animation.
  83320. */
  83321. execute(): void;
  83322. /**
  83323. * Serializes the actions and its related information.
  83324. * @param parent defines the object to serialize in
  83325. * @returns the serialized object
  83326. */
  83327. serialize(parent: any): any;
  83328. }
  83329. /**
  83330. * This defines an action responsible that does nothing once triggered.
  83331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83332. */
  83333. export class DoNothingAction extends Action {
  83334. /**
  83335. * Instantiate the action
  83336. * @param triggerOptions defines the trigger options
  83337. * @param condition defines the trigger related conditions
  83338. */
  83339. constructor(triggerOptions?: any, condition?: Condition);
  83340. /**
  83341. * Execute the action and do nothing.
  83342. */
  83343. execute(): void;
  83344. /**
  83345. * Serializes the actions and its related information.
  83346. * @param parent defines the object to serialize in
  83347. * @returns the serialized object
  83348. */
  83349. serialize(parent: any): any;
  83350. }
  83351. /**
  83352. * This defines an action responsible to trigger several actions once triggered.
  83353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83354. */
  83355. export class CombineAction extends Action {
  83356. /**
  83357. * The list of aggregated animations to run.
  83358. */
  83359. children: Action[];
  83360. /**
  83361. * Instantiate the action
  83362. * @param triggerOptions defines the trigger options
  83363. * @param children defines the list of aggregated animations to run
  83364. * @param condition defines the trigger related conditions
  83365. */
  83366. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  83367. /** @hidden */
  83368. _prepare(): void;
  83369. /**
  83370. * Execute the action and executes all the aggregated actions.
  83371. */
  83372. execute(evt: ActionEvent): void;
  83373. /**
  83374. * Serializes the actions and its related information.
  83375. * @param parent defines the object to serialize in
  83376. * @returns the serialized object
  83377. */
  83378. serialize(parent: any): any;
  83379. }
  83380. /**
  83381. * This defines an action responsible to run code (external event) once triggered.
  83382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83383. */
  83384. export class ExecuteCodeAction extends Action {
  83385. /**
  83386. * The callback function to run.
  83387. */
  83388. func: (evt: ActionEvent) => void;
  83389. /**
  83390. * Instantiate the action
  83391. * @param triggerOptions defines the trigger options
  83392. * @param func defines the callback function to run
  83393. * @param condition defines the trigger related conditions
  83394. */
  83395. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  83396. /**
  83397. * Execute the action and run the attached code.
  83398. */
  83399. execute(evt: ActionEvent): void;
  83400. }
  83401. /**
  83402. * This defines an action responsible to set the parent property of the target once triggered.
  83403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83404. */
  83405. export class SetParentAction extends Action {
  83406. private _parent;
  83407. private _target;
  83408. /**
  83409. * Instantiate the action
  83410. * @param triggerOptions defines the trigger options
  83411. * @param target defines the target containing the parent property
  83412. * @param parent defines from where the animation should start (animation frame)
  83413. * @param condition defines the trigger related conditions
  83414. */
  83415. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  83416. /** @hidden */
  83417. _prepare(): void;
  83418. /**
  83419. * Execute the action and set the parent property.
  83420. */
  83421. execute(): void;
  83422. /**
  83423. * Serializes the actions and its related information.
  83424. * @param parent defines the object to serialize in
  83425. * @returns the serialized object
  83426. */
  83427. serialize(parent: any): any;
  83428. }
  83429. }
  83430. declare module BABYLON {
  83431. /**
  83432. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  83433. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  83434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83435. */
  83436. export class ActionManager extends AbstractActionManager {
  83437. /**
  83438. * Nothing
  83439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83440. */
  83441. static readonly NothingTrigger: number;
  83442. /**
  83443. * On pick
  83444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83445. */
  83446. static readonly OnPickTrigger: number;
  83447. /**
  83448. * On left pick
  83449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83450. */
  83451. static readonly OnLeftPickTrigger: number;
  83452. /**
  83453. * On right pick
  83454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83455. */
  83456. static readonly OnRightPickTrigger: number;
  83457. /**
  83458. * On center pick
  83459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83460. */
  83461. static readonly OnCenterPickTrigger: number;
  83462. /**
  83463. * On pick down
  83464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83465. */
  83466. static readonly OnPickDownTrigger: number;
  83467. /**
  83468. * On double pick
  83469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83470. */
  83471. static readonly OnDoublePickTrigger: number;
  83472. /**
  83473. * On pick up
  83474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83475. */
  83476. static readonly OnPickUpTrigger: number;
  83477. /**
  83478. * On pick out.
  83479. * This trigger will only be raised if you also declared a OnPickDown
  83480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83481. */
  83482. static readonly OnPickOutTrigger: number;
  83483. /**
  83484. * On long press
  83485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83486. */
  83487. static readonly OnLongPressTrigger: number;
  83488. /**
  83489. * On pointer over
  83490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83491. */
  83492. static readonly OnPointerOverTrigger: number;
  83493. /**
  83494. * On pointer out
  83495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83496. */
  83497. static readonly OnPointerOutTrigger: number;
  83498. /**
  83499. * On every frame
  83500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83501. */
  83502. static readonly OnEveryFrameTrigger: number;
  83503. /**
  83504. * On intersection enter
  83505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83506. */
  83507. static readonly OnIntersectionEnterTrigger: number;
  83508. /**
  83509. * On intersection exit
  83510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83511. */
  83512. static readonly OnIntersectionExitTrigger: number;
  83513. /**
  83514. * On key down
  83515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83516. */
  83517. static readonly OnKeyDownTrigger: number;
  83518. /**
  83519. * On key up
  83520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83521. */
  83522. static readonly OnKeyUpTrigger: number;
  83523. private _scene;
  83524. /**
  83525. * Creates a new action manager
  83526. * @param scene defines the hosting scene
  83527. */
  83528. constructor(scene: Scene);
  83529. /**
  83530. * Releases all associated resources
  83531. */
  83532. dispose(): void;
  83533. /**
  83534. * Gets hosting scene
  83535. * @returns the hosting scene
  83536. */
  83537. getScene(): Scene;
  83538. /**
  83539. * Does this action manager handles actions of any of the given triggers
  83540. * @param triggers defines the triggers to be tested
  83541. * @return a boolean indicating whether one (or more) of the triggers is handled
  83542. */
  83543. hasSpecificTriggers(triggers: number[]): boolean;
  83544. /**
  83545. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83546. * speed.
  83547. * @param triggerA defines the trigger to be tested
  83548. * @param triggerB defines the trigger to be tested
  83549. * @return a boolean indicating whether one (or more) of the triggers is handled
  83550. */
  83551. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83552. /**
  83553. * Does this action manager handles actions of a given trigger
  83554. * @param trigger defines the trigger to be tested
  83555. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83556. * @return whether the trigger is handled
  83557. */
  83558. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83559. /**
  83560. * Does this action manager has pointer triggers
  83561. */
  83562. get hasPointerTriggers(): boolean;
  83563. /**
  83564. * Does this action manager has pick triggers
  83565. */
  83566. get hasPickTriggers(): boolean;
  83567. /**
  83568. * Registers an action to this action manager
  83569. * @param action defines the action to be registered
  83570. * @return the action amended (prepared) after registration
  83571. */
  83572. registerAction(action: IAction): Nullable<IAction>;
  83573. /**
  83574. * Unregisters an action to this action manager
  83575. * @param action defines the action to be unregistered
  83576. * @return a boolean indicating whether the action has been unregistered
  83577. */
  83578. unregisterAction(action: IAction): Boolean;
  83579. /**
  83580. * Process a specific trigger
  83581. * @param trigger defines the trigger to process
  83582. * @param evt defines the event details to be processed
  83583. */
  83584. processTrigger(trigger: number, evt?: IActionEvent): void;
  83585. /** @hidden */
  83586. _getEffectiveTarget(target: any, propertyPath: string): any;
  83587. /** @hidden */
  83588. _getProperty(propertyPath: string): string;
  83589. /**
  83590. * Serialize this manager to a JSON object
  83591. * @param name defines the property name to store this manager
  83592. * @returns a JSON representation of this manager
  83593. */
  83594. serialize(name: string): any;
  83595. /**
  83596. * Creates a new ActionManager from a JSON data
  83597. * @param parsedActions defines the JSON data to read from
  83598. * @param object defines the hosting mesh
  83599. * @param scene defines the hosting scene
  83600. */
  83601. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  83602. /**
  83603. * Get a trigger name by index
  83604. * @param trigger defines the trigger index
  83605. * @returns a trigger name
  83606. */
  83607. static GetTriggerName(trigger: number): string;
  83608. }
  83609. }
  83610. declare module BABYLON {
  83611. /**
  83612. * Class representing a ray with position and direction
  83613. */
  83614. export class Ray {
  83615. /** origin point */
  83616. origin: Vector3;
  83617. /** direction */
  83618. direction: Vector3;
  83619. /** length of the ray */
  83620. length: number;
  83621. private static readonly TmpVector3;
  83622. private _tmpRay;
  83623. /**
  83624. * Creates a new ray
  83625. * @param origin origin point
  83626. * @param direction direction
  83627. * @param length length of the ray
  83628. */
  83629. constructor(
  83630. /** origin point */
  83631. origin: Vector3,
  83632. /** direction */
  83633. direction: Vector3,
  83634. /** length of the ray */
  83635. length?: number);
  83636. /**
  83637. * Checks if the ray intersects a box
  83638. * @param minimum bound of the box
  83639. * @param maximum bound of the box
  83640. * @param intersectionTreshold extra extend to be added to the box in all direction
  83641. * @returns if the box was hit
  83642. */
  83643. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83644. /**
  83645. * Checks if the ray intersects a box
  83646. * @param box the bounding box to check
  83647. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83648. * @returns if the box was hit
  83649. */
  83650. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83651. /**
  83652. * If the ray hits a sphere
  83653. * @param sphere the bounding sphere to check
  83654. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83655. * @returns true if it hits the sphere
  83656. */
  83657. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83658. /**
  83659. * If the ray hits a triange
  83660. * @param vertex0 triangle vertex
  83661. * @param vertex1 triangle vertex
  83662. * @param vertex2 triangle vertex
  83663. * @returns intersection information if hit
  83664. */
  83665. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83666. /**
  83667. * Checks if ray intersects a plane
  83668. * @param plane the plane to check
  83669. * @returns the distance away it was hit
  83670. */
  83671. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83672. /**
  83673. * Calculate the intercept of a ray on a given axis
  83674. * @param axis to check 'x' | 'y' | 'z'
  83675. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83676. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83677. */
  83678. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83679. /**
  83680. * Checks if ray intersects a mesh
  83681. * @param mesh the mesh to check
  83682. * @param fastCheck if only the bounding box should checked
  83683. * @returns picking info of the intersecton
  83684. */
  83685. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83686. /**
  83687. * Checks if ray intersects a mesh
  83688. * @param meshes the meshes to check
  83689. * @param fastCheck if only the bounding box should checked
  83690. * @param results array to store result in
  83691. * @returns Array of picking infos
  83692. */
  83693. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83694. private _comparePickingInfo;
  83695. private static smallnum;
  83696. private static rayl;
  83697. /**
  83698. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83699. * @param sega the first point of the segment to test the intersection against
  83700. * @param segb the second point of the segment to test the intersection against
  83701. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83702. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83703. */
  83704. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83705. /**
  83706. * Update the ray from viewport position
  83707. * @param x position
  83708. * @param y y position
  83709. * @param viewportWidth viewport width
  83710. * @param viewportHeight viewport height
  83711. * @param world world matrix
  83712. * @param view view matrix
  83713. * @param projection projection matrix
  83714. * @returns this ray updated
  83715. */
  83716. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83717. /**
  83718. * Creates a ray with origin and direction of 0,0,0
  83719. * @returns the new ray
  83720. */
  83721. static Zero(): Ray;
  83722. /**
  83723. * Creates a new ray from screen space and viewport
  83724. * @param x position
  83725. * @param y y position
  83726. * @param viewportWidth viewport width
  83727. * @param viewportHeight viewport height
  83728. * @param world world matrix
  83729. * @param view view matrix
  83730. * @param projection projection matrix
  83731. * @returns new ray
  83732. */
  83733. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83734. /**
  83735. * 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
  83736. * transformed to the given world matrix.
  83737. * @param origin The origin point
  83738. * @param end The end point
  83739. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83740. * @returns the new ray
  83741. */
  83742. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83743. /**
  83744. * Transforms a ray by a matrix
  83745. * @param ray ray to transform
  83746. * @param matrix matrix to apply
  83747. * @returns the resulting new ray
  83748. */
  83749. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83750. /**
  83751. * Transforms a ray by a matrix
  83752. * @param ray ray to transform
  83753. * @param matrix matrix to apply
  83754. * @param result ray to store result in
  83755. */
  83756. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83757. /**
  83758. * Unproject a ray from screen space to object space
  83759. * @param sourceX defines the screen space x coordinate to use
  83760. * @param sourceY defines the screen space y coordinate to use
  83761. * @param viewportWidth defines the current width of the viewport
  83762. * @param viewportHeight defines the current height of the viewport
  83763. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83764. * @param view defines the view matrix to use
  83765. * @param projection defines the projection matrix to use
  83766. */
  83767. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83768. }
  83769. /**
  83770. * Type used to define predicate used to select faces when a mesh intersection is detected
  83771. */
  83772. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83773. interface Scene {
  83774. /** @hidden */
  83775. _tempPickingRay: Nullable<Ray>;
  83776. /** @hidden */
  83777. _cachedRayForTransform: Ray;
  83778. /** @hidden */
  83779. _pickWithRayInverseMatrix: Matrix;
  83780. /** @hidden */
  83781. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83782. /** @hidden */
  83783. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83784. }
  83785. }
  83786. declare module BABYLON {
  83787. /**
  83788. * Groups all the scene component constants in one place to ease maintenance.
  83789. * @hidden
  83790. */
  83791. export class SceneComponentConstants {
  83792. static readonly NAME_EFFECTLAYER: string;
  83793. static readonly NAME_LAYER: string;
  83794. static readonly NAME_LENSFLARESYSTEM: string;
  83795. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83796. static readonly NAME_PARTICLESYSTEM: string;
  83797. static readonly NAME_GAMEPAD: string;
  83798. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83799. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83800. static readonly NAME_DEPTHRENDERER: string;
  83801. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83802. static readonly NAME_SPRITE: string;
  83803. static readonly NAME_OUTLINERENDERER: string;
  83804. static readonly NAME_PROCEDURALTEXTURE: string;
  83805. static readonly NAME_SHADOWGENERATOR: string;
  83806. static readonly NAME_OCTREE: string;
  83807. static readonly NAME_PHYSICSENGINE: string;
  83808. static readonly NAME_AUDIO: string;
  83809. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83810. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83811. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83812. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83813. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83814. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83815. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83816. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83817. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83818. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83819. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83820. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83821. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83822. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83823. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83824. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83825. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83826. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83827. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83828. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83829. static readonly STEP_AFTERRENDER_AUDIO: number;
  83830. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83831. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83832. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83833. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83834. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83835. static readonly STEP_POINTERMOVE_SPRITE: number;
  83836. static readonly STEP_POINTERDOWN_SPRITE: number;
  83837. static readonly STEP_POINTERUP_SPRITE: number;
  83838. }
  83839. /**
  83840. * This represents a scene component.
  83841. *
  83842. * This is used to decouple the dependency the scene is having on the different workloads like
  83843. * layers, post processes...
  83844. */
  83845. export interface ISceneComponent {
  83846. /**
  83847. * The name of the component. Each component must have a unique name.
  83848. */
  83849. name: string;
  83850. /**
  83851. * The scene the component belongs to.
  83852. */
  83853. scene: Scene;
  83854. /**
  83855. * Register the component to one instance of a scene.
  83856. */
  83857. register(): void;
  83858. /**
  83859. * Rebuilds the elements related to this component in case of
  83860. * context lost for instance.
  83861. */
  83862. rebuild(): void;
  83863. /**
  83864. * Disposes the component and the associated ressources.
  83865. */
  83866. dispose(): void;
  83867. }
  83868. /**
  83869. * This represents a SERIALIZABLE scene component.
  83870. *
  83871. * This extends Scene Component to add Serialization methods on top.
  83872. */
  83873. export interface ISceneSerializableComponent extends ISceneComponent {
  83874. /**
  83875. * Adds all the elements from the container to the scene
  83876. * @param container the container holding the elements
  83877. */
  83878. addFromContainer(container: AbstractScene): void;
  83879. /**
  83880. * Removes all the elements in the container from the scene
  83881. * @param container contains the elements to remove
  83882. * @param dispose if the removed element should be disposed (default: false)
  83883. */
  83884. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83885. /**
  83886. * Serializes the component data to the specified json object
  83887. * @param serializationObject The object to serialize to
  83888. */
  83889. serialize(serializationObject: any): void;
  83890. }
  83891. /**
  83892. * Strong typing of a Mesh related stage step action
  83893. */
  83894. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83895. /**
  83896. * Strong typing of a Evaluate Sub Mesh related stage step action
  83897. */
  83898. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83899. /**
  83900. * Strong typing of a Active Mesh related stage step action
  83901. */
  83902. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83903. /**
  83904. * Strong typing of a Camera related stage step action
  83905. */
  83906. export type CameraStageAction = (camera: Camera) => void;
  83907. /**
  83908. * Strong typing of a Camera Frame buffer related stage step action
  83909. */
  83910. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83911. /**
  83912. * Strong typing of a Render Target related stage step action
  83913. */
  83914. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83915. /**
  83916. * Strong typing of a RenderingGroup related stage step action
  83917. */
  83918. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83919. /**
  83920. * Strong typing of a Mesh Render related stage step action
  83921. */
  83922. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83923. /**
  83924. * Strong typing of a simple stage step action
  83925. */
  83926. export type SimpleStageAction = () => void;
  83927. /**
  83928. * Strong typing of a render target action.
  83929. */
  83930. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83931. /**
  83932. * Strong typing of a pointer move action.
  83933. */
  83934. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83935. /**
  83936. * Strong typing of a pointer up/down action.
  83937. */
  83938. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83939. /**
  83940. * Representation of a stage in the scene (Basically a list of ordered steps)
  83941. * @hidden
  83942. */
  83943. export class Stage<T extends Function> extends Array<{
  83944. index: number;
  83945. component: ISceneComponent;
  83946. action: T;
  83947. }> {
  83948. /**
  83949. * Hide ctor from the rest of the world.
  83950. * @param items The items to add.
  83951. */
  83952. private constructor();
  83953. /**
  83954. * Creates a new Stage.
  83955. * @returns A new instance of a Stage
  83956. */
  83957. static Create<T extends Function>(): Stage<T>;
  83958. /**
  83959. * Registers a step in an ordered way in the targeted stage.
  83960. * @param index Defines the position to register the step in
  83961. * @param component Defines the component attached to the step
  83962. * @param action Defines the action to launch during the step
  83963. */
  83964. registerStep(index: number, component: ISceneComponent, action: T): void;
  83965. /**
  83966. * Clears all the steps from the stage.
  83967. */
  83968. clear(): void;
  83969. }
  83970. }
  83971. declare module BABYLON {
  83972. interface Scene {
  83973. /** @hidden */
  83974. _pointerOverSprite: Nullable<Sprite>;
  83975. /** @hidden */
  83976. _pickedDownSprite: Nullable<Sprite>;
  83977. /** @hidden */
  83978. _tempSpritePickingRay: Nullable<Ray>;
  83979. /**
  83980. * All of the sprite managers added to this scene
  83981. * @see http://doc.babylonjs.com/babylon101/sprites
  83982. */
  83983. spriteManagers: Array<ISpriteManager>;
  83984. /**
  83985. * An event triggered when sprites rendering is about to start
  83986. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83987. */
  83988. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83989. /**
  83990. * An event triggered when sprites rendering is done
  83991. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83992. */
  83993. onAfterSpritesRenderingObservable: Observable<Scene>;
  83994. /** @hidden */
  83995. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83996. /** Launch a ray to try to pick a sprite in the scene
  83997. * @param x position on screen
  83998. * @param y position on screen
  83999. * @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
  84000. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84001. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84002. * @returns a PickingInfo
  84003. */
  84004. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84005. /** Use the given ray to pick a sprite in the scene
  84006. * @param ray The ray (in world space) to use to pick meshes
  84007. * @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
  84008. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84009. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84010. * @returns a PickingInfo
  84011. */
  84012. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84013. /** @hidden */
  84014. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84015. /** Launch a ray to try to pick sprites in the scene
  84016. * @param x position on screen
  84017. * @param y position on screen
  84018. * @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
  84019. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84020. * @returns a PickingInfo array
  84021. */
  84022. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84023. /** Use the given ray to pick sprites in the scene
  84024. * @param ray The ray (in world space) to use to pick meshes
  84025. * @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
  84026. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84027. * @returns a PickingInfo array
  84028. */
  84029. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84030. /**
  84031. * Force the sprite under the pointer
  84032. * @param sprite defines the sprite to use
  84033. */
  84034. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84035. /**
  84036. * Gets the sprite under the pointer
  84037. * @returns a Sprite or null if no sprite is under the pointer
  84038. */
  84039. getPointerOverSprite(): Nullable<Sprite>;
  84040. }
  84041. /**
  84042. * Defines the sprite scene component responsible to manage sprites
  84043. * in a given scene.
  84044. */
  84045. export class SpriteSceneComponent implements ISceneComponent {
  84046. /**
  84047. * The component name helpfull to identify the component in the list of scene components.
  84048. */
  84049. readonly name: string;
  84050. /**
  84051. * The scene the component belongs to.
  84052. */
  84053. scene: Scene;
  84054. /** @hidden */
  84055. private _spritePredicate;
  84056. /**
  84057. * Creates a new instance of the component for the given scene
  84058. * @param scene Defines the scene to register the component in
  84059. */
  84060. constructor(scene: Scene);
  84061. /**
  84062. * Registers the component in a given scene
  84063. */
  84064. register(): void;
  84065. /**
  84066. * Rebuilds the elements related to this component in case of
  84067. * context lost for instance.
  84068. */
  84069. rebuild(): void;
  84070. /**
  84071. * Disposes the component and the associated ressources.
  84072. */
  84073. dispose(): void;
  84074. private _pickSpriteButKeepRay;
  84075. private _pointerMove;
  84076. private _pointerDown;
  84077. private _pointerUp;
  84078. }
  84079. }
  84080. declare module BABYLON {
  84081. /** @hidden */
  84082. export var fogFragmentDeclaration: {
  84083. name: string;
  84084. shader: string;
  84085. };
  84086. }
  84087. declare module BABYLON {
  84088. /** @hidden */
  84089. export var fogFragment: {
  84090. name: string;
  84091. shader: string;
  84092. };
  84093. }
  84094. declare module BABYLON {
  84095. /** @hidden */
  84096. export var spritesPixelShader: {
  84097. name: string;
  84098. shader: string;
  84099. };
  84100. }
  84101. declare module BABYLON {
  84102. /** @hidden */
  84103. export var fogVertexDeclaration: {
  84104. name: string;
  84105. shader: string;
  84106. };
  84107. }
  84108. declare module BABYLON {
  84109. /** @hidden */
  84110. export var spritesVertexShader: {
  84111. name: string;
  84112. shader: string;
  84113. };
  84114. }
  84115. declare module BABYLON {
  84116. /**
  84117. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84118. */
  84119. export interface ISpriteManager extends IDisposable {
  84120. /**
  84121. * Restricts the camera to viewing objects with the same layerMask.
  84122. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84123. */
  84124. layerMask: number;
  84125. /**
  84126. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84127. */
  84128. isPickable: boolean;
  84129. /**
  84130. * Specifies the rendering group id for this mesh (0 by default)
  84131. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84132. */
  84133. renderingGroupId: number;
  84134. /**
  84135. * Defines the list of sprites managed by the manager.
  84136. */
  84137. sprites: Array<Sprite>;
  84138. /**
  84139. * Tests the intersection of a sprite with a specific ray.
  84140. * @param ray The ray we are sending to test the collision
  84141. * @param camera The camera space we are sending rays in
  84142. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84143. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84144. * @returns picking info or null.
  84145. */
  84146. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84147. /**
  84148. * Intersects the sprites with a ray
  84149. * @param ray defines the ray to intersect with
  84150. * @param camera defines the current active camera
  84151. * @param predicate defines a predicate used to select candidate sprites
  84152. * @returns null if no hit or a PickingInfo array
  84153. */
  84154. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84155. /**
  84156. * Renders the list of sprites on screen.
  84157. */
  84158. render(): void;
  84159. }
  84160. /**
  84161. * Class used to manage multiple sprites on the same spritesheet
  84162. * @see http://doc.babylonjs.com/babylon101/sprites
  84163. */
  84164. export class SpriteManager implements ISpriteManager {
  84165. /** defines the manager's name */
  84166. name: string;
  84167. /** Gets the list of sprites */
  84168. sprites: Sprite[];
  84169. /** Gets or sets the rendering group id (0 by default) */
  84170. renderingGroupId: number;
  84171. /** Gets or sets camera layer mask */
  84172. layerMask: number;
  84173. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84174. fogEnabled: boolean;
  84175. /** Gets or sets a boolean indicating if the sprites are pickable */
  84176. isPickable: boolean;
  84177. /** Defines the default width of a cell in the spritesheet */
  84178. cellWidth: number;
  84179. /** Defines the default height of a cell in the spritesheet */
  84180. cellHeight: number;
  84181. /** Associative array from JSON sprite data file */
  84182. private _cellData;
  84183. /** Array of sprite names from JSON sprite data file */
  84184. private _spriteMap;
  84185. /** True when packed cell data from JSON file is ready*/
  84186. private _packedAndReady;
  84187. /**
  84188. * An event triggered when the manager is disposed.
  84189. */
  84190. onDisposeObservable: Observable<SpriteManager>;
  84191. private _onDisposeObserver;
  84192. /**
  84193. * Callback called when the manager is disposed
  84194. */
  84195. set onDispose(callback: () => void);
  84196. private _capacity;
  84197. private _fromPacked;
  84198. private _spriteTexture;
  84199. private _epsilon;
  84200. private _scene;
  84201. private _vertexData;
  84202. private _buffer;
  84203. private _vertexBuffers;
  84204. private _indexBuffer;
  84205. private _effectBase;
  84206. private _effectFog;
  84207. /**
  84208. * Gets or sets the spritesheet texture
  84209. */
  84210. get texture(): Texture;
  84211. set texture(value: Texture);
  84212. /**
  84213. * Creates a new sprite manager
  84214. * @param name defines the manager's name
  84215. * @param imgUrl defines the sprite sheet url
  84216. * @param capacity defines the maximum allowed number of sprites
  84217. * @param cellSize defines the size of a sprite cell
  84218. * @param scene defines the hosting scene
  84219. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84220. * @param samplingMode defines the smapling mode to use with spritesheet
  84221. * @param fromPacked set to false; do not alter
  84222. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84223. */
  84224. constructor(
  84225. /** defines the manager's name */
  84226. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84227. private _makePacked;
  84228. private _appendSpriteVertex;
  84229. /**
  84230. * Intersects the sprites with a ray
  84231. * @param ray defines the ray to intersect with
  84232. * @param camera defines the current active camera
  84233. * @param predicate defines a predicate used to select candidate sprites
  84234. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84235. * @returns null if no hit or a PickingInfo
  84236. */
  84237. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84238. /**
  84239. * Intersects the sprites with a ray
  84240. * @param ray defines the ray to intersect with
  84241. * @param camera defines the current active camera
  84242. * @param predicate defines a predicate used to select candidate sprites
  84243. * @returns null if no hit or a PickingInfo array
  84244. */
  84245. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84246. /**
  84247. * Render all child sprites
  84248. */
  84249. render(): void;
  84250. /**
  84251. * Release associated resources
  84252. */
  84253. dispose(): void;
  84254. }
  84255. }
  84256. declare module BABYLON {
  84257. /**
  84258. * Class used to represent a sprite
  84259. * @see http://doc.babylonjs.com/babylon101/sprites
  84260. */
  84261. export class Sprite {
  84262. /** defines the name */
  84263. name: string;
  84264. /** Gets or sets the current world position */
  84265. position: Vector3;
  84266. /** Gets or sets the main color */
  84267. color: Color4;
  84268. /** Gets or sets the width */
  84269. width: number;
  84270. /** Gets or sets the height */
  84271. height: number;
  84272. /** Gets or sets rotation angle */
  84273. angle: number;
  84274. /** Gets or sets the cell index in the sprite sheet */
  84275. cellIndex: number;
  84276. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  84277. cellRef: string;
  84278. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  84279. invertU: number;
  84280. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  84281. invertV: number;
  84282. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  84283. disposeWhenFinishedAnimating: boolean;
  84284. /** Gets the list of attached animations */
  84285. animations: Animation[];
  84286. /** Gets or sets a boolean indicating if the sprite can be picked */
  84287. isPickable: boolean;
  84288. /**
  84289. * Gets or sets the associated action manager
  84290. */
  84291. actionManager: Nullable<ActionManager>;
  84292. private _animationStarted;
  84293. private _loopAnimation;
  84294. private _fromIndex;
  84295. private _toIndex;
  84296. private _delay;
  84297. private _direction;
  84298. private _manager;
  84299. private _time;
  84300. private _onAnimationEnd;
  84301. /**
  84302. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  84303. */
  84304. isVisible: boolean;
  84305. /**
  84306. * Gets or sets the sprite size
  84307. */
  84308. get size(): number;
  84309. set size(value: number);
  84310. /**
  84311. * Creates a new Sprite
  84312. * @param name defines the name
  84313. * @param manager defines the manager
  84314. */
  84315. constructor(
  84316. /** defines the name */
  84317. name: string, manager: ISpriteManager);
  84318. /**
  84319. * Starts an animation
  84320. * @param from defines the initial key
  84321. * @param to defines the end key
  84322. * @param loop defines if the animation must loop
  84323. * @param delay defines the start delay (in ms)
  84324. * @param onAnimationEnd defines a callback to call when animation ends
  84325. */
  84326. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  84327. /** Stops current animation (if any) */
  84328. stopAnimation(): void;
  84329. /** @hidden */
  84330. _animate(deltaTime: number): void;
  84331. /** Release associated resources */
  84332. dispose(): void;
  84333. }
  84334. }
  84335. declare module BABYLON {
  84336. /**
  84337. * Information about the result of picking within a scene
  84338. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  84339. */
  84340. export class PickingInfo {
  84341. /** @hidden */
  84342. _pickingUnavailable: boolean;
  84343. /**
  84344. * If the pick collided with an object
  84345. */
  84346. hit: boolean;
  84347. /**
  84348. * Distance away where the pick collided
  84349. */
  84350. distance: number;
  84351. /**
  84352. * The location of pick collision
  84353. */
  84354. pickedPoint: Nullable<Vector3>;
  84355. /**
  84356. * The mesh corresponding the the pick collision
  84357. */
  84358. pickedMesh: Nullable<AbstractMesh>;
  84359. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  84360. bu: number;
  84361. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  84362. bv: number;
  84363. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  84364. faceId: number;
  84365. /** Id of the the submesh that was picked */
  84366. subMeshId: number;
  84367. /** If a sprite was picked, this will be the sprite the pick collided with */
  84368. pickedSprite: Nullable<Sprite>;
  84369. /**
  84370. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  84371. */
  84372. originMesh: Nullable<AbstractMesh>;
  84373. /**
  84374. * The ray that was used to perform the picking.
  84375. */
  84376. ray: Nullable<Ray>;
  84377. /**
  84378. * Gets the normal correspodning to the face the pick collided with
  84379. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  84380. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  84381. * @returns The normal correspodning to the face the pick collided with
  84382. */
  84383. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  84384. /**
  84385. * Gets the texture coordinates of where the pick occured
  84386. * @returns the vector containing the coordnates of the texture
  84387. */
  84388. getTextureCoordinates(): Nullable<Vector2>;
  84389. }
  84390. }
  84391. declare module BABYLON {
  84392. /**
  84393. * Gather the list of pointer event types as constants.
  84394. */
  84395. export class PointerEventTypes {
  84396. /**
  84397. * 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.
  84398. */
  84399. static readonly POINTERDOWN: number;
  84400. /**
  84401. * The pointerup event is fired when a pointer is no longer active.
  84402. */
  84403. static readonly POINTERUP: number;
  84404. /**
  84405. * The pointermove event is fired when a pointer changes coordinates.
  84406. */
  84407. static readonly POINTERMOVE: number;
  84408. /**
  84409. * The pointerwheel event is fired when a mouse wheel has been rotated.
  84410. */
  84411. static readonly POINTERWHEEL: number;
  84412. /**
  84413. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  84414. */
  84415. static readonly POINTERPICK: number;
  84416. /**
  84417. * The pointertap event is fired when a the object has been touched and released without drag.
  84418. */
  84419. static readonly POINTERTAP: number;
  84420. /**
  84421. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  84422. */
  84423. static readonly POINTERDOUBLETAP: number;
  84424. }
  84425. /**
  84426. * Base class of pointer info types.
  84427. */
  84428. export class PointerInfoBase {
  84429. /**
  84430. * Defines the type of event (PointerEventTypes)
  84431. */
  84432. type: number;
  84433. /**
  84434. * Defines the related dom event
  84435. */
  84436. event: PointerEvent | MouseWheelEvent;
  84437. /**
  84438. * Instantiates the base class of pointers info.
  84439. * @param type Defines the type of event (PointerEventTypes)
  84440. * @param event Defines the related dom event
  84441. */
  84442. constructor(
  84443. /**
  84444. * Defines the type of event (PointerEventTypes)
  84445. */
  84446. type: number,
  84447. /**
  84448. * Defines the related dom event
  84449. */
  84450. event: PointerEvent | MouseWheelEvent);
  84451. }
  84452. /**
  84453. * This class is used to store pointer related info for the onPrePointerObservable event.
  84454. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  84455. */
  84456. export class PointerInfoPre extends PointerInfoBase {
  84457. /**
  84458. * Ray from a pointer if availible (eg. 6dof controller)
  84459. */
  84460. ray: Nullable<Ray>;
  84461. /**
  84462. * Defines the local position of the pointer on the canvas.
  84463. */
  84464. localPosition: Vector2;
  84465. /**
  84466. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  84467. */
  84468. skipOnPointerObservable: boolean;
  84469. /**
  84470. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  84471. * @param type Defines the type of event (PointerEventTypes)
  84472. * @param event Defines the related dom event
  84473. * @param localX Defines the local x coordinates of the pointer when the event occured
  84474. * @param localY Defines the local y coordinates of the pointer when the event occured
  84475. */
  84476. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  84477. }
  84478. /**
  84479. * This type contains all the data related to a pointer event in Babylon.js.
  84480. * 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.
  84481. */
  84482. export class PointerInfo extends PointerInfoBase {
  84483. /**
  84484. * Defines the picking info associated to the info (if any)\
  84485. */
  84486. pickInfo: Nullable<PickingInfo>;
  84487. /**
  84488. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  84489. * @param type Defines the type of event (PointerEventTypes)
  84490. * @param event Defines the related dom event
  84491. * @param pickInfo Defines the picking info associated to the info (if any)\
  84492. */
  84493. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  84494. /**
  84495. * Defines the picking info associated to the info (if any)\
  84496. */
  84497. pickInfo: Nullable<PickingInfo>);
  84498. }
  84499. /**
  84500. * Data relating to a touch event on the screen.
  84501. */
  84502. export interface PointerTouch {
  84503. /**
  84504. * X coordinate of touch.
  84505. */
  84506. x: number;
  84507. /**
  84508. * Y coordinate of touch.
  84509. */
  84510. y: number;
  84511. /**
  84512. * Id of touch. Unique for each finger.
  84513. */
  84514. pointerId: number;
  84515. /**
  84516. * Event type passed from DOM.
  84517. */
  84518. type: any;
  84519. }
  84520. }
  84521. declare module BABYLON {
  84522. /**
  84523. * Manage the mouse inputs to control the movement of a free camera.
  84524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84525. */
  84526. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  84527. /**
  84528. * Define if touch is enabled in the mouse input
  84529. */
  84530. touchEnabled: boolean;
  84531. /**
  84532. * Defines the camera the input is attached to.
  84533. */
  84534. camera: FreeCamera;
  84535. /**
  84536. * Defines the buttons associated with the input to handle camera move.
  84537. */
  84538. buttons: number[];
  84539. /**
  84540. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  84541. */
  84542. angularSensibility: number;
  84543. private _pointerInput;
  84544. private _onMouseMove;
  84545. private _observer;
  84546. private previousPosition;
  84547. /**
  84548. * Observable for when a pointer move event occurs containing the move offset
  84549. */
  84550. onPointerMovedObservable: Observable<{
  84551. offsetX: number;
  84552. offsetY: number;
  84553. }>;
  84554. /**
  84555. * @hidden
  84556. * If the camera should be rotated automatically based on pointer movement
  84557. */
  84558. _allowCameraRotation: boolean;
  84559. /**
  84560. * Manage the mouse inputs to control the movement of a free camera.
  84561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84562. * @param touchEnabled Defines if touch is enabled or not
  84563. */
  84564. constructor(
  84565. /**
  84566. * Define if touch is enabled in the mouse input
  84567. */
  84568. touchEnabled?: boolean);
  84569. /**
  84570. * Attach the input controls to a specific dom element to get the input from.
  84571. * @param element Defines the element the controls should be listened from
  84572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84573. */
  84574. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84575. /**
  84576. * Called on JS contextmenu event.
  84577. * Override this method to provide functionality.
  84578. */
  84579. protected onContextMenu(evt: PointerEvent): void;
  84580. /**
  84581. * Detach the current controls from the specified dom element.
  84582. * @param element Defines the element to stop listening the inputs from
  84583. */
  84584. detachControl(element: Nullable<HTMLElement>): void;
  84585. /**
  84586. * Gets the class name of the current intput.
  84587. * @returns the class name
  84588. */
  84589. getClassName(): string;
  84590. /**
  84591. * Get the friendly name associated with the input class.
  84592. * @returns the input friendly name
  84593. */
  84594. getSimpleName(): string;
  84595. }
  84596. }
  84597. declare module BABYLON {
  84598. /**
  84599. * Manage the touch inputs to control the movement of a free camera.
  84600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84601. */
  84602. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  84603. /**
  84604. * Defines the camera the input is attached to.
  84605. */
  84606. camera: FreeCamera;
  84607. /**
  84608. * Defines the touch sensibility for rotation.
  84609. * The higher the faster.
  84610. */
  84611. touchAngularSensibility: number;
  84612. /**
  84613. * Defines the touch sensibility for move.
  84614. * The higher the faster.
  84615. */
  84616. touchMoveSensibility: number;
  84617. private _offsetX;
  84618. private _offsetY;
  84619. private _pointerPressed;
  84620. private _pointerInput;
  84621. private _observer;
  84622. private _onLostFocus;
  84623. /**
  84624. * Attach the input controls to a specific dom element to get the input from.
  84625. * @param element Defines the element the controls should be listened from
  84626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84627. */
  84628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84629. /**
  84630. * Detach the current controls from the specified dom element.
  84631. * @param element Defines the element to stop listening the inputs from
  84632. */
  84633. detachControl(element: Nullable<HTMLElement>): void;
  84634. /**
  84635. * Update the current camera state depending on the inputs that have been used this frame.
  84636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84637. */
  84638. checkInputs(): void;
  84639. /**
  84640. * Gets the class name of the current intput.
  84641. * @returns the class name
  84642. */
  84643. getClassName(): string;
  84644. /**
  84645. * Get the friendly name associated with the input class.
  84646. * @returns the input friendly name
  84647. */
  84648. getSimpleName(): string;
  84649. }
  84650. }
  84651. declare module BABYLON {
  84652. /**
  84653. * Default Inputs manager for the FreeCamera.
  84654. * It groups all the default supported inputs for ease of use.
  84655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84656. */
  84657. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  84658. /**
  84659. * @hidden
  84660. */
  84661. _mouseInput: Nullable<FreeCameraMouseInput>;
  84662. /**
  84663. * Instantiates a new FreeCameraInputsManager.
  84664. * @param camera Defines the camera the inputs belong to
  84665. */
  84666. constructor(camera: FreeCamera);
  84667. /**
  84668. * Add keyboard input support to the input manager.
  84669. * @returns the current input manager
  84670. */
  84671. addKeyboard(): FreeCameraInputsManager;
  84672. /**
  84673. * Add mouse input support to the input manager.
  84674. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  84675. * @returns the current input manager
  84676. */
  84677. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  84678. /**
  84679. * Removes the mouse input support from the manager
  84680. * @returns the current input manager
  84681. */
  84682. removeMouse(): FreeCameraInputsManager;
  84683. /**
  84684. * Add touch input support to the input manager.
  84685. * @returns the current input manager
  84686. */
  84687. addTouch(): FreeCameraInputsManager;
  84688. /**
  84689. * Remove all attached input methods from a camera
  84690. */
  84691. clear(): void;
  84692. }
  84693. }
  84694. declare module BABYLON {
  84695. /**
  84696. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  84697. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  84698. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  84699. */
  84700. export class FreeCamera extends TargetCamera {
  84701. /**
  84702. * Define the collision ellipsoid of the camera.
  84703. * This is helpful to simulate a camera body like the player body around the camera
  84704. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  84705. */
  84706. ellipsoid: Vector3;
  84707. /**
  84708. * Define an offset for the position of the ellipsoid around the camera.
  84709. * This can be helpful to determine the center of the body near the gravity center of the body
  84710. * instead of its head.
  84711. */
  84712. ellipsoidOffset: Vector3;
  84713. /**
  84714. * Enable or disable collisions of the camera with the rest of the scene objects.
  84715. */
  84716. checkCollisions: boolean;
  84717. /**
  84718. * Enable or disable gravity on the camera.
  84719. */
  84720. applyGravity: boolean;
  84721. /**
  84722. * Define the input manager associated to the camera.
  84723. */
  84724. inputs: FreeCameraInputsManager;
  84725. /**
  84726. * Gets the input sensibility for a mouse input. (default is 2000.0)
  84727. * Higher values reduce sensitivity.
  84728. */
  84729. get angularSensibility(): number;
  84730. /**
  84731. * Sets the input sensibility for a mouse input. (default is 2000.0)
  84732. * Higher values reduce sensitivity.
  84733. */
  84734. set angularSensibility(value: number);
  84735. /**
  84736. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84737. */
  84738. get keysUp(): number[];
  84739. set keysUp(value: number[]);
  84740. /**
  84741. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84742. */
  84743. get keysDown(): number[];
  84744. set keysDown(value: number[]);
  84745. /**
  84746. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84747. */
  84748. get keysLeft(): number[];
  84749. set keysLeft(value: number[]);
  84750. /**
  84751. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84752. */
  84753. get keysRight(): number[];
  84754. set keysRight(value: number[]);
  84755. /**
  84756. * Event raised when the camera collide with a mesh in the scene.
  84757. */
  84758. onCollide: (collidedMesh: AbstractMesh) => void;
  84759. private _collider;
  84760. private _needMoveForGravity;
  84761. private _oldPosition;
  84762. private _diffPosition;
  84763. private _newPosition;
  84764. /** @hidden */
  84765. _localDirection: Vector3;
  84766. /** @hidden */
  84767. _transformedDirection: Vector3;
  84768. /**
  84769. * Instantiates a Free Camera.
  84770. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  84771. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  84772. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  84773. * @param name Define the name of the camera in the scene
  84774. * @param position Define the start position of the camera in the scene
  84775. * @param scene Define the scene the camera belongs to
  84776. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84777. */
  84778. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84779. /**
  84780. * Attached controls to the current camera.
  84781. * @param element Defines the element the controls should be listened from
  84782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84783. */
  84784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84785. /**
  84786. * Detach the current controls from the camera.
  84787. * The camera will stop reacting to inputs.
  84788. * @param element Defines the element to stop listening the inputs from
  84789. */
  84790. detachControl(element: HTMLElement): void;
  84791. private _collisionMask;
  84792. /**
  84793. * Define a collision mask to limit the list of object the camera can collide with
  84794. */
  84795. get collisionMask(): number;
  84796. set collisionMask(mask: number);
  84797. /** @hidden */
  84798. _collideWithWorld(displacement: Vector3): void;
  84799. private _onCollisionPositionChange;
  84800. /** @hidden */
  84801. _checkInputs(): void;
  84802. /** @hidden */
  84803. _decideIfNeedsToMove(): boolean;
  84804. /** @hidden */
  84805. _updatePosition(): void;
  84806. /**
  84807. * Destroy the camera and release the current resources hold by it.
  84808. */
  84809. dispose(): void;
  84810. /**
  84811. * Gets the current object class name.
  84812. * @return the class name
  84813. */
  84814. getClassName(): string;
  84815. }
  84816. }
  84817. declare module BABYLON {
  84818. /**
  84819. * Represents a gamepad control stick position
  84820. */
  84821. export class StickValues {
  84822. /**
  84823. * The x component of the control stick
  84824. */
  84825. x: number;
  84826. /**
  84827. * The y component of the control stick
  84828. */
  84829. y: number;
  84830. /**
  84831. * Initializes the gamepad x and y control stick values
  84832. * @param x The x component of the gamepad control stick value
  84833. * @param y The y component of the gamepad control stick value
  84834. */
  84835. constructor(
  84836. /**
  84837. * The x component of the control stick
  84838. */
  84839. x: number,
  84840. /**
  84841. * The y component of the control stick
  84842. */
  84843. y: number);
  84844. }
  84845. /**
  84846. * An interface which manages callbacks for gamepad button changes
  84847. */
  84848. export interface GamepadButtonChanges {
  84849. /**
  84850. * Called when a gamepad has been changed
  84851. */
  84852. changed: boolean;
  84853. /**
  84854. * Called when a gamepad press event has been triggered
  84855. */
  84856. pressChanged: boolean;
  84857. /**
  84858. * Called when a touch event has been triggered
  84859. */
  84860. touchChanged: boolean;
  84861. /**
  84862. * Called when a value has changed
  84863. */
  84864. valueChanged: boolean;
  84865. }
  84866. /**
  84867. * Represents a gamepad
  84868. */
  84869. export class Gamepad {
  84870. /**
  84871. * The id of the gamepad
  84872. */
  84873. id: string;
  84874. /**
  84875. * The index of the gamepad
  84876. */
  84877. index: number;
  84878. /**
  84879. * The browser gamepad
  84880. */
  84881. browserGamepad: any;
  84882. /**
  84883. * Specifies what type of gamepad this represents
  84884. */
  84885. type: number;
  84886. private _leftStick;
  84887. private _rightStick;
  84888. /** @hidden */
  84889. _isConnected: boolean;
  84890. private _leftStickAxisX;
  84891. private _leftStickAxisY;
  84892. private _rightStickAxisX;
  84893. private _rightStickAxisY;
  84894. /**
  84895. * Triggered when the left control stick has been changed
  84896. */
  84897. private _onleftstickchanged;
  84898. /**
  84899. * Triggered when the right control stick has been changed
  84900. */
  84901. private _onrightstickchanged;
  84902. /**
  84903. * Represents a gamepad controller
  84904. */
  84905. static GAMEPAD: number;
  84906. /**
  84907. * Represents a generic controller
  84908. */
  84909. static GENERIC: number;
  84910. /**
  84911. * Represents an XBox controller
  84912. */
  84913. static XBOX: number;
  84914. /**
  84915. * Represents a pose-enabled controller
  84916. */
  84917. static POSE_ENABLED: number;
  84918. /**
  84919. * Represents an Dual Shock controller
  84920. */
  84921. static DUALSHOCK: number;
  84922. /**
  84923. * Specifies whether the left control stick should be Y-inverted
  84924. */
  84925. protected _invertLeftStickY: boolean;
  84926. /**
  84927. * Specifies if the gamepad has been connected
  84928. */
  84929. get isConnected(): boolean;
  84930. /**
  84931. * Initializes the gamepad
  84932. * @param id The id of the gamepad
  84933. * @param index The index of the gamepad
  84934. * @param browserGamepad The browser gamepad
  84935. * @param leftStickX The x component of the left joystick
  84936. * @param leftStickY The y component of the left joystick
  84937. * @param rightStickX The x component of the right joystick
  84938. * @param rightStickY The y component of the right joystick
  84939. */
  84940. constructor(
  84941. /**
  84942. * The id of the gamepad
  84943. */
  84944. id: string,
  84945. /**
  84946. * The index of the gamepad
  84947. */
  84948. index: number,
  84949. /**
  84950. * The browser gamepad
  84951. */
  84952. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  84953. /**
  84954. * Callback triggered when the left joystick has changed
  84955. * @param callback
  84956. */
  84957. onleftstickchanged(callback: (values: StickValues) => void): void;
  84958. /**
  84959. * Callback triggered when the right joystick has changed
  84960. * @param callback
  84961. */
  84962. onrightstickchanged(callback: (values: StickValues) => void): void;
  84963. /**
  84964. * Gets the left joystick
  84965. */
  84966. get leftStick(): StickValues;
  84967. /**
  84968. * Sets the left joystick values
  84969. */
  84970. set leftStick(newValues: StickValues);
  84971. /**
  84972. * Gets the right joystick
  84973. */
  84974. get rightStick(): StickValues;
  84975. /**
  84976. * Sets the right joystick value
  84977. */
  84978. set rightStick(newValues: StickValues);
  84979. /**
  84980. * Updates the gamepad joystick positions
  84981. */
  84982. update(): void;
  84983. /**
  84984. * Disposes the gamepad
  84985. */
  84986. dispose(): void;
  84987. }
  84988. /**
  84989. * Represents a generic gamepad
  84990. */
  84991. export class GenericPad extends Gamepad {
  84992. private _buttons;
  84993. private _onbuttondown;
  84994. private _onbuttonup;
  84995. /**
  84996. * Observable triggered when a button has been pressed
  84997. */
  84998. onButtonDownObservable: Observable<number>;
  84999. /**
  85000. * Observable triggered when a button has been released
  85001. */
  85002. onButtonUpObservable: Observable<number>;
  85003. /**
  85004. * Callback triggered when a button has been pressed
  85005. * @param callback Called when a button has been pressed
  85006. */
  85007. onbuttondown(callback: (buttonPressed: number) => void): void;
  85008. /**
  85009. * Callback triggered when a button has been released
  85010. * @param callback Called when a button has been released
  85011. */
  85012. onbuttonup(callback: (buttonReleased: number) => void): void;
  85013. /**
  85014. * Initializes the generic gamepad
  85015. * @param id The id of the generic gamepad
  85016. * @param index The index of the generic gamepad
  85017. * @param browserGamepad The browser gamepad
  85018. */
  85019. constructor(id: string, index: number, browserGamepad: any);
  85020. private _setButtonValue;
  85021. /**
  85022. * Updates the generic gamepad
  85023. */
  85024. update(): void;
  85025. /**
  85026. * Disposes the generic gamepad
  85027. */
  85028. dispose(): void;
  85029. }
  85030. }
  85031. declare module BABYLON {
  85032. interface Engine {
  85033. /**
  85034. * Creates a raw texture
  85035. * @param data defines the data to store in the texture
  85036. * @param width defines the width of the texture
  85037. * @param height defines the height of the texture
  85038. * @param format defines the format of the data
  85039. * @param generateMipMaps defines if the engine should generate the mip levels
  85040. * @param invertY defines if data must be stored with Y axis inverted
  85041. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85042. * @param compression defines the compression used (null by default)
  85043. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85044. * @returns the raw texture inside an InternalTexture
  85045. */
  85046. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  85047. /**
  85048. * Update a raw texture
  85049. * @param texture defines the texture to update
  85050. * @param data defines the data to store in the texture
  85051. * @param format defines the format of the data
  85052. * @param invertY defines if data must be stored with Y axis inverted
  85053. */
  85054. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85055. /**
  85056. * Update a raw texture
  85057. * @param texture defines the texture to update
  85058. * @param data defines the data to store in the texture
  85059. * @param format defines the format of the data
  85060. * @param invertY defines if data must be stored with Y axis inverted
  85061. * @param compression defines the compression used (null by default)
  85062. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85063. */
  85064. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  85065. /**
  85066. * Creates a new raw cube texture
  85067. * @param data defines the array of data to use to create each face
  85068. * @param size defines the size of the textures
  85069. * @param format defines the format of the data
  85070. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85071. * @param generateMipMaps defines if the engine should generate the mip levels
  85072. * @param invertY defines if data must be stored with Y axis inverted
  85073. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85074. * @param compression defines the compression used (null by default)
  85075. * @returns the cube texture as an InternalTexture
  85076. */
  85077. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  85078. /**
  85079. * Update a raw cube texture
  85080. * @param texture defines the texture to udpdate
  85081. * @param data defines the data to store
  85082. * @param format defines the data format
  85083. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85084. * @param invertY defines if data must be stored with Y axis inverted
  85085. */
  85086. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  85087. /**
  85088. * Update a raw cube texture
  85089. * @param texture defines the texture to udpdate
  85090. * @param data defines the data to store
  85091. * @param format defines the data format
  85092. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85093. * @param invertY defines if data must be stored with Y axis inverted
  85094. * @param compression defines the compression used (null by default)
  85095. */
  85096. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  85097. /**
  85098. * Update a raw cube texture
  85099. * @param texture defines the texture to udpdate
  85100. * @param data defines the data to store
  85101. * @param format defines the data format
  85102. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85103. * @param invertY defines if data must be stored with Y axis inverted
  85104. * @param compression defines the compression used (null by default)
  85105. * @param level defines which level of the texture to update
  85106. */
  85107. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  85108. /**
  85109. * Creates a new raw cube texture from a specified url
  85110. * @param url defines the url where the data is located
  85111. * @param scene defines the current scene
  85112. * @param size defines the size of the textures
  85113. * @param format defines the format of the data
  85114. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85115. * @param noMipmap defines if the engine should avoid generating the mip levels
  85116. * @param callback defines a callback used to extract texture data from loaded data
  85117. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85118. * @param onLoad defines a callback called when texture is loaded
  85119. * @param onError defines a callback called if there is an error
  85120. * @returns the cube texture as an InternalTexture
  85121. */
  85122. 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;
  85123. /**
  85124. * Creates a new raw cube texture from a specified url
  85125. * @param url defines the url where the data is located
  85126. * @param scene defines the current scene
  85127. * @param size defines the size of the textures
  85128. * @param format defines the format of the data
  85129. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85130. * @param noMipmap defines if the engine should avoid generating the mip levels
  85131. * @param callback defines a callback used to extract texture data from loaded data
  85132. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85133. * @param onLoad defines a callback called when texture is loaded
  85134. * @param onError defines a callback called if there is an error
  85135. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85136. * @param invertY defines if data must be stored with Y axis inverted
  85137. * @returns the cube texture as an InternalTexture
  85138. */
  85139. 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;
  85140. /**
  85141. * Creates a new raw 3D texture
  85142. * @param data defines the data used to create the texture
  85143. * @param width defines the width of the texture
  85144. * @param height defines the height of the texture
  85145. * @param depth defines the depth of the texture
  85146. * @param format defines the format of the texture
  85147. * @param generateMipMaps defines if the engine must generate mip levels
  85148. * @param invertY defines if data must be stored with Y axis inverted
  85149. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85150. * @param compression defines the compressed used (can be null)
  85151. * @param textureType defines the compressed used (can be null)
  85152. * @returns a new raw 3D texture (stored in an InternalTexture)
  85153. */
  85154. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85155. /**
  85156. * Update a raw 3D texture
  85157. * @param texture defines the texture to update
  85158. * @param data defines the data to store
  85159. * @param format defines the data format
  85160. * @param invertY defines if data must be stored with Y axis inverted
  85161. */
  85162. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85163. /**
  85164. * Update a raw 3D texture
  85165. * @param texture defines the texture to update
  85166. * @param data defines the data to store
  85167. * @param format defines the data format
  85168. * @param invertY defines if data must be stored with Y axis inverted
  85169. * @param compression defines the used compression (can be null)
  85170. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85171. */
  85172. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85173. /**
  85174. * Creates a new raw 2D array texture
  85175. * @param data defines the data used to create the texture
  85176. * @param width defines the width of the texture
  85177. * @param height defines the height of the texture
  85178. * @param depth defines the number of layers of the texture
  85179. * @param format defines the format of the texture
  85180. * @param generateMipMaps defines if the engine must generate mip levels
  85181. * @param invertY defines if data must be stored with Y axis inverted
  85182. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85183. * @param compression defines the compressed used (can be null)
  85184. * @param textureType defines the compressed used (can be null)
  85185. * @returns a new raw 2D array texture (stored in an InternalTexture)
  85186. */
  85187. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85188. /**
  85189. * Update a raw 2D array texture
  85190. * @param texture defines the texture to update
  85191. * @param data defines the data to store
  85192. * @param format defines the data format
  85193. * @param invertY defines if data must be stored with Y axis inverted
  85194. */
  85195. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85196. /**
  85197. * Update a raw 2D array texture
  85198. * @param texture defines the texture to update
  85199. * @param data defines the data to store
  85200. * @param format defines the data format
  85201. * @param invertY defines if data must be stored with Y axis inverted
  85202. * @param compression defines the used compression (can be null)
  85203. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85204. */
  85205. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85206. }
  85207. }
  85208. declare module BABYLON {
  85209. /**
  85210. * Raw texture can help creating a texture directly from an array of data.
  85211. * This can be super useful if you either get the data from an uncompressed source or
  85212. * if you wish to create your texture pixel by pixel.
  85213. */
  85214. export class RawTexture extends Texture {
  85215. /**
  85216. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85217. */
  85218. format: number;
  85219. private _engine;
  85220. /**
  85221. * Instantiates a new RawTexture.
  85222. * Raw texture can help creating a texture directly from an array of data.
  85223. * This can be super useful if you either get the data from an uncompressed source or
  85224. * if you wish to create your texture pixel by pixel.
  85225. * @param data define the array of data to use to create the texture
  85226. * @param width define the width of the texture
  85227. * @param height define the height of the texture
  85228. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85229. * @param scene define the scene the texture belongs to
  85230. * @param generateMipMaps define whether mip maps should be generated or not
  85231. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85232. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85233. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85234. */
  85235. constructor(data: ArrayBufferView, width: number, height: number,
  85236. /**
  85237. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85238. */
  85239. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  85240. /**
  85241. * Updates the texture underlying data.
  85242. * @param data Define the new data of the texture
  85243. */
  85244. update(data: ArrayBufferView): void;
  85245. /**
  85246. * Creates a luminance texture from some data.
  85247. * @param data Define the texture data
  85248. * @param width Define the width of the texture
  85249. * @param height Define the height of the texture
  85250. * @param scene Define the scene the texture belongs to
  85251. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85252. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85253. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85254. * @returns the luminance texture
  85255. */
  85256. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85257. /**
  85258. * Creates a luminance alpha texture from some data.
  85259. * @param data Define the texture data
  85260. * @param width Define the width of the texture
  85261. * @param height Define the height of the texture
  85262. * @param scene Define the scene the texture belongs to
  85263. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85264. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85265. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85266. * @returns the luminance alpha texture
  85267. */
  85268. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85269. /**
  85270. * Creates an alpha texture from some data.
  85271. * @param data Define the texture data
  85272. * @param width Define the width of the texture
  85273. * @param height Define the height of the texture
  85274. * @param scene Define the scene the texture belongs to
  85275. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85276. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85277. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85278. * @returns the alpha texture
  85279. */
  85280. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85281. /**
  85282. * Creates a RGB texture from some data.
  85283. * @param data Define the texture data
  85284. * @param width Define the width of the texture
  85285. * @param height Define the height of the texture
  85286. * @param scene Define the scene the texture belongs to
  85287. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85288. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85289. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85290. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85291. * @returns the RGB alpha texture
  85292. */
  85293. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85294. /**
  85295. * Creates a RGBA texture from some data.
  85296. * @param data Define the texture data
  85297. * @param width Define the width of the texture
  85298. * @param height Define the height of the texture
  85299. * @param scene Define the scene the texture belongs to
  85300. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85303. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85304. * @returns the RGBA texture
  85305. */
  85306. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85307. /**
  85308. * Creates a R texture from some data.
  85309. * @param data Define the texture data
  85310. * @param width Define the width of the texture
  85311. * @param height Define the height of the texture
  85312. * @param scene Define the scene the texture belongs to
  85313. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85314. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85315. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85316. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85317. * @returns the R texture
  85318. */
  85319. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85320. }
  85321. }
  85322. declare module BABYLON {
  85323. /**
  85324. * Interface for the size containing width and height
  85325. */
  85326. export interface ISize {
  85327. /**
  85328. * Width
  85329. */
  85330. width: number;
  85331. /**
  85332. * Heighht
  85333. */
  85334. height: number;
  85335. }
  85336. /**
  85337. * Size containing widht and height
  85338. */
  85339. export class Size implements ISize {
  85340. /**
  85341. * Width
  85342. */
  85343. width: number;
  85344. /**
  85345. * Height
  85346. */
  85347. height: number;
  85348. /**
  85349. * Creates a Size object from the given width and height (floats).
  85350. * @param width width of the new size
  85351. * @param height height of the new size
  85352. */
  85353. constructor(width: number, height: number);
  85354. /**
  85355. * Returns a string with the Size width and height
  85356. * @returns a string with the Size width and height
  85357. */
  85358. toString(): string;
  85359. /**
  85360. * "Size"
  85361. * @returns the string "Size"
  85362. */
  85363. getClassName(): string;
  85364. /**
  85365. * Returns the Size hash code.
  85366. * @returns a hash code for a unique width and height
  85367. */
  85368. getHashCode(): number;
  85369. /**
  85370. * Updates the current size from the given one.
  85371. * @param src the given size
  85372. */
  85373. copyFrom(src: Size): void;
  85374. /**
  85375. * Updates in place the current Size from the given floats.
  85376. * @param width width of the new size
  85377. * @param height height of the new size
  85378. * @returns the updated Size.
  85379. */
  85380. copyFromFloats(width: number, height: number): Size;
  85381. /**
  85382. * Updates in place the current Size from the given floats.
  85383. * @param width width to set
  85384. * @param height height to set
  85385. * @returns the updated Size.
  85386. */
  85387. set(width: number, height: number): Size;
  85388. /**
  85389. * Multiplies the width and height by numbers
  85390. * @param w factor to multiple the width by
  85391. * @param h factor to multiple the height by
  85392. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85393. */
  85394. multiplyByFloats(w: number, h: number): Size;
  85395. /**
  85396. * Clones the size
  85397. * @returns a new Size copied from the given one.
  85398. */
  85399. clone(): Size;
  85400. /**
  85401. * True if the current Size and the given one width and height are strictly equal.
  85402. * @param other the other size to compare against
  85403. * @returns True if the current Size and the given one width and height are strictly equal.
  85404. */
  85405. equals(other: Size): boolean;
  85406. /**
  85407. * The surface of the Size : width * height (float).
  85408. */
  85409. get surface(): number;
  85410. /**
  85411. * Create a new size of zero
  85412. * @returns a new Size set to (0.0, 0.0)
  85413. */
  85414. static Zero(): Size;
  85415. /**
  85416. * Sums the width and height of two sizes
  85417. * @param otherSize size to add to this size
  85418. * @returns a new Size set as the addition result of the current Size and the given one.
  85419. */
  85420. add(otherSize: Size): Size;
  85421. /**
  85422. * Subtracts the width and height of two
  85423. * @param otherSize size to subtract to this size
  85424. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85425. */
  85426. subtract(otherSize: Size): Size;
  85427. /**
  85428. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85429. * @param start starting size to lerp between
  85430. * @param end end size to lerp between
  85431. * @param amount amount to lerp between the start and end values
  85432. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85433. */
  85434. static Lerp(start: Size, end: Size, amount: number): Size;
  85435. }
  85436. }
  85437. declare module BABYLON {
  85438. /**
  85439. * Defines a runtime animation
  85440. */
  85441. export class RuntimeAnimation {
  85442. private _events;
  85443. /**
  85444. * The current frame of the runtime animation
  85445. */
  85446. private _currentFrame;
  85447. /**
  85448. * The animation used by the runtime animation
  85449. */
  85450. private _animation;
  85451. /**
  85452. * The target of the runtime animation
  85453. */
  85454. private _target;
  85455. /**
  85456. * The initiating animatable
  85457. */
  85458. private _host;
  85459. /**
  85460. * The original value of the runtime animation
  85461. */
  85462. private _originalValue;
  85463. /**
  85464. * The original blend value of the runtime animation
  85465. */
  85466. private _originalBlendValue;
  85467. /**
  85468. * The offsets cache of the runtime animation
  85469. */
  85470. private _offsetsCache;
  85471. /**
  85472. * The high limits cache of the runtime animation
  85473. */
  85474. private _highLimitsCache;
  85475. /**
  85476. * Specifies if the runtime animation has been stopped
  85477. */
  85478. private _stopped;
  85479. /**
  85480. * The blending factor of the runtime animation
  85481. */
  85482. private _blendingFactor;
  85483. /**
  85484. * The BabylonJS scene
  85485. */
  85486. private _scene;
  85487. /**
  85488. * The current value of the runtime animation
  85489. */
  85490. private _currentValue;
  85491. /** @hidden */
  85492. _animationState: _IAnimationState;
  85493. /**
  85494. * The active target of the runtime animation
  85495. */
  85496. private _activeTargets;
  85497. private _currentActiveTarget;
  85498. private _directTarget;
  85499. /**
  85500. * The target path of the runtime animation
  85501. */
  85502. private _targetPath;
  85503. /**
  85504. * The weight of the runtime animation
  85505. */
  85506. private _weight;
  85507. /**
  85508. * The ratio offset of the runtime animation
  85509. */
  85510. private _ratioOffset;
  85511. /**
  85512. * The previous delay of the runtime animation
  85513. */
  85514. private _previousDelay;
  85515. /**
  85516. * The previous ratio of the runtime animation
  85517. */
  85518. private _previousRatio;
  85519. private _enableBlending;
  85520. private _keys;
  85521. private _minFrame;
  85522. private _maxFrame;
  85523. private _minValue;
  85524. private _maxValue;
  85525. private _targetIsArray;
  85526. /**
  85527. * Gets the current frame of the runtime animation
  85528. */
  85529. get currentFrame(): number;
  85530. /**
  85531. * Gets the weight of the runtime animation
  85532. */
  85533. get weight(): number;
  85534. /**
  85535. * Gets the current value of the runtime animation
  85536. */
  85537. get currentValue(): any;
  85538. /**
  85539. * Gets the target path of the runtime animation
  85540. */
  85541. get targetPath(): string;
  85542. /**
  85543. * Gets the actual target of the runtime animation
  85544. */
  85545. get target(): any;
  85546. /** @hidden */
  85547. _onLoop: () => void;
  85548. /**
  85549. * Create a new RuntimeAnimation object
  85550. * @param target defines the target of the animation
  85551. * @param animation defines the source animation object
  85552. * @param scene defines the hosting scene
  85553. * @param host defines the initiating Animatable
  85554. */
  85555. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  85556. private _preparePath;
  85557. /**
  85558. * Gets the animation from the runtime animation
  85559. */
  85560. get animation(): Animation;
  85561. /**
  85562. * Resets the runtime animation to the beginning
  85563. * @param restoreOriginal defines whether to restore the target property to the original value
  85564. */
  85565. reset(restoreOriginal?: boolean): void;
  85566. /**
  85567. * Specifies if the runtime animation is stopped
  85568. * @returns Boolean specifying if the runtime animation is stopped
  85569. */
  85570. isStopped(): boolean;
  85571. /**
  85572. * Disposes of the runtime animation
  85573. */
  85574. dispose(): void;
  85575. /**
  85576. * Apply the interpolated value to the target
  85577. * @param currentValue defines the value computed by the animation
  85578. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  85579. */
  85580. setValue(currentValue: any, weight: number): void;
  85581. private _getOriginalValues;
  85582. private _setValue;
  85583. /**
  85584. * Gets the loop pmode of the runtime animation
  85585. * @returns Loop Mode
  85586. */
  85587. private _getCorrectLoopMode;
  85588. /**
  85589. * Move the current animation to a given frame
  85590. * @param frame defines the frame to move to
  85591. */
  85592. goToFrame(frame: number): void;
  85593. /**
  85594. * @hidden Internal use only
  85595. */
  85596. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  85597. /**
  85598. * Execute the current animation
  85599. * @param delay defines the delay to add to the current frame
  85600. * @param from defines the lower bound of the animation range
  85601. * @param to defines the upper bound of the animation range
  85602. * @param loop defines if the current animation must loop
  85603. * @param speedRatio defines the current speed ratio
  85604. * @param weight defines the weight of the animation (default is -1 so no weight)
  85605. * @param onLoop optional callback called when animation loops
  85606. * @returns a boolean indicating if the animation is running
  85607. */
  85608. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  85609. }
  85610. }
  85611. declare module BABYLON {
  85612. /**
  85613. * Class used to store an actual running animation
  85614. */
  85615. export class Animatable {
  85616. /** defines the target object */
  85617. target: any;
  85618. /** defines the starting frame number (default is 0) */
  85619. fromFrame: number;
  85620. /** defines the ending frame number (default is 100) */
  85621. toFrame: number;
  85622. /** defines if the animation must loop (default is false) */
  85623. loopAnimation: boolean;
  85624. /** defines a callback to call when animation ends if it is not looping */
  85625. onAnimationEnd?: (() => void) | null | undefined;
  85626. /** defines a callback to call when animation loops */
  85627. onAnimationLoop?: (() => void) | null | undefined;
  85628. private _localDelayOffset;
  85629. private _pausedDelay;
  85630. private _runtimeAnimations;
  85631. private _paused;
  85632. private _scene;
  85633. private _speedRatio;
  85634. private _weight;
  85635. private _syncRoot;
  85636. /**
  85637. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  85638. * This will only apply for non looping animation (default is true)
  85639. */
  85640. disposeOnEnd: boolean;
  85641. /**
  85642. * Gets a boolean indicating if the animation has started
  85643. */
  85644. animationStarted: boolean;
  85645. /**
  85646. * Observer raised when the animation ends
  85647. */
  85648. onAnimationEndObservable: Observable<Animatable>;
  85649. /**
  85650. * Observer raised when the animation loops
  85651. */
  85652. onAnimationLoopObservable: Observable<Animatable>;
  85653. /**
  85654. * Gets the root Animatable used to synchronize and normalize animations
  85655. */
  85656. get syncRoot(): Nullable<Animatable>;
  85657. /**
  85658. * Gets the current frame of the first RuntimeAnimation
  85659. * Used to synchronize Animatables
  85660. */
  85661. get masterFrame(): number;
  85662. /**
  85663. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  85664. */
  85665. get weight(): number;
  85666. set weight(value: number);
  85667. /**
  85668. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  85669. */
  85670. get speedRatio(): number;
  85671. set speedRatio(value: number);
  85672. /**
  85673. * Creates a new Animatable
  85674. * @param scene defines the hosting scene
  85675. * @param target defines the target object
  85676. * @param fromFrame defines the starting frame number (default is 0)
  85677. * @param toFrame defines the ending frame number (default is 100)
  85678. * @param loopAnimation defines if the animation must loop (default is false)
  85679. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  85680. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  85681. * @param animations defines a group of animation to add to the new Animatable
  85682. * @param onAnimationLoop defines a callback to call when animation loops
  85683. */
  85684. constructor(scene: Scene,
  85685. /** defines the target object */
  85686. target: any,
  85687. /** defines the starting frame number (default is 0) */
  85688. fromFrame?: number,
  85689. /** defines the ending frame number (default is 100) */
  85690. toFrame?: number,
  85691. /** defines if the animation must loop (default is false) */
  85692. loopAnimation?: boolean, speedRatio?: number,
  85693. /** defines a callback to call when animation ends if it is not looping */
  85694. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  85695. /** defines a callback to call when animation loops */
  85696. onAnimationLoop?: (() => void) | null | undefined);
  85697. /**
  85698. * Synchronize and normalize current Animatable with a source Animatable
  85699. * This is useful when using animation weights and when animations are not of the same length
  85700. * @param root defines the root Animatable to synchronize with
  85701. * @returns the current Animatable
  85702. */
  85703. syncWith(root: Animatable): Animatable;
  85704. /**
  85705. * Gets the list of runtime animations
  85706. * @returns an array of RuntimeAnimation
  85707. */
  85708. getAnimations(): RuntimeAnimation[];
  85709. /**
  85710. * Adds more animations to the current animatable
  85711. * @param target defines the target of the animations
  85712. * @param animations defines the new animations to add
  85713. */
  85714. appendAnimations(target: any, animations: Animation[]): void;
  85715. /**
  85716. * Gets the source animation for a specific property
  85717. * @param property defines the propertyu to look for
  85718. * @returns null or the source animation for the given property
  85719. */
  85720. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  85721. /**
  85722. * Gets the runtime animation for a specific property
  85723. * @param property defines the propertyu to look for
  85724. * @returns null or the runtime animation for the given property
  85725. */
  85726. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  85727. /**
  85728. * Resets the animatable to its original state
  85729. */
  85730. reset(): void;
  85731. /**
  85732. * Allows the animatable to blend with current running animations
  85733. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85734. * @param blendingSpeed defines the blending speed to use
  85735. */
  85736. enableBlending(blendingSpeed: number): void;
  85737. /**
  85738. * Disable animation blending
  85739. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85740. */
  85741. disableBlending(): void;
  85742. /**
  85743. * Jump directly to a given frame
  85744. * @param frame defines the frame to jump to
  85745. */
  85746. goToFrame(frame: number): void;
  85747. /**
  85748. * Pause the animation
  85749. */
  85750. pause(): void;
  85751. /**
  85752. * Restart the animation
  85753. */
  85754. restart(): void;
  85755. private _raiseOnAnimationEnd;
  85756. /**
  85757. * Stop and delete the current animation
  85758. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  85759. * @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)
  85760. */
  85761. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  85762. /**
  85763. * Wait asynchronously for the animation to end
  85764. * @returns a promise which will be fullfilled when the animation ends
  85765. */
  85766. waitAsync(): Promise<Animatable>;
  85767. /** @hidden */
  85768. _animate(delay: number): boolean;
  85769. }
  85770. interface Scene {
  85771. /** @hidden */
  85772. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  85773. /** @hidden */
  85774. _processLateAnimationBindingsForMatrices(holder: {
  85775. totalWeight: number;
  85776. animations: RuntimeAnimation[];
  85777. originalValue: Matrix;
  85778. }): any;
  85779. /** @hidden */
  85780. _processLateAnimationBindingsForQuaternions(holder: {
  85781. totalWeight: number;
  85782. animations: RuntimeAnimation[];
  85783. originalValue: Quaternion;
  85784. }, refQuaternion: Quaternion): Quaternion;
  85785. /** @hidden */
  85786. _processLateAnimationBindings(): void;
  85787. /**
  85788. * Will start the animation sequence of a given target
  85789. * @param target defines the target
  85790. * @param from defines from which frame should animation start
  85791. * @param to defines until which frame should animation run.
  85792. * @param weight defines the weight to apply to the animation (1.0 by default)
  85793. * @param loop defines if the animation loops
  85794. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  85795. * @param onAnimationEnd defines the function to be executed when the animation ends
  85796. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  85797. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  85798. * @param onAnimationLoop defines the callback to call when an animation loops
  85799. * @returns the animatable object created for this animation
  85800. */
  85801. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  85802. /**
  85803. * Will start the animation sequence of a given target
  85804. * @param target defines the target
  85805. * @param from defines from which frame should animation start
  85806. * @param to defines until which frame should animation run.
  85807. * @param loop defines if the animation loops
  85808. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  85809. * @param onAnimationEnd defines the function to be executed when the animation ends
  85810. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  85811. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  85812. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  85813. * @param onAnimationLoop defines the callback to call when an animation loops
  85814. * @returns the animatable object created for this animation
  85815. */
  85816. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  85817. /**
  85818. * Will start the animation sequence of a given target and its hierarchy
  85819. * @param target defines the target
  85820. * @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.
  85821. * @param from defines from which frame should animation start
  85822. * @param to defines until which frame should animation run.
  85823. * @param loop defines if the animation loops
  85824. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  85825. * @param onAnimationEnd defines the function to be executed when the animation ends
  85826. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  85827. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  85828. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  85829. * @param onAnimationLoop defines the callback to call when an animation loops
  85830. * @returns the list of created animatables
  85831. */
  85832. 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[];
  85833. /**
  85834. * Begin a new animation on a given node
  85835. * @param target defines the target where the animation will take place
  85836. * @param animations defines the list of animations to start
  85837. * @param from defines the initial value
  85838. * @param to defines the final value
  85839. * @param loop defines if you want animation to loop (off by default)
  85840. * @param speedRatio defines the speed ratio to apply to all animations
  85841. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85842. * @param onAnimationLoop defines the callback to call when an animation loops
  85843. * @returns the list of created animatables
  85844. */
  85845. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  85846. /**
  85847. * Begin a new animation on a given node and its hierarchy
  85848. * @param target defines the root node where the animation will take place
  85849. * @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.
  85850. * @param animations defines the list of animations to start
  85851. * @param from defines the initial value
  85852. * @param to defines the final value
  85853. * @param loop defines if you want animation to loop (off by default)
  85854. * @param speedRatio defines the speed ratio to apply to all animations
  85855. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85856. * @param onAnimationLoop defines the callback to call when an animation loops
  85857. * @returns the list of animatables created for all nodes
  85858. */
  85859. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  85860. /**
  85861. * Gets the animatable associated with a specific target
  85862. * @param target defines the target of the animatable
  85863. * @returns the required animatable if found
  85864. */
  85865. getAnimatableByTarget(target: any): Nullable<Animatable>;
  85866. /**
  85867. * Gets all animatables associated with a given target
  85868. * @param target defines the target to look animatables for
  85869. * @returns an array of Animatables
  85870. */
  85871. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  85872. /**
  85873. * Stops and removes all animations that have been applied to the scene
  85874. */
  85875. stopAllAnimations(): void;
  85876. /**
  85877. * Gets the current delta time used by animation engine
  85878. */
  85879. deltaTime: number;
  85880. }
  85881. interface Bone {
  85882. /**
  85883. * Copy an animation range from another bone
  85884. * @param source defines the source bone
  85885. * @param rangeName defines the range name to copy
  85886. * @param frameOffset defines the frame offset
  85887. * @param rescaleAsRequired defines if rescaling must be applied if required
  85888. * @param skelDimensionsRatio defines the scaling ratio
  85889. * @returns true if operation was successful
  85890. */
  85891. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  85892. }
  85893. }
  85894. declare module BABYLON {
  85895. /**
  85896. * Class used to override all child animations of a given target
  85897. */
  85898. export class AnimationPropertiesOverride {
  85899. /**
  85900. * Gets or sets a value indicating if animation blending must be used
  85901. */
  85902. enableBlending: boolean;
  85903. /**
  85904. * Gets or sets the blending speed to use when enableBlending is true
  85905. */
  85906. blendingSpeed: number;
  85907. /**
  85908. * Gets or sets the default loop mode to use
  85909. */
  85910. loopMode: number;
  85911. }
  85912. }
  85913. declare module BABYLON {
  85914. /**
  85915. * Class used to handle skinning animations
  85916. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  85917. */
  85918. export class Skeleton implements IAnimatable {
  85919. /** defines the skeleton name */
  85920. name: string;
  85921. /** defines the skeleton Id */
  85922. id: string;
  85923. /**
  85924. * Defines the list of child bones
  85925. */
  85926. bones: Bone[];
  85927. /**
  85928. * Defines an estimate of the dimension of the skeleton at rest
  85929. */
  85930. dimensionsAtRest: Vector3;
  85931. /**
  85932. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  85933. */
  85934. needInitialSkinMatrix: boolean;
  85935. /**
  85936. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  85937. */
  85938. overrideMesh: Nullable<AbstractMesh>;
  85939. /**
  85940. * Gets the list of animations attached to this skeleton
  85941. */
  85942. animations: Array<Animation>;
  85943. private _scene;
  85944. private _isDirty;
  85945. private _transformMatrices;
  85946. private _transformMatrixTexture;
  85947. private _meshesWithPoseMatrix;
  85948. private _animatables;
  85949. private _identity;
  85950. private _synchronizedWithMesh;
  85951. private _ranges;
  85952. private _lastAbsoluteTransformsUpdateId;
  85953. private _canUseTextureForBones;
  85954. private _uniqueId;
  85955. /** @hidden */
  85956. _numBonesWithLinkedTransformNode: number;
  85957. /** @hidden */
  85958. _hasWaitingData: Nullable<boolean>;
  85959. /**
  85960. * Specifies if the skeleton should be serialized
  85961. */
  85962. doNotSerialize: boolean;
  85963. private _useTextureToStoreBoneMatrices;
  85964. /**
  85965. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  85966. * Please note that this option is not available if the hardware does not support it
  85967. */
  85968. get useTextureToStoreBoneMatrices(): boolean;
  85969. set useTextureToStoreBoneMatrices(value: boolean);
  85970. private _animationPropertiesOverride;
  85971. /**
  85972. * Gets or sets the animation properties override
  85973. */
  85974. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  85975. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  85976. /**
  85977. * List of inspectable custom properties (used by the Inspector)
  85978. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85979. */
  85980. inspectableCustomProperties: IInspectable[];
  85981. /**
  85982. * An observable triggered before computing the skeleton's matrices
  85983. */
  85984. onBeforeComputeObservable: Observable<Skeleton>;
  85985. /**
  85986. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  85987. */
  85988. get isUsingTextureForMatrices(): boolean;
  85989. /**
  85990. * Gets the unique ID of this skeleton
  85991. */
  85992. get uniqueId(): number;
  85993. /**
  85994. * Creates a new skeleton
  85995. * @param name defines the skeleton name
  85996. * @param id defines the skeleton Id
  85997. * @param scene defines the hosting scene
  85998. */
  85999. constructor(
  86000. /** defines the skeleton name */
  86001. name: string,
  86002. /** defines the skeleton Id */
  86003. id: string, scene: Scene);
  86004. /**
  86005. * Gets the current object class name.
  86006. * @return the class name
  86007. */
  86008. getClassName(): string;
  86009. /**
  86010. * Returns an array containing the root bones
  86011. * @returns an array containing the root bones
  86012. */
  86013. getChildren(): Array<Bone>;
  86014. /**
  86015. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  86016. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86017. * @returns a Float32Array containing matrices data
  86018. */
  86019. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  86020. /**
  86021. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  86022. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86023. * @returns a raw texture containing the data
  86024. */
  86025. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  86026. /**
  86027. * Gets the current hosting scene
  86028. * @returns a scene object
  86029. */
  86030. getScene(): Scene;
  86031. /**
  86032. * Gets a string representing the current skeleton data
  86033. * @param fullDetails defines a boolean indicating if we want a verbose version
  86034. * @returns a string representing the current skeleton data
  86035. */
  86036. toString(fullDetails?: boolean): string;
  86037. /**
  86038. * Get bone's index searching by name
  86039. * @param name defines bone's name to search for
  86040. * @return the indice of the bone. Returns -1 if not found
  86041. */
  86042. getBoneIndexByName(name: string): number;
  86043. /**
  86044. * Creater a new animation range
  86045. * @param name defines the name of the range
  86046. * @param from defines the start key
  86047. * @param to defines the end key
  86048. */
  86049. createAnimationRange(name: string, from: number, to: number): void;
  86050. /**
  86051. * Delete a specific animation range
  86052. * @param name defines the name of the range
  86053. * @param deleteFrames defines if frames must be removed as well
  86054. */
  86055. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  86056. /**
  86057. * Gets a specific animation range
  86058. * @param name defines the name of the range to look for
  86059. * @returns the requested animation range or null if not found
  86060. */
  86061. getAnimationRange(name: string): Nullable<AnimationRange>;
  86062. /**
  86063. * Gets the list of all animation ranges defined on this skeleton
  86064. * @returns an array
  86065. */
  86066. getAnimationRanges(): Nullable<AnimationRange>[];
  86067. /**
  86068. * Copy animation range from a source skeleton.
  86069. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  86070. * @param source defines the source skeleton
  86071. * @param name defines the name of the range to copy
  86072. * @param rescaleAsRequired defines if rescaling must be applied if required
  86073. * @returns true if operation was successful
  86074. */
  86075. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  86076. /**
  86077. * Forces the skeleton to go to rest pose
  86078. */
  86079. returnToRest(): void;
  86080. private _getHighestAnimationFrame;
  86081. /**
  86082. * Begin a specific animation range
  86083. * @param name defines the name of the range to start
  86084. * @param loop defines if looping must be turned on (false by default)
  86085. * @param speedRatio defines the speed ratio to apply (1 by default)
  86086. * @param onAnimationEnd defines a callback which will be called when animation will end
  86087. * @returns a new animatable
  86088. */
  86089. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  86090. /** @hidden */
  86091. _markAsDirty(): void;
  86092. /** @hidden */
  86093. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86094. /** @hidden */
  86095. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86096. private _computeTransformMatrices;
  86097. /**
  86098. * Build all resources required to render a skeleton
  86099. */
  86100. prepare(): void;
  86101. /**
  86102. * Gets the list of animatables currently running for this skeleton
  86103. * @returns an array of animatables
  86104. */
  86105. getAnimatables(): IAnimatable[];
  86106. /**
  86107. * Clone the current skeleton
  86108. * @param name defines the name of the new skeleton
  86109. * @param id defines the id of the new skeleton
  86110. * @returns the new skeleton
  86111. */
  86112. clone(name: string, id?: string): Skeleton;
  86113. /**
  86114. * Enable animation blending for this skeleton
  86115. * @param blendingSpeed defines the blending speed to apply
  86116. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86117. */
  86118. enableBlending(blendingSpeed?: number): void;
  86119. /**
  86120. * Releases all resources associated with the current skeleton
  86121. */
  86122. dispose(): void;
  86123. /**
  86124. * Serialize the skeleton in a JSON object
  86125. * @returns a JSON object
  86126. */
  86127. serialize(): any;
  86128. /**
  86129. * Creates a new skeleton from serialized data
  86130. * @param parsedSkeleton defines the serialized data
  86131. * @param scene defines the hosting scene
  86132. * @returns a new skeleton
  86133. */
  86134. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  86135. /**
  86136. * Compute all node absolute transforms
  86137. * @param forceUpdate defines if computation must be done even if cache is up to date
  86138. */
  86139. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  86140. /**
  86141. * Gets the root pose matrix
  86142. * @returns a matrix
  86143. */
  86144. getPoseMatrix(): Nullable<Matrix>;
  86145. /**
  86146. * Sorts bones per internal index
  86147. */
  86148. sortBones(): void;
  86149. private _sortBones;
  86150. }
  86151. }
  86152. declare module BABYLON {
  86153. /**
  86154. * Class used to store bone information
  86155. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86156. */
  86157. export class Bone extends Node {
  86158. /**
  86159. * defines the bone name
  86160. */
  86161. name: string;
  86162. private static _tmpVecs;
  86163. private static _tmpQuat;
  86164. private static _tmpMats;
  86165. /**
  86166. * Gets the list of child bones
  86167. */
  86168. children: Bone[];
  86169. /** Gets the animations associated with this bone */
  86170. animations: Animation[];
  86171. /**
  86172. * Gets or sets bone length
  86173. */
  86174. length: number;
  86175. /**
  86176. * @hidden Internal only
  86177. * Set this value to map this bone to a different index in the transform matrices
  86178. * Set this value to -1 to exclude the bone from the transform matrices
  86179. */
  86180. _index: Nullable<number>;
  86181. private _skeleton;
  86182. private _localMatrix;
  86183. private _restPose;
  86184. private _baseMatrix;
  86185. private _absoluteTransform;
  86186. private _invertedAbsoluteTransform;
  86187. private _parent;
  86188. private _scalingDeterminant;
  86189. private _worldTransform;
  86190. private _localScaling;
  86191. private _localRotation;
  86192. private _localPosition;
  86193. private _needToDecompose;
  86194. private _needToCompose;
  86195. /** @hidden */
  86196. _linkedTransformNode: Nullable<TransformNode>;
  86197. /** @hidden */
  86198. _waitingTransformNodeId: Nullable<string>;
  86199. /** @hidden */
  86200. get _matrix(): Matrix;
  86201. /** @hidden */
  86202. set _matrix(value: Matrix);
  86203. /**
  86204. * Create a new bone
  86205. * @param name defines the bone name
  86206. * @param skeleton defines the parent skeleton
  86207. * @param parentBone defines the parent (can be null if the bone is the root)
  86208. * @param localMatrix defines the local matrix
  86209. * @param restPose defines the rest pose matrix
  86210. * @param baseMatrix defines the base matrix
  86211. * @param index defines index of the bone in the hiearchy
  86212. */
  86213. constructor(
  86214. /**
  86215. * defines the bone name
  86216. */
  86217. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  86218. /**
  86219. * Gets the current object class name.
  86220. * @return the class name
  86221. */
  86222. getClassName(): string;
  86223. /**
  86224. * Gets the parent skeleton
  86225. * @returns a skeleton
  86226. */
  86227. getSkeleton(): Skeleton;
  86228. /**
  86229. * Gets parent bone
  86230. * @returns a bone or null if the bone is the root of the bone hierarchy
  86231. */
  86232. getParent(): Nullable<Bone>;
  86233. /**
  86234. * Returns an array containing the root bones
  86235. * @returns an array containing the root bones
  86236. */
  86237. getChildren(): Array<Bone>;
  86238. /**
  86239. * Gets the node index in matrix array generated for rendering
  86240. * @returns the node index
  86241. */
  86242. getIndex(): number;
  86243. /**
  86244. * Sets the parent bone
  86245. * @param parent defines the parent (can be null if the bone is the root)
  86246. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86247. */
  86248. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  86249. /**
  86250. * Gets the local matrix
  86251. * @returns a matrix
  86252. */
  86253. getLocalMatrix(): Matrix;
  86254. /**
  86255. * Gets the base matrix (initial matrix which remains unchanged)
  86256. * @returns a matrix
  86257. */
  86258. getBaseMatrix(): Matrix;
  86259. /**
  86260. * Gets the rest pose matrix
  86261. * @returns a matrix
  86262. */
  86263. getRestPose(): Matrix;
  86264. /**
  86265. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  86266. */
  86267. getWorldMatrix(): Matrix;
  86268. /**
  86269. * Sets the local matrix to rest pose matrix
  86270. */
  86271. returnToRest(): void;
  86272. /**
  86273. * Gets the inverse of the absolute transform matrix.
  86274. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  86275. * @returns a matrix
  86276. */
  86277. getInvertedAbsoluteTransform(): Matrix;
  86278. /**
  86279. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  86280. * @returns a matrix
  86281. */
  86282. getAbsoluteTransform(): Matrix;
  86283. /**
  86284. * Links with the given transform node.
  86285. * The local matrix of this bone is copied from the transform node every frame.
  86286. * @param transformNode defines the transform node to link to
  86287. */
  86288. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  86289. /**
  86290. * Gets the node used to drive the bone's transformation
  86291. * @returns a transform node or null
  86292. */
  86293. getTransformNode(): Nullable<TransformNode>;
  86294. /** Gets or sets current position (in local space) */
  86295. get position(): Vector3;
  86296. set position(newPosition: Vector3);
  86297. /** Gets or sets current rotation (in local space) */
  86298. get rotation(): Vector3;
  86299. set rotation(newRotation: Vector3);
  86300. /** Gets or sets current rotation quaternion (in local space) */
  86301. get rotationQuaternion(): Quaternion;
  86302. set rotationQuaternion(newRotation: Quaternion);
  86303. /** Gets or sets current scaling (in local space) */
  86304. get scaling(): Vector3;
  86305. set scaling(newScaling: Vector3);
  86306. /**
  86307. * Gets the animation properties override
  86308. */
  86309. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86310. private _decompose;
  86311. private _compose;
  86312. /**
  86313. * Update the base and local matrices
  86314. * @param matrix defines the new base or local matrix
  86315. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86316. * @param updateLocalMatrix defines if the local matrix should be updated
  86317. */
  86318. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  86319. /** @hidden */
  86320. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  86321. /**
  86322. * Flag the bone as dirty (Forcing it to update everything)
  86323. */
  86324. markAsDirty(): void;
  86325. /** @hidden */
  86326. _markAsDirtyAndCompose(): void;
  86327. private _markAsDirtyAndDecompose;
  86328. /**
  86329. * Translate the bone in local or world space
  86330. * @param vec The amount to translate the bone
  86331. * @param space The space that the translation is in
  86332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86333. */
  86334. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86335. /**
  86336. * Set the postion of the bone in local or world space
  86337. * @param position The position to set the bone
  86338. * @param space The space that the position is in
  86339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86340. */
  86341. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86342. /**
  86343. * Set the absolute position of the bone (world space)
  86344. * @param position The position to set the bone
  86345. * @param mesh The mesh that this bone is attached to
  86346. */
  86347. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  86348. /**
  86349. * Scale the bone on the x, y and z axes (in local space)
  86350. * @param x The amount to scale the bone on the x axis
  86351. * @param y The amount to scale the bone on the y axis
  86352. * @param z The amount to scale the bone on the z axis
  86353. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  86354. */
  86355. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  86356. /**
  86357. * Set the bone scaling in local space
  86358. * @param scale defines the scaling vector
  86359. */
  86360. setScale(scale: Vector3): void;
  86361. /**
  86362. * Gets the current scaling in local space
  86363. * @returns the current scaling vector
  86364. */
  86365. getScale(): Vector3;
  86366. /**
  86367. * Gets the current scaling in local space and stores it in a target vector
  86368. * @param result defines the target vector
  86369. */
  86370. getScaleToRef(result: Vector3): void;
  86371. /**
  86372. * Set the yaw, pitch, and roll of the bone in local or world space
  86373. * @param yaw The rotation of the bone on the y axis
  86374. * @param pitch The rotation of the bone on the x axis
  86375. * @param roll The rotation of the bone on the z axis
  86376. * @param space The space that the axes of rotation are in
  86377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86378. */
  86379. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  86380. /**
  86381. * Add a rotation to the bone on an axis in local or world space
  86382. * @param axis The axis to rotate the bone on
  86383. * @param amount The amount to rotate the bone
  86384. * @param space The space that the axis is in
  86385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86386. */
  86387. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  86388. /**
  86389. * Set the rotation of the bone to a particular axis angle in local or world space
  86390. * @param axis The axis to rotate the bone on
  86391. * @param angle The angle that the bone should be rotated to
  86392. * @param space The space that the axis is in
  86393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86394. */
  86395. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  86396. /**
  86397. * Set the euler rotation of the bone in local of world space
  86398. * @param rotation The euler rotation that the bone should be set to
  86399. * @param space The space that the rotation is in
  86400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86401. */
  86402. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86403. /**
  86404. * Set the quaternion rotation of the bone in local of world space
  86405. * @param quat The quaternion rotation that the bone should be set to
  86406. * @param space The space that the rotation is in
  86407. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86408. */
  86409. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  86410. /**
  86411. * Set the rotation matrix of the bone in local of world space
  86412. * @param rotMat The rotation matrix that the bone should be set to
  86413. * @param space The space that the rotation is in
  86414. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86415. */
  86416. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  86417. private _rotateWithMatrix;
  86418. private _getNegativeRotationToRef;
  86419. /**
  86420. * Get the position of the bone in local or world space
  86421. * @param space The space that the returned position is in
  86422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86423. * @returns The position of the bone
  86424. */
  86425. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86426. /**
  86427. * Copy the position of the bone to a vector3 in local or world space
  86428. * @param space The space that the returned position is in
  86429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86430. * @param result The vector3 to copy the position to
  86431. */
  86432. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  86433. /**
  86434. * Get the absolute position of the bone (world space)
  86435. * @param mesh The mesh that this bone is attached to
  86436. * @returns The absolute position of the bone
  86437. */
  86438. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  86439. /**
  86440. * Copy the absolute position of the bone (world space) to the result param
  86441. * @param mesh The mesh that this bone is attached to
  86442. * @param result The vector3 to copy the absolute position to
  86443. */
  86444. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  86445. /**
  86446. * Compute the absolute transforms of this bone and its children
  86447. */
  86448. computeAbsoluteTransforms(): void;
  86449. /**
  86450. * Get the world direction from an axis that is in the local space of the bone
  86451. * @param localAxis The local direction that is used to compute the world direction
  86452. * @param mesh The mesh that this bone is attached to
  86453. * @returns The world direction
  86454. */
  86455. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86456. /**
  86457. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  86458. * @param localAxis The local direction that is used to compute the world direction
  86459. * @param mesh The mesh that this bone is attached to
  86460. * @param result The vector3 that the world direction will be copied to
  86461. */
  86462. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86463. /**
  86464. * Get the euler rotation of the bone in local or world space
  86465. * @param space The space that the rotation should be in
  86466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86467. * @returns The euler rotation
  86468. */
  86469. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86470. /**
  86471. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  86472. * @param space The space that the rotation should be in
  86473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86474. * @param result The vector3 that the rotation should be copied to
  86475. */
  86476. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86477. /**
  86478. * Get the quaternion rotation of the bone in either local or world space
  86479. * @param space The space that the rotation should be in
  86480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86481. * @returns The quaternion rotation
  86482. */
  86483. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  86484. /**
  86485. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  86486. * @param space The space that the rotation should be in
  86487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86488. * @param result The quaternion that the rotation should be copied to
  86489. */
  86490. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  86491. /**
  86492. * Get the rotation matrix of the bone in local or world space
  86493. * @param space The space that the rotation should be in
  86494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86495. * @returns The rotation matrix
  86496. */
  86497. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  86498. /**
  86499. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  86500. * @param space The space that the rotation should be in
  86501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86502. * @param result The quaternion that the rotation should be copied to
  86503. */
  86504. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  86505. /**
  86506. * Get the world position of a point that is in the local space of the bone
  86507. * @param position The local position
  86508. * @param mesh The mesh that this bone is attached to
  86509. * @returns The world position
  86510. */
  86511. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86512. /**
  86513. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  86514. * @param position The local position
  86515. * @param mesh The mesh that this bone is attached to
  86516. * @param result The vector3 that the world position should be copied to
  86517. */
  86518. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86519. /**
  86520. * Get the local position of a point that is in world space
  86521. * @param position The world position
  86522. * @param mesh The mesh that this bone is attached to
  86523. * @returns The local position
  86524. */
  86525. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86526. /**
  86527. * Get the local position of a point that is in world space and copy it to the result param
  86528. * @param position The world position
  86529. * @param mesh The mesh that this bone is attached to
  86530. * @param result The vector3 that the local position should be copied to
  86531. */
  86532. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86533. }
  86534. }
  86535. declare module BABYLON {
  86536. /**
  86537. * 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.
  86538. * @see https://doc.babylonjs.com/how_to/transformnode
  86539. */
  86540. export class TransformNode extends Node {
  86541. /**
  86542. * Object will not rotate to face the camera
  86543. */
  86544. static BILLBOARDMODE_NONE: number;
  86545. /**
  86546. * Object will rotate to face the camera but only on the x axis
  86547. */
  86548. static BILLBOARDMODE_X: number;
  86549. /**
  86550. * Object will rotate to face the camera but only on the y axis
  86551. */
  86552. static BILLBOARDMODE_Y: number;
  86553. /**
  86554. * Object will rotate to face the camera but only on the z axis
  86555. */
  86556. static BILLBOARDMODE_Z: number;
  86557. /**
  86558. * Object will rotate to face the camera
  86559. */
  86560. static BILLBOARDMODE_ALL: number;
  86561. /**
  86562. * Object will rotate to face the camera's position instead of orientation
  86563. */
  86564. static BILLBOARDMODE_USE_POSITION: number;
  86565. private _forward;
  86566. private _forwardInverted;
  86567. private _up;
  86568. private _right;
  86569. private _rightInverted;
  86570. private _position;
  86571. private _rotation;
  86572. private _rotationQuaternion;
  86573. protected _scaling: Vector3;
  86574. protected _isDirty: boolean;
  86575. private _transformToBoneReferal;
  86576. private _isAbsoluteSynced;
  86577. private _billboardMode;
  86578. /**
  86579. * Gets or sets the billboard mode. Default is 0.
  86580. *
  86581. * | Value | Type | Description |
  86582. * | --- | --- | --- |
  86583. * | 0 | BILLBOARDMODE_NONE | |
  86584. * | 1 | BILLBOARDMODE_X | |
  86585. * | 2 | BILLBOARDMODE_Y | |
  86586. * | 4 | BILLBOARDMODE_Z | |
  86587. * | 7 | BILLBOARDMODE_ALL | |
  86588. *
  86589. */
  86590. get billboardMode(): number;
  86591. set billboardMode(value: number);
  86592. private _preserveParentRotationForBillboard;
  86593. /**
  86594. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86595. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86596. */
  86597. get preserveParentRotationForBillboard(): boolean;
  86598. set preserveParentRotationForBillboard(value: boolean);
  86599. /**
  86600. * 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
  86601. */
  86602. scalingDeterminant: number;
  86603. private _infiniteDistance;
  86604. /**
  86605. * Gets or sets the distance of the object to max, often used by skybox
  86606. */
  86607. get infiniteDistance(): boolean;
  86608. set infiniteDistance(value: boolean);
  86609. /**
  86610. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86611. * By default the system will update normals to compensate
  86612. */
  86613. ignoreNonUniformScaling: boolean;
  86614. /**
  86615. * 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
  86616. */
  86617. reIntegrateRotationIntoRotationQuaternion: boolean;
  86618. /** @hidden */
  86619. _poseMatrix: Nullable<Matrix>;
  86620. /** @hidden */
  86621. _localMatrix: Matrix;
  86622. private _usePivotMatrix;
  86623. private _absolutePosition;
  86624. private _absoluteScaling;
  86625. private _absoluteRotationQuaternion;
  86626. private _pivotMatrix;
  86627. private _pivotMatrixInverse;
  86628. protected _postMultiplyPivotMatrix: boolean;
  86629. protected _isWorldMatrixFrozen: boolean;
  86630. /** @hidden */
  86631. _indexInSceneTransformNodesArray: number;
  86632. /**
  86633. * An event triggered after the world matrix is updated
  86634. */
  86635. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86636. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86637. /**
  86638. * Gets a string identifying the name of the class
  86639. * @returns "TransformNode" string
  86640. */
  86641. getClassName(): string;
  86642. /**
  86643. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86644. */
  86645. get position(): Vector3;
  86646. set position(newPosition: Vector3);
  86647. /**
  86648. * 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)).
  86649. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86650. */
  86651. get rotation(): Vector3;
  86652. set rotation(newRotation: Vector3);
  86653. /**
  86654. * 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)).
  86655. */
  86656. get scaling(): Vector3;
  86657. set scaling(newScaling: Vector3);
  86658. /**
  86659. * 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).
  86660. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86661. */
  86662. get rotationQuaternion(): Nullable<Quaternion>;
  86663. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86664. /**
  86665. * The forward direction of that transform in world space.
  86666. */
  86667. get forward(): Vector3;
  86668. /**
  86669. * The up direction of that transform in world space.
  86670. */
  86671. get up(): Vector3;
  86672. /**
  86673. * The right direction of that transform in world space.
  86674. */
  86675. get right(): Vector3;
  86676. /**
  86677. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86678. * @param matrix the matrix to copy the pose from
  86679. * @returns this TransformNode.
  86680. */
  86681. updatePoseMatrix(matrix: Matrix): TransformNode;
  86682. /**
  86683. * Returns the mesh Pose matrix.
  86684. * @returns the pose matrix
  86685. */
  86686. getPoseMatrix(): Matrix;
  86687. /** @hidden */
  86688. _isSynchronized(): boolean;
  86689. /** @hidden */
  86690. _initCache(): void;
  86691. /**
  86692. * Flag the transform node as dirty (Forcing it to update everything)
  86693. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86694. * @returns this transform node
  86695. */
  86696. markAsDirty(property: string): TransformNode;
  86697. /**
  86698. * Returns the current mesh absolute position.
  86699. * Returns a Vector3.
  86700. */
  86701. get absolutePosition(): Vector3;
  86702. /**
  86703. * Returns the current mesh absolute scaling.
  86704. * Returns a Vector3.
  86705. */
  86706. get absoluteScaling(): Vector3;
  86707. /**
  86708. * Returns the current mesh absolute rotation.
  86709. * Returns a Quaternion.
  86710. */
  86711. get absoluteRotationQuaternion(): Quaternion;
  86712. /**
  86713. * Sets a new matrix to apply before all other transformation
  86714. * @param matrix defines the transform matrix
  86715. * @returns the current TransformNode
  86716. */
  86717. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86718. /**
  86719. * Sets a new pivot matrix to the current node
  86720. * @param matrix defines the new pivot matrix to use
  86721. * @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
  86722. * @returns the current TransformNode
  86723. */
  86724. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86725. /**
  86726. * Returns the mesh pivot matrix.
  86727. * Default : Identity.
  86728. * @returns the matrix
  86729. */
  86730. getPivotMatrix(): Matrix;
  86731. /**
  86732. * Instantiate (when possible) or clone that node with its hierarchy
  86733. * @param newParent defines the new parent to use for the instance (or clone)
  86734. * @param options defines options to configure how copy is done
  86735. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86736. * @returns an instance (or a clone) of the current node with its hiearchy
  86737. */
  86738. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86739. doNotInstantiate: boolean;
  86740. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86741. /**
  86742. * Prevents the World matrix to be computed any longer
  86743. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86744. * @returns the TransformNode.
  86745. */
  86746. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86747. /**
  86748. * Allows back the World matrix computation.
  86749. * @returns the TransformNode.
  86750. */
  86751. unfreezeWorldMatrix(): this;
  86752. /**
  86753. * True if the World matrix has been frozen.
  86754. */
  86755. get isWorldMatrixFrozen(): boolean;
  86756. /**
  86757. * Retuns the mesh absolute position in the World.
  86758. * @returns a Vector3.
  86759. */
  86760. getAbsolutePosition(): Vector3;
  86761. /**
  86762. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86763. * @param absolutePosition the absolute position to set
  86764. * @returns the TransformNode.
  86765. */
  86766. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86767. /**
  86768. * Sets the mesh position in its local space.
  86769. * @param vector3 the position to set in localspace
  86770. * @returns the TransformNode.
  86771. */
  86772. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86773. /**
  86774. * Returns the mesh position in the local space from the current World matrix values.
  86775. * @returns a new Vector3.
  86776. */
  86777. getPositionExpressedInLocalSpace(): Vector3;
  86778. /**
  86779. * Translates the mesh along the passed Vector3 in its local space.
  86780. * @param vector3 the distance to translate in localspace
  86781. * @returns the TransformNode.
  86782. */
  86783. locallyTranslate(vector3: Vector3): TransformNode;
  86784. private static _lookAtVectorCache;
  86785. /**
  86786. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86787. * @param targetPoint the position (must be in same space as current mesh) to look at
  86788. * @param yawCor optional yaw (y-axis) correction in radians
  86789. * @param pitchCor optional pitch (x-axis) correction in radians
  86790. * @param rollCor optional roll (z-axis) correction in radians
  86791. * @param space the choosen space of the target
  86792. * @returns the TransformNode.
  86793. */
  86794. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86795. /**
  86796. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86797. * This Vector3 is expressed in the World space.
  86798. * @param localAxis axis to rotate
  86799. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86800. */
  86801. getDirection(localAxis: Vector3): Vector3;
  86802. /**
  86803. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86804. * localAxis is expressed in the mesh local space.
  86805. * result is computed in the Wordl space from the mesh World matrix.
  86806. * @param localAxis axis to rotate
  86807. * @param result the resulting transformnode
  86808. * @returns this TransformNode.
  86809. */
  86810. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  86811. /**
  86812. * Sets this transform node rotation to the given local axis.
  86813. * @param localAxis the axis in local space
  86814. * @param yawCor optional yaw (y-axis) correction in radians
  86815. * @param pitchCor optional pitch (x-axis) correction in radians
  86816. * @param rollCor optional roll (z-axis) correction in radians
  86817. * @returns this TransformNode
  86818. */
  86819. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  86820. /**
  86821. * Sets a new pivot point to the current node
  86822. * @param point defines the new pivot point to use
  86823. * @param space defines if the point is in world or local space (local by default)
  86824. * @returns the current TransformNode
  86825. */
  86826. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  86827. /**
  86828. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  86829. * @returns the pivot point
  86830. */
  86831. getPivotPoint(): Vector3;
  86832. /**
  86833. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  86834. * @param result the vector3 to store the result
  86835. * @returns this TransformNode.
  86836. */
  86837. getPivotPointToRef(result: Vector3): TransformNode;
  86838. /**
  86839. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  86840. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  86841. */
  86842. getAbsolutePivotPoint(): Vector3;
  86843. /**
  86844. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  86845. * @param result vector3 to store the result
  86846. * @returns this TransformNode.
  86847. */
  86848. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  86849. /**
  86850. * Defines the passed node as the parent of the current node.
  86851. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  86852. * @see https://doc.babylonjs.com/how_to/parenting
  86853. * @param node the node ot set as the parent
  86854. * @returns this TransformNode.
  86855. */
  86856. setParent(node: Nullable<Node>): TransformNode;
  86857. private _nonUniformScaling;
  86858. /**
  86859. * True if the scaling property of this object is non uniform eg. (1,2,1)
  86860. */
  86861. get nonUniformScaling(): boolean;
  86862. /** @hidden */
  86863. _updateNonUniformScalingState(value: boolean): boolean;
  86864. /**
  86865. * Attach the current TransformNode to another TransformNode associated with a bone
  86866. * @param bone Bone affecting the TransformNode
  86867. * @param affectedTransformNode TransformNode associated with the bone
  86868. * @returns this object
  86869. */
  86870. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  86871. /**
  86872. * Detach the transform node if its associated with a bone
  86873. * @returns this object
  86874. */
  86875. detachFromBone(): TransformNode;
  86876. private static _rotationAxisCache;
  86877. /**
  86878. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  86879. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  86880. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  86881. * The passed axis is also normalized.
  86882. * @param axis the axis to rotate around
  86883. * @param amount the amount to rotate in radians
  86884. * @param space Space to rotate in (Default: local)
  86885. * @returns the TransformNode.
  86886. */
  86887. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86888. /**
  86889. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  86890. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  86891. * The passed axis is also normalized. .
  86892. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  86893. * @param point the point to rotate around
  86894. * @param axis the axis to rotate around
  86895. * @param amount the amount to rotate in radians
  86896. * @returns the TransformNode
  86897. */
  86898. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  86899. /**
  86900. * Translates the mesh along the axis vector for the passed distance in the given space.
  86901. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  86902. * @param axis the axis to translate in
  86903. * @param distance the distance to translate
  86904. * @param space Space to rotate in (Default: local)
  86905. * @returns the TransformNode.
  86906. */
  86907. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86908. /**
  86909. * Adds a rotation step to the mesh current rotation.
  86910. * x, y, z are Euler angles expressed in radians.
  86911. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  86912. * This means this rotation is made in the mesh local space only.
  86913. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  86914. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  86915. * ```javascript
  86916. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  86917. * ```
  86918. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  86919. * 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.
  86920. * @param x Rotation to add
  86921. * @param y Rotation to add
  86922. * @param z Rotation to add
  86923. * @returns the TransformNode.
  86924. */
  86925. addRotation(x: number, y: number, z: number): TransformNode;
  86926. /**
  86927. * @hidden
  86928. */
  86929. protected _getEffectiveParent(): Nullable<Node>;
  86930. /**
  86931. * Computes the world matrix of the node
  86932. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86933. * @returns the world matrix
  86934. */
  86935. computeWorldMatrix(force?: boolean): Matrix;
  86936. protected _afterComputeWorldMatrix(): void;
  86937. /**
  86938. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  86939. * @param func callback function to add
  86940. *
  86941. * @returns the TransformNode.
  86942. */
  86943. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  86944. /**
  86945. * Removes a registered callback function.
  86946. * @param func callback function to remove
  86947. * @returns the TransformNode.
  86948. */
  86949. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  86950. /**
  86951. * Gets the position of the current mesh in camera space
  86952. * @param camera defines the camera to use
  86953. * @returns a position
  86954. */
  86955. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  86956. /**
  86957. * Returns the distance from the mesh to the active camera
  86958. * @param camera defines the camera to use
  86959. * @returns the distance
  86960. */
  86961. getDistanceToCamera(camera?: Nullable<Camera>): number;
  86962. /**
  86963. * Clone the current transform node
  86964. * @param name Name of the new clone
  86965. * @param newParent New parent for the clone
  86966. * @param doNotCloneChildren Do not clone children hierarchy
  86967. * @returns the new transform node
  86968. */
  86969. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  86970. /**
  86971. * Serializes the objects information.
  86972. * @param currentSerializationObject defines the object to serialize in
  86973. * @returns the serialized object
  86974. */
  86975. serialize(currentSerializationObject?: any): any;
  86976. /**
  86977. * Returns a new TransformNode object parsed from the source provided.
  86978. * @param parsedTransformNode is the source.
  86979. * @param scene the scne the object belongs to
  86980. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  86981. * @returns a new TransformNode object parsed from the source provided.
  86982. */
  86983. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  86984. /**
  86985. * Get all child-transformNodes of this node
  86986. * @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
  86987. * @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
  86988. * @returns an array of TransformNode
  86989. */
  86990. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  86991. /**
  86992. * Releases resources associated with this transform node.
  86993. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86994. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86995. */
  86996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86997. /**
  86998. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  86999. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87000. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87001. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87002. * @returns the current mesh
  87003. */
  87004. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87005. private _syncAbsoluteScalingAndRotation;
  87006. }
  87007. }
  87008. declare module BABYLON {
  87009. /**
  87010. * Defines the types of pose enabled controllers that are supported
  87011. */
  87012. export enum PoseEnabledControllerType {
  87013. /**
  87014. * HTC Vive
  87015. */
  87016. VIVE = 0,
  87017. /**
  87018. * Oculus Rift
  87019. */
  87020. OCULUS = 1,
  87021. /**
  87022. * Windows mixed reality
  87023. */
  87024. WINDOWS = 2,
  87025. /**
  87026. * Samsung gear VR
  87027. */
  87028. GEAR_VR = 3,
  87029. /**
  87030. * Google Daydream
  87031. */
  87032. DAYDREAM = 4,
  87033. /**
  87034. * Generic
  87035. */
  87036. GENERIC = 5
  87037. }
  87038. /**
  87039. * Defines the MutableGamepadButton interface for the state of a gamepad button
  87040. */
  87041. export interface MutableGamepadButton {
  87042. /**
  87043. * Value of the button/trigger
  87044. */
  87045. value: number;
  87046. /**
  87047. * If the button/trigger is currently touched
  87048. */
  87049. touched: boolean;
  87050. /**
  87051. * If the button/trigger is currently pressed
  87052. */
  87053. pressed: boolean;
  87054. }
  87055. /**
  87056. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  87057. * @hidden
  87058. */
  87059. export interface ExtendedGamepadButton extends GamepadButton {
  87060. /**
  87061. * If the button/trigger is currently pressed
  87062. */
  87063. readonly pressed: boolean;
  87064. /**
  87065. * If the button/trigger is currently touched
  87066. */
  87067. readonly touched: boolean;
  87068. /**
  87069. * Value of the button/trigger
  87070. */
  87071. readonly value: number;
  87072. }
  87073. /** @hidden */
  87074. export interface _GamePadFactory {
  87075. /**
  87076. * Returns wether or not the current gamepad can be created for this type of controller.
  87077. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  87078. * @returns true if it can be created, otherwise false
  87079. */
  87080. canCreate(gamepadInfo: any): boolean;
  87081. /**
  87082. * Creates a new instance of the Gamepad.
  87083. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  87084. * @returns the new gamepad instance
  87085. */
  87086. create(gamepadInfo: any): Gamepad;
  87087. }
  87088. /**
  87089. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87090. */
  87091. export class PoseEnabledControllerHelper {
  87092. /** @hidden */
  87093. static _ControllerFactories: _GamePadFactory[];
  87094. /** @hidden */
  87095. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  87096. /**
  87097. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87098. * @param vrGamepad the gamepad to initialized
  87099. * @returns a vr controller of the type the gamepad identified as
  87100. */
  87101. static InitiateController(vrGamepad: any): Gamepad;
  87102. }
  87103. /**
  87104. * Defines the PoseEnabledController object that contains state of a vr capable controller
  87105. */
  87106. export class PoseEnabledController extends Gamepad implements PoseControlled {
  87107. /**
  87108. * If the controller is used in a webXR session
  87109. */
  87110. isXR: boolean;
  87111. private _deviceRoomPosition;
  87112. private _deviceRoomRotationQuaternion;
  87113. /**
  87114. * The device position in babylon space
  87115. */
  87116. devicePosition: Vector3;
  87117. /**
  87118. * The device rotation in babylon space
  87119. */
  87120. deviceRotationQuaternion: Quaternion;
  87121. /**
  87122. * The scale factor of the device in babylon space
  87123. */
  87124. deviceScaleFactor: number;
  87125. /**
  87126. * (Likely devicePosition should be used instead) The device position in its room space
  87127. */
  87128. position: Vector3;
  87129. /**
  87130. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  87131. */
  87132. rotationQuaternion: Quaternion;
  87133. /**
  87134. * The type of controller (Eg. Windows mixed reality)
  87135. */
  87136. controllerType: PoseEnabledControllerType;
  87137. protected _calculatedPosition: Vector3;
  87138. private _calculatedRotation;
  87139. /**
  87140. * The raw pose from the device
  87141. */
  87142. rawPose: DevicePose;
  87143. private _trackPosition;
  87144. private _maxRotationDistFromHeadset;
  87145. private _draggedRoomRotation;
  87146. /**
  87147. * @hidden
  87148. */
  87149. _disableTrackPosition(fixedPosition: Vector3): void;
  87150. /**
  87151. * Internal, the mesh attached to the controller
  87152. * @hidden
  87153. */
  87154. _mesh: Nullable<AbstractMesh>;
  87155. private _poseControlledCamera;
  87156. private _leftHandSystemQuaternion;
  87157. /**
  87158. * Internal, matrix used to convert room space to babylon space
  87159. * @hidden
  87160. */
  87161. _deviceToWorld: Matrix;
  87162. /**
  87163. * Node to be used when casting a ray from the controller
  87164. * @hidden
  87165. */
  87166. _pointingPoseNode: Nullable<TransformNode>;
  87167. /**
  87168. * Name of the child mesh that can be used to cast a ray from the controller
  87169. */
  87170. static readonly POINTING_POSE: string;
  87171. /**
  87172. * Creates a new PoseEnabledController from a gamepad
  87173. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  87174. */
  87175. constructor(browserGamepad: any);
  87176. private _workingMatrix;
  87177. /**
  87178. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  87179. */
  87180. update(): void;
  87181. /**
  87182. * Updates only the pose device and mesh without doing any button event checking
  87183. */
  87184. protected _updatePoseAndMesh(): void;
  87185. /**
  87186. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  87187. * @param poseData raw pose fromthe device
  87188. */
  87189. updateFromDevice(poseData: DevicePose): void;
  87190. /**
  87191. * @hidden
  87192. */
  87193. _meshAttachedObservable: Observable<AbstractMesh>;
  87194. /**
  87195. * Attaches a mesh to the controller
  87196. * @param mesh the mesh to be attached
  87197. */
  87198. attachToMesh(mesh: AbstractMesh): void;
  87199. /**
  87200. * Attaches the controllers mesh to a camera
  87201. * @param camera the camera the mesh should be attached to
  87202. */
  87203. attachToPoseControlledCamera(camera: TargetCamera): void;
  87204. /**
  87205. * Disposes of the controller
  87206. */
  87207. dispose(): void;
  87208. /**
  87209. * The mesh that is attached to the controller
  87210. */
  87211. get mesh(): Nullable<AbstractMesh>;
  87212. /**
  87213. * Gets the ray of the controller in the direction the controller is pointing
  87214. * @param length the length the resulting ray should be
  87215. * @returns a ray in the direction the controller is pointing
  87216. */
  87217. getForwardRay(length?: number): Ray;
  87218. }
  87219. }
  87220. declare module BABYLON {
  87221. /**
  87222. * Defines the WebVRController object that represents controllers tracked in 3D space
  87223. */
  87224. export abstract class WebVRController extends PoseEnabledController {
  87225. /**
  87226. * Internal, the default controller model for the controller
  87227. */
  87228. protected _defaultModel: Nullable<AbstractMesh>;
  87229. /**
  87230. * Fired when the trigger state has changed
  87231. */
  87232. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  87233. /**
  87234. * Fired when the main button state has changed
  87235. */
  87236. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87237. /**
  87238. * Fired when the secondary button state has changed
  87239. */
  87240. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87241. /**
  87242. * Fired when the pad state has changed
  87243. */
  87244. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  87245. /**
  87246. * Fired when controllers stick values have changed
  87247. */
  87248. onPadValuesChangedObservable: Observable<StickValues>;
  87249. /**
  87250. * Array of button availible on the controller
  87251. */
  87252. protected _buttons: Array<MutableGamepadButton>;
  87253. private _onButtonStateChange;
  87254. /**
  87255. * Fired when a controller button's state has changed
  87256. * @param callback the callback containing the button that was modified
  87257. */
  87258. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  87259. /**
  87260. * X and Y axis corresponding to the controllers joystick
  87261. */
  87262. pad: StickValues;
  87263. /**
  87264. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  87265. */
  87266. hand: string;
  87267. /**
  87268. * The default controller model for the controller
  87269. */
  87270. get defaultModel(): Nullable<AbstractMesh>;
  87271. /**
  87272. * Creates a new WebVRController from a gamepad
  87273. * @param vrGamepad the gamepad that the WebVRController should be created from
  87274. */
  87275. constructor(vrGamepad: any);
  87276. /**
  87277. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  87278. */
  87279. update(): void;
  87280. /**
  87281. * Function to be called when a button is modified
  87282. */
  87283. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  87284. /**
  87285. * Loads a mesh and attaches it to the controller
  87286. * @param scene the scene the mesh should be added to
  87287. * @param meshLoaded callback for when the mesh has been loaded
  87288. */
  87289. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  87290. private _setButtonValue;
  87291. private _changes;
  87292. private _checkChanges;
  87293. /**
  87294. * Disposes of th webVRCOntroller
  87295. */
  87296. dispose(): void;
  87297. }
  87298. }
  87299. declare module BABYLON {
  87300. /**
  87301. * The HemisphericLight simulates the ambient environment light,
  87302. * so the passed direction is the light reflection direction, not the incoming direction.
  87303. */
  87304. export class HemisphericLight extends Light {
  87305. /**
  87306. * The groundColor is the light in the opposite direction to the one specified during creation.
  87307. * 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.
  87308. */
  87309. groundColor: Color3;
  87310. /**
  87311. * The light reflection direction, not the incoming direction.
  87312. */
  87313. direction: Vector3;
  87314. /**
  87315. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  87316. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  87317. * The HemisphericLight can't cast shadows.
  87318. * Documentation : https://doc.babylonjs.com/babylon101/lights
  87319. * @param name The friendly name of the light
  87320. * @param direction The direction of the light reflection
  87321. * @param scene The scene the light belongs to
  87322. */
  87323. constructor(name: string, direction: Vector3, scene: Scene);
  87324. protected _buildUniformLayout(): void;
  87325. /**
  87326. * Returns the string "HemisphericLight".
  87327. * @return The class name
  87328. */
  87329. getClassName(): string;
  87330. /**
  87331. * Sets the HemisphericLight direction towards the passed target (Vector3).
  87332. * Returns the updated direction.
  87333. * @param target The target the direction should point to
  87334. * @return The computed direction
  87335. */
  87336. setDirectionToTarget(target: Vector3): Vector3;
  87337. /**
  87338. * Returns the shadow generator associated to the light.
  87339. * @returns Always null for hemispheric lights because it does not support shadows.
  87340. */
  87341. getShadowGenerator(): Nullable<IShadowGenerator>;
  87342. /**
  87343. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  87344. * @param effect The effect to update
  87345. * @param lightIndex The index of the light in the effect to update
  87346. * @returns The hemispheric light
  87347. */
  87348. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  87349. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  87350. /**
  87351. * Computes the world matrix of the node
  87352. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87353. * @param useWasUpdatedFlag defines a reserved property
  87354. * @returns the world matrix
  87355. */
  87356. computeWorldMatrix(): Matrix;
  87357. /**
  87358. * Returns the integer 3.
  87359. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  87360. */
  87361. getTypeID(): number;
  87362. /**
  87363. * Prepares the list of defines specific to the light type.
  87364. * @param defines the list of defines
  87365. * @param lightIndex defines the index of the light for the effect
  87366. */
  87367. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  87368. }
  87369. }
  87370. declare module BABYLON {
  87371. /** @hidden */
  87372. export var vrMultiviewToSingleviewPixelShader: {
  87373. name: string;
  87374. shader: string;
  87375. };
  87376. }
  87377. declare module BABYLON {
  87378. /**
  87379. * Renders to multiple views with a single draw call
  87380. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  87381. */
  87382. export class MultiviewRenderTarget extends RenderTargetTexture {
  87383. /**
  87384. * Creates a multiview render target
  87385. * @param scene scene used with the render target
  87386. * @param size the size of the render target (used for each view)
  87387. */
  87388. constructor(scene: Scene, size?: number | {
  87389. width: number;
  87390. height: number;
  87391. } | {
  87392. ratio: number;
  87393. });
  87394. /**
  87395. * @hidden
  87396. * @param faceIndex the face index, if its a cube texture
  87397. */
  87398. _bindFrameBuffer(faceIndex?: number): void;
  87399. /**
  87400. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87401. * @returns the view count
  87402. */
  87403. getViewCount(): number;
  87404. }
  87405. }
  87406. declare module BABYLON {
  87407. /**
  87408. * Represents a camera frustum
  87409. */
  87410. export class Frustum {
  87411. /**
  87412. * Gets the planes representing the frustum
  87413. * @param transform matrix to be applied to the returned planes
  87414. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87415. */
  87416. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87417. /**
  87418. * Gets the near frustum plane transformed by the transform matrix
  87419. * @param transform transformation matrix to be applied to the resulting frustum plane
  87420. * @param frustumPlane the resuling frustum plane
  87421. */
  87422. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87423. /**
  87424. * Gets the far frustum plane transformed by the transform matrix
  87425. * @param transform transformation matrix to be applied to the resulting frustum plane
  87426. * @param frustumPlane the resuling frustum plane
  87427. */
  87428. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87429. /**
  87430. * Gets the left frustum plane transformed by the transform matrix
  87431. * @param transform transformation matrix to be applied to the resulting frustum plane
  87432. * @param frustumPlane the resuling frustum plane
  87433. */
  87434. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87435. /**
  87436. * Gets the right frustum plane transformed by the transform matrix
  87437. * @param transform transformation matrix to be applied to the resulting frustum plane
  87438. * @param frustumPlane the resuling frustum plane
  87439. */
  87440. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87441. /**
  87442. * Gets the top frustum plane transformed by the transform matrix
  87443. * @param transform transformation matrix to be applied to the resulting frustum plane
  87444. * @param frustumPlane the resuling frustum plane
  87445. */
  87446. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87447. /**
  87448. * Gets the bottom frustum plane transformed by the transform matrix
  87449. * @param transform transformation matrix to be applied to the resulting frustum plane
  87450. * @param frustumPlane the resuling frustum plane
  87451. */
  87452. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87453. /**
  87454. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87455. * @param transform transformation matrix to be applied to the resulting frustum planes
  87456. * @param frustumPlanes the resuling frustum planes
  87457. */
  87458. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87459. }
  87460. }
  87461. declare module BABYLON {
  87462. interface Engine {
  87463. /**
  87464. * Creates a new multiview render target
  87465. * @param width defines the width of the texture
  87466. * @param height defines the height of the texture
  87467. * @returns the created multiview texture
  87468. */
  87469. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  87470. /**
  87471. * Binds a multiview framebuffer to be drawn to
  87472. * @param multiviewTexture texture to bind
  87473. */
  87474. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  87475. }
  87476. interface Camera {
  87477. /**
  87478. * @hidden
  87479. * 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)
  87480. */
  87481. _useMultiviewToSingleView: boolean;
  87482. /**
  87483. * @hidden
  87484. * 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)
  87485. */
  87486. _multiviewTexture: Nullable<RenderTargetTexture>;
  87487. /**
  87488. * @hidden
  87489. * ensures the multiview texture of the camera exists and has the specified width/height
  87490. * @param width height to set on the multiview texture
  87491. * @param height width to set on the multiview texture
  87492. */
  87493. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  87494. }
  87495. interface Scene {
  87496. /** @hidden */
  87497. _transformMatrixR: Matrix;
  87498. /** @hidden */
  87499. _multiviewSceneUbo: Nullable<UniformBuffer>;
  87500. /** @hidden */
  87501. _createMultiviewUbo(): void;
  87502. /** @hidden */
  87503. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  87504. /** @hidden */
  87505. _renderMultiviewToSingleView(camera: Camera): void;
  87506. }
  87507. }
  87508. declare module BABYLON {
  87509. /**
  87510. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  87511. * This will not be used for webXR as it supports displaying texture arrays directly
  87512. */
  87513. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  87514. /**
  87515. * Initializes a VRMultiviewToSingleview
  87516. * @param name name of the post process
  87517. * @param camera camera to be applied to
  87518. * @param scaleFactor scaling factor to the size of the output texture
  87519. */
  87520. constructor(name: string, camera: Camera, scaleFactor: number);
  87521. }
  87522. }
  87523. declare module BABYLON {
  87524. /**
  87525. * Interface used to define additional presentation attributes
  87526. */
  87527. export interface IVRPresentationAttributes {
  87528. /**
  87529. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  87530. */
  87531. highRefreshRate: boolean;
  87532. /**
  87533. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  87534. */
  87535. foveationLevel: number;
  87536. }
  87537. interface Engine {
  87538. /** @hidden */
  87539. _vrDisplay: any;
  87540. /** @hidden */
  87541. _vrSupported: boolean;
  87542. /** @hidden */
  87543. _oldSize: Size;
  87544. /** @hidden */
  87545. _oldHardwareScaleFactor: number;
  87546. /** @hidden */
  87547. _vrExclusivePointerMode: boolean;
  87548. /** @hidden */
  87549. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  87550. /** @hidden */
  87551. _onVRDisplayPointerRestricted: () => void;
  87552. /** @hidden */
  87553. _onVRDisplayPointerUnrestricted: () => void;
  87554. /** @hidden */
  87555. _onVrDisplayConnect: Nullable<(display: any) => void>;
  87556. /** @hidden */
  87557. _onVrDisplayDisconnect: Nullable<() => void>;
  87558. /** @hidden */
  87559. _onVrDisplayPresentChange: Nullable<() => void>;
  87560. /**
  87561. * Observable signaled when VR display mode changes
  87562. */
  87563. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  87564. /**
  87565. * Observable signaled when VR request present is complete
  87566. */
  87567. onVRRequestPresentComplete: Observable<boolean>;
  87568. /**
  87569. * Observable signaled when VR request present starts
  87570. */
  87571. onVRRequestPresentStart: Observable<Engine>;
  87572. /**
  87573. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  87574. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  87575. */
  87576. isInVRExclusivePointerMode: boolean;
  87577. /**
  87578. * Gets a boolean indicating if a webVR device was detected
  87579. * @returns true if a webVR device was detected
  87580. */
  87581. isVRDevicePresent(): boolean;
  87582. /**
  87583. * Gets the current webVR device
  87584. * @returns the current webVR device (or null)
  87585. */
  87586. getVRDevice(): any;
  87587. /**
  87588. * Initializes a webVR display and starts listening to display change events
  87589. * The onVRDisplayChangedObservable will be notified upon these changes
  87590. * @returns A promise containing a VRDisplay and if vr is supported
  87591. */
  87592. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87593. /** @hidden */
  87594. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  87595. /**
  87596. * Gets or sets the presentation attributes used to configure VR rendering
  87597. */
  87598. vrPresentationAttributes?: IVRPresentationAttributes;
  87599. /**
  87600. * Call this function to switch to webVR mode
  87601. * Will do nothing if webVR is not supported or if there is no webVR device
  87602. * @param options the webvr options provided to the camera. mainly used for multiview
  87603. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87604. */
  87605. enableVR(options: WebVROptions): void;
  87606. /** @hidden */
  87607. _onVRFullScreenTriggered(): void;
  87608. }
  87609. }
  87610. declare module BABYLON {
  87611. /**
  87612. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  87613. * IMPORTANT!! The data is right-hand data.
  87614. * @export
  87615. * @interface DevicePose
  87616. */
  87617. export interface DevicePose {
  87618. /**
  87619. * The position of the device, values in array are [x,y,z].
  87620. */
  87621. readonly position: Nullable<Float32Array>;
  87622. /**
  87623. * The linearVelocity of the device, values in array are [x,y,z].
  87624. */
  87625. readonly linearVelocity: Nullable<Float32Array>;
  87626. /**
  87627. * The linearAcceleration of the device, values in array are [x,y,z].
  87628. */
  87629. readonly linearAcceleration: Nullable<Float32Array>;
  87630. /**
  87631. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  87632. */
  87633. readonly orientation: Nullable<Float32Array>;
  87634. /**
  87635. * The angularVelocity of the device, values in array are [x,y,z].
  87636. */
  87637. readonly angularVelocity: Nullable<Float32Array>;
  87638. /**
  87639. * The angularAcceleration of the device, values in array are [x,y,z].
  87640. */
  87641. readonly angularAcceleration: Nullable<Float32Array>;
  87642. }
  87643. /**
  87644. * Interface representing a pose controlled object in Babylon.
  87645. * A pose controlled object has both regular pose values as well as pose values
  87646. * from an external device such as a VR head mounted display
  87647. */
  87648. export interface PoseControlled {
  87649. /**
  87650. * The position of the object in babylon space.
  87651. */
  87652. position: Vector3;
  87653. /**
  87654. * The rotation quaternion of the object in babylon space.
  87655. */
  87656. rotationQuaternion: Quaternion;
  87657. /**
  87658. * The position of the device in babylon space.
  87659. */
  87660. devicePosition?: Vector3;
  87661. /**
  87662. * The rotation quaternion of the device in babylon space.
  87663. */
  87664. deviceRotationQuaternion: Quaternion;
  87665. /**
  87666. * The raw pose coming from the device.
  87667. */
  87668. rawPose: Nullable<DevicePose>;
  87669. /**
  87670. * The scale of the device to be used when translating from device space to babylon space.
  87671. */
  87672. deviceScaleFactor: number;
  87673. /**
  87674. * Updates the poseControlled values based on the input device pose.
  87675. * @param poseData the pose data to update the object with
  87676. */
  87677. updateFromDevice(poseData: DevicePose): void;
  87678. }
  87679. /**
  87680. * Set of options to customize the webVRCamera
  87681. */
  87682. export interface WebVROptions {
  87683. /**
  87684. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  87685. */
  87686. trackPosition?: boolean;
  87687. /**
  87688. * Sets the scale of the vrDevice in babylon space. (default: 1)
  87689. */
  87690. positionScale?: number;
  87691. /**
  87692. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  87693. */
  87694. displayName?: string;
  87695. /**
  87696. * Should the native controller meshes be initialized. (default: true)
  87697. */
  87698. controllerMeshes?: boolean;
  87699. /**
  87700. * Creating a default HemiLight only on controllers. (default: true)
  87701. */
  87702. defaultLightingOnControllers?: boolean;
  87703. /**
  87704. * If you don't want to use the default VR button of the helper. (default: false)
  87705. */
  87706. useCustomVRButton?: boolean;
  87707. /**
  87708. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  87709. */
  87710. customVRButton?: HTMLButtonElement;
  87711. /**
  87712. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  87713. */
  87714. rayLength?: number;
  87715. /**
  87716. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  87717. */
  87718. defaultHeight?: number;
  87719. /**
  87720. * If multiview should be used if availible (default: false)
  87721. */
  87722. useMultiview?: boolean;
  87723. }
  87724. /**
  87725. * This represents a WebVR camera.
  87726. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  87727. * @example http://doc.babylonjs.com/how_to/webvr_camera
  87728. */
  87729. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  87730. private webVROptions;
  87731. /**
  87732. * @hidden
  87733. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  87734. */
  87735. _vrDevice: any;
  87736. /**
  87737. * The rawPose of the vrDevice.
  87738. */
  87739. rawPose: Nullable<DevicePose>;
  87740. private _onVREnabled;
  87741. private _specsVersion;
  87742. private _attached;
  87743. private _frameData;
  87744. protected _descendants: Array<Node>;
  87745. private _deviceRoomPosition;
  87746. /** @hidden */
  87747. _deviceRoomRotationQuaternion: Quaternion;
  87748. private _standingMatrix;
  87749. /**
  87750. * Represents device position in babylon space.
  87751. */
  87752. devicePosition: Vector3;
  87753. /**
  87754. * Represents device rotation in babylon space.
  87755. */
  87756. deviceRotationQuaternion: Quaternion;
  87757. /**
  87758. * The scale of the device to be used when translating from device space to babylon space.
  87759. */
  87760. deviceScaleFactor: number;
  87761. private _deviceToWorld;
  87762. private _worldToDevice;
  87763. /**
  87764. * References to the webVR controllers for the vrDevice.
  87765. */
  87766. controllers: Array<WebVRController>;
  87767. /**
  87768. * Emits an event when a controller is attached.
  87769. */
  87770. onControllersAttachedObservable: Observable<WebVRController[]>;
  87771. /**
  87772. * Emits an event when a controller's mesh has been loaded;
  87773. */
  87774. onControllerMeshLoadedObservable: Observable<WebVRController>;
  87775. /**
  87776. * Emits an event when the HMD's pose has been updated.
  87777. */
  87778. onPoseUpdatedFromDeviceObservable: Observable<any>;
  87779. private _poseSet;
  87780. /**
  87781. * If the rig cameras be used as parent instead of this camera.
  87782. */
  87783. rigParenting: boolean;
  87784. private _lightOnControllers;
  87785. private _defaultHeight?;
  87786. /**
  87787. * Instantiates a WebVRFreeCamera.
  87788. * @param name The name of the WebVRFreeCamera
  87789. * @param position The starting anchor position for the camera
  87790. * @param scene The scene the camera belongs to
  87791. * @param webVROptions a set of customizable options for the webVRCamera
  87792. */
  87793. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  87794. /**
  87795. * Gets the device distance from the ground in meters.
  87796. * @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.
  87797. */
  87798. deviceDistanceToRoomGround(): number;
  87799. /**
  87800. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  87801. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  87802. */
  87803. useStandingMatrix(callback?: (bool: boolean) => void): void;
  87804. /**
  87805. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  87806. * @returns A promise with a boolean set to if the standing matrix is supported.
  87807. */
  87808. useStandingMatrixAsync(): Promise<boolean>;
  87809. /**
  87810. * Disposes the camera
  87811. */
  87812. dispose(): void;
  87813. /**
  87814. * Gets a vrController by name.
  87815. * @param name The name of the controller to retreive
  87816. * @returns the controller matching the name specified or null if not found
  87817. */
  87818. getControllerByName(name: string): Nullable<WebVRController>;
  87819. private _leftController;
  87820. /**
  87821. * The controller corresponding to the users left hand.
  87822. */
  87823. get leftController(): Nullable<WebVRController>;
  87824. private _rightController;
  87825. /**
  87826. * The controller corresponding to the users right hand.
  87827. */
  87828. get rightController(): Nullable<WebVRController>;
  87829. /**
  87830. * Casts a ray forward from the vrCamera's gaze.
  87831. * @param length Length of the ray (default: 100)
  87832. * @returns the ray corresponding to the gaze
  87833. */
  87834. getForwardRay(length?: number): Ray;
  87835. /**
  87836. * @hidden
  87837. * Updates the camera based on device's frame data
  87838. */
  87839. _checkInputs(): void;
  87840. /**
  87841. * Updates the poseControlled values based on the input device pose.
  87842. * @param poseData Pose coming from the device
  87843. */
  87844. updateFromDevice(poseData: DevicePose): void;
  87845. private _htmlElementAttached;
  87846. private _detachIfAttached;
  87847. /**
  87848. * WebVR's attach control will start broadcasting frames to the device.
  87849. * Note that in certain browsers (chrome for example) this function must be called
  87850. * within a user-interaction callback. Example:
  87851. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  87852. *
  87853. * @param element html element to attach the vrDevice to
  87854. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  87855. */
  87856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87857. /**
  87858. * Detaches the camera from the html element and disables VR
  87859. *
  87860. * @param element html element to detach from
  87861. */
  87862. detachControl(element: HTMLElement): void;
  87863. /**
  87864. * @returns the name of this class
  87865. */
  87866. getClassName(): string;
  87867. /**
  87868. * Calls resetPose on the vrDisplay
  87869. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  87870. */
  87871. resetToCurrentRotation(): void;
  87872. /**
  87873. * @hidden
  87874. * Updates the rig cameras (left and right eye)
  87875. */
  87876. _updateRigCameras(): void;
  87877. private _workingVector;
  87878. private _oneVector;
  87879. private _workingMatrix;
  87880. private updateCacheCalled;
  87881. private _correctPositionIfNotTrackPosition;
  87882. /**
  87883. * @hidden
  87884. * Updates the cached values of the camera
  87885. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  87886. */
  87887. _updateCache(ignoreParentClass?: boolean): void;
  87888. /**
  87889. * @hidden
  87890. * Get current device position in babylon world
  87891. */
  87892. _computeDevicePosition(): void;
  87893. /**
  87894. * Updates the current device position and rotation in the babylon world
  87895. */
  87896. update(): void;
  87897. /**
  87898. * @hidden
  87899. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  87900. * @returns an identity matrix
  87901. */
  87902. _getViewMatrix(): Matrix;
  87903. private _tmpMatrix;
  87904. /**
  87905. * This function is called by the two RIG cameras.
  87906. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  87907. * @hidden
  87908. */
  87909. _getWebVRViewMatrix(): Matrix;
  87910. /** @hidden */
  87911. _getWebVRProjectionMatrix(): Matrix;
  87912. private _onGamepadConnectedObserver;
  87913. private _onGamepadDisconnectedObserver;
  87914. private _updateCacheWhenTrackingDisabledObserver;
  87915. /**
  87916. * Initializes the controllers and their meshes
  87917. */
  87918. initControllers(): void;
  87919. }
  87920. }
  87921. declare module BABYLON {
  87922. /**
  87923. * Size options for a post process
  87924. */
  87925. export type PostProcessOptions = {
  87926. width: number;
  87927. height: number;
  87928. };
  87929. /**
  87930. * PostProcess can be used to apply a shader to a texture after it has been rendered
  87931. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  87932. */
  87933. export class PostProcess {
  87934. /** Name of the PostProcess. */
  87935. name: string;
  87936. /**
  87937. * Gets or sets the unique id of the post process
  87938. */
  87939. uniqueId: number;
  87940. /**
  87941. * Width of the texture to apply the post process on
  87942. */
  87943. width: number;
  87944. /**
  87945. * Height of the texture to apply the post process on
  87946. */
  87947. height: number;
  87948. /**
  87949. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  87950. * @hidden
  87951. */
  87952. _outputTexture: Nullable<InternalTexture>;
  87953. /**
  87954. * Sampling mode used by the shader
  87955. * See https://doc.babylonjs.com/classes/3.1/texture
  87956. */
  87957. renderTargetSamplingMode: number;
  87958. /**
  87959. * Clear color to use when screen clearing
  87960. */
  87961. clearColor: Color4;
  87962. /**
  87963. * If the buffer needs to be cleared before applying the post process. (default: true)
  87964. * Should be set to false if shader will overwrite all previous pixels.
  87965. */
  87966. autoClear: boolean;
  87967. /**
  87968. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  87969. */
  87970. alphaMode: number;
  87971. /**
  87972. * Sets the setAlphaBlendConstants of the babylon engine
  87973. */
  87974. alphaConstants: Color4;
  87975. /**
  87976. * Animations to be used for the post processing
  87977. */
  87978. animations: Animation[];
  87979. /**
  87980. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  87981. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  87982. */
  87983. enablePixelPerfectMode: boolean;
  87984. /**
  87985. * Force the postprocess to be applied without taking in account viewport
  87986. */
  87987. forceFullscreenViewport: boolean;
  87988. /**
  87989. * List of inspectable custom properties (used by the Inspector)
  87990. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87991. */
  87992. inspectableCustomProperties: IInspectable[];
  87993. /**
  87994. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  87995. *
  87996. * | Value | Type | Description |
  87997. * | ----- | ----------------------------------- | ----------- |
  87998. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  87999. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  88000. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  88001. *
  88002. */
  88003. scaleMode: number;
  88004. /**
  88005. * Force textures to be a power of two (default: false)
  88006. */
  88007. alwaysForcePOT: boolean;
  88008. private _samples;
  88009. /**
  88010. * Number of sample textures (default: 1)
  88011. */
  88012. get samples(): number;
  88013. set samples(n: number);
  88014. /**
  88015. * Modify the scale of the post process to be the same as the viewport (default: false)
  88016. */
  88017. adaptScaleToCurrentViewport: boolean;
  88018. private _camera;
  88019. private _scene;
  88020. private _engine;
  88021. private _options;
  88022. private _reusable;
  88023. private _textureType;
  88024. private _textureFormat;
  88025. /**
  88026. * Smart array of input and output textures for the post process.
  88027. * @hidden
  88028. */
  88029. _textures: SmartArray<InternalTexture>;
  88030. /**
  88031. * The index in _textures that corresponds to the output texture.
  88032. * @hidden
  88033. */
  88034. _currentRenderTextureInd: number;
  88035. private _effect;
  88036. private _samplers;
  88037. private _fragmentUrl;
  88038. private _vertexUrl;
  88039. private _parameters;
  88040. private _scaleRatio;
  88041. protected _indexParameters: any;
  88042. private _shareOutputWithPostProcess;
  88043. private _texelSize;
  88044. private _forcedOutputTexture;
  88045. /**
  88046. * Returns the fragment url or shader name used in the post process.
  88047. * @returns the fragment url or name in the shader store.
  88048. */
  88049. getEffectName(): string;
  88050. /**
  88051. * An event triggered when the postprocess is activated.
  88052. */
  88053. onActivateObservable: Observable<Camera>;
  88054. private _onActivateObserver;
  88055. /**
  88056. * A function that is added to the onActivateObservable
  88057. */
  88058. set onActivate(callback: Nullable<(camera: Camera) => void>);
  88059. /**
  88060. * An event triggered when the postprocess changes its size.
  88061. */
  88062. onSizeChangedObservable: Observable<PostProcess>;
  88063. private _onSizeChangedObserver;
  88064. /**
  88065. * A function that is added to the onSizeChangedObservable
  88066. */
  88067. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  88068. /**
  88069. * An event triggered when the postprocess applies its effect.
  88070. */
  88071. onApplyObservable: Observable<Effect>;
  88072. private _onApplyObserver;
  88073. /**
  88074. * A function that is added to the onApplyObservable
  88075. */
  88076. set onApply(callback: (effect: Effect) => void);
  88077. /**
  88078. * An event triggered before rendering the postprocess
  88079. */
  88080. onBeforeRenderObservable: Observable<Effect>;
  88081. private _onBeforeRenderObserver;
  88082. /**
  88083. * A function that is added to the onBeforeRenderObservable
  88084. */
  88085. set onBeforeRender(callback: (effect: Effect) => void);
  88086. /**
  88087. * An event triggered after rendering the postprocess
  88088. */
  88089. onAfterRenderObservable: Observable<Effect>;
  88090. private _onAfterRenderObserver;
  88091. /**
  88092. * A function that is added to the onAfterRenderObservable
  88093. */
  88094. set onAfterRender(callback: (efect: Effect) => void);
  88095. /**
  88096. * 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
  88097. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  88098. */
  88099. get inputTexture(): InternalTexture;
  88100. set inputTexture(value: InternalTexture);
  88101. /**
  88102. * Gets the camera which post process is applied to.
  88103. * @returns The camera the post process is applied to.
  88104. */
  88105. getCamera(): Camera;
  88106. /**
  88107. * Gets the texel size of the postprocess.
  88108. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  88109. */
  88110. get texelSize(): Vector2;
  88111. /**
  88112. * Creates a new instance PostProcess
  88113. * @param name The name of the PostProcess.
  88114. * @param fragmentUrl The url of the fragment shader to be used.
  88115. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  88116. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  88117. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88118. * @param camera The camera to apply the render pass to.
  88119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88120. * @param engine The engine which the post process will be applied. (default: current engine)
  88121. * @param reusable If the post process can be reused on the same frame. (default: false)
  88122. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  88123. * @param textureType Type of textures used when performing the post process. (default: 0)
  88124. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  88125. * @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
  88126. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  88127. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  88128. */
  88129. constructor(
  88130. /** Name of the PostProcess. */
  88131. 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);
  88132. /**
  88133. * Gets a string idenfifying the name of the class
  88134. * @returns "PostProcess" string
  88135. */
  88136. getClassName(): string;
  88137. /**
  88138. * Gets the engine which this post process belongs to.
  88139. * @returns The engine the post process was enabled with.
  88140. */
  88141. getEngine(): Engine;
  88142. /**
  88143. * The effect that is created when initializing the post process.
  88144. * @returns The created effect corresponding the the postprocess.
  88145. */
  88146. getEffect(): Effect;
  88147. /**
  88148. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  88149. * @param postProcess The post process to share the output with.
  88150. * @returns This post process.
  88151. */
  88152. shareOutputWith(postProcess: PostProcess): PostProcess;
  88153. /**
  88154. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  88155. * This should be called if the post process that shares output with this post process is disabled/disposed.
  88156. */
  88157. useOwnOutput(): void;
  88158. /**
  88159. * Updates the effect with the current post process compile time values and recompiles the shader.
  88160. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88161. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88162. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88163. * @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
  88164. * @param onCompiled Called when the shader has been compiled.
  88165. * @param onError Called if there is an error when compiling a shader.
  88166. */
  88167. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88168. /**
  88169. * The post process is reusable if it can be used multiple times within one frame.
  88170. * @returns If the post process is reusable
  88171. */
  88172. isReusable(): boolean;
  88173. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  88174. markTextureDirty(): void;
  88175. /**
  88176. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  88177. * 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.
  88178. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  88179. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  88180. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  88181. * @returns The target texture that was bound to be written to.
  88182. */
  88183. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  88184. /**
  88185. * If the post process is supported.
  88186. */
  88187. get isSupported(): boolean;
  88188. /**
  88189. * The aspect ratio of the output texture.
  88190. */
  88191. get aspectRatio(): number;
  88192. /**
  88193. * Get a value indicating if the post-process is ready to be used
  88194. * @returns true if the post-process is ready (shader is compiled)
  88195. */
  88196. isReady(): boolean;
  88197. /**
  88198. * Binds all textures and uniforms to the shader, this will be run on every pass.
  88199. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  88200. */
  88201. apply(): Nullable<Effect>;
  88202. private _disposeTextures;
  88203. /**
  88204. * Disposes the post process.
  88205. * @param camera The camera to dispose the post process on.
  88206. */
  88207. dispose(camera?: Camera): void;
  88208. }
  88209. }
  88210. declare module BABYLON {
  88211. /** @hidden */
  88212. export var kernelBlurVaryingDeclaration: {
  88213. name: string;
  88214. shader: string;
  88215. };
  88216. }
  88217. declare module BABYLON {
  88218. /** @hidden */
  88219. export var kernelBlurFragment: {
  88220. name: string;
  88221. shader: string;
  88222. };
  88223. }
  88224. declare module BABYLON {
  88225. /** @hidden */
  88226. export var kernelBlurFragment2: {
  88227. name: string;
  88228. shader: string;
  88229. };
  88230. }
  88231. declare module BABYLON {
  88232. /** @hidden */
  88233. export var kernelBlurPixelShader: {
  88234. name: string;
  88235. shader: string;
  88236. };
  88237. }
  88238. declare module BABYLON {
  88239. /** @hidden */
  88240. export var kernelBlurVertex: {
  88241. name: string;
  88242. shader: string;
  88243. };
  88244. }
  88245. declare module BABYLON {
  88246. /** @hidden */
  88247. export var kernelBlurVertexShader: {
  88248. name: string;
  88249. shader: string;
  88250. };
  88251. }
  88252. declare module BABYLON {
  88253. /**
  88254. * The Blur Post Process which blurs an image based on a kernel and direction.
  88255. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  88256. */
  88257. export class BlurPostProcess extends PostProcess {
  88258. /** The direction in which to blur the image. */
  88259. direction: Vector2;
  88260. private blockCompilation;
  88261. protected _kernel: number;
  88262. protected _idealKernel: number;
  88263. protected _packedFloat: boolean;
  88264. private _staticDefines;
  88265. /**
  88266. * Sets the length in pixels of the blur sample region
  88267. */
  88268. set kernel(v: number);
  88269. /**
  88270. * Gets the length in pixels of the blur sample region
  88271. */
  88272. get kernel(): number;
  88273. /**
  88274. * Sets wether or not the blur needs to unpack/repack floats
  88275. */
  88276. set packedFloat(v: boolean);
  88277. /**
  88278. * Gets wether or not the blur is unpacking/repacking floats
  88279. */
  88280. get packedFloat(): boolean;
  88281. /**
  88282. * Creates a new instance BlurPostProcess
  88283. * @param name The name of the effect.
  88284. * @param direction The direction in which to blur the image.
  88285. * @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.
  88286. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88287. * @param camera The camera to apply the render pass to.
  88288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88289. * @param engine The engine which the post process will be applied. (default: current engine)
  88290. * @param reusable If the post process can be reused on the same frame. (default: false)
  88291. * @param textureType Type of textures used when performing the post process. (default: 0)
  88292. * @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)
  88293. */
  88294. constructor(name: string,
  88295. /** The direction in which to blur the image. */
  88296. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  88297. /**
  88298. * Updates the effect with the current post process compile time values and recompiles the shader.
  88299. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88300. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88301. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88302. * @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
  88303. * @param onCompiled Called when the shader has been compiled.
  88304. * @param onError Called if there is an error when compiling a shader.
  88305. */
  88306. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88307. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88308. /**
  88309. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  88310. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  88311. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  88312. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  88313. * The gaps between physical kernels are compensated for in the weighting of the samples
  88314. * @param idealKernel Ideal blur kernel.
  88315. * @return Nearest best kernel.
  88316. */
  88317. protected _nearestBestKernel(idealKernel: number): number;
  88318. /**
  88319. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  88320. * @param x The point on the Gaussian distribution to sample.
  88321. * @return the value of the Gaussian function at x.
  88322. */
  88323. protected _gaussianWeight(x: number): number;
  88324. /**
  88325. * Generates a string that can be used as a floating point number in GLSL.
  88326. * @param x Value to print.
  88327. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  88328. * @return GLSL float string.
  88329. */
  88330. protected _glslFloat(x: number, decimalFigures?: number): string;
  88331. }
  88332. }
  88333. declare module BABYLON {
  88334. /**
  88335. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88336. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88337. * You can then easily use it as a reflectionTexture on a flat surface.
  88338. * In case the surface is not a plane, please consider relying on reflection probes.
  88339. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88340. */
  88341. export class MirrorTexture extends RenderTargetTexture {
  88342. private scene;
  88343. /**
  88344. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  88345. * 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.
  88346. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88347. */
  88348. mirrorPlane: Plane;
  88349. /**
  88350. * Define the blur ratio used to blur the reflection if needed.
  88351. */
  88352. set blurRatio(value: number);
  88353. get blurRatio(): number;
  88354. /**
  88355. * Define the adaptive blur kernel used to blur the reflection if needed.
  88356. * This will autocompute the closest best match for the `blurKernel`
  88357. */
  88358. set adaptiveBlurKernel(value: number);
  88359. /**
  88360. * Define the blur kernel used to blur the reflection if needed.
  88361. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88362. */
  88363. set blurKernel(value: number);
  88364. /**
  88365. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  88366. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88367. */
  88368. set blurKernelX(value: number);
  88369. get blurKernelX(): number;
  88370. /**
  88371. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  88372. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88373. */
  88374. set blurKernelY(value: number);
  88375. get blurKernelY(): number;
  88376. private _autoComputeBlurKernel;
  88377. protected _onRatioRescale(): void;
  88378. private _updateGammaSpace;
  88379. private _imageProcessingConfigChangeObserver;
  88380. private _transformMatrix;
  88381. private _mirrorMatrix;
  88382. private _savedViewMatrix;
  88383. private _blurX;
  88384. private _blurY;
  88385. private _adaptiveBlurKernel;
  88386. private _blurKernelX;
  88387. private _blurKernelY;
  88388. private _blurRatio;
  88389. /**
  88390. * Instantiates a Mirror Texture.
  88391. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88392. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88393. * You can then easily use it as a reflectionTexture on a flat surface.
  88394. * In case the surface is not a plane, please consider relying on reflection probes.
  88395. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88396. * @param name
  88397. * @param size
  88398. * @param scene
  88399. * @param generateMipMaps
  88400. * @param type
  88401. * @param samplingMode
  88402. * @param generateDepthBuffer
  88403. */
  88404. constructor(name: string, size: number | {
  88405. width: number;
  88406. height: number;
  88407. } | {
  88408. ratio: number;
  88409. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  88410. private _preparePostProcesses;
  88411. /**
  88412. * Clone the mirror texture.
  88413. * @returns the cloned texture
  88414. */
  88415. clone(): MirrorTexture;
  88416. /**
  88417. * Serialize the texture to a JSON representation you could use in Parse later on
  88418. * @returns the serialized JSON representation
  88419. */
  88420. serialize(): any;
  88421. /**
  88422. * Dispose the texture and release its associated resources.
  88423. */
  88424. dispose(): void;
  88425. }
  88426. }
  88427. declare module BABYLON {
  88428. /**
  88429. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88430. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88431. */
  88432. export class Texture extends BaseTexture {
  88433. /**
  88434. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  88435. */
  88436. static SerializeBuffers: boolean;
  88437. /** @hidden */
  88438. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  88439. /** @hidden */
  88440. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  88441. /** @hidden */
  88442. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  88443. /** nearest is mag = nearest and min = nearest and mip = linear */
  88444. static readonly NEAREST_SAMPLINGMODE: number;
  88445. /** nearest is mag = nearest and min = nearest and mip = linear */
  88446. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  88447. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88448. static readonly BILINEAR_SAMPLINGMODE: number;
  88449. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88450. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  88451. /** Trilinear is mag = linear and min = linear and mip = linear */
  88452. static readonly TRILINEAR_SAMPLINGMODE: number;
  88453. /** Trilinear is mag = linear and min = linear and mip = linear */
  88454. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  88455. /** mag = nearest and min = nearest and mip = nearest */
  88456. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  88457. /** mag = nearest and min = linear and mip = nearest */
  88458. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  88459. /** mag = nearest and min = linear and mip = linear */
  88460. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  88461. /** mag = nearest and min = linear and mip = none */
  88462. static readonly NEAREST_LINEAR: number;
  88463. /** mag = nearest and min = nearest and mip = none */
  88464. static readonly NEAREST_NEAREST: number;
  88465. /** mag = linear and min = nearest and mip = nearest */
  88466. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  88467. /** mag = linear and min = nearest and mip = linear */
  88468. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  88469. /** mag = linear and min = linear and mip = none */
  88470. static readonly LINEAR_LINEAR: number;
  88471. /** mag = linear and min = nearest and mip = none */
  88472. static readonly LINEAR_NEAREST: number;
  88473. /** Explicit coordinates mode */
  88474. static readonly EXPLICIT_MODE: number;
  88475. /** Spherical coordinates mode */
  88476. static readonly SPHERICAL_MODE: number;
  88477. /** Planar coordinates mode */
  88478. static readonly PLANAR_MODE: number;
  88479. /** Cubic coordinates mode */
  88480. static readonly CUBIC_MODE: number;
  88481. /** Projection coordinates mode */
  88482. static readonly PROJECTION_MODE: number;
  88483. /** Inverse Cubic coordinates mode */
  88484. static readonly SKYBOX_MODE: number;
  88485. /** Inverse Cubic coordinates mode */
  88486. static readonly INVCUBIC_MODE: number;
  88487. /** Equirectangular coordinates mode */
  88488. static readonly EQUIRECTANGULAR_MODE: number;
  88489. /** Equirectangular Fixed coordinates mode */
  88490. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  88491. /** Equirectangular Fixed Mirrored coordinates mode */
  88492. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  88493. /** Texture is not repeating outside of 0..1 UVs */
  88494. static readonly CLAMP_ADDRESSMODE: number;
  88495. /** Texture is repeating outside of 0..1 UVs */
  88496. static readonly WRAP_ADDRESSMODE: number;
  88497. /** Texture is repeating and mirrored */
  88498. static readonly MIRROR_ADDRESSMODE: number;
  88499. /**
  88500. * 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
  88501. */
  88502. static UseSerializedUrlIfAny: boolean;
  88503. /**
  88504. * Define the url of the texture.
  88505. */
  88506. url: Nullable<string>;
  88507. /**
  88508. * Define an offset on the texture to offset the u coordinates of the UVs
  88509. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88510. */
  88511. uOffset: number;
  88512. /**
  88513. * Define an offset on the texture to offset the v coordinates of the UVs
  88514. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88515. */
  88516. vOffset: number;
  88517. /**
  88518. * Define an offset on the texture to scale the u coordinates of the UVs
  88519. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88520. */
  88521. uScale: number;
  88522. /**
  88523. * Define an offset on the texture to scale the v coordinates of the UVs
  88524. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88525. */
  88526. vScale: number;
  88527. /**
  88528. * Define an offset on the texture to rotate around the u coordinates of the UVs
  88529. * @see http://doc.babylonjs.com/how_to/more_materials
  88530. */
  88531. uAng: number;
  88532. /**
  88533. * Define an offset on the texture to rotate around the v coordinates of the UVs
  88534. * @see http://doc.babylonjs.com/how_to/more_materials
  88535. */
  88536. vAng: number;
  88537. /**
  88538. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  88539. * @see http://doc.babylonjs.com/how_to/more_materials
  88540. */
  88541. wAng: number;
  88542. /**
  88543. * Defines the center of rotation (U)
  88544. */
  88545. uRotationCenter: number;
  88546. /**
  88547. * Defines the center of rotation (V)
  88548. */
  88549. vRotationCenter: number;
  88550. /**
  88551. * Defines the center of rotation (W)
  88552. */
  88553. wRotationCenter: number;
  88554. /**
  88555. * Are mip maps generated for this texture or not.
  88556. */
  88557. get noMipmap(): boolean;
  88558. /**
  88559. * List of inspectable custom properties (used by the Inspector)
  88560. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88561. */
  88562. inspectableCustomProperties: Nullable<IInspectable[]>;
  88563. private _noMipmap;
  88564. /** @hidden */
  88565. _invertY: boolean;
  88566. private _rowGenerationMatrix;
  88567. private _cachedTextureMatrix;
  88568. private _projectionModeMatrix;
  88569. private _t0;
  88570. private _t1;
  88571. private _t2;
  88572. private _cachedUOffset;
  88573. private _cachedVOffset;
  88574. private _cachedUScale;
  88575. private _cachedVScale;
  88576. private _cachedUAng;
  88577. private _cachedVAng;
  88578. private _cachedWAng;
  88579. private _cachedProjectionMatrixId;
  88580. private _cachedCoordinatesMode;
  88581. /** @hidden */
  88582. protected _initialSamplingMode: number;
  88583. /** @hidden */
  88584. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  88585. private _deleteBuffer;
  88586. protected _format: Nullable<number>;
  88587. private _delayedOnLoad;
  88588. private _delayedOnError;
  88589. private _mimeType?;
  88590. /**
  88591. * Observable triggered once the texture has been loaded.
  88592. */
  88593. onLoadObservable: Observable<Texture>;
  88594. protected _isBlocking: boolean;
  88595. /**
  88596. * Is the texture preventing material to render while loading.
  88597. * If false, a default texture will be used instead of the loading one during the preparation step.
  88598. */
  88599. set isBlocking(value: boolean);
  88600. get isBlocking(): boolean;
  88601. /**
  88602. * Get the current sampling mode associated with the texture.
  88603. */
  88604. get samplingMode(): number;
  88605. /**
  88606. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  88607. */
  88608. get invertY(): boolean;
  88609. /**
  88610. * Instantiates a new texture.
  88611. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88612. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88613. * @param url defines the url of the picture to load as a texture
  88614. * @param scene defines the scene or engine the texture will belong to
  88615. * @param noMipmap defines if the texture will require mip maps or not
  88616. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  88617. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88618. * @param onLoad defines a callback triggered when the texture has been loaded
  88619. * @param onError defines a callback triggered when an error occurred during the loading session
  88620. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  88621. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  88622. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88623. * @param mimeType defines an optional mime type information
  88624. */
  88625. 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);
  88626. /**
  88627. * Update the url (and optional buffer) of this texture if url was null during construction.
  88628. * @param url the url of the texture
  88629. * @param buffer the buffer of the texture (defaults to null)
  88630. * @param onLoad callback called when the texture is loaded (defaults to null)
  88631. */
  88632. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  88633. /**
  88634. * Finish the loading sequence of a texture flagged as delayed load.
  88635. * @hidden
  88636. */
  88637. delayLoad(): void;
  88638. private _prepareRowForTextureGeneration;
  88639. /**
  88640. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  88641. * @returns the transform matrix of the texture.
  88642. */
  88643. getTextureMatrix(uBase?: number): Matrix;
  88644. /**
  88645. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  88646. * @returns The reflection texture transform
  88647. */
  88648. getReflectionTextureMatrix(): Matrix;
  88649. /**
  88650. * Clones the texture.
  88651. * @returns the cloned texture
  88652. */
  88653. clone(): Texture;
  88654. /**
  88655. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88656. * @returns The JSON representation of the texture
  88657. */
  88658. serialize(): any;
  88659. /**
  88660. * Get the current class name of the texture useful for serialization or dynamic coding.
  88661. * @returns "Texture"
  88662. */
  88663. getClassName(): string;
  88664. /**
  88665. * Dispose the texture and release its associated resources.
  88666. */
  88667. dispose(): void;
  88668. /**
  88669. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  88670. * @param parsedTexture Define the JSON representation of the texture
  88671. * @param scene Define the scene the parsed texture should be instantiated in
  88672. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  88673. * @returns The parsed texture if successful
  88674. */
  88675. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  88676. /**
  88677. * Creates a texture from its base 64 representation.
  88678. * @param data Define the base64 payload without the data: prefix
  88679. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  88680. * @param scene Define the scene the texture should belong to
  88681. * @param noMipmap Forces the texture to not create mip map information if true
  88682. * @param invertY define if the texture needs to be inverted on the y axis during loading
  88683. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88684. * @param onLoad define a callback triggered when the texture has been loaded
  88685. * @param onError define a callback triggered when an error occurred during the loading session
  88686. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88687. * @returns the created texture
  88688. */
  88689. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  88690. /**
  88691. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  88692. * @param data Define the base64 payload without the data: prefix
  88693. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  88694. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  88695. * @param scene Define the scene the texture should belong to
  88696. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  88697. * @param noMipmap Forces the texture to not create mip map information if true
  88698. * @param invertY define if the texture needs to be inverted on the y axis during loading
  88699. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  88700. * @param onLoad define a callback triggered when the texture has been loaded
  88701. * @param onError define a callback triggered when an error occurred during the loading session
  88702. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  88703. * @returns the created texture
  88704. */
  88705. 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;
  88706. }
  88707. }
  88708. declare module BABYLON {
  88709. /**
  88710. * PostProcessManager is used to manage one or more post processes or post process pipelines
  88711. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  88712. */
  88713. export class PostProcessManager {
  88714. private _scene;
  88715. private _indexBuffer;
  88716. private _vertexBuffers;
  88717. /**
  88718. * Creates a new instance PostProcess
  88719. * @param scene The scene that the post process is associated with.
  88720. */
  88721. constructor(scene: Scene);
  88722. private _prepareBuffers;
  88723. private _buildIndexBuffer;
  88724. /**
  88725. * Rebuilds the vertex buffers of the manager.
  88726. * @hidden
  88727. */
  88728. _rebuild(): void;
  88729. /**
  88730. * Prepares a frame to be run through a post process.
  88731. * @param sourceTexture The input texture to the post procesess. (default: null)
  88732. * @param postProcesses An array of post processes to be run. (default: null)
  88733. * @returns True if the post processes were able to be run.
  88734. * @hidden
  88735. */
  88736. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  88737. /**
  88738. * Manually render a set of post processes to a texture.
  88739. * @param postProcesses An array of post processes to be run.
  88740. * @param targetTexture The target texture to render to.
  88741. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  88742. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  88743. * @param lodLevel defines which lod of the texture to render to
  88744. */
  88745. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  88746. /**
  88747. * Finalize the result of the output of the postprocesses.
  88748. * @param doNotPresent If true the result will not be displayed to the screen.
  88749. * @param targetTexture The target texture to render to.
  88750. * @param faceIndex The index of the face to bind the target texture to.
  88751. * @param postProcesses The array of post processes to render.
  88752. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  88753. * @hidden
  88754. */
  88755. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  88756. /**
  88757. * Disposes of the post process manager.
  88758. */
  88759. dispose(): void;
  88760. }
  88761. }
  88762. declare module BABYLON {
  88763. /** Interface used by value gradients (color, factor, ...) */
  88764. export interface IValueGradient {
  88765. /**
  88766. * Gets or sets the gradient value (between 0 and 1)
  88767. */
  88768. gradient: number;
  88769. }
  88770. /** Class used to store color4 gradient */
  88771. export class ColorGradient implements IValueGradient {
  88772. /**
  88773. * Gets or sets the gradient value (between 0 and 1)
  88774. */
  88775. gradient: number;
  88776. /**
  88777. * Gets or sets first associated color
  88778. */
  88779. color1: Color4;
  88780. /**
  88781. * Gets or sets second associated color
  88782. */
  88783. color2?: Color4;
  88784. /**
  88785. * Will get a color picked randomly between color1 and color2.
  88786. * If color2 is undefined then color1 will be used
  88787. * @param result defines the target Color4 to store the result in
  88788. */
  88789. getColorToRef(result: Color4): void;
  88790. }
  88791. /** Class used to store color 3 gradient */
  88792. export class Color3Gradient implements IValueGradient {
  88793. /**
  88794. * Gets or sets the gradient value (between 0 and 1)
  88795. */
  88796. gradient: number;
  88797. /**
  88798. * Gets or sets the associated color
  88799. */
  88800. color: Color3;
  88801. }
  88802. /** Class used to store factor gradient */
  88803. export class FactorGradient implements IValueGradient {
  88804. /**
  88805. * Gets or sets the gradient value (between 0 and 1)
  88806. */
  88807. gradient: number;
  88808. /**
  88809. * Gets or sets first associated factor
  88810. */
  88811. factor1: number;
  88812. /**
  88813. * Gets or sets second associated factor
  88814. */
  88815. factor2?: number;
  88816. /**
  88817. * Will get a number picked randomly between factor1 and factor2.
  88818. * If factor2 is undefined then factor1 will be used
  88819. * @returns the picked number
  88820. */
  88821. getFactor(): number;
  88822. }
  88823. /**
  88824. * Helper used to simplify some generic gradient tasks
  88825. */
  88826. export class GradientHelper {
  88827. /**
  88828. * Gets the current gradient from an array of IValueGradient
  88829. * @param ratio defines the current ratio to get
  88830. * @param gradients defines the array of IValueGradient
  88831. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88832. */
  88833. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88834. }
  88835. }
  88836. declare module BABYLON {
  88837. interface ThinEngine {
  88838. /**
  88839. * Creates a dynamic texture
  88840. * @param width defines the width of the texture
  88841. * @param height defines the height of the texture
  88842. * @param generateMipMaps defines if the engine should generate the mip levels
  88843. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88844. * @returns the dynamic texture inside an InternalTexture
  88845. */
  88846. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88847. /**
  88848. * Update the content of a dynamic texture
  88849. * @param texture defines the texture to update
  88850. * @param canvas defines the canvas containing the source
  88851. * @param invertY defines if data must be stored with Y axis inverted
  88852. * @param premulAlpha defines if alpha is stored as premultiplied
  88853. * @param format defines the format of the data
  88854. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88855. */
  88856. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88857. }
  88858. }
  88859. declare module BABYLON {
  88860. /**
  88861. * Helper class used to generate a canvas to manipulate images
  88862. */
  88863. export class CanvasGenerator {
  88864. /**
  88865. * Create a new canvas (or offscreen canvas depending on the context)
  88866. * @param width defines the expected width
  88867. * @param height defines the expected height
  88868. * @return a new canvas or offscreen canvas
  88869. */
  88870. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88871. }
  88872. }
  88873. declare module BABYLON {
  88874. /**
  88875. * A class extending Texture allowing drawing on a texture
  88876. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88877. */
  88878. export class DynamicTexture extends Texture {
  88879. private _generateMipMaps;
  88880. private _canvas;
  88881. private _context;
  88882. private _engine;
  88883. /**
  88884. * Creates a DynamicTexture
  88885. * @param name defines the name of the texture
  88886. * @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
  88887. * @param scene defines the scene where you want the texture
  88888. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88889. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88890. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88891. */
  88892. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88893. /**
  88894. * Get the current class name of the texture useful for serialization or dynamic coding.
  88895. * @returns "DynamicTexture"
  88896. */
  88897. getClassName(): string;
  88898. /**
  88899. * Gets the current state of canRescale
  88900. */
  88901. get canRescale(): boolean;
  88902. private _recreate;
  88903. /**
  88904. * Scales the texture
  88905. * @param ratio the scale factor to apply to both width and height
  88906. */
  88907. scale(ratio: number): void;
  88908. /**
  88909. * Resizes the texture
  88910. * @param width the new width
  88911. * @param height the new height
  88912. */
  88913. scaleTo(width: number, height: number): void;
  88914. /**
  88915. * Gets the context of the canvas used by the texture
  88916. * @returns the canvas context of the dynamic texture
  88917. */
  88918. getContext(): CanvasRenderingContext2D;
  88919. /**
  88920. * Clears the texture
  88921. */
  88922. clear(): void;
  88923. /**
  88924. * Updates the texture
  88925. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88926. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88927. */
  88928. update(invertY?: boolean, premulAlpha?: boolean): void;
  88929. /**
  88930. * Draws text onto the texture
  88931. * @param text defines the text to be drawn
  88932. * @param x defines the placement of the text from the left
  88933. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88934. * @param font defines the font to be used with font-style, font-size, font-name
  88935. * @param color defines the color used for the text
  88936. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88937. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88938. * @param update defines whether texture is immediately update (default is true)
  88939. */
  88940. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  88941. /**
  88942. * Clones the texture
  88943. * @returns the clone of the texture.
  88944. */
  88945. clone(): DynamicTexture;
  88946. /**
  88947. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88948. * @returns a serialized dynamic texture object
  88949. */
  88950. serialize(): any;
  88951. /** @hidden */
  88952. _rebuild(): void;
  88953. }
  88954. }
  88955. declare module BABYLON {
  88956. interface AbstractScene {
  88957. /**
  88958. * The list of procedural textures added to the scene
  88959. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88960. */
  88961. proceduralTextures: Array<ProceduralTexture>;
  88962. }
  88963. /**
  88964. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  88965. * in a given scene.
  88966. */
  88967. export class ProceduralTextureSceneComponent implements ISceneComponent {
  88968. /**
  88969. * The component name helpfull to identify the component in the list of scene components.
  88970. */
  88971. readonly name: string;
  88972. /**
  88973. * The scene the component belongs to.
  88974. */
  88975. scene: Scene;
  88976. /**
  88977. * Creates a new instance of the component for the given scene
  88978. * @param scene Defines the scene to register the component in
  88979. */
  88980. constructor(scene: Scene);
  88981. /**
  88982. * Registers the component in a given scene
  88983. */
  88984. register(): void;
  88985. /**
  88986. * Rebuilds the elements related to this component in case of
  88987. * context lost for instance.
  88988. */
  88989. rebuild(): void;
  88990. /**
  88991. * Disposes the component and the associated ressources.
  88992. */
  88993. dispose(): void;
  88994. private _beforeClear;
  88995. }
  88996. }
  88997. declare module BABYLON {
  88998. interface ThinEngine {
  88999. /**
  89000. * Creates a new render target cube texture
  89001. * @param size defines the size of the texture
  89002. * @param options defines the options used to create the texture
  89003. * @returns a new render target cube texture stored in an InternalTexture
  89004. */
  89005. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89006. }
  89007. }
  89008. declare module BABYLON {
  89009. /** @hidden */
  89010. export var proceduralVertexShader: {
  89011. name: string;
  89012. shader: string;
  89013. };
  89014. }
  89015. declare module BABYLON {
  89016. /**
  89017. * 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.
  89018. * This is the base class of any Procedural texture and contains most of the shareable code.
  89019. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89020. */
  89021. export class ProceduralTexture extends Texture {
  89022. isCube: boolean;
  89023. /**
  89024. * Define if the texture is enabled or not (disabled texture will not render)
  89025. */
  89026. isEnabled: boolean;
  89027. /**
  89028. * Define if the texture must be cleared before rendering (default is true)
  89029. */
  89030. autoClear: boolean;
  89031. /**
  89032. * Callback called when the texture is generated
  89033. */
  89034. onGenerated: () => void;
  89035. /**
  89036. * Event raised when the texture is generated
  89037. */
  89038. onGeneratedObservable: Observable<ProceduralTexture>;
  89039. /** @hidden */
  89040. _generateMipMaps: boolean;
  89041. /** @hidden **/
  89042. _effect: Effect;
  89043. /** @hidden */
  89044. _textures: {
  89045. [key: string]: Texture;
  89046. };
  89047. private _size;
  89048. private _currentRefreshId;
  89049. private _frameId;
  89050. private _refreshRate;
  89051. private _vertexBuffers;
  89052. private _indexBuffer;
  89053. private _uniforms;
  89054. private _samplers;
  89055. private _fragment;
  89056. private _floats;
  89057. private _ints;
  89058. private _floatsArrays;
  89059. private _colors3;
  89060. private _colors4;
  89061. private _vectors2;
  89062. private _vectors3;
  89063. private _matrices;
  89064. private _fallbackTexture;
  89065. private _fallbackTextureUsed;
  89066. private _engine;
  89067. private _cachedDefines;
  89068. private _contentUpdateId;
  89069. private _contentData;
  89070. /**
  89071. * Instantiates a new procedural texture.
  89072. * 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.
  89073. * This is the base class of any Procedural texture and contains most of the shareable code.
  89074. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89075. * @param name Define the name of the texture
  89076. * @param size Define the size of the texture to create
  89077. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89078. * @param scene Define the scene the texture belongs to
  89079. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89080. * @param generateMipMaps Define if the texture should creates mip maps or not
  89081. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89082. */
  89083. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89084. /**
  89085. * The effect that is created when initializing the post process.
  89086. * @returns The created effect corresponding the the postprocess.
  89087. */
  89088. getEffect(): Effect;
  89089. /**
  89090. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89091. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89092. */
  89093. getContent(): Nullable<ArrayBufferView>;
  89094. private _createIndexBuffer;
  89095. /** @hidden */
  89096. _rebuild(): void;
  89097. /**
  89098. * Resets the texture in order to recreate its associated resources.
  89099. * This can be called in case of context loss
  89100. */
  89101. reset(): void;
  89102. protected _getDefines(): string;
  89103. /**
  89104. * Is the texture ready to be used ? (rendered at least once)
  89105. * @returns true if ready, otherwise, false.
  89106. */
  89107. isReady(): boolean;
  89108. /**
  89109. * Resets the refresh counter of the texture and start bak from scratch.
  89110. * Could be useful to regenerate the texture if it is setup to render only once.
  89111. */
  89112. resetRefreshCounter(): void;
  89113. /**
  89114. * Set the fragment shader to use in order to render the texture.
  89115. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89116. */
  89117. setFragment(fragment: any): void;
  89118. /**
  89119. * Define the refresh rate of the texture or the rendering frequency.
  89120. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89121. */
  89122. get refreshRate(): number;
  89123. set refreshRate(value: number);
  89124. /** @hidden */
  89125. _shouldRender(): boolean;
  89126. /**
  89127. * Get the size the texture is rendering at.
  89128. * @returns the size (texture is always squared)
  89129. */
  89130. getRenderSize(): number;
  89131. /**
  89132. * Resize the texture to new value.
  89133. * @param size Define the new size the texture should have
  89134. * @param generateMipMaps Define whether the new texture should create mip maps
  89135. */
  89136. resize(size: number, generateMipMaps: boolean): void;
  89137. private _checkUniform;
  89138. /**
  89139. * Set a texture in the shader program used to render.
  89140. * @param name Define the name of the uniform samplers as defined in the shader
  89141. * @param texture Define the texture to bind to this sampler
  89142. * @return the texture itself allowing "fluent" like uniform updates
  89143. */
  89144. setTexture(name: string, texture: Texture): ProceduralTexture;
  89145. /**
  89146. * Set a float in the shader.
  89147. * @param name Define the name of the uniform as defined in the shader
  89148. * @param value Define the value to give to the uniform
  89149. * @return the texture itself allowing "fluent" like uniform updates
  89150. */
  89151. setFloat(name: string, value: number): ProceduralTexture;
  89152. /**
  89153. * Set a int in the shader.
  89154. * @param name Define the name of the uniform as defined in the shader
  89155. * @param value Define the value to give to the uniform
  89156. * @return the texture itself allowing "fluent" like uniform updates
  89157. */
  89158. setInt(name: string, value: number): ProceduralTexture;
  89159. /**
  89160. * Set an array of floats in the shader.
  89161. * @param name Define the name of the uniform as defined in the shader
  89162. * @param value Define the value to give to the uniform
  89163. * @return the texture itself allowing "fluent" like uniform updates
  89164. */
  89165. setFloats(name: string, value: number[]): ProceduralTexture;
  89166. /**
  89167. * Set a vec3 in the shader from a Color3.
  89168. * @param name Define the name of the uniform as defined in the shader
  89169. * @param value Define the value to give to the uniform
  89170. * @return the texture itself allowing "fluent" like uniform updates
  89171. */
  89172. setColor3(name: string, value: Color3): ProceduralTexture;
  89173. /**
  89174. * Set a vec4 in the shader from a Color4.
  89175. * @param name Define the name of the uniform as defined in the shader
  89176. * @param value Define the value to give to the uniform
  89177. * @return the texture itself allowing "fluent" like uniform updates
  89178. */
  89179. setColor4(name: string, value: Color4): ProceduralTexture;
  89180. /**
  89181. * Set a vec2 in the shader from a Vector2.
  89182. * @param name Define the name of the uniform as defined in the shader
  89183. * @param value Define the value to give to the uniform
  89184. * @return the texture itself allowing "fluent" like uniform updates
  89185. */
  89186. setVector2(name: string, value: Vector2): ProceduralTexture;
  89187. /**
  89188. * Set a vec3 in the shader from a Vector3.
  89189. * @param name Define the name of the uniform as defined in the shader
  89190. * @param value Define the value to give to the uniform
  89191. * @return the texture itself allowing "fluent" like uniform updates
  89192. */
  89193. setVector3(name: string, value: Vector3): ProceduralTexture;
  89194. /**
  89195. * Set a mat4 in the shader from a MAtrix.
  89196. * @param name Define the name of the uniform as defined in the shader
  89197. * @param value Define the value to give to the uniform
  89198. * @return the texture itself allowing "fluent" like uniform updates
  89199. */
  89200. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89201. /**
  89202. * Render the texture to its associated render target.
  89203. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89204. */
  89205. render(useCameraPostProcess?: boolean): void;
  89206. /**
  89207. * Clone the texture.
  89208. * @returns the cloned texture
  89209. */
  89210. clone(): ProceduralTexture;
  89211. /**
  89212. * Dispose the texture and release its asoociated resources.
  89213. */
  89214. dispose(): void;
  89215. }
  89216. }
  89217. declare module BABYLON {
  89218. /**
  89219. * This represents the base class for particle system in Babylon.
  89220. * 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.
  89221. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89222. * @example https://doc.babylonjs.com/babylon101/particles
  89223. */
  89224. export class BaseParticleSystem {
  89225. /**
  89226. * Source color is added to the destination color without alpha affecting the result
  89227. */
  89228. static BLENDMODE_ONEONE: number;
  89229. /**
  89230. * Blend current color and particle color using particle’s alpha
  89231. */
  89232. static BLENDMODE_STANDARD: number;
  89233. /**
  89234. * Add current color and particle color multiplied by particle’s alpha
  89235. */
  89236. static BLENDMODE_ADD: number;
  89237. /**
  89238. * Multiply current color with particle color
  89239. */
  89240. static BLENDMODE_MULTIPLY: number;
  89241. /**
  89242. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89243. */
  89244. static BLENDMODE_MULTIPLYADD: number;
  89245. /**
  89246. * List of animations used by the particle system.
  89247. */
  89248. animations: Animation[];
  89249. /**
  89250. * The id of the Particle system.
  89251. */
  89252. id: string;
  89253. /**
  89254. * The friendly name of the Particle system.
  89255. */
  89256. name: string;
  89257. /**
  89258. * The rendering group used by the Particle system to chose when to render.
  89259. */
  89260. renderingGroupId: number;
  89261. /**
  89262. * The emitter represents the Mesh or position we are attaching the particle system to.
  89263. */
  89264. emitter: Nullable<AbstractMesh | Vector3>;
  89265. /**
  89266. * The maximum number of particles to emit per frame
  89267. */
  89268. emitRate: number;
  89269. /**
  89270. * If you want to launch only a few particles at once, that can be done, as well.
  89271. */
  89272. manualEmitCount: number;
  89273. /**
  89274. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89275. */
  89276. updateSpeed: number;
  89277. /**
  89278. * The amount of time the particle system is running (depends of the overall update speed).
  89279. */
  89280. targetStopDuration: number;
  89281. /**
  89282. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89283. */
  89284. disposeOnStop: boolean;
  89285. /**
  89286. * Minimum power of emitting particles.
  89287. */
  89288. minEmitPower: number;
  89289. /**
  89290. * Maximum power of emitting particles.
  89291. */
  89292. maxEmitPower: number;
  89293. /**
  89294. * Minimum life time of emitting particles.
  89295. */
  89296. minLifeTime: number;
  89297. /**
  89298. * Maximum life time of emitting particles.
  89299. */
  89300. maxLifeTime: number;
  89301. /**
  89302. * Minimum Size of emitting particles.
  89303. */
  89304. minSize: number;
  89305. /**
  89306. * Maximum Size of emitting particles.
  89307. */
  89308. maxSize: number;
  89309. /**
  89310. * Minimum scale of emitting particles on X axis.
  89311. */
  89312. minScaleX: number;
  89313. /**
  89314. * Maximum scale of emitting particles on X axis.
  89315. */
  89316. maxScaleX: number;
  89317. /**
  89318. * Minimum scale of emitting particles on Y axis.
  89319. */
  89320. minScaleY: number;
  89321. /**
  89322. * Maximum scale of emitting particles on Y axis.
  89323. */
  89324. maxScaleY: number;
  89325. /**
  89326. * Gets or sets the minimal initial rotation in radians.
  89327. */
  89328. minInitialRotation: number;
  89329. /**
  89330. * Gets or sets the maximal initial rotation in radians.
  89331. */
  89332. maxInitialRotation: number;
  89333. /**
  89334. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89335. */
  89336. minAngularSpeed: number;
  89337. /**
  89338. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89339. */
  89340. maxAngularSpeed: number;
  89341. /**
  89342. * The texture used to render each particle. (this can be a spritesheet)
  89343. */
  89344. particleTexture: Nullable<Texture>;
  89345. /**
  89346. * The layer mask we are rendering the particles through.
  89347. */
  89348. layerMask: number;
  89349. /**
  89350. * This can help using your own shader to render the particle system.
  89351. * The according effect will be created
  89352. */
  89353. customShader: any;
  89354. /**
  89355. * By default particle system starts as soon as they are created. This prevents the
  89356. * automatic start to happen and let you decide when to start emitting particles.
  89357. */
  89358. preventAutoStart: boolean;
  89359. private _noiseTexture;
  89360. /**
  89361. * Gets or sets a texture used to add random noise to particle positions
  89362. */
  89363. get noiseTexture(): Nullable<ProceduralTexture>;
  89364. set noiseTexture(value: Nullable<ProceduralTexture>);
  89365. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89366. noiseStrength: Vector3;
  89367. /**
  89368. * Callback triggered when the particle animation is ending.
  89369. */
  89370. onAnimationEnd: Nullable<() => void>;
  89371. /**
  89372. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89373. */
  89374. blendMode: number;
  89375. /**
  89376. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89377. * to override the particles.
  89378. */
  89379. forceDepthWrite: boolean;
  89380. /** 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 */
  89381. preWarmCycles: number;
  89382. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89383. preWarmStepOffset: number;
  89384. /**
  89385. * 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)
  89386. */
  89387. spriteCellChangeSpeed: number;
  89388. /**
  89389. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89390. */
  89391. startSpriteCellID: number;
  89392. /**
  89393. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89394. */
  89395. endSpriteCellID: number;
  89396. /**
  89397. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89398. */
  89399. spriteCellWidth: number;
  89400. /**
  89401. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89402. */
  89403. spriteCellHeight: number;
  89404. /**
  89405. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89406. */
  89407. spriteRandomStartCell: boolean;
  89408. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89409. translationPivot: Vector2;
  89410. /** @hidden */
  89411. protected _isAnimationSheetEnabled: boolean;
  89412. /**
  89413. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89414. */
  89415. beginAnimationOnStart: boolean;
  89416. /**
  89417. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89418. */
  89419. beginAnimationFrom: number;
  89420. /**
  89421. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89422. */
  89423. beginAnimationTo: number;
  89424. /**
  89425. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89426. */
  89427. beginAnimationLoop: boolean;
  89428. /**
  89429. * Gets or sets a world offset applied to all particles
  89430. */
  89431. worldOffset: Vector3;
  89432. /**
  89433. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89434. */
  89435. get isAnimationSheetEnabled(): boolean;
  89436. set isAnimationSheetEnabled(value: boolean);
  89437. /**
  89438. * Get hosting scene
  89439. * @returns the scene
  89440. */
  89441. getScene(): Scene;
  89442. /**
  89443. * You can use gravity if you want to give an orientation to your particles.
  89444. */
  89445. gravity: Vector3;
  89446. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89447. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89448. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89449. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89450. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89451. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89452. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89453. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89454. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89455. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89456. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89457. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89458. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89459. /**
  89460. * Defines the delay in milliseconds before starting the system (0 by default)
  89461. */
  89462. startDelay: number;
  89463. /**
  89464. * Gets the current list of drag gradients.
  89465. * You must use addDragGradient and removeDragGradient to udpate this list
  89466. * @returns the list of drag gradients
  89467. */
  89468. getDragGradients(): Nullable<Array<FactorGradient>>;
  89469. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89470. limitVelocityDamping: number;
  89471. /**
  89472. * Gets the current list of limit velocity gradients.
  89473. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89474. * @returns the list of limit velocity gradients
  89475. */
  89476. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89477. /**
  89478. * Gets the current list of color gradients.
  89479. * You must use addColorGradient and removeColorGradient to udpate this list
  89480. * @returns the list of color gradients
  89481. */
  89482. getColorGradients(): Nullable<Array<ColorGradient>>;
  89483. /**
  89484. * Gets the current list of size gradients.
  89485. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89486. * @returns the list of size gradients
  89487. */
  89488. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89489. /**
  89490. * Gets the current list of color remap gradients.
  89491. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89492. * @returns the list of color remap gradients
  89493. */
  89494. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89495. /**
  89496. * Gets the current list of alpha remap gradients.
  89497. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89498. * @returns the list of alpha remap gradients
  89499. */
  89500. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89501. /**
  89502. * Gets the current list of life time gradients.
  89503. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89504. * @returns the list of life time gradients
  89505. */
  89506. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89507. /**
  89508. * Gets the current list of angular speed gradients.
  89509. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89510. * @returns the list of angular speed gradients
  89511. */
  89512. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89513. /**
  89514. * Gets the current list of velocity gradients.
  89515. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89516. * @returns the list of velocity gradients
  89517. */
  89518. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89519. /**
  89520. * Gets the current list of start size gradients.
  89521. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89522. * @returns the list of start size gradients
  89523. */
  89524. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89525. /**
  89526. * Gets the current list of emit rate gradients.
  89527. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89528. * @returns the list of emit rate gradients
  89529. */
  89530. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89531. /**
  89532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89533. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89534. */
  89535. get direction1(): Vector3;
  89536. set direction1(value: Vector3);
  89537. /**
  89538. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89540. */
  89541. get direction2(): Vector3;
  89542. set direction2(value: Vector3);
  89543. /**
  89544. * 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.
  89545. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89546. */
  89547. get minEmitBox(): Vector3;
  89548. set minEmitBox(value: Vector3);
  89549. /**
  89550. * 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.
  89551. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89552. */
  89553. get maxEmitBox(): Vector3;
  89554. set maxEmitBox(value: Vector3);
  89555. /**
  89556. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89557. */
  89558. color1: Color4;
  89559. /**
  89560. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89561. */
  89562. color2: Color4;
  89563. /**
  89564. * Color the particle will have at the end of its lifetime
  89565. */
  89566. colorDead: Color4;
  89567. /**
  89568. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89569. */
  89570. textureMask: Color4;
  89571. /**
  89572. * The particle emitter type defines the emitter used by the particle system.
  89573. * It can be for example box, sphere, or cone...
  89574. */
  89575. particleEmitterType: IParticleEmitterType;
  89576. /** @hidden */
  89577. _isSubEmitter: boolean;
  89578. /**
  89579. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89580. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89581. */
  89582. billboardMode: number;
  89583. protected _isBillboardBased: boolean;
  89584. /**
  89585. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89586. */
  89587. get isBillboardBased(): boolean;
  89588. set isBillboardBased(value: boolean);
  89589. /**
  89590. * The scene the particle system belongs to.
  89591. */
  89592. protected _scene: Scene;
  89593. /**
  89594. * Local cache of defines for image processing.
  89595. */
  89596. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89597. /**
  89598. * Default configuration related to image processing available in the standard Material.
  89599. */
  89600. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89601. /**
  89602. * Gets the image processing configuration used either in this material.
  89603. */
  89604. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89605. /**
  89606. * Sets the Default image processing configuration used either in the this material.
  89607. *
  89608. * If sets to null, the scene one is in use.
  89609. */
  89610. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89611. /**
  89612. * Attaches a new image processing configuration to the Standard Material.
  89613. * @param configuration
  89614. */
  89615. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89616. /** @hidden */
  89617. protected _reset(): void;
  89618. /** @hidden */
  89619. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89620. /**
  89621. * Instantiates a particle system.
  89622. * 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.
  89623. * @param name The name of the particle system
  89624. */
  89625. constructor(name: string);
  89626. /**
  89627. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89630. * @returns the emitter
  89631. */
  89632. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89633. /**
  89634. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89635. * @param radius The radius of the hemisphere to emit from
  89636. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89637. * @returns the emitter
  89638. */
  89639. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89640. /**
  89641. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89642. * @param radius The radius of the sphere to emit from
  89643. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89644. * @returns the emitter
  89645. */
  89646. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89647. /**
  89648. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89649. * @param radius The radius of the sphere to emit from
  89650. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89651. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89652. * @returns the emitter
  89653. */
  89654. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89655. /**
  89656. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89657. * @param radius The radius of the emission cylinder
  89658. * @param height The height of the emission cylinder
  89659. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89660. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89661. * @returns the emitter
  89662. */
  89663. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89664. /**
  89665. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89666. * @param radius The radius of the cylinder to emit from
  89667. * @param height The height of the emission cylinder
  89668. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89671. * @returns the emitter
  89672. */
  89673. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89674. /**
  89675. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89676. * @param radius The radius of the cone to emit from
  89677. * @param angle The base angle of the cone
  89678. * @returns the emitter
  89679. */
  89680. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89681. /**
  89682. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89683. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89684. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89685. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89686. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89687. * @returns the emitter
  89688. */
  89689. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89690. }
  89691. }
  89692. declare module BABYLON {
  89693. /**
  89694. * Type of sub emitter
  89695. */
  89696. export enum SubEmitterType {
  89697. /**
  89698. * Attached to the particle over it's lifetime
  89699. */
  89700. ATTACHED = 0,
  89701. /**
  89702. * Created when the particle dies
  89703. */
  89704. END = 1
  89705. }
  89706. /**
  89707. * Sub emitter class used to emit particles from an existing particle
  89708. */
  89709. export class SubEmitter {
  89710. /**
  89711. * the particle system to be used by the sub emitter
  89712. */
  89713. particleSystem: ParticleSystem;
  89714. /**
  89715. * Type of the submitter (Default: END)
  89716. */
  89717. type: SubEmitterType;
  89718. /**
  89719. * 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)
  89720. * Note: This only is supported when using an emitter of type Mesh
  89721. */
  89722. inheritDirection: boolean;
  89723. /**
  89724. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89725. */
  89726. inheritedVelocityAmount: number;
  89727. /**
  89728. * Creates a sub emitter
  89729. * @param particleSystem the particle system to be used by the sub emitter
  89730. */
  89731. constructor(
  89732. /**
  89733. * the particle system to be used by the sub emitter
  89734. */
  89735. particleSystem: ParticleSystem);
  89736. /**
  89737. * Clones the sub emitter
  89738. * @returns the cloned sub emitter
  89739. */
  89740. clone(): SubEmitter;
  89741. /**
  89742. * Serialize current object to a JSON object
  89743. * @returns the serialized object
  89744. */
  89745. serialize(): any;
  89746. /** @hidden */
  89747. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89748. /**
  89749. * Creates a new SubEmitter from a serialized JSON version
  89750. * @param serializationObject defines the JSON object to read from
  89751. * @param scene defines the hosting scene
  89752. * @param rootUrl defines the rootUrl for data loading
  89753. * @returns a new SubEmitter
  89754. */
  89755. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89756. /** Release associated resources */
  89757. dispose(): void;
  89758. }
  89759. }
  89760. declare module BABYLON {
  89761. /** @hidden */
  89762. export var clipPlaneFragmentDeclaration: {
  89763. name: string;
  89764. shader: string;
  89765. };
  89766. }
  89767. declare module BABYLON {
  89768. /** @hidden */
  89769. export var imageProcessingDeclaration: {
  89770. name: string;
  89771. shader: string;
  89772. };
  89773. }
  89774. declare module BABYLON {
  89775. /** @hidden */
  89776. export var imageProcessingFunctions: {
  89777. name: string;
  89778. shader: string;
  89779. };
  89780. }
  89781. declare module BABYLON {
  89782. /** @hidden */
  89783. export var clipPlaneFragment: {
  89784. name: string;
  89785. shader: string;
  89786. };
  89787. }
  89788. declare module BABYLON {
  89789. /** @hidden */
  89790. export var particlesPixelShader: {
  89791. name: string;
  89792. shader: string;
  89793. };
  89794. }
  89795. declare module BABYLON {
  89796. /** @hidden */
  89797. export var clipPlaneVertexDeclaration: {
  89798. name: string;
  89799. shader: string;
  89800. };
  89801. }
  89802. declare module BABYLON {
  89803. /** @hidden */
  89804. export var clipPlaneVertex: {
  89805. name: string;
  89806. shader: string;
  89807. };
  89808. }
  89809. declare module BABYLON {
  89810. /** @hidden */
  89811. export var particlesVertexShader: {
  89812. name: string;
  89813. shader: string;
  89814. };
  89815. }
  89816. declare module BABYLON {
  89817. /**
  89818. * This represents a particle system in Babylon.
  89819. * 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.
  89820. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89821. * @example https://doc.babylonjs.com/babylon101/particles
  89822. */
  89823. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89824. /**
  89825. * Billboard mode will only apply to Y axis
  89826. */
  89827. static readonly BILLBOARDMODE_Y: number;
  89828. /**
  89829. * Billboard mode will apply to all axes
  89830. */
  89831. static readonly BILLBOARDMODE_ALL: number;
  89832. /**
  89833. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89834. */
  89835. static readonly BILLBOARDMODE_STRETCHED: number;
  89836. /**
  89837. * This function can be defined to provide custom update for active particles.
  89838. * This function will be called instead of regular update (age, position, color, etc.).
  89839. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  89840. */
  89841. updateFunction: (particles: Particle[]) => void;
  89842. private _emitterWorldMatrix;
  89843. /**
  89844. * This function can be defined to specify initial direction for every new particle.
  89845. * It by default use the emitterType defined function
  89846. */
  89847. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  89848. /**
  89849. * This function can be defined to specify initial position for every new particle.
  89850. * It by default use the emitterType defined function
  89851. */
  89852. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  89853. /**
  89854. * @hidden
  89855. */
  89856. _inheritedVelocityOffset: Vector3;
  89857. /**
  89858. * An event triggered when the system is disposed
  89859. */
  89860. onDisposeObservable: Observable<ParticleSystem>;
  89861. private _onDisposeObserver;
  89862. /**
  89863. * Sets a callback that will be triggered when the system is disposed
  89864. */
  89865. set onDispose(callback: () => void);
  89866. private _particles;
  89867. private _epsilon;
  89868. private _capacity;
  89869. private _stockParticles;
  89870. private _newPartsExcess;
  89871. private _vertexData;
  89872. private _vertexBuffer;
  89873. private _vertexBuffers;
  89874. private _spriteBuffer;
  89875. private _indexBuffer;
  89876. private _effect;
  89877. private _customEffect;
  89878. private _cachedDefines;
  89879. private _scaledColorStep;
  89880. private _colorDiff;
  89881. private _scaledDirection;
  89882. private _scaledGravity;
  89883. private _currentRenderId;
  89884. private _alive;
  89885. private _useInstancing;
  89886. private _started;
  89887. private _stopped;
  89888. private _actualFrame;
  89889. private _scaledUpdateSpeed;
  89890. private _vertexBufferSize;
  89891. /** @hidden */
  89892. _currentEmitRateGradient: Nullable<FactorGradient>;
  89893. /** @hidden */
  89894. _currentEmitRate1: number;
  89895. /** @hidden */
  89896. _currentEmitRate2: number;
  89897. /** @hidden */
  89898. _currentStartSizeGradient: Nullable<FactorGradient>;
  89899. /** @hidden */
  89900. _currentStartSize1: number;
  89901. /** @hidden */
  89902. _currentStartSize2: number;
  89903. private readonly _rawTextureWidth;
  89904. private _rampGradientsTexture;
  89905. private _useRampGradients;
  89906. /** Gets or sets a boolean indicating that ramp gradients must be used
  89907. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89908. */
  89909. get useRampGradients(): boolean;
  89910. set useRampGradients(value: boolean);
  89911. /**
  89912. * 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.
  89913. * 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: [])
  89914. */
  89915. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  89916. private _subEmitters;
  89917. /**
  89918. * @hidden
  89919. * If the particle systems emitter should be disposed when the particle system is disposed
  89920. */
  89921. _disposeEmitterOnDispose: boolean;
  89922. /**
  89923. * The current active Sub-systems, this property is used by the root particle system only.
  89924. */
  89925. activeSubSystems: Array<ParticleSystem>;
  89926. private _rootParticleSystem;
  89927. /**
  89928. * Gets the current list of active particles
  89929. */
  89930. get particles(): Particle[];
  89931. /**
  89932. * Returns the string "ParticleSystem"
  89933. * @returns a string containing the class name
  89934. */
  89935. getClassName(): string;
  89936. /**
  89937. * Instantiates a particle system.
  89938. * 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.
  89939. * @param name The name of the particle system
  89940. * @param capacity The max number of particles alive at the same time
  89941. * @param scene The scene the particle system belongs to
  89942. * @param customEffect a custom effect used to change the way particles are rendered by default
  89943. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  89944. * @param epsilon Offset used to render the particles
  89945. */
  89946. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  89947. private _addFactorGradient;
  89948. private _removeFactorGradient;
  89949. /**
  89950. * Adds a new life time gradient
  89951. * @param gradient defines the gradient to use (between 0 and 1)
  89952. * @param factor defines the life time factor to affect to the specified gradient
  89953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89954. * @returns the current particle system
  89955. */
  89956. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89957. /**
  89958. * Remove a specific life time gradient
  89959. * @param gradient defines the gradient to remove
  89960. * @returns the current particle system
  89961. */
  89962. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89963. /**
  89964. * Adds a new size gradient
  89965. * @param gradient defines the gradient to use (between 0 and 1)
  89966. * @param factor defines the size factor to affect to the specified gradient
  89967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89968. * @returns the current particle system
  89969. */
  89970. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89971. /**
  89972. * Remove a specific size gradient
  89973. * @param gradient defines the gradient to remove
  89974. * @returns the current particle system
  89975. */
  89976. removeSizeGradient(gradient: number): IParticleSystem;
  89977. /**
  89978. * Adds a new color remap gradient
  89979. * @param gradient defines the gradient to use (between 0 and 1)
  89980. * @param min defines the color remap minimal range
  89981. * @param max defines the color remap maximal range
  89982. * @returns the current particle system
  89983. */
  89984. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89985. /**
  89986. * Remove a specific color remap gradient
  89987. * @param gradient defines the gradient to remove
  89988. * @returns the current particle system
  89989. */
  89990. removeColorRemapGradient(gradient: number): IParticleSystem;
  89991. /**
  89992. * Adds a new alpha remap gradient
  89993. * @param gradient defines the gradient to use (between 0 and 1)
  89994. * @param min defines the alpha remap minimal range
  89995. * @param max defines the alpha remap maximal range
  89996. * @returns the current particle system
  89997. */
  89998. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89999. /**
  90000. * Remove a specific alpha remap gradient
  90001. * @param gradient defines the gradient to remove
  90002. * @returns the current particle system
  90003. */
  90004. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90005. /**
  90006. * Adds a new angular speed gradient
  90007. * @param gradient defines the gradient to use (between 0 and 1)
  90008. * @param factor defines the angular speed to affect to the specified gradient
  90009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90010. * @returns the current particle system
  90011. */
  90012. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90013. /**
  90014. * Remove a specific angular speed gradient
  90015. * @param gradient defines the gradient to remove
  90016. * @returns the current particle system
  90017. */
  90018. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90019. /**
  90020. * Adds a new velocity gradient
  90021. * @param gradient defines the gradient to use (between 0 and 1)
  90022. * @param factor defines the velocity to affect to the specified gradient
  90023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90024. * @returns the current particle system
  90025. */
  90026. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90027. /**
  90028. * Remove a specific velocity gradient
  90029. * @param gradient defines the gradient to remove
  90030. * @returns the current particle system
  90031. */
  90032. removeVelocityGradient(gradient: number): IParticleSystem;
  90033. /**
  90034. * Adds a new limit velocity gradient
  90035. * @param gradient defines the gradient to use (between 0 and 1)
  90036. * @param factor defines the limit velocity value to affect to the specified gradient
  90037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90038. * @returns the current particle system
  90039. */
  90040. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90041. /**
  90042. * Remove a specific limit velocity gradient
  90043. * @param gradient defines the gradient to remove
  90044. * @returns the current particle system
  90045. */
  90046. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90047. /**
  90048. * Adds a new drag gradient
  90049. * @param gradient defines the gradient to use (between 0 and 1)
  90050. * @param factor defines the drag value to affect to the specified gradient
  90051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90052. * @returns the current particle system
  90053. */
  90054. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90055. /**
  90056. * Remove a specific drag gradient
  90057. * @param gradient defines the gradient to remove
  90058. * @returns the current particle system
  90059. */
  90060. removeDragGradient(gradient: number): IParticleSystem;
  90061. /**
  90062. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90063. * @param gradient defines the gradient to use (between 0 and 1)
  90064. * @param factor defines the emit rate value to affect to the specified gradient
  90065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90066. * @returns the current particle system
  90067. */
  90068. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90069. /**
  90070. * Remove a specific emit rate gradient
  90071. * @param gradient defines the gradient to remove
  90072. * @returns the current particle system
  90073. */
  90074. removeEmitRateGradient(gradient: number): IParticleSystem;
  90075. /**
  90076. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90077. * @param gradient defines the gradient to use (between 0 and 1)
  90078. * @param factor defines the start size value to affect to the specified gradient
  90079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90080. * @returns the current particle system
  90081. */
  90082. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90083. /**
  90084. * Remove a specific start size gradient
  90085. * @param gradient defines the gradient to remove
  90086. * @returns the current particle system
  90087. */
  90088. removeStartSizeGradient(gradient: number): IParticleSystem;
  90089. private _createRampGradientTexture;
  90090. /**
  90091. * Gets the current list of ramp gradients.
  90092. * You must use addRampGradient and removeRampGradient to udpate this list
  90093. * @returns the list of ramp gradients
  90094. */
  90095. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90096. /**
  90097. * Adds a new ramp gradient used to remap particle colors
  90098. * @param gradient defines the gradient to use (between 0 and 1)
  90099. * @param color defines the color to affect to the specified gradient
  90100. * @returns the current particle system
  90101. */
  90102. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90103. /**
  90104. * Remove a specific ramp gradient
  90105. * @param gradient defines the gradient to remove
  90106. * @returns the current particle system
  90107. */
  90108. removeRampGradient(gradient: number): ParticleSystem;
  90109. /**
  90110. * Adds a new color gradient
  90111. * @param gradient defines the gradient to use (between 0 and 1)
  90112. * @param color1 defines the color to affect to the specified gradient
  90113. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90114. * @returns this particle system
  90115. */
  90116. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90117. /**
  90118. * Remove a specific color gradient
  90119. * @param gradient defines the gradient to remove
  90120. * @returns this particle system
  90121. */
  90122. removeColorGradient(gradient: number): IParticleSystem;
  90123. private _fetchR;
  90124. protected _reset(): void;
  90125. private _resetEffect;
  90126. private _createVertexBuffers;
  90127. private _createIndexBuffer;
  90128. /**
  90129. * Gets the maximum number of particles active at the same time.
  90130. * @returns The max number of active particles.
  90131. */
  90132. getCapacity(): number;
  90133. /**
  90134. * Gets whether there are still active particles in the system.
  90135. * @returns True if it is alive, otherwise false.
  90136. */
  90137. isAlive(): boolean;
  90138. /**
  90139. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90140. * @returns True if it has been started, otherwise false.
  90141. */
  90142. isStarted(): boolean;
  90143. private _prepareSubEmitterInternalArray;
  90144. /**
  90145. * Starts the particle system and begins to emit
  90146. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90147. */
  90148. start(delay?: number): void;
  90149. /**
  90150. * Stops the particle system.
  90151. * @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.
  90152. */
  90153. stop(stopSubEmitters?: boolean): void;
  90154. /**
  90155. * Remove all active particles
  90156. */
  90157. reset(): void;
  90158. /**
  90159. * @hidden (for internal use only)
  90160. */
  90161. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90162. /**
  90163. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90164. * Its lifetime will start back at 0.
  90165. */
  90166. recycleParticle: (particle: Particle) => void;
  90167. private _stopSubEmitters;
  90168. private _createParticle;
  90169. private _removeFromRoot;
  90170. private _emitFromParticle;
  90171. private _update;
  90172. /** @hidden */
  90173. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90174. /** @hidden */
  90175. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90176. /** @hidden */
  90177. private _getEffect;
  90178. /**
  90179. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90180. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90181. */
  90182. animate(preWarmOnly?: boolean): void;
  90183. private _appendParticleVertices;
  90184. /**
  90185. * Rebuilds the particle system.
  90186. */
  90187. rebuild(): void;
  90188. /**
  90189. * Is this system ready to be used/rendered
  90190. * @return true if the system is ready
  90191. */
  90192. isReady(): boolean;
  90193. private _render;
  90194. /**
  90195. * Renders the particle system in its current state.
  90196. * @returns the current number of particles
  90197. */
  90198. render(): number;
  90199. /**
  90200. * Disposes the particle system and free the associated resources
  90201. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90202. */
  90203. dispose(disposeTexture?: boolean): void;
  90204. /**
  90205. * Clones the particle system.
  90206. * @param name The name of the cloned object
  90207. * @param newEmitter The new emitter to use
  90208. * @returns the cloned particle system
  90209. */
  90210. clone(name: string, newEmitter: any): ParticleSystem;
  90211. /**
  90212. * Serializes the particle system to a JSON object.
  90213. * @returns the JSON object
  90214. */
  90215. serialize(): any;
  90216. /** @hidden */
  90217. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  90218. /** @hidden */
  90219. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90220. /**
  90221. * Parses a JSON object to create a particle system.
  90222. * @param parsedParticleSystem The JSON object to parse
  90223. * @param scene The scene to create the particle system in
  90224. * @param rootUrl The root url to use to load external dependencies like texture
  90225. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90226. * @returns the Parsed particle system
  90227. */
  90228. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90229. }
  90230. }
  90231. declare module BABYLON {
  90232. /**
  90233. * A particle represents one of the element emitted by a particle system.
  90234. * This is mainly define by its coordinates, direction, velocity and age.
  90235. */
  90236. export class Particle {
  90237. /**
  90238. * The particle system the particle belongs to.
  90239. */
  90240. particleSystem: ParticleSystem;
  90241. private static _Count;
  90242. /**
  90243. * Unique ID of the particle
  90244. */
  90245. id: number;
  90246. /**
  90247. * The world position of the particle in the scene.
  90248. */
  90249. position: Vector3;
  90250. /**
  90251. * The world direction of the particle in the scene.
  90252. */
  90253. direction: Vector3;
  90254. /**
  90255. * The color of the particle.
  90256. */
  90257. color: Color4;
  90258. /**
  90259. * The color change of the particle per step.
  90260. */
  90261. colorStep: Color4;
  90262. /**
  90263. * Defines how long will the life of the particle be.
  90264. */
  90265. lifeTime: number;
  90266. /**
  90267. * The current age of the particle.
  90268. */
  90269. age: number;
  90270. /**
  90271. * The current size of the particle.
  90272. */
  90273. size: number;
  90274. /**
  90275. * The current scale of the particle.
  90276. */
  90277. scale: Vector2;
  90278. /**
  90279. * The current angle of the particle.
  90280. */
  90281. angle: number;
  90282. /**
  90283. * Defines how fast is the angle changing.
  90284. */
  90285. angularSpeed: number;
  90286. /**
  90287. * Defines the cell index used by the particle to be rendered from a sprite.
  90288. */
  90289. cellIndex: number;
  90290. /**
  90291. * The information required to support color remapping
  90292. */
  90293. remapData: Vector4;
  90294. /** @hidden */
  90295. _randomCellOffset?: number;
  90296. /** @hidden */
  90297. _initialDirection: Nullable<Vector3>;
  90298. /** @hidden */
  90299. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90300. /** @hidden */
  90301. _initialStartSpriteCellID: number;
  90302. /** @hidden */
  90303. _initialEndSpriteCellID: number;
  90304. /** @hidden */
  90305. _currentColorGradient: Nullable<ColorGradient>;
  90306. /** @hidden */
  90307. _currentColor1: Color4;
  90308. /** @hidden */
  90309. _currentColor2: Color4;
  90310. /** @hidden */
  90311. _currentSizeGradient: Nullable<FactorGradient>;
  90312. /** @hidden */
  90313. _currentSize1: number;
  90314. /** @hidden */
  90315. _currentSize2: number;
  90316. /** @hidden */
  90317. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90318. /** @hidden */
  90319. _currentAngularSpeed1: number;
  90320. /** @hidden */
  90321. _currentAngularSpeed2: number;
  90322. /** @hidden */
  90323. _currentVelocityGradient: Nullable<FactorGradient>;
  90324. /** @hidden */
  90325. _currentVelocity1: number;
  90326. /** @hidden */
  90327. _currentVelocity2: number;
  90328. /** @hidden */
  90329. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90330. /** @hidden */
  90331. _currentLimitVelocity1: number;
  90332. /** @hidden */
  90333. _currentLimitVelocity2: number;
  90334. /** @hidden */
  90335. _currentDragGradient: Nullable<FactorGradient>;
  90336. /** @hidden */
  90337. _currentDrag1: number;
  90338. /** @hidden */
  90339. _currentDrag2: number;
  90340. /** @hidden */
  90341. _randomNoiseCoordinates1: Vector3;
  90342. /** @hidden */
  90343. _randomNoiseCoordinates2: Vector3;
  90344. /**
  90345. * Creates a new instance Particle
  90346. * @param particleSystem the particle system the particle belongs to
  90347. */
  90348. constructor(
  90349. /**
  90350. * The particle system the particle belongs to.
  90351. */
  90352. particleSystem: ParticleSystem);
  90353. private updateCellInfoFromSystem;
  90354. /**
  90355. * Defines how the sprite cell index is updated for the particle
  90356. */
  90357. updateCellIndex(): void;
  90358. /** @hidden */
  90359. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90360. /** @hidden */
  90361. _inheritParticleInfoToSubEmitters(): void;
  90362. /** @hidden */
  90363. _reset(): void;
  90364. /**
  90365. * Copy the properties of particle to another one.
  90366. * @param other the particle to copy the information to.
  90367. */
  90368. copyTo(other: Particle): void;
  90369. }
  90370. }
  90371. declare module BABYLON {
  90372. /**
  90373. * Particle emitter represents a volume emitting particles.
  90374. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90375. */
  90376. export interface IParticleEmitterType {
  90377. /**
  90378. * Called by the particle System when the direction is computed for the created particle.
  90379. * @param worldMatrix is the world matrix of the particle system
  90380. * @param directionToUpdate is the direction vector to update with the result
  90381. * @param particle is the particle we are computed the direction for
  90382. */
  90383. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90384. /**
  90385. * Called by the particle System when the position is computed for the created particle.
  90386. * @param worldMatrix is the world matrix of the particle system
  90387. * @param positionToUpdate is the position vector to update with the result
  90388. * @param particle is the particle we are computed the position for
  90389. */
  90390. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90391. /**
  90392. * Clones the current emitter and returns a copy of it
  90393. * @returns the new emitter
  90394. */
  90395. clone(): IParticleEmitterType;
  90396. /**
  90397. * Called by the GPUParticleSystem to setup the update shader
  90398. * @param effect defines the update shader
  90399. */
  90400. applyToShader(effect: Effect): void;
  90401. /**
  90402. * Returns a string to use to update the GPU particles update shader
  90403. * @returns the effect defines string
  90404. */
  90405. getEffectDefines(): string;
  90406. /**
  90407. * Returns a string representing the class name
  90408. * @returns a string containing the class name
  90409. */
  90410. getClassName(): string;
  90411. /**
  90412. * Serializes the particle system to a JSON object.
  90413. * @returns the JSON object
  90414. */
  90415. serialize(): any;
  90416. /**
  90417. * Parse properties from a JSON object
  90418. * @param serializationObject defines the JSON object
  90419. */
  90420. parse(serializationObject: any): void;
  90421. }
  90422. }
  90423. declare module BABYLON {
  90424. /**
  90425. * Particle emitter emitting particles from the inside of a box.
  90426. * It emits the particles randomly between 2 given directions.
  90427. */
  90428. export class BoxParticleEmitter implements IParticleEmitterType {
  90429. /**
  90430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90431. */
  90432. direction1: Vector3;
  90433. /**
  90434. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90435. */
  90436. direction2: Vector3;
  90437. /**
  90438. * 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.
  90439. */
  90440. minEmitBox: Vector3;
  90441. /**
  90442. * 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.
  90443. */
  90444. maxEmitBox: Vector3;
  90445. /**
  90446. * Creates a new instance BoxParticleEmitter
  90447. */
  90448. constructor();
  90449. /**
  90450. * Called by the particle System when the direction is computed for the created particle.
  90451. * @param worldMatrix is the world matrix of the particle system
  90452. * @param directionToUpdate is the direction vector to update with the result
  90453. * @param particle is the particle we are computed the direction for
  90454. */
  90455. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90456. /**
  90457. * Called by the particle System when the position is computed for the created particle.
  90458. * @param worldMatrix is the world matrix of the particle system
  90459. * @param positionToUpdate is the position vector to update with the result
  90460. * @param particle is the particle we are computed the position for
  90461. */
  90462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90463. /**
  90464. * Clones the current emitter and returns a copy of it
  90465. * @returns the new emitter
  90466. */
  90467. clone(): BoxParticleEmitter;
  90468. /**
  90469. * Called by the GPUParticleSystem to setup the update shader
  90470. * @param effect defines the update shader
  90471. */
  90472. applyToShader(effect: Effect): void;
  90473. /**
  90474. * Returns a string to use to update the GPU particles update shader
  90475. * @returns a string containng the defines string
  90476. */
  90477. getEffectDefines(): string;
  90478. /**
  90479. * Returns the string "BoxParticleEmitter"
  90480. * @returns a string containing the class name
  90481. */
  90482. getClassName(): string;
  90483. /**
  90484. * Serializes the particle system to a JSON object.
  90485. * @returns the JSON object
  90486. */
  90487. serialize(): any;
  90488. /**
  90489. * Parse properties from a JSON object
  90490. * @param serializationObject defines the JSON object
  90491. */
  90492. parse(serializationObject: any): void;
  90493. }
  90494. }
  90495. declare module BABYLON {
  90496. /**
  90497. * Particle emitter emitting particles from the inside of a cone.
  90498. * It emits the particles alongside the cone volume from the base to the particle.
  90499. * The emission direction might be randomized.
  90500. */
  90501. export class ConeParticleEmitter implements IParticleEmitterType {
  90502. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90503. directionRandomizer: number;
  90504. private _radius;
  90505. private _angle;
  90506. private _height;
  90507. /**
  90508. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90509. */
  90510. radiusRange: number;
  90511. /**
  90512. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90513. */
  90514. heightRange: number;
  90515. /**
  90516. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90517. */
  90518. emitFromSpawnPointOnly: boolean;
  90519. /**
  90520. * Gets or sets the radius of the emission cone
  90521. */
  90522. get radius(): number;
  90523. set radius(value: number);
  90524. /**
  90525. * Gets or sets the angle of the emission cone
  90526. */
  90527. get angle(): number;
  90528. set angle(value: number);
  90529. private _buildHeight;
  90530. /**
  90531. * Creates a new instance ConeParticleEmitter
  90532. * @param radius the radius of the emission cone (1 by default)
  90533. * @param angle the cone base angle (PI by default)
  90534. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90535. */
  90536. constructor(radius?: number, angle?: number,
  90537. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90538. directionRandomizer?: number);
  90539. /**
  90540. * Called by the particle System when the direction is computed for the created particle.
  90541. * @param worldMatrix is the world matrix of the particle system
  90542. * @param directionToUpdate is the direction vector to update with the result
  90543. * @param particle is the particle we are computed the direction for
  90544. */
  90545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90546. /**
  90547. * Called by the particle System when the position is computed for the created particle.
  90548. * @param worldMatrix is the world matrix of the particle system
  90549. * @param positionToUpdate is the position vector to update with the result
  90550. * @param particle is the particle we are computed the position for
  90551. */
  90552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90553. /**
  90554. * Clones the current emitter and returns a copy of it
  90555. * @returns the new emitter
  90556. */
  90557. clone(): ConeParticleEmitter;
  90558. /**
  90559. * Called by the GPUParticleSystem to setup the update shader
  90560. * @param effect defines the update shader
  90561. */
  90562. applyToShader(effect: Effect): void;
  90563. /**
  90564. * Returns a string to use to update the GPU particles update shader
  90565. * @returns a string containng the defines string
  90566. */
  90567. getEffectDefines(): string;
  90568. /**
  90569. * Returns the string "ConeParticleEmitter"
  90570. * @returns a string containing the class name
  90571. */
  90572. getClassName(): string;
  90573. /**
  90574. * Serializes the particle system to a JSON object.
  90575. * @returns the JSON object
  90576. */
  90577. serialize(): any;
  90578. /**
  90579. * Parse properties from a JSON object
  90580. * @param serializationObject defines the JSON object
  90581. */
  90582. parse(serializationObject: any): void;
  90583. }
  90584. }
  90585. declare module BABYLON {
  90586. /**
  90587. * Particle emitter emitting particles from the inside of a cylinder.
  90588. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90589. */
  90590. export class CylinderParticleEmitter implements IParticleEmitterType {
  90591. /**
  90592. * The radius of the emission cylinder.
  90593. */
  90594. radius: number;
  90595. /**
  90596. * The height of the emission cylinder.
  90597. */
  90598. height: number;
  90599. /**
  90600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90601. */
  90602. radiusRange: number;
  90603. /**
  90604. * How much to randomize the particle direction [0-1].
  90605. */
  90606. directionRandomizer: number;
  90607. /**
  90608. * Creates a new instance CylinderParticleEmitter
  90609. * @param radius the radius of the emission cylinder (1 by default)
  90610. * @param height the height of the emission cylinder (1 by default)
  90611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90612. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90613. */
  90614. constructor(
  90615. /**
  90616. * The radius of the emission cylinder.
  90617. */
  90618. radius?: number,
  90619. /**
  90620. * The height of the emission cylinder.
  90621. */
  90622. height?: number,
  90623. /**
  90624. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90625. */
  90626. radiusRange?: number,
  90627. /**
  90628. * How much to randomize the particle direction [0-1].
  90629. */
  90630. directionRandomizer?: number);
  90631. /**
  90632. * Called by the particle System when the direction is computed for the created particle.
  90633. * @param worldMatrix is the world matrix of the particle system
  90634. * @param directionToUpdate is the direction vector to update with the result
  90635. * @param particle is the particle we are computed the direction for
  90636. */
  90637. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90638. /**
  90639. * Called by the particle System when the position is computed for the created particle.
  90640. * @param worldMatrix is the world matrix of the particle system
  90641. * @param positionToUpdate is the position vector to update with the result
  90642. * @param particle is the particle we are computed the position for
  90643. */
  90644. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90645. /**
  90646. * Clones the current emitter and returns a copy of it
  90647. * @returns the new emitter
  90648. */
  90649. clone(): CylinderParticleEmitter;
  90650. /**
  90651. * Called by the GPUParticleSystem to setup the update shader
  90652. * @param effect defines the update shader
  90653. */
  90654. applyToShader(effect: Effect): void;
  90655. /**
  90656. * Returns a string to use to update the GPU particles update shader
  90657. * @returns a string containng the defines string
  90658. */
  90659. getEffectDefines(): string;
  90660. /**
  90661. * Returns the string "CylinderParticleEmitter"
  90662. * @returns a string containing the class name
  90663. */
  90664. getClassName(): string;
  90665. /**
  90666. * Serializes the particle system to a JSON object.
  90667. * @returns the JSON object
  90668. */
  90669. serialize(): any;
  90670. /**
  90671. * Parse properties from a JSON object
  90672. * @param serializationObject defines the JSON object
  90673. */
  90674. parse(serializationObject: any): void;
  90675. }
  90676. /**
  90677. * Particle emitter emitting particles from the inside of a cylinder.
  90678. * It emits the particles randomly between two vectors.
  90679. */
  90680. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90681. /**
  90682. * The min limit of the emission direction.
  90683. */
  90684. direction1: Vector3;
  90685. /**
  90686. * The max limit of the emission direction.
  90687. */
  90688. direction2: Vector3;
  90689. /**
  90690. * Creates a new instance CylinderDirectedParticleEmitter
  90691. * @param radius the radius of the emission cylinder (1 by default)
  90692. * @param height the height of the emission cylinder (1 by default)
  90693. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90694. * @param direction1 the min limit of the emission direction (up vector by default)
  90695. * @param direction2 the max limit of the emission direction (up vector by default)
  90696. */
  90697. constructor(radius?: number, height?: number, radiusRange?: number,
  90698. /**
  90699. * The min limit of the emission direction.
  90700. */
  90701. direction1?: Vector3,
  90702. /**
  90703. * The max limit of the emission direction.
  90704. */
  90705. direction2?: Vector3);
  90706. /**
  90707. * Called by the particle System when the direction is computed for the created particle.
  90708. * @param worldMatrix is the world matrix of the particle system
  90709. * @param directionToUpdate is the direction vector to update with the result
  90710. * @param particle is the particle we are computed the direction for
  90711. */
  90712. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90713. /**
  90714. * Clones the current emitter and returns a copy of it
  90715. * @returns the new emitter
  90716. */
  90717. clone(): CylinderDirectedParticleEmitter;
  90718. /**
  90719. * Called by the GPUParticleSystem to setup the update shader
  90720. * @param effect defines the update shader
  90721. */
  90722. applyToShader(effect: Effect): void;
  90723. /**
  90724. * Returns a string to use to update the GPU particles update shader
  90725. * @returns a string containng the defines string
  90726. */
  90727. getEffectDefines(): string;
  90728. /**
  90729. * Returns the string "CylinderDirectedParticleEmitter"
  90730. * @returns a string containing the class name
  90731. */
  90732. getClassName(): string;
  90733. /**
  90734. * Serializes the particle system to a JSON object.
  90735. * @returns the JSON object
  90736. */
  90737. serialize(): any;
  90738. /**
  90739. * Parse properties from a JSON object
  90740. * @param serializationObject defines the JSON object
  90741. */
  90742. parse(serializationObject: any): void;
  90743. }
  90744. }
  90745. declare module BABYLON {
  90746. /**
  90747. * Particle emitter emitting particles from the inside of a hemisphere.
  90748. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90749. */
  90750. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90751. /**
  90752. * The radius of the emission hemisphere.
  90753. */
  90754. radius: number;
  90755. /**
  90756. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90757. */
  90758. radiusRange: number;
  90759. /**
  90760. * How much to randomize the particle direction [0-1].
  90761. */
  90762. directionRandomizer: number;
  90763. /**
  90764. * Creates a new instance HemisphericParticleEmitter
  90765. * @param radius the radius of the emission hemisphere (1 by default)
  90766. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90767. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90768. */
  90769. constructor(
  90770. /**
  90771. * The radius of the emission hemisphere.
  90772. */
  90773. radius?: number,
  90774. /**
  90775. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90776. */
  90777. radiusRange?: number,
  90778. /**
  90779. * How much to randomize the particle direction [0-1].
  90780. */
  90781. directionRandomizer?: number);
  90782. /**
  90783. * Called by the particle System when the direction is computed for the created particle.
  90784. * @param worldMatrix is the world matrix of the particle system
  90785. * @param directionToUpdate is the direction vector to update with the result
  90786. * @param particle is the particle we are computed the direction for
  90787. */
  90788. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90789. /**
  90790. * Called by the particle System when the position is computed for the created particle.
  90791. * @param worldMatrix is the world matrix of the particle system
  90792. * @param positionToUpdate is the position vector to update with the result
  90793. * @param particle is the particle we are computed the position for
  90794. */
  90795. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90796. /**
  90797. * Clones the current emitter and returns a copy of it
  90798. * @returns the new emitter
  90799. */
  90800. clone(): HemisphericParticleEmitter;
  90801. /**
  90802. * Called by the GPUParticleSystem to setup the update shader
  90803. * @param effect defines the update shader
  90804. */
  90805. applyToShader(effect: Effect): void;
  90806. /**
  90807. * Returns a string to use to update the GPU particles update shader
  90808. * @returns a string containng the defines string
  90809. */
  90810. getEffectDefines(): string;
  90811. /**
  90812. * Returns the string "HemisphericParticleEmitter"
  90813. * @returns a string containing the class name
  90814. */
  90815. getClassName(): string;
  90816. /**
  90817. * Serializes the particle system to a JSON object.
  90818. * @returns the JSON object
  90819. */
  90820. serialize(): any;
  90821. /**
  90822. * Parse properties from a JSON object
  90823. * @param serializationObject defines the JSON object
  90824. */
  90825. parse(serializationObject: any): void;
  90826. }
  90827. }
  90828. declare module BABYLON {
  90829. /**
  90830. * Particle emitter emitting particles from a point.
  90831. * It emits the particles randomly between 2 given directions.
  90832. */
  90833. export class PointParticleEmitter implements IParticleEmitterType {
  90834. /**
  90835. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90836. */
  90837. direction1: Vector3;
  90838. /**
  90839. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90840. */
  90841. direction2: Vector3;
  90842. /**
  90843. * Creates a new instance PointParticleEmitter
  90844. */
  90845. constructor();
  90846. /**
  90847. * Called by the particle System when the direction is computed for the created particle.
  90848. * @param worldMatrix is the world matrix of the particle system
  90849. * @param directionToUpdate is the direction vector to update with the result
  90850. * @param particle is the particle we are computed the direction for
  90851. */
  90852. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90853. /**
  90854. * Called by the particle System when the position is computed for the created particle.
  90855. * @param worldMatrix is the world matrix of the particle system
  90856. * @param positionToUpdate is the position vector to update with the result
  90857. * @param particle is the particle we are computed the position for
  90858. */
  90859. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90860. /**
  90861. * Clones the current emitter and returns a copy of it
  90862. * @returns the new emitter
  90863. */
  90864. clone(): PointParticleEmitter;
  90865. /**
  90866. * Called by the GPUParticleSystem to setup the update shader
  90867. * @param effect defines the update shader
  90868. */
  90869. applyToShader(effect: Effect): void;
  90870. /**
  90871. * Returns a string to use to update the GPU particles update shader
  90872. * @returns a string containng the defines string
  90873. */
  90874. getEffectDefines(): string;
  90875. /**
  90876. * Returns the string "PointParticleEmitter"
  90877. * @returns a string containing the class name
  90878. */
  90879. getClassName(): string;
  90880. /**
  90881. * Serializes the particle system to a JSON object.
  90882. * @returns the JSON object
  90883. */
  90884. serialize(): any;
  90885. /**
  90886. * Parse properties from a JSON object
  90887. * @param serializationObject defines the JSON object
  90888. */
  90889. parse(serializationObject: any): void;
  90890. }
  90891. }
  90892. declare module BABYLON {
  90893. /**
  90894. * Particle emitter emitting particles from the inside of a sphere.
  90895. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  90896. */
  90897. export class SphereParticleEmitter implements IParticleEmitterType {
  90898. /**
  90899. * The radius of the emission sphere.
  90900. */
  90901. radius: number;
  90902. /**
  90903. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90904. */
  90905. radiusRange: number;
  90906. /**
  90907. * How much to randomize the particle direction [0-1].
  90908. */
  90909. directionRandomizer: number;
  90910. /**
  90911. * Creates a new instance SphereParticleEmitter
  90912. * @param radius the radius of the emission sphere (1 by default)
  90913. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90914. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90915. */
  90916. constructor(
  90917. /**
  90918. * The radius of the emission sphere.
  90919. */
  90920. radius?: number,
  90921. /**
  90922. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90923. */
  90924. radiusRange?: number,
  90925. /**
  90926. * How much to randomize the particle direction [0-1].
  90927. */
  90928. directionRandomizer?: number);
  90929. /**
  90930. * Called by the particle System when the direction is computed for the created particle.
  90931. * @param worldMatrix is the world matrix of the particle system
  90932. * @param directionToUpdate is the direction vector to update with the result
  90933. * @param particle is the particle we are computed the direction for
  90934. */
  90935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90936. /**
  90937. * Called by the particle System when the position is computed for the created particle.
  90938. * @param worldMatrix is the world matrix of the particle system
  90939. * @param positionToUpdate is the position vector to update with the result
  90940. * @param particle is the particle we are computed the position for
  90941. */
  90942. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90943. /**
  90944. * Clones the current emitter and returns a copy of it
  90945. * @returns the new emitter
  90946. */
  90947. clone(): SphereParticleEmitter;
  90948. /**
  90949. * Called by the GPUParticleSystem to setup the update shader
  90950. * @param effect defines the update shader
  90951. */
  90952. applyToShader(effect: Effect): void;
  90953. /**
  90954. * Returns a string to use to update the GPU particles update shader
  90955. * @returns a string containng the defines string
  90956. */
  90957. getEffectDefines(): string;
  90958. /**
  90959. * Returns the string "SphereParticleEmitter"
  90960. * @returns a string containing the class name
  90961. */
  90962. getClassName(): string;
  90963. /**
  90964. * Serializes the particle system to a JSON object.
  90965. * @returns the JSON object
  90966. */
  90967. serialize(): any;
  90968. /**
  90969. * Parse properties from a JSON object
  90970. * @param serializationObject defines the JSON object
  90971. */
  90972. parse(serializationObject: any): void;
  90973. }
  90974. /**
  90975. * Particle emitter emitting particles from the inside of a sphere.
  90976. * It emits the particles randomly between two vectors.
  90977. */
  90978. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  90979. /**
  90980. * The min limit of the emission direction.
  90981. */
  90982. direction1: Vector3;
  90983. /**
  90984. * The max limit of the emission direction.
  90985. */
  90986. direction2: Vector3;
  90987. /**
  90988. * Creates a new instance SphereDirectedParticleEmitter
  90989. * @param radius the radius of the emission sphere (1 by default)
  90990. * @param direction1 the min limit of the emission direction (up vector by default)
  90991. * @param direction2 the max limit of the emission direction (up vector by default)
  90992. */
  90993. constructor(radius?: number,
  90994. /**
  90995. * The min limit of the emission direction.
  90996. */
  90997. direction1?: Vector3,
  90998. /**
  90999. * The max limit of the emission direction.
  91000. */
  91001. direction2?: Vector3);
  91002. /**
  91003. * Called by the particle System when the direction is computed for the created particle.
  91004. * @param worldMatrix is the world matrix of the particle system
  91005. * @param directionToUpdate is the direction vector to update with the result
  91006. * @param particle is the particle we are computed the direction for
  91007. */
  91008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91009. /**
  91010. * Clones the current emitter and returns a copy of it
  91011. * @returns the new emitter
  91012. */
  91013. clone(): SphereDirectedParticleEmitter;
  91014. /**
  91015. * Called by the GPUParticleSystem to setup the update shader
  91016. * @param effect defines the update shader
  91017. */
  91018. applyToShader(effect: Effect): void;
  91019. /**
  91020. * Returns a string to use to update the GPU particles update shader
  91021. * @returns a string containng the defines string
  91022. */
  91023. getEffectDefines(): string;
  91024. /**
  91025. * Returns the string "SphereDirectedParticleEmitter"
  91026. * @returns a string containing the class name
  91027. */
  91028. getClassName(): string;
  91029. /**
  91030. * Serializes the particle system to a JSON object.
  91031. * @returns the JSON object
  91032. */
  91033. serialize(): any;
  91034. /**
  91035. * Parse properties from a JSON object
  91036. * @param serializationObject defines the JSON object
  91037. */
  91038. parse(serializationObject: any): void;
  91039. }
  91040. }
  91041. declare module BABYLON {
  91042. /**
  91043. * Particle emitter emitting particles from a custom list of positions.
  91044. */
  91045. export class CustomParticleEmitter implements IParticleEmitterType {
  91046. /**
  91047. * Gets or sets the position generator that will create the inital position of each particle.
  91048. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91049. */
  91050. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91051. /**
  91052. * Gets or sets the destination generator that will create the final destination of each particle.
  91053. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91054. */
  91055. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91056. /**
  91057. * Creates a new instance CustomParticleEmitter
  91058. */
  91059. constructor();
  91060. /**
  91061. * Called by the particle System when the direction is computed for the created particle.
  91062. * @param worldMatrix is the world matrix of the particle system
  91063. * @param directionToUpdate is the direction vector to update with the result
  91064. * @param particle is the particle we are computed the direction for
  91065. */
  91066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91067. /**
  91068. * Called by the particle System when the position is computed for the created particle.
  91069. * @param worldMatrix is the world matrix of the particle system
  91070. * @param positionToUpdate is the position vector to update with the result
  91071. * @param particle is the particle we are computed the position for
  91072. */
  91073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91074. /**
  91075. * Clones the current emitter and returns a copy of it
  91076. * @returns the new emitter
  91077. */
  91078. clone(): CustomParticleEmitter;
  91079. /**
  91080. * Called by the GPUParticleSystem to setup the update shader
  91081. * @param effect defines the update shader
  91082. */
  91083. applyToShader(effect: Effect): void;
  91084. /**
  91085. * Returns a string to use to update the GPU particles update shader
  91086. * @returns a string containng the defines string
  91087. */
  91088. getEffectDefines(): string;
  91089. /**
  91090. * Returns the string "PointParticleEmitter"
  91091. * @returns a string containing the class name
  91092. */
  91093. getClassName(): string;
  91094. /**
  91095. * Serializes the particle system to a JSON object.
  91096. * @returns the JSON object
  91097. */
  91098. serialize(): any;
  91099. /**
  91100. * Parse properties from a JSON object
  91101. * @param serializationObject defines the JSON object
  91102. */
  91103. parse(serializationObject: any): void;
  91104. }
  91105. }
  91106. declare module BABYLON {
  91107. /**
  91108. * Interface representing a particle system in Babylon.js.
  91109. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91110. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91111. */
  91112. export interface IParticleSystem {
  91113. /**
  91114. * List of animations used by the particle system.
  91115. */
  91116. animations: Animation[];
  91117. /**
  91118. * The id of the Particle system.
  91119. */
  91120. id: string;
  91121. /**
  91122. * The name of the Particle system.
  91123. */
  91124. name: string;
  91125. /**
  91126. * The emitter represents the Mesh or position we are attaching the particle system to.
  91127. */
  91128. emitter: Nullable<AbstractMesh | Vector3>;
  91129. /**
  91130. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91131. */
  91132. isBillboardBased: boolean;
  91133. /**
  91134. * The rendering group used by the Particle system to chose when to render.
  91135. */
  91136. renderingGroupId: number;
  91137. /**
  91138. * The layer mask we are rendering the particles through.
  91139. */
  91140. layerMask: number;
  91141. /**
  91142. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91143. */
  91144. updateSpeed: number;
  91145. /**
  91146. * The amount of time the particle system is running (depends of the overall update speed).
  91147. */
  91148. targetStopDuration: number;
  91149. /**
  91150. * The texture used to render each particle. (this can be a spritesheet)
  91151. */
  91152. particleTexture: Nullable<Texture>;
  91153. /**
  91154. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91155. */
  91156. blendMode: number;
  91157. /**
  91158. * Minimum life time of emitting particles.
  91159. */
  91160. minLifeTime: number;
  91161. /**
  91162. * Maximum life time of emitting particles.
  91163. */
  91164. maxLifeTime: number;
  91165. /**
  91166. * Minimum Size of emitting particles.
  91167. */
  91168. minSize: number;
  91169. /**
  91170. * Maximum Size of emitting particles.
  91171. */
  91172. maxSize: number;
  91173. /**
  91174. * Minimum scale of emitting particles on X axis.
  91175. */
  91176. minScaleX: number;
  91177. /**
  91178. * Maximum scale of emitting particles on X axis.
  91179. */
  91180. maxScaleX: number;
  91181. /**
  91182. * Minimum scale of emitting particles on Y axis.
  91183. */
  91184. minScaleY: number;
  91185. /**
  91186. * Maximum scale of emitting particles on Y axis.
  91187. */
  91188. maxScaleY: number;
  91189. /**
  91190. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91191. */
  91192. color1: Color4;
  91193. /**
  91194. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91195. */
  91196. color2: Color4;
  91197. /**
  91198. * Color the particle will have at the end of its lifetime.
  91199. */
  91200. colorDead: Color4;
  91201. /**
  91202. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91203. */
  91204. emitRate: number;
  91205. /**
  91206. * You can use gravity if you want to give an orientation to your particles.
  91207. */
  91208. gravity: Vector3;
  91209. /**
  91210. * Minimum power of emitting particles.
  91211. */
  91212. minEmitPower: number;
  91213. /**
  91214. * Maximum power of emitting particles.
  91215. */
  91216. maxEmitPower: number;
  91217. /**
  91218. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91219. */
  91220. minAngularSpeed: number;
  91221. /**
  91222. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91223. */
  91224. maxAngularSpeed: number;
  91225. /**
  91226. * Gets or sets the minimal initial rotation in radians.
  91227. */
  91228. minInitialRotation: number;
  91229. /**
  91230. * Gets or sets the maximal initial rotation in radians.
  91231. */
  91232. maxInitialRotation: number;
  91233. /**
  91234. * The particle emitter type defines the emitter used by the particle system.
  91235. * It can be for example box, sphere, or cone...
  91236. */
  91237. particleEmitterType: Nullable<IParticleEmitterType>;
  91238. /**
  91239. * Defines the delay in milliseconds before starting the system (0 by default)
  91240. */
  91241. startDelay: number;
  91242. /**
  91243. * 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
  91244. */
  91245. preWarmCycles: number;
  91246. /**
  91247. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91248. */
  91249. preWarmStepOffset: number;
  91250. /**
  91251. * 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)
  91252. */
  91253. spriteCellChangeSpeed: number;
  91254. /**
  91255. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91256. */
  91257. startSpriteCellID: number;
  91258. /**
  91259. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91260. */
  91261. endSpriteCellID: number;
  91262. /**
  91263. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91264. */
  91265. spriteCellWidth: number;
  91266. /**
  91267. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91268. */
  91269. spriteCellHeight: number;
  91270. /**
  91271. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91272. */
  91273. spriteRandomStartCell: boolean;
  91274. /**
  91275. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91276. */
  91277. isAnimationSheetEnabled: boolean;
  91278. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91279. translationPivot: Vector2;
  91280. /**
  91281. * Gets or sets a texture used to add random noise to particle positions
  91282. */
  91283. noiseTexture: Nullable<BaseTexture>;
  91284. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91285. noiseStrength: Vector3;
  91286. /**
  91287. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91288. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91289. */
  91290. billboardMode: number;
  91291. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91292. limitVelocityDamping: number;
  91293. /**
  91294. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91295. */
  91296. beginAnimationOnStart: boolean;
  91297. /**
  91298. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91299. */
  91300. beginAnimationFrom: number;
  91301. /**
  91302. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91303. */
  91304. beginAnimationTo: number;
  91305. /**
  91306. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91307. */
  91308. beginAnimationLoop: boolean;
  91309. /**
  91310. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91311. */
  91312. disposeOnStop: boolean;
  91313. /**
  91314. * Gets the maximum number of particles active at the same time.
  91315. * @returns The max number of active particles.
  91316. */
  91317. getCapacity(): number;
  91318. /**
  91319. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91320. * @returns True if it has been started, otherwise false.
  91321. */
  91322. isStarted(): boolean;
  91323. /**
  91324. * Animates the particle system for this frame.
  91325. */
  91326. animate(): void;
  91327. /**
  91328. * Renders the particle system in its current state.
  91329. * @returns the current number of particles
  91330. */
  91331. render(): number;
  91332. /**
  91333. * Dispose the particle system and frees its associated resources.
  91334. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91335. */
  91336. dispose(disposeTexture?: boolean): void;
  91337. /**
  91338. * Clones the particle system.
  91339. * @param name The name of the cloned object
  91340. * @param newEmitter The new emitter to use
  91341. * @returns the cloned particle system
  91342. */
  91343. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91344. /**
  91345. * Serializes the particle system to a JSON object.
  91346. * @returns the JSON object
  91347. */
  91348. serialize(): any;
  91349. /**
  91350. * Rebuild the particle system
  91351. */
  91352. rebuild(): void;
  91353. /**
  91354. * Starts the particle system and begins to emit
  91355. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91356. */
  91357. start(delay?: number): void;
  91358. /**
  91359. * Stops the particle system.
  91360. */
  91361. stop(): void;
  91362. /**
  91363. * Remove all active particles
  91364. */
  91365. reset(): void;
  91366. /**
  91367. * Is this system ready to be used/rendered
  91368. * @return true if the system is ready
  91369. */
  91370. isReady(): boolean;
  91371. /**
  91372. * Adds a new color gradient
  91373. * @param gradient defines the gradient to use (between 0 and 1)
  91374. * @param color1 defines the color to affect to the specified gradient
  91375. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91376. * @returns the current particle system
  91377. */
  91378. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91379. /**
  91380. * Remove a specific color gradient
  91381. * @param gradient defines the gradient to remove
  91382. * @returns the current particle system
  91383. */
  91384. removeColorGradient(gradient: number): IParticleSystem;
  91385. /**
  91386. * Adds a new size gradient
  91387. * @param gradient defines the gradient to use (between 0 and 1)
  91388. * @param factor defines the size factor to affect to the specified gradient
  91389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91390. * @returns the current particle system
  91391. */
  91392. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91393. /**
  91394. * Remove a specific size gradient
  91395. * @param gradient defines the gradient to remove
  91396. * @returns the current particle system
  91397. */
  91398. removeSizeGradient(gradient: number): IParticleSystem;
  91399. /**
  91400. * Gets the current list of color gradients.
  91401. * You must use addColorGradient and removeColorGradient to udpate this list
  91402. * @returns the list of color gradients
  91403. */
  91404. getColorGradients(): Nullable<Array<ColorGradient>>;
  91405. /**
  91406. * Gets the current list of size gradients.
  91407. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91408. * @returns the list of size gradients
  91409. */
  91410. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91411. /**
  91412. * Gets the current list of angular speed gradients.
  91413. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91414. * @returns the list of angular speed gradients
  91415. */
  91416. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91417. /**
  91418. * Adds a new angular speed gradient
  91419. * @param gradient defines the gradient to use (between 0 and 1)
  91420. * @param factor defines the angular speed to affect to the specified gradient
  91421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91422. * @returns the current particle system
  91423. */
  91424. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91425. /**
  91426. * Remove a specific angular speed gradient
  91427. * @param gradient defines the gradient to remove
  91428. * @returns the current particle system
  91429. */
  91430. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91431. /**
  91432. * Gets the current list of velocity gradients.
  91433. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91434. * @returns the list of velocity gradients
  91435. */
  91436. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91437. /**
  91438. * Adds a new velocity gradient
  91439. * @param gradient defines the gradient to use (between 0 and 1)
  91440. * @param factor defines the velocity to affect to the specified gradient
  91441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91442. * @returns the current particle system
  91443. */
  91444. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91445. /**
  91446. * Remove a specific velocity gradient
  91447. * @param gradient defines the gradient to remove
  91448. * @returns the current particle system
  91449. */
  91450. removeVelocityGradient(gradient: number): IParticleSystem;
  91451. /**
  91452. * Gets the current list of limit velocity gradients.
  91453. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91454. * @returns the list of limit velocity gradients
  91455. */
  91456. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91457. /**
  91458. * Adds a new limit velocity gradient
  91459. * @param gradient defines the gradient to use (between 0 and 1)
  91460. * @param factor defines the limit velocity to affect to the specified gradient
  91461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91462. * @returns the current particle system
  91463. */
  91464. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91465. /**
  91466. * Remove a specific limit velocity gradient
  91467. * @param gradient defines the gradient to remove
  91468. * @returns the current particle system
  91469. */
  91470. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91471. /**
  91472. * Adds a new drag gradient
  91473. * @param gradient defines the gradient to use (between 0 and 1)
  91474. * @param factor defines the drag to affect to the specified gradient
  91475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91476. * @returns the current particle system
  91477. */
  91478. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91479. /**
  91480. * Remove a specific drag gradient
  91481. * @param gradient defines the gradient to remove
  91482. * @returns the current particle system
  91483. */
  91484. removeDragGradient(gradient: number): IParticleSystem;
  91485. /**
  91486. * Gets the current list of drag gradients.
  91487. * You must use addDragGradient and removeDragGradient to udpate this list
  91488. * @returns the list of drag gradients
  91489. */
  91490. getDragGradients(): Nullable<Array<FactorGradient>>;
  91491. /**
  91492. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91493. * @param gradient defines the gradient to use (between 0 and 1)
  91494. * @param factor defines the emit rate to affect to the specified gradient
  91495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91496. * @returns the current particle system
  91497. */
  91498. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91499. /**
  91500. * Remove a specific emit rate gradient
  91501. * @param gradient defines the gradient to remove
  91502. * @returns the current particle system
  91503. */
  91504. removeEmitRateGradient(gradient: number): IParticleSystem;
  91505. /**
  91506. * Gets the current list of emit rate gradients.
  91507. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91508. * @returns the list of emit rate gradients
  91509. */
  91510. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91511. /**
  91512. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91513. * @param gradient defines the gradient to use (between 0 and 1)
  91514. * @param factor defines the start size to affect to the specified gradient
  91515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91516. * @returns the current particle system
  91517. */
  91518. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91519. /**
  91520. * Remove a specific start size gradient
  91521. * @param gradient defines the gradient to remove
  91522. * @returns the current particle system
  91523. */
  91524. removeStartSizeGradient(gradient: number): IParticleSystem;
  91525. /**
  91526. * Gets the current list of start size gradients.
  91527. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91528. * @returns the list of start size gradients
  91529. */
  91530. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91531. /**
  91532. * Adds a new life time gradient
  91533. * @param gradient defines the gradient to use (between 0 and 1)
  91534. * @param factor defines the life time factor to affect to the specified gradient
  91535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91536. * @returns the current particle system
  91537. */
  91538. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91539. /**
  91540. * Remove a specific life time gradient
  91541. * @param gradient defines the gradient to remove
  91542. * @returns the current particle system
  91543. */
  91544. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91545. /**
  91546. * Gets the current list of life time gradients.
  91547. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91548. * @returns the list of life time gradients
  91549. */
  91550. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91551. /**
  91552. * Gets the current list of color gradients.
  91553. * You must use addColorGradient and removeColorGradient to udpate this list
  91554. * @returns the list of color gradients
  91555. */
  91556. getColorGradients(): Nullable<Array<ColorGradient>>;
  91557. /**
  91558. * Adds a new ramp gradient used to remap particle colors
  91559. * @param gradient defines the gradient to use (between 0 and 1)
  91560. * @param color defines the color to affect to the specified gradient
  91561. * @returns the current particle system
  91562. */
  91563. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91564. /**
  91565. * Gets the current list of ramp gradients.
  91566. * You must use addRampGradient and removeRampGradient to udpate this list
  91567. * @returns the list of ramp gradients
  91568. */
  91569. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91570. /** Gets or sets a boolean indicating that ramp gradients must be used
  91571. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91572. */
  91573. useRampGradients: boolean;
  91574. /**
  91575. * Adds a new color remap gradient
  91576. * @param gradient defines the gradient to use (between 0 and 1)
  91577. * @param min defines the color remap minimal range
  91578. * @param max defines the color remap maximal range
  91579. * @returns the current particle system
  91580. */
  91581. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91582. /**
  91583. * Gets the current list of color remap gradients.
  91584. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91585. * @returns the list of color remap gradients
  91586. */
  91587. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91588. /**
  91589. * Adds a new alpha remap gradient
  91590. * @param gradient defines the gradient to use (between 0 and 1)
  91591. * @param min defines the alpha remap minimal range
  91592. * @param max defines the alpha remap maximal range
  91593. * @returns the current particle system
  91594. */
  91595. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91596. /**
  91597. * Gets the current list of alpha remap gradients.
  91598. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91599. * @returns the list of alpha remap gradients
  91600. */
  91601. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91602. /**
  91603. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91604. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91605. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91606. * @returns the emitter
  91607. */
  91608. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91609. /**
  91610. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91611. * @param radius The radius of the hemisphere to emit from
  91612. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91613. * @returns the emitter
  91614. */
  91615. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91616. /**
  91617. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91618. * @param radius The radius of the sphere to emit from
  91619. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91620. * @returns the emitter
  91621. */
  91622. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91623. /**
  91624. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91625. * @param radius The radius of the sphere to emit from
  91626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91628. * @returns the emitter
  91629. */
  91630. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91631. /**
  91632. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91633. * @param radius The radius of the emission cylinder
  91634. * @param height The height of the emission cylinder
  91635. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91636. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91637. * @returns the emitter
  91638. */
  91639. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  91640. /**
  91641. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91642. * @param radius The radius of the cylinder to emit from
  91643. * @param height The height of the emission cylinder
  91644. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91645. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91646. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91647. * @returns the emitter
  91648. */
  91649. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  91650. /**
  91651. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91652. * @param radius The radius of the cone to emit from
  91653. * @param angle The base angle of the cone
  91654. * @returns the emitter
  91655. */
  91656. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  91657. /**
  91658. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91659. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91660. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91661. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91662. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91663. * @returns the emitter
  91664. */
  91665. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91666. /**
  91667. * Get hosting scene
  91668. * @returns the scene
  91669. */
  91670. getScene(): Scene;
  91671. }
  91672. }
  91673. declare module BABYLON {
  91674. /**
  91675. * Creates an instance based on a source mesh.
  91676. */
  91677. export class InstancedMesh extends AbstractMesh {
  91678. private _sourceMesh;
  91679. private _currentLOD;
  91680. /** @hidden */
  91681. _indexInSourceMeshInstanceArray: number;
  91682. constructor(name: string, source: Mesh);
  91683. /**
  91684. * Returns the string "InstancedMesh".
  91685. */
  91686. getClassName(): string;
  91687. /** Gets the list of lights affecting that mesh */
  91688. get lightSources(): Light[];
  91689. _resyncLightSources(): void;
  91690. _resyncLightSource(light: Light): void;
  91691. _removeLightSource(light: Light, dispose: boolean): void;
  91692. /**
  91693. * If the source mesh receives shadows
  91694. */
  91695. get receiveShadows(): boolean;
  91696. /**
  91697. * The material of the source mesh
  91698. */
  91699. get material(): Nullable<Material>;
  91700. /**
  91701. * Visibility of the source mesh
  91702. */
  91703. get visibility(): number;
  91704. /**
  91705. * Skeleton of the source mesh
  91706. */
  91707. get skeleton(): Nullable<Skeleton>;
  91708. /**
  91709. * Rendering ground id of the source mesh
  91710. */
  91711. get renderingGroupId(): number;
  91712. set renderingGroupId(value: number);
  91713. /**
  91714. * Returns the total number of vertices (integer).
  91715. */
  91716. getTotalVertices(): number;
  91717. /**
  91718. * Returns a positive integer : the total number of indices in this mesh geometry.
  91719. * @returns the numner of indices or zero if the mesh has no geometry.
  91720. */
  91721. getTotalIndices(): number;
  91722. /**
  91723. * The source mesh of the instance
  91724. */
  91725. get sourceMesh(): Mesh;
  91726. /**
  91727. * Is this node ready to be used/rendered
  91728. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91729. * @return {boolean} is it ready
  91730. */
  91731. isReady(completeCheck?: boolean): boolean;
  91732. /**
  91733. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91734. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91735. * @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.
  91736. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91737. */
  91738. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91739. /**
  91740. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91741. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91742. * The `data` are either a numeric array either a Float32Array.
  91743. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91744. * 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).
  91745. * Note that a new underlying VertexBuffer object is created each call.
  91746. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91747. *
  91748. * Possible `kind` values :
  91749. * - VertexBuffer.PositionKind
  91750. * - VertexBuffer.UVKind
  91751. * - VertexBuffer.UV2Kind
  91752. * - VertexBuffer.UV3Kind
  91753. * - VertexBuffer.UV4Kind
  91754. * - VertexBuffer.UV5Kind
  91755. * - VertexBuffer.UV6Kind
  91756. * - VertexBuffer.ColorKind
  91757. * - VertexBuffer.MatricesIndicesKind
  91758. * - VertexBuffer.MatricesIndicesExtraKind
  91759. * - VertexBuffer.MatricesWeightsKind
  91760. * - VertexBuffer.MatricesWeightsExtraKind
  91761. *
  91762. * Returns the Mesh.
  91763. */
  91764. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91765. /**
  91766. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91767. * If the mesh has no geometry, it is simply returned as it is.
  91768. * The `data` are either a numeric array either a Float32Array.
  91769. * No new underlying VertexBuffer object is created.
  91770. * 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.
  91771. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91772. *
  91773. * Possible `kind` values :
  91774. * - VertexBuffer.PositionKind
  91775. * - VertexBuffer.UVKind
  91776. * - VertexBuffer.UV2Kind
  91777. * - VertexBuffer.UV3Kind
  91778. * - VertexBuffer.UV4Kind
  91779. * - VertexBuffer.UV5Kind
  91780. * - VertexBuffer.UV6Kind
  91781. * - VertexBuffer.ColorKind
  91782. * - VertexBuffer.MatricesIndicesKind
  91783. * - VertexBuffer.MatricesIndicesExtraKind
  91784. * - VertexBuffer.MatricesWeightsKind
  91785. * - VertexBuffer.MatricesWeightsExtraKind
  91786. *
  91787. * Returns the Mesh.
  91788. */
  91789. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91790. /**
  91791. * Sets the mesh indices.
  91792. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  91793. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91794. * This method creates a new index buffer each call.
  91795. * Returns the Mesh.
  91796. */
  91797. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  91798. /**
  91799. * Boolean : True if the mesh owns the requested kind of data.
  91800. */
  91801. isVerticesDataPresent(kind: string): boolean;
  91802. /**
  91803. * Returns an array of indices (IndicesArray).
  91804. */
  91805. getIndices(): Nullable<IndicesArray>;
  91806. get _positions(): Nullable<Vector3[]>;
  91807. /**
  91808. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91809. * This means the mesh underlying bounding box and sphere are recomputed.
  91810. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91811. * @returns the current mesh
  91812. */
  91813. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  91814. /** @hidden */
  91815. _preActivate(): InstancedMesh;
  91816. /** @hidden */
  91817. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91818. /** @hidden */
  91819. _postActivate(): void;
  91820. getWorldMatrix(): Matrix;
  91821. get isAnInstance(): boolean;
  91822. /**
  91823. * Returns the current associated LOD AbstractMesh.
  91824. */
  91825. getLOD(camera: Camera): AbstractMesh;
  91826. /** @hidden */
  91827. _syncSubMeshes(): InstancedMesh;
  91828. /** @hidden */
  91829. _generatePointsArray(): boolean;
  91830. /**
  91831. * Creates a new InstancedMesh from the current mesh.
  91832. * - name (string) : the cloned mesh name
  91833. * - newParent (optional Node) : the optional Node to parent the clone to.
  91834. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  91835. *
  91836. * Returns the clone.
  91837. */
  91838. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  91839. /**
  91840. * Disposes the InstancedMesh.
  91841. * Returns nothing.
  91842. */
  91843. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91844. }
  91845. interface Mesh {
  91846. /**
  91847. * Register a custom buffer that will be instanced
  91848. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91849. * @param kind defines the buffer kind
  91850. * @param stride defines the stride in floats
  91851. */
  91852. registerInstancedBuffer(kind: string, stride: number): void;
  91853. /** @hidden */
  91854. _userInstancedBuffersStorage: {
  91855. data: {
  91856. [key: string]: Float32Array;
  91857. };
  91858. sizes: {
  91859. [key: string]: number;
  91860. };
  91861. vertexBuffers: {
  91862. [key: string]: Nullable<VertexBuffer>;
  91863. };
  91864. strides: {
  91865. [key: string]: number;
  91866. };
  91867. };
  91868. }
  91869. interface AbstractMesh {
  91870. /**
  91871. * Object used to store instanced buffers defined by user
  91872. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91873. */
  91874. instancedBuffers: {
  91875. [key: string]: any;
  91876. };
  91877. }
  91878. }
  91879. declare module BABYLON {
  91880. /**
  91881. * Defines the options associated with the creation of a shader material.
  91882. */
  91883. export interface IShaderMaterialOptions {
  91884. /**
  91885. * Does the material work in alpha blend mode
  91886. */
  91887. needAlphaBlending: boolean;
  91888. /**
  91889. * Does the material work in alpha test mode
  91890. */
  91891. needAlphaTesting: boolean;
  91892. /**
  91893. * The list of attribute names used in the shader
  91894. */
  91895. attributes: string[];
  91896. /**
  91897. * The list of unifrom names used in the shader
  91898. */
  91899. uniforms: string[];
  91900. /**
  91901. * The list of UBO names used in the shader
  91902. */
  91903. uniformBuffers: string[];
  91904. /**
  91905. * The list of sampler names used in the shader
  91906. */
  91907. samplers: string[];
  91908. /**
  91909. * The list of defines used in the shader
  91910. */
  91911. defines: string[];
  91912. }
  91913. /**
  91914. * 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.
  91915. *
  91916. * This returned material effects how the mesh will look based on the code in the shaders.
  91917. *
  91918. * @see http://doc.babylonjs.com/how_to/shader_material
  91919. */
  91920. export class ShaderMaterial extends Material {
  91921. private _shaderPath;
  91922. private _options;
  91923. private _textures;
  91924. private _textureArrays;
  91925. private _floats;
  91926. private _ints;
  91927. private _floatsArrays;
  91928. private _colors3;
  91929. private _colors3Arrays;
  91930. private _colors4;
  91931. private _colors4Arrays;
  91932. private _vectors2;
  91933. private _vectors3;
  91934. private _vectors4;
  91935. private _matrices;
  91936. private _matrixArrays;
  91937. private _matrices3x3;
  91938. private _matrices2x2;
  91939. private _vectors2Arrays;
  91940. private _vectors3Arrays;
  91941. private _vectors4Arrays;
  91942. private _cachedWorldViewMatrix;
  91943. private _cachedWorldViewProjectionMatrix;
  91944. private _renderId;
  91945. private _multiview;
  91946. /**
  91947. * Instantiate a new shader material.
  91948. * 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.
  91949. * This returned material effects how the mesh will look based on the code in the shaders.
  91950. * @see http://doc.babylonjs.com/how_to/shader_material
  91951. * @param name Define the name of the material in the scene
  91952. * @param scene Define the scene the material belongs to
  91953. * @param shaderPath Defines the route to the shader code in one of three ways:
  91954. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  91955. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  91956. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  91957. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  91958. * @param options Define the options used to create the shader
  91959. */
  91960. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  91961. /**
  91962. * Gets the shader path used to define the shader code
  91963. * It can be modified to trigger a new compilation
  91964. */
  91965. get shaderPath(): any;
  91966. /**
  91967. * Sets the shader path used to define the shader code
  91968. * It can be modified to trigger a new compilation
  91969. */
  91970. set shaderPath(shaderPath: any);
  91971. /**
  91972. * Gets the options used to compile the shader.
  91973. * They can be modified to trigger a new compilation
  91974. */
  91975. get options(): IShaderMaterialOptions;
  91976. /**
  91977. * Gets the current class name of the material e.g. "ShaderMaterial"
  91978. * Mainly use in serialization.
  91979. * @returns the class name
  91980. */
  91981. getClassName(): string;
  91982. /**
  91983. * Specifies if the material will require alpha blending
  91984. * @returns a boolean specifying if alpha blending is needed
  91985. */
  91986. needAlphaBlending(): boolean;
  91987. /**
  91988. * Specifies if this material should be rendered in alpha test mode
  91989. * @returns a boolean specifying if an alpha test is needed.
  91990. */
  91991. needAlphaTesting(): boolean;
  91992. private _checkUniform;
  91993. /**
  91994. * Set a texture in the shader.
  91995. * @param name Define the name of the uniform samplers as defined in the shader
  91996. * @param texture Define the texture to bind to this sampler
  91997. * @return the material itself allowing "fluent" like uniform updates
  91998. */
  91999. setTexture(name: string, texture: Texture): ShaderMaterial;
  92000. /**
  92001. * Set a texture array in the shader.
  92002. * @param name Define the name of the uniform sampler array as defined in the shader
  92003. * @param textures Define the list of textures to bind to this sampler
  92004. * @return the material itself allowing "fluent" like uniform updates
  92005. */
  92006. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  92007. /**
  92008. * Set a float in the shader.
  92009. * @param name Define the name of the uniform as defined in the shader
  92010. * @param value Define the value to give to the uniform
  92011. * @return the material itself allowing "fluent" like uniform updates
  92012. */
  92013. setFloat(name: string, value: number): ShaderMaterial;
  92014. /**
  92015. * Set a int in the shader.
  92016. * @param name Define the name of the uniform as defined in the shader
  92017. * @param value Define the value to give to the uniform
  92018. * @return the material itself allowing "fluent" like uniform updates
  92019. */
  92020. setInt(name: string, value: number): ShaderMaterial;
  92021. /**
  92022. * Set an array of floats in the shader.
  92023. * @param name Define the name of the uniform as defined in the shader
  92024. * @param value Define the value to give to the uniform
  92025. * @return the material itself allowing "fluent" like uniform updates
  92026. */
  92027. setFloats(name: string, value: number[]): ShaderMaterial;
  92028. /**
  92029. * Set a vec3 in the shader from a Color3.
  92030. * @param name Define the name of the uniform as defined in the shader
  92031. * @param value Define the value to give to the uniform
  92032. * @return the material itself allowing "fluent" like uniform updates
  92033. */
  92034. setColor3(name: string, value: Color3): ShaderMaterial;
  92035. /**
  92036. * Set a vec3 array in the shader from a Color3 array.
  92037. * @param name Define the name of the uniform as defined in the shader
  92038. * @param value Define the value to give to the uniform
  92039. * @return the material itself allowing "fluent" like uniform updates
  92040. */
  92041. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  92042. /**
  92043. * Set a vec4 in the shader from a Color4.
  92044. * @param name Define the name of the uniform as defined in the shader
  92045. * @param value Define the value to give to the uniform
  92046. * @return the material itself allowing "fluent" like uniform updates
  92047. */
  92048. setColor4(name: string, value: Color4): ShaderMaterial;
  92049. /**
  92050. * Set a vec4 array in the shader from a Color4 array.
  92051. * @param name Define the name of the uniform as defined in the shader
  92052. * @param value Define the value to give to the uniform
  92053. * @return the material itself allowing "fluent" like uniform updates
  92054. */
  92055. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  92056. /**
  92057. * Set a vec2 in the shader from a Vector2.
  92058. * @param name Define the name of the uniform as defined in the shader
  92059. * @param value Define the value to give to the uniform
  92060. * @return the material itself allowing "fluent" like uniform updates
  92061. */
  92062. setVector2(name: string, value: Vector2): ShaderMaterial;
  92063. /**
  92064. * Set a vec3 in the shader from a Vector3.
  92065. * @param name Define the name of the uniform as defined in the shader
  92066. * @param value Define the value to give to the uniform
  92067. * @return the material itself allowing "fluent" like uniform updates
  92068. */
  92069. setVector3(name: string, value: Vector3): ShaderMaterial;
  92070. /**
  92071. * Set a vec4 in the shader from a Vector4.
  92072. * @param name Define the name of the uniform as defined in the shader
  92073. * @param value Define the value to give to the uniform
  92074. * @return the material itself allowing "fluent" like uniform updates
  92075. */
  92076. setVector4(name: string, value: Vector4): ShaderMaterial;
  92077. /**
  92078. * Set a mat4 in the shader from a Matrix.
  92079. * @param name Define the name of the uniform as defined in the shader
  92080. * @param value Define the value to give to the uniform
  92081. * @return the material itself allowing "fluent" like uniform updates
  92082. */
  92083. setMatrix(name: string, value: Matrix): ShaderMaterial;
  92084. /**
  92085. * Set a float32Array in the shader from a matrix array.
  92086. * @param name Define the name of the uniform as defined in the shader
  92087. * @param value Define the value to give to the uniform
  92088. * @return the material itself allowing "fluent" like uniform updates
  92089. */
  92090. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  92091. /**
  92092. * Set a mat3 in the shader from a Float32Array.
  92093. * @param name Define the name of the uniform as defined in the shader
  92094. * @param value Define the value to give to the uniform
  92095. * @return the material itself allowing "fluent" like uniform updates
  92096. */
  92097. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  92098. /**
  92099. * Set a mat2 in the shader from a Float32Array.
  92100. * @param name Define the name of the uniform as defined in the shader
  92101. * @param value Define the value to give to the uniform
  92102. * @return the material itself allowing "fluent" like uniform updates
  92103. */
  92104. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  92105. /**
  92106. * Set a vec2 array in the shader from a number array.
  92107. * @param name Define the name of the uniform as defined in the shader
  92108. * @param value Define the value to give to the uniform
  92109. * @return the material itself allowing "fluent" like uniform updates
  92110. */
  92111. setArray2(name: string, value: number[]): ShaderMaterial;
  92112. /**
  92113. * Set a vec3 array in the shader from a number array.
  92114. * @param name Define the name of the uniform as defined in the shader
  92115. * @param value Define the value to give to the uniform
  92116. * @return the material itself allowing "fluent" like uniform updates
  92117. */
  92118. setArray3(name: string, value: number[]): ShaderMaterial;
  92119. /**
  92120. * Set a vec4 array in the shader from a number array.
  92121. * @param name Define the name of the uniform as defined in the shader
  92122. * @param value Define the value to give to the uniform
  92123. * @return the material itself allowing "fluent" like uniform updates
  92124. */
  92125. setArray4(name: string, value: number[]): ShaderMaterial;
  92126. private _checkCache;
  92127. /**
  92128. * Specifies that the submesh is ready to be used
  92129. * @param mesh defines the mesh to check
  92130. * @param subMesh defines which submesh to check
  92131. * @param useInstances specifies that instances should be used
  92132. * @returns a boolean indicating that the submesh is ready or not
  92133. */
  92134. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92135. /**
  92136. * Checks if the material is ready to render the requested mesh
  92137. * @param mesh Define the mesh to render
  92138. * @param useInstances Define whether or not the material is used with instances
  92139. * @returns true if ready, otherwise false
  92140. */
  92141. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  92142. /**
  92143. * Binds the world matrix to the material
  92144. * @param world defines the world transformation matrix
  92145. */
  92146. bindOnlyWorldMatrix(world: Matrix): void;
  92147. /**
  92148. * Binds the material to the mesh
  92149. * @param world defines the world transformation matrix
  92150. * @param mesh defines the mesh to bind the material to
  92151. */
  92152. bind(world: Matrix, mesh?: Mesh): void;
  92153. /**
  92154. * Gets the active textures from the material
  92155. * @returns an array of textures
  92156. */
  92157. getActiveTextures(): BaseTexture[];
  92158. /**
  92159. * Specifies if the material uses a texture
  92160. * @param texture defines the texture to check against the material
  92161. * @returns a boolean specifying if the material uses the texture
  92162. */
  92163. hasTexture(texture: BaseTexture): boolean;
  92164. /**
  92165. * Makes a duplicate of the material, and gives it a new name
  92166. * @param name defines the new name for the duplicated material
  92167. * @returns the cloned material
  92168. */
  92169. clone(name: string): ShaderMaterial;
  92170. /**
  92171. * Disposes the material
  92172. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92173. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  92174. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  92175. */
  92176. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  92177. /**
  92178. * Serializes this material in a JSON representation
  92179. * @returns the serialized material object
  92180. */
  92181. serialize(): any;
  92182. /**
  92183. * Creates a shader material from parsed shader material data
  92184. * @param source defines the JSON represnetation of the material
  92185. * @param scene defines the hosting scene
  92186. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92187. * @returns a new material
  92188. */
  92189. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  92190. }
  92191. }
  92192. declare module BABYLON {
  92193. /** @hidden */
  92194. export var colorPixelShader: {
  92195. name: string;
  92196. shader: string;
  92197. };
  92198. }
  92199. declare module BABYLON {
  92200. /** @hidden */
  92201. export var colorVertexShader: {
  92202. name: string;
  92203. shader: string;
  92204. };
  92205. }
  92206. declare module BABYLON {
  92207. /**
  92208. * Line mesh
  92209. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  92210. */
  92211. export class LinesMesh extends Mesh {
  92212. /**
  92213. * If vertex color should be applied to the mesh
  92214. */
  92215. readonly useVertexColor?: boolean | undefined;
  92216. /**
  92217. * If vertex alpha should be applied to the mesh
  92218. */
  92219. readonly useVertexAlpha?: boolean | undefined;
  92220. /**
  92221. * Color of the line (Default: White)
  92222. */
  92223. color: Color3;
  92224. /**
  92225. * Alpha of the line (Default: 1)
  92226. */
  92227. alpha: number;
  92228. /**
  92229. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92230. * This margin is expressed in world space coordinates, so its value may vary.
  92231. * Default value is 0.1
  92232. */
  92233. intersectionThreshold: number;
  92234. private _colorShader;
  92235. private color4;
  92236. /**
  92237. * Creates a new LinesMesh
  92238. * @param name defines the name
  92239. * @param scene defines the hosting scene
  92240. * @param parent defines the parent mesh if any
  92241. * @param source defines the optional source LinesMesh used to clone data from
  92242. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92243. * When false, achieved by calling a clone(), also passing False.
  92244. * This will make creation of children, recursive.
  92245. * @param useVertexColor defines if this LinesMesh supports vertex color
  92246. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  92247. */
  92248. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  92249. /**
  92250. * If vertex color should be applied to the mesh
  92251. */
  92252. useVertexColor?: boolean | undefined,
  92253. /**
  92254. * If vertex alpha should be applied to the mesh
  92255. */
  92256. useVertexAlpha?: boolean | undefined);
  92257. private _addClipPlaneDefine;
  92258. private _removeClipPlaneDefine;
  92259. isReady(): boolean;
  92260. /**
  92261. * Returns the string "LineMesh"
  92262. */
  92263. getClassName(): string;
  92264. /**
  92265. * @hidden
  92266. */
  92267. get material(): Material;
  92268. /**
  92269. * @hidden
  92270. */
  92271. set material(value: Material);
  92272. /**
  92273. * @hidden
  92274. */
  92275. get checkCollisions(): boolean;
  92276. /** @hidden */
  92277. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92278. /** @hidden */
  92279. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92280. /**
  92281. * Disposes of the line mesh
  92282. * @param doNotRecurse If children should be disposed
  92283. */
  92284. dispose(doNotRecurse?: boolean): void;
  92285. /**
  92286. * Returns a new LineMesh object cloned from the current one.
  92287. */
  92288. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  92289. /**
  92290. * Creates a new InstancedLinesMesh object from the mesh model.
  92291. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92292. * @param name defines the name of the new instance
  92293. * @returns a new InstancedLinesMesh
  92294. */
  92295. createInstance(name: string): InstancedLinesMesh;
  92296. }
  92297. /**
  92298. * Creates an instance based on a source LinesMesh
  92299. */
  92300. export class InstancedLinesMesh extends InstancedMesh {
  92301. /**
  92302. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92303. * This margin is expressed in world space coordinates, so its value may vary.
  92304. * Initilized with the intersectionThreshold value of the source LinesMesh
  92305. */
  92306. intersectionThreshold: number;
  92307. constructor(name: string, source: LinesMesh);
  92308. /**
  92309. * Returns the string "InstancedLinesMesh".
  92310. */
  92311. getClassName(): string;
  92312. }
  92313. }
  92314. declare module BABYLON {
  92315. /** @hidden */
  92316. export var linePixelShader: {
  92317. name: string;
  92318. shader: string;
  92319. };
  92320. }
  92321. declare module BABYLON {
  92322. /** @hidden */
  92323. export var lineVertexShader: {
  92324. name: string;
  92325. shader: string;
  92326. };
  92327. }
  92328. declare module BABYLON {
  92329. interface AbstractMesh {
  92330. /**
  92331. * Gets the edgesRenderer associated with the mesh
  92332. */
  92333. edgesRenderer: Nullable<EdgesRenderer>;
  92334. }
  92335. interface LinesMesh {
  92336. /**
  92337. * Enables the edge rendering mode on the mesh.
  92338. * This mode makes the mesh edges visible
  92339. * @param epsilon defines the maximal distance between two angles to detect a face
  92340. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92341. * @returns the currentAbstractMesh
  92342. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92343. */
  92344. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92345. }
  92346. interface InstancedLinesMesh {
  92347. /**
  92348. * Enables the edge rendering mode on the mesh.
  92349. * This mode makes the mesh edges visible
  92350. * @param epsilon defines the maximal distance between two angles to detect a face
  92351. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92352. * @returns the current InstancedLinesMesh
  92353. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92354. */
  92355. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  92356. }
  92357. /**
  92358. * Defines the minimum contract an Edges renderer should follow.
  92359. */
  92360. export interface IEdgesRenderer extends IDisposable {
  92361. /**
  92362. * Gets or sets a boolean indicating if the edgesRenderer is active
  92363. */
  92364. isEnabled: boolean;
  92365. /**
  92366. * Renders the edges of the attached mesh,
  92367. */
  92368. render(): void;
  92369. /**
  92370. * Checks wether or not the edges renderer is ready to render.
  92371. * @return true if ready, otherwise false.
  92372. */
  92373. isReady(): boolean;
  92374. }
  92375. /**
  92376. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  92377. */
  92378. export class EdgesRenderer implements IEdgesRenderer {
  92379. /**
  92380. * Define the size of the edges with an orthographic camera
  92381. */
  92382. edgesWidthScalerForOrthographic: number;
  92383. /**
  92384. * Define the size of the edges with a perspective camera
  92385. */
  92386. edgesWidthScalerForPerspective: number;
  92387. protected _source: AbstractMesh;
  92388. protected _linesPositions: number[];
  92389. protected _linesNormals: number[];
  92390. protected _linesIndices: number[];
  92391. protected _epsilon: number;
  92392. protected _indicesCount: number;
  92393. protected _lineShader: ShaderMaterial;
  92394. protected _ib: DataBuffer;
  92395. protected _buffers: {
  92396. [key: string]: Nullable<VertexBuffer>;
  92397. };
  92398. protected _checkVerticesInsteadOfIndices: boolean;
  92399. private _meshRebuildObserver;
  92400. private _meshDisposeObserver;
  92401. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  92402. isEnabled: boolean;
  92403. /**
  92404. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  92405. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  92406. * @param source Mesh used to create edges
  92407. * @param epsilon sum of angles in adjacency to check for edge
  92408. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  92409. * @param generateEdgesLines - should generate Lines or only prepare resources.
  92410. */
  92411. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  92412. protected _prepareRessources(): void;
  92413. /** @hidden */
  92414. _rebuild(): void;
  92415. /**
  92416. * Releases the required resources for the edges renderer
  92417. */
  92418. dispose(): void;
  92419. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92420. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92421. /**
  92422. * Checks if the pair of p0 and p1 is en edge
  92423. * @param faceIndex
  92424. * @param edge
  92425. * @param faceNormals
  92426. * @param p0
  92427. * @param p1
  92428. * @private
  92429. */
  92430. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92431. /**
  92432. * push line into the position, normal and index buffer
  92433. * @protected
  92434. */
  92435. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92436. /**
  92437. * Generates lines edges from adjacencjes
  92438. * @private
  92439. */
  92440. _generateEdgesLines(): void;
  92441. /**
  92442. * Checks wether or not the edges renderer is ready to render.
  92443. * @return true if ready, otherwise false.
  92444. */
  92445. isReady(): boolean;
  92446. /**
  92447. * Renders the edges of the attached mesh,
  92448. */
  92449. render(): void;
  92450. }
  92451. /**
  92452. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92453. */
  92454. export class LineEdgesRenderer extends EdgesRenderer {
  92455. /**
  92456. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92457. * @param source LineMesh used to generate edges
  92458. * @param epsilon not important (specified angle for edge detection)
  92459. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92460. */
  92461. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92462. /**
  92463. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92464. */
  92465. _generateEdgesLines(): void;
  92466. }
  92467. }
  92468. declare module BABYLON {
  92469. /**
  92470. * This represents the object necessary to create a rendering group.
  92471. * This is exclusively used and created by the rendering manager.
  92472. * To modify the behavior, you use the available helpers in your scene or meshes.
  92473. * @hidden
  92474. */
  92475. export class RenderingGroup {
  92476. index: number;
  92477. private static _zeroVector;
  92478. private _scene;
  92479. private _opaqueSubMeshes;
  92480. private _transparentSubMeshes;
  92481. private _alphaTestSubMeshes;
  92482. private _depthOnlySubMeshes;
  92483. private _particleSystems;
  92484. private _spriteManagers;
  92485. private _opaqueSortCompareFn;
  92486. private _alphaTestSortCompareFn;
  92487. private _transparentSortCompareFn;
  92488. private _renderOpaque;
  92489. private _renderAlphaTest;
  92490. private _renderTransparent;
  92491. /** @hidden */
  92492. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92493. onBeforeTransparentRendering: () => void;
  92494. /**
  92495. * Set the opaque sort comparison function.
  92496. * If null the sub meshes will be render in the order they were created
  92497. */
  92498. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92499. /**
  92500. * Set the alpha test sort comparison function.
  92501. * If null the sub meshes will be render in the order they were created
  92502. */
  92503. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92504. /**
  92505. * Set the transparent sort comparison function.
  92506. * If null the sub meshes will be render in the order they were created
  92507. */
  92508. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92509. /**
  92510. * Creates a new rendering group.
  92511. * @param index The rendering group index
  92512. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92513. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92514. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92515. */
  92516. 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>);
  92517. /**
  92518. * Render all the sub meshes contained in the group.
  92519. * @param customRenderFunction Used to override the default render behaviour of the group.
  92520. * @returns true if rendered some submeshes.
  92521. */
  92522. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92523. /**
  92524. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92525. * @param subMeshes The submeshes to render
  92526. */
  92527. private renderOpaqueSorted;
  92528. /**
  92529. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92530. * @param subMeshes The submeshes to render
  92531. */
  92532. private renderAlphaTestSorted;
  92533. /**
  92534. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92535. * @param subMeshes The submeshes to render
  92536. */
  92537. private renderTransparentSorted;
  92538. /**
  92539. * Renders the submeshes in a specified order.
  92540. * @param subMeshes The submeshes to sort before render
  92541. * @param sortCompareFn The comparison function use to sort
  92542. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92543. * @param transparent Specifies to activate blending if true
  92544. */
  92545. private static renderSorted;
  92546. /**
  92547. * Renders the submeshes in the order they were dispatched (no sort applied).
  92548. * @param subMeshes The submeshes to render
  92549. */
  92550. private static renderUnsorted;
  92551. /**
  92552. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92553. * are rendered back to front if in the same alpha index.
  92554. *
  92555. * @param a The first submesh
  92556. * @param b The second submesh
  92557. * @returns The result of the comparison
  92558. */
  92559. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92560. /**
  92561. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92562. * are rendered back to front.
  92563. *
  92564. * @param a The first submesh
  92565. * @param b The second submesh
  92566. * @returns The result of the comparison
  92567. */
  92568. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92569. /**
  92570. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92571. * are rendered front to back (prevent overdraw).
  92572. *
  92573. * @param a The first submesh
  92574. * @param b The second submesh
  92575. * @returns The result of the comparison
  92576. */
  92577. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  92578. /**
  92579. * Resets the different lists of submeshes to prepare a new frame.
  92580. */
  92581. prepare(): void;
  92582. dispose(): void;
  92583. /**
  92584. * Inserts the submesh in its correct queue depending on its material.
  92585. * @param subMesh The submesh to dispatch
  92586. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92587. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92588. */
  92589. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92590. dispatchSprites(spriteManager: ISpriteManager): void;
  92591. dispatchParticles(particleSystem: IParticleSystem): void;
  92592. private _renderParticles;
  92593. private _renderSprites;
  92594. }
  92595. }
  92596. declare module BABYLON {
  92597. /**
  92598. * Interface describing the different options available in the rendering manager
  92599. * regarding Auto Clear between groups.
  92600. */
  92601. export interface IRenderingManagerAutoClearSetup {
  92602. /**
  92603. * Defines whether or not autoclear is enable.
  92604. */
  92605. autoClear: boolean;
  92606. /**
  92607. * Defines whether or not to autoclear the depth buffer.
  92608. */
  92609. depth: boolean;
  92610. /**
  92611. * Defines whether or not to autoclear the stencil buffer.
  92612. */
  92613. stencil: boolean;
  92614. }
  92615. /**
  92616. * This class is used by the onRenderingGroupObservable
  92617. */
  92618. export class RenderingGroupInfo {
  92619. /**
  92620. * The Scene that being rendered
  92621. */
  92622. scene: Scene;
  92623. /**
  92624. * The camera currently used for the rendering pass
  92625. */
  92626. camera: Nullable<Camera>;
  92627. /**
  92628. * The ID of the renderingGroup being processed
  92629. */
  92630. renderingGroupId: number;
  92631. }
  92632. /**
  92633. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92634. * It is enable to manage the different groups as well as the different necessary sort functions.
  92635. * This should not be used directly aside of the few static configurations
  92636. */
  92637. export class RenderingManager {
  92638. /**
  92639. * The max id used for rendering groups (not included)
  92640. */
  92641. static MAX_RENDERINGGROUPS: number;
  92642. /**
  92643. * The min id used for rendering groups (included)
  92644. */
  92645. static MIN_RENDERINGGROUPS: number;
  92646. /**
  92647. * Used to globally prevent autoclearing scenes.
  92648. */
  92649. static AUTOCLEAR: boolean;
  92650. /**
  92651. * @hidden
  92652. */
  92653. _useSceneAutoClearSetup: boolean;
  92654. private _scene;
  92655. private _renderingGroups;
  92656. private _depthStencilBufferAlreadyCleaned;
  92657. private _autoClearDepthStencil;
  92658. private _customOpaqueSortCompareFn;
  92659. private _customAlphaTestSortCompareFn;
  92660. private _customTransparentSortCompareFn;
  92661. private _renderingGroupInfo;
  92662. /**
  92663. * Instantiates a new rendering group for a particular scene
  92664. * @param scene Defines the scene the groups belongs to
  92665. */
  92666. constructor(scene: Scene);
  92667. private _clearDepthStencilBuffer;
  92668. /**
  92669. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92670. * @hidden
  92671. */
  92672. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92673. /**
  92674. * Resets the different information of the group to prepare a new frame
  92675. * @hidden
  92676. */
  92677. reset(): void;
  92678. /**
  92679. * Dispose and release the group and its associated resources.
  92680. * @hidden
  92681. */
  92682. dispose(): void;
  92683. /**
  92684. * Clear the info related to rendering groups preventing retention points during dispose.
  92685. */
  92686. freeRenderingGroups(): void;
  92687. private _prepareRenderingGroup;
  92688. /**
  92689. * Add a sprite manager to the rendering manager in order to render it this frame.
  92690. * @param spriteManager Define the sprite manager to render
  92691. */
  92692. dispatchSprites(spriteManager: ISpriteManager): void;
  92693. /**
  92694. * Add a particle system to the rendering manager in order to render it this frame.
  92695. * @param particleSystem Define the particle system to render
  92696. */
  92697. dispatchParticles(particleSystem: IParticleSystem): void;
  92698. /**
  92699. * Add a submesh to the manager in order to render it this frame
  92700. * @param subMesh The submesh to dispatch
  92701. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92702. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92703. */
  92704. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92705. /**
  92706. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92707. * This allowed control for front to back rendering or reversly depending of the special needs.
  92708. *
  92709. * @param renderingGroupId The rendering group id corresponding to its index
  92710. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92711. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92712. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92713. */
  92714. 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;
  92715. /**
  92716. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92717. *
  92718. * @param renderingGroupId The rendering group id corresponding to its index
  92719. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92720. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92721. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92722. */
  92723. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92724. /**
  92725. * Gets the current auto clear configuration for one rendering group of the rendering
  92726. * manager.
  92727. * @param index the rendering group index to get the information for
  92728. * @returns The auto clear setup for the requested rendering group
  92729. */
  92730. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92731. }
  92732. }
  92733. declare module BABYLON {
  92734. /**
  92735. * This Helps creating a texture that will be created from a camera in your scene.
  92736. * It is basically a dynamic texture that could be used to create special effects for instance.
  92737. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  92738. */
  92739. export class RenderTargetTexture extends Texture {
  92740. isCube: boolean;
  92741. /**
  92742. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  92743. */
  92744. static readonly REFRESHRATE_RENDER_ONCE: number;
  92745. /**
  92746. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  92747. */
  92748. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  92749. /**
  92750. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  92751. * the central point of your effect and can save a lot of performances.
  92752. */
  92753. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  92754. /**
  92755. * Use this predicate to dynamically define the list of mesh you want to render.
  92756. * If set, the renderList property will be overwritten.
  92757. */
  92758. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  92759. private _renderList;
  92760. /**
  92761. * Use this list to define the list of mesh you want to render.
  92762. */
  92763. get renderList(): Nullable<Array<AbstractMesh>>;
  92764. set renderList(value: Nullable<Array<AbstractMesh>>);
  92765. /**
  92766. * Use this function to overload the renderList array at rendering time.
  92767. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  92768. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  92769. * the cube (if the RTT is a cube, else layerOrFace=0).
  92770. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  92771. */
  92772. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  92773. private _hookArray;
  92774. /**
  92775. * Define if particles should be rendered in your texture.
  92776. */
  92777. renderParticles: boolean;
  92778. /**
  92779. * Define if sprites should be rendered in your texture.
  92780. */
  92781. renderSprites: boolean;
  92782. /**
  92783. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  92784. */
  92785. coordinatesMode: number;
  92786. /**
  92787. * Define the camera used to render the texture.
  92788. */
  92789. activeCamera: Nullable<Camera>;
  92790. /**
  92791. * Override the render function of the texture with your own one.
  92792. */
  92793. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  92794. /**
  92795. * Define if camera post processes should be use while rendering the texture.
  92796. */
  92797. useCameraPostProcesses: boolean;
  92798. /**
  92799. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  92800. */
  92801. ignoreCameraViewport: boolean;
  92802. private _postProcessManager;
  92803. private _postProcesses;
  92804. private _resizeObserver;
  92805. /**
  92806. * An event triggered when the texture is unbind.
  92807. */
  92808. onBeforeBindObservable: Observable<RenderTargetTexture>;
  92809. /**
  92810. * An event triggered when the texture is unbind.
  92811. */
  92812. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  92813. private _onAfterUnbindObserver;
  92814. /**
  92815. * Set a after unbind callback in the texture.
  92816. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  92817. */
  92818. set onAfterUnbind(callback: () => void);
  92819. /**
  92820. * An event triggered before rendering the texture
  92821. */
  92822. onBeforeRenderObservable: Observable<number>;
  92823. private _onBeforeRenderObserver;
  92824. /**
  92825. * Set a before render callback in the texture.
  92826. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  92827. */
  92828. set onBeforeRender(callback: (faceIndex: number) => void);
  92829. /**
  92830. * An event triggered after rendering the texture
  92831. */
  92832. onAfterRenderObservable: Observable<number>;
  92833. private _onAfterRenderObserver;
  92834. /**
  92835. * Set a after render callback in the texture.
  92836. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  92837. */
  92838. set onAfterRender(callback: (faceIndex: number) => void);
  92839. /**
  92840. * An event triggered after the texture clear
  92841. */
  92842. onClearObservable: Observable<Engine>;
  92843. private _onClearObserver;
  92844. /**
  92845. * Set a clear callback in the texture.
  92846. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  92847. */
  92848. set onClear(callback: (Engine: Engine) => void);
  92849. /**
  92850. * An event triggered when the texture is resized.
  92851. */
  92852. onResizeObservable: Observable<RenderTargetTexture>;
  92853. /**
  92854. * Define the clear color of the Render Target if it should be different from the scene.
  92855. */
  92856. clearColor: Color4;
  92857. protected _size: number | {
  92858. width: number;
  92859. height: number;
  92860. layers?: number;
  92861. };
  92862. protected _initialSizeParameter: number | {
  92863. width: number;
  92864. height: number;
  92865. } | {
  92866. ratio: number;
  92867. };
  92868. protected _sizeRatio: Nullable<number>;
  92869. /** @hidden */
  92870. _generateMipMaps: boolean;
  92871. protected _renderingManager: RenderingManager;
  92872. /** @hidden */
  92873. _waitingRenderList: string[];
  92874. protected _doNotChangeAspectRatio: boolean;
  92875. protected _currentRefreshId: number;
  92876. protected _refreshRate: number;
  92877. protected _textureMatrix: Matrix;
  92878. protected _samples: number;
  92879. protected _renderTargetOptions: RenderTargetCreationOptions;
  92880. /**
  92881. * Gets render target creation options that were used.
  92882. */
  92883. get renderTargetOptions(): RenderTargetCreationOptions;
  92884. protected _engine: Engine;
  92885. protected _onRatioRescale(): void;
  92886. /**
  92887. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  92888. * It must define where the camera used to render the texture is set
  92889. */
  92890. boundingBoxPosition: Vector3;
  92891. private _boundingBoxSize;
  92892. /**
  92893. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  92894. * When defined, the cubemap will switch to local mode
  92895. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  92896. * @example https://www.babylonjs-playground.com/#RNASML
  92897. */
  92898. set boundingBoxSize(value: Vector3);
  92899. get boundingBoxSize(): Vector3;
  92900. /**
  92901. * In case the RTT has been created with a depth texture, get the associated
  92902. * depth texture.
  92903. * Otherwise, return null.
  92904. */
  92905. get depthStencilTexture(): Nullable<InternalTexture>;
  92906. /**
  92907. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  92908. * or used a shadow, depth texture...
  92909. * @param name The friendly name of the texture
  92910. * @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)
  92911. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  92912. * @param generateMipMaps True if mip maps need to be generated after render.
  92913. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  92914. * @param type The type of the buffer in the RTT (int, half float, float...)
  92915. * @param isCube True if a cube texture needs to be created
  92916. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  92917. * @param generateDepthBuffer True to generate a depth buffer
  92918. * @param generateStencilBuffer True to generate a stencil buffer
  92919. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  92920. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  92921. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92922. */
  92923. constructor(name: string, size: number | {
  92924. width: number;
  92925. height: number;
  92926. layers?: number;
  92927. } | {
  92928. ratio: number;
  92929. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  92930. /**
  92931. * Creates a depth stencil texture.
  92932. * This is only available in WebGL 2 or with the depth texture extension available.
  92933. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  92934. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  92935. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  92936. */
  92937. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  92938. private _processSizeParameter;
  92939. /**
  92940. * Define the number of samples to use in case of MSAA.
  92941. * It defaults to one meaning no MSAA has been enabled.
  92942. */
  92943. get samples(): number;
  92944. set samples(value: number);
  92945. /**
  92946. * Resets the refresh counter of the texture and start bak from scratch.
  92947. * Could be useful to regenerate the texture if it is setup to render only once.
  92948. */
  92949. resetRefreshCounter(): void;
  92950. /**
  92951. * Define the refresh rate of the texture or the rendering frequency.
  92952. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92953. */
  92954. get refreshRate(): number;
  92955. set refreshRate(value: number);
  92956. /**
  92957. * Adds a post process to the render target rendering passes.
  92958. * @param postProcess define the post process to add
  92959. */
  92960. addPostProcess(postProcess: PostProcess): void;
  92961. /**
  92962. * Clear all the post processes attached to the render target
  92963. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  92964. */
  92965. clearPostProcesses(dispose?: boolean): void;
  92966. /**
  92967. * Remove one of the post process from the list of attached post processes to the texture
  92968. * @param postProcess define the post process to remove from the list
  92969. */
  92970. removePostProcess(postProcess: PostProcess): void;
  92971. /** @hidden */
  92972. _shouldRender(): boolean;
  92973. /**
  92974. * Gets the actual render size of the texture.
  92975. * @returns the width of the render size
  92976. */
  92977. getRenderSize(): number;
  92978. /**
  92979. * Gets the actual render width of the texture.
  92980. * @returns the width of the render size
  92981. */
  92982. getRenderWidth(): number;
  92983. /**
  92984. * Gets the actual render height of the texture.
  92985. * @returns the height of the render size
  92986. */
  92987. getRenderHeight(): number;
  92988. /**
  92989. * Gets the actual number of layers of the texture.
  92990. * @returns the number of layers
  92991. */
  92992. getRenderLayers(): number;
  92993. /**
  92994. * Get if the texture can be rescaled or not.
  92995. */
  92996. get canRescale(): boolean;
  92997. /**
  92998. * Resize the texture using a ratio.
  92999. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93000. */
  93001. scale(ratio: number): void;
  93002. /**
  93003. * Get the texture reflection matrix used to rotate/transform the reflection.
  93004. * @returns the reflection matrix
  93005. */
  93006. getReflectionTextureMatrix(): Matrix;
  93007. /**
  93008. * Resize the texture to a new desired size.
  93009. * Be carrefull as it will recreate all the data in the new texture.
  93010. * @param size Define the new size. It can be:
  93011. * - a number for squared texture,
  93012. * - an object containing { width: number, height: number }
  93013. * - or an object containing a ratio { ratio: number }
  93014. */
  93015. resize(size: number | {
  93016. width: number;
  93017. height: number;
  93018. } | {
  93019. ratio: number;
  93020. }): void;
  93021. private _defaultRenderListPrepared;
  93022. /**
  93023. * Renders all the objects from the render list into the texture.
  93024. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93025. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93026. */
  93027. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93028. private _bestReflectionRenderTargetDimension;
  93029. private _prepareRenderingManager;
  93030. /**
  93031. * @hidden
  93032. * @param faceIndex face index to bind to if this is a cubetexture
  93033. * @param layer defines the index of the texture to bind in the array
  93034. */
  93035. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93036. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93037. private renderToTarget;
  93038. /**
  93039. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93040. * This allowed control for front to back rendering or reversly depending of the special needs.
  93041. *
  93042. * @param renderingGroupId The rendering group id corresponding to its index
  93043. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93044. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93045. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93046. */
  93047. 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;
  93048. /**
  93049. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93050. *
  93051. * @param renderingGroupId The rendering group id corresponding to its index
  93052. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93053. */
  93054. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93055. /**
  93056. * Clones the texture.
  93057. * @returns the cloned texture
  93058. */
  93059. clone(): RenderTargetTexture;
  93060. /**
  93061. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93062. * @returns The JSON representation of the texture
  93063. */
  93064. serialize(): any;
  93065. /**
  93066. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93067. */
  93068. disposeFramebufferObjects(): void;
  93069. /**
  93070. * Dispose the texture and release its associated resources.
  93071. */
  93072. dispose(): void;
  93073. /** @hidden */
  93074. _rebuild(): void;
  93075. /**
  93076. * Clear the info related to rendering groups preventing retention point in material dispose.
  93077. */
  93078. freeRenderingGroups(): void;
  93079. /**
  93080. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93081. * @returns the view count
  93082. */
  93083. getViewCount(): number;
  93084. }
  93085. }
  93086. declare module BABYLON {
  93087. /**
  93088. * Options for compiling materials.
  93089. */
  93090. export interface IMaterialCompilationOptions {
  93091. /**
  93092. * Defines whether clip planes are enabled.
  93093. */
  93094. clipPlane: boolean;
  93095. /**
  93096. * Defines whether instances are enabled.
  93097. */
  93098. useInstances: boolean;
  93099. }
  93100. /**
  93101. * Base class for the main features of a material in Babylon.js
  93102. */
  93103. export class Material implements IAnimatable {
  93104. /**
  93105. * Returns the triangle fill mode
  93106. */
  93107. static readonly TriangleFillMode: number;
  93108. /**
  93109. * Returns the wireframe mode
  93110. */
  93111. static readonly WireFrameFillMode: number;
  93112. /**
  93113. * Returns the point fill mode
  93114. */
  93115. static readonly PointFillMode: number;
  93116. /**
  93117. * Returns the point list draw mode
  93118. */
  93119. static readonly PointListDrawMode: number;
  93120. /**
  93121. * Returns the line list draw mode
  93122. */
  93123. static readonly LineListDrawMode: number;
  93124. /**
  93125. * Returns the line loop draw mode
  93126. */
  93127. static readonly LineLoopDrawMode: number;
  93128. /**
  93129. * Returns the line strip draw mode
  93130. */
  93131. static readonly LineStripDrawMode: number;
  93132. /**
  93133. * Returns the triangle strip draw mode
  93134. */
  93135. static readonly TriangleStripDrawMode: number;
  93136. /**
  93137. * Returns the triangle fan draw mode
  93138. */
  93139. static readonly TriangleFanDrawMode: number;
  93140. /**
  93141. * Stores the clock-wise side orientation
  93142. */
  93143. static readonly ClockWiseSideOrientation: number;
  93144. /**
  93145. * Stores the counter clock-wise side orientation
  93146. */
  93147. static readonly CounterClockWiseSideOrientation: number;
  93148. /**
  93149. * The dirty texture flag value
  93150. */
  93151. static readonly TextureDirtyFlag: number;
  93152. /**
  93153. * The dirty light flag value
  93154. */
  93155. static readonly LightDirtyFlag: number;
  93156. /**
  93157. * The dirty fresnel flag value
  93158. */
  93159. static readonly FresnelDirtyFlag: number;
  93160. /**
  93161. * The dirty attribute flag value
  93162. */
  93163. static readonly AttributesDirtyFlag: number;
  93164. /**
  93165. * The dirty misc flag value
  93166. */
  93167. static readonly MiscDirtyFlag: number;
  93168. /**
  93169. * The all dirty flag value
  93170. */
  93171. static readonly AllDirtyFlag: number;
  93172. /**
  93173. * The ID of the material
  93174. */
  93175. id: string;
  93176. /**
  93177. * Gets or sets the unique id of the material
  93178. */
  93179. uniqueId: number;
  93180. /**
  93181. * The name of the material
  93182. */
  93183. name: string;
  93184. /**
  93185. * Gets or sets user defined metadata
  93186. */
  93187. metadata: any;
  93188. /**
  93189. * For internal use only. Please do not use.
  93190. */
  93191. reservedDataStore: any;
  93192. /**
  93193. * Specifies if the ready state should be checked on each call
  93194. */
  93195. checkReadyOnEveryCall: boolean;
  93196. /**
  93197. * Specifies if the ready state should be checked once
  93198. */
  93199. checkReadyOnlyOnce: boolean;
  93200. /**
  93201. * The state of the material
  93202. */
  93203. state: string;
  93204. /**
  93205. * The alpha value of the material
  93206. */
  93207. protected _alpha: number;
  93208. /**
  93209. * List of inspectable custom properties (used by the Inspector)
  93210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93211. */
  93212. inspectableCustomProperties: IInspectable[];
  93213. /**
  93214. * Sets the alpha value of the material
  93215. */
  93216. set alpha(value: number);
  93217. /**
  93218. * Gets the alpha value of the material
  93219. */
  93220. get alpha(): number;
  93221. /**
  93222. * Specifies if back face culling is enabled
  93223. */
  93224. protected _backFaceCulling: boolean;
  93225. /**
  93226. * Sets the back-face culling state
  93227. */
  93228. set backFaceCulling(value: boolean);
  93229. /**
  93230. * Gets the back-face culling state
  93231. */
  93232. get backFaceCulling(): boolean;
  93233. /**
  93234. * Stores the value for side orientation
  93235. */
  93236. sideOrientation: number;
  93237. /**
  93238. * Callback triggered when the material is compiled
  93239. */
  93240. onCompiled: Nullable<(effect: Effect) => void>;
  93241. /**
  93242. * Callback triggered when an error occurs
  93243. */
  93244. onError: Nullable<(effect: Effect, errors: string) => void>;
  93245. /**
  93246. * Callback triggered to get the render target textures
  93247. */
  93248. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  93249. /**
  93250. * Gets a boolean indicating that current material needs to register RTT
  93251. */
  93252. get hasRenderTargetTextures(): boolean;
  93253. /**
  93254. * Specifies if the material should be serialized
  93255. */
  93256. doNotSerialize: boolean;
  93257. /**
  93258. * @hidden
  93259. */
  93260. _storeEffectOnSubMeshes: boolean;
  93261. /**
  93262. * Stores the animations for the material
  93263. */
  93264. animations: Nullable<Array<Animation>>;
  93265. /**
  93266. * An event triggered when the material is disposed
  93267. */
  93268. onDisposeObservable: Observable<Material>;
  93269. /**
  93270. * An observer which watches for dispose events
  93271. */
  93272. private _onDisposeObserver;
  93273. private _onUnBindObservable;
  93274. /**
  93275. * Called during a dispose event
  93276. */
  93277. set onDispose(callback: () => void);
  93278. private _onBindObservable;
  93279. /**
  93280. * An event triggered when the material is bound
  93281. */
  93282. get onBindObservable(): Observable<AbstractMesh>;
  93283. /**
  93284. * An observer which watches for bind events
  93285. */
  93286. private _onBindObserver;
  93287. /**
  93288. * Called during a bind event
  93289. */
  93290. set onBind(callback: (Mesh: AbstractMesh) => void);
  93291. /**
  93292. * An event triggered when the material is unbound
  93293. */
  93294. get onUnBindObservable(): Observable<Material>;
  93295. /**
  93296. * Stores the value of the alpha mode
  93297. */
  93298. private _alphaMode;
  93299. /**
  93300. * Sets the value of the alpha mode.
  93301. *
  93302. * | Value | Type | Description |
  93303. * | --- | --- | --- |
  93304. * | 0 | ALPHA_DISABLE | |
  93305. * | 1 | ALPHA_ADD | |
  93306. * | 2 | ALPHA_COMBINE | |
  93307. * | 3 | ALPHA_SUBTRACT | |
  93308. * | 4 | ALPHA_MULTIPLY | |
  93309. * | 5 | ALPHA_MAXIMIZED | |
  93310. * | 6 | ALPHA_ONEONE | |
  93311. * | 7 | ALPHA_PREMULTIPLIED | |
  93312. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  93313. * | 9 | ALPHA_INTERPOLATE | |
  93314. * | 10 | ALPHA_SCREENMODE | |
  93315. *
  93316. */
  93317. set alphaMode(value: number);
  93318. /**
  93319. * Gets the value of the alpha mode
  93320. */
  93321. get alphaMode(): number;
  93322. /**
  93323. * Stores the state of the need depth pre-pass value
  93324. */
  93325. private _needDepthPrePass;
  93326. /**
  93327. * Sets the need depth pre-pass value
  93328. */
  93329. set needDepthPrePass(value: boolean);
  93330. /**
  93331. * Gets the depth pre-pass value
  93332. */
  93333. get needDepthPrePass(): boolean;
  93334. /**
  93335. * Specifies if depth writing should be disabled
  93336. */
  93337. disableDepthWrite: boolean;
  93338. /**
  93339. * Specifies if depth writing should be forced
  93340. */
  93341. forceDepthWrite: boolean;
  93342. /**
  93343. * Specifies the depth function that should be used. 0 means the default engine function
  93344. */
  93345. depthFunction: number;
  93346. /**
  93347. * Specifies if there should be a separate pass for culling
  93348. */
  93349. separateCullingPass: boolean;
  93350. /**
  93351. * Stores the state specifing if fog should be enabled
  93352. */
  93353. private _fogEnabled;
  93354. /**
  93355. * Sets the state for enabling fog
  93356. */
  93357. set fogEnabled(value: boolean);
  93358. /**
  93359. * Gets the value of the fog enabled state
  93360. */
  93361. get fogEnabled(): boolean;
  93362. /**
  93363. * Stores the size of points
  93364. */
  93365. pointSize: number;
  93366. /**
  93367. * Stores the z offset value
  93368. */
  93369. zOffset: number;
  93370. /**
  93371. * Gets a value specifying if wireframe mode is enabled
  93372. */
  93373. get wireframe(): boolean;
  93374. /**
  93375. * Sets the state of wireframe mode
  93376. */
  93377. set wireframe(value: boolean);
  93378. /**
  93379. * Gets the value specifying if point clouds are enabled
  93380. */
  93381. get pointsCloud(): boolean;
  93382. /**
  93383. * Sets the state of point cloud mode
  93384. */
  93385. set pointsCloud(value: boolean);
  93386. /**
  93387. * Gets the material fill mode
  93388. */
  93389. get fillMode(): number;
  93390. /**
  93391. * Sets the material fill mode
  93392. */
  93393. set fillMode(value: number);
  93394. /**
  93395. * @hidden
  93396. * Stores the effects for the material
  93397. */
  93398. _effect: Nullable<Effect>;
  93399. /**
  93400. * Specifies if uniform buffers should be used
  93401. */
  93402. private _useUBO;
  93403. /**
  93404. * Stores a reference to the scene
  93405. */
  93406. private _scene;
  93407. /**
  93408. * Stores the fill mode state
  93409. */
  93410. private _fillMode;
  93411. /**
  93412. * Specifies if the depth write state should be cached
  93413. */
  93414. private _cachedDepthWriteState;
  93415. /**
  93416. * Specifies if the depth function state should be cached
  93417. */
  93418. private _cachedDepthFunctionState;
  93419. /**
  93420. * Stores the uniform buffer
  93421. */
  93422. protected _uniformBuffer: UniformBuffer;
  93423. /** @hidden */
  93424. _indexInSceneMaterialArray: number;
  93425. /** @hidden */
  93426. meshMap: Nullable<{
  93427. [id: string]: AbstractMesh | undefined;
  93428. }>;
  93429. /**
  93430. * Creates a material instance
  93431. * @param name defines the name of the material
  93432. * @param scene defines the scene to reference
  93433. * @param doNotAdd specifies if the material should be added to the scene
  93434. */
  93435. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  93436. /**
  93437. * Returns a string representation of the current material
  93438. * @param fullDetails defines a boolean indicating which levels of logging is desired
  93439. * @returns a string with material information
  93440. */
  93441. toString(fullDetails?: boolean): string;
  93442. /**
  93443. * Gets the class name of the material
  93444. * @returns a string with the class name of the material
  93445. */
  93446. getClassName(): string;
  93447. /**
  93448. * Specifies if updates for the material been locked
  93449. */
  93450. get isFrozen(): boolean;
  93451. /**
  93452. * Locks updates for the material
  93453. */
  93454. freeze(): void;
  93455. /**
  93456. * Unlocks updates for the material
  93457. */
  93458. unfreeze(): void;
  93459. /**
  93460. * Specifies if the material is ready to be used
  93461. * @param mesh defines the mesh to check
  93462. * @param useInstances specifies if instances should be used
  93463. * @returns a boolean indicating if the material is ready to be used
  93464. */
  93465. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93466. /**
  93467. * Specifies that the submesh is ready to be used
  93468. * @param mesh defines the mesh to check
  93469. * @param subMesh defines which submesh to check
  93470. * @param useInstances specifies that instances should be used
  93471. * @returns a boolean indicating that the submesh is ready or not
  93472. */
  93473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93474. /**
  93475. * Returns the material effect
  93476. * @returns the effect associated with the material
  93477. */
  93478. getEffect(): Nullable<Effect>;
  93479. /**
  93480. * Returns the current scene
  93481. * @returns a Scene
  93482. */
  93483. getScene(): Scene;
  93484. /**
  93485. * Specifies if the material will require alpha blending
  93486. * @returns a boolean specifying if alpha blending is needed
  93487. */
  93488. needAlphaBlending(): boolean;
  93489. /**
  93490. * Specifies if the mesh will require alpha blending
  93491. * @param mesh defines the mesh to check
  93492. * @returns a boolean specifying if alpha blending is needed for the mesh
  93493. */
  93494. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  93495. /**
  93496. * Specifies if this material should be rendered in alpha test mode
  93497. * @returns a boolean specifying if an alpha test is needed.
  93498. */
  93499. needAlphaTesting(): boolean;
  93500. /**
  93501. * Gets the texture used for the alpha test
  93502. * @returns the texture to use for alpha testing
  93503. */
  93504. getAlphaTestTexture(): Nullable<BaseTexture>;
  93505. /**
  93506. * Marks the material to indicate that it needs to be re-calculated
  93507. */
  93508. markDirty(): void;
  93509. /** @hidden */
  93510. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  93511. /**
  93512. * Binds the material to the mesh
  93513. * @param world defines the world transformation matrix
  93514. * @param mesh defines the mesh to bind the material to
  93515. */
  93516. bind(world: Matrix, mesh?: Mesh): void;
  93517. /**
  93518. * Binds the submesh to the material
  93519. * @param world defines the world transformation matrix
  93520. * @param mesh defines the mesh containing the submesh
  93521. * @param subMesh defines the submesh to bind the material to
  93522. */
  93523. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93524. /**
  93525. * Binds the world matrix to the material
  93526. * @param world defines the world transformation matrix
  93527. */
  93528. bindOnlyWorldMatrix(world: Matrix): void;
  93529. /**
  93530. * Binds the scene's uniform buffer to the effect.
  93531. * @param effect defines the effect to bind to the scene uniform buffer
  93532. * @param sceneUbo defines the uniform buffer storing scene data
  93533. */
  93534. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  93535. /**
  93536. * Binds the view matrix to the effect
  93537. * @param effect defines the effect to bind the view matrix to
  93538. */
  93539. bindView(effect: Effect): void;
  93540. /**
  93541. * Binds the view projection matrix to the effect
  93542. * @param effect defines the effect to bind the view projection matrix to
  93543. */
  93544. bindViewProjection(effect: Effect): void;
  93545. /**
  93546. * Specifies if material alpha testing should be turned on for the mesh
  93547. * @param mesh defines the mesh to check
  93548. */
  93549. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  93550. /**
  93551. * Processes to execute after binding the material to a mesh
  93552. * @param mesh defines the rendered mesh
  93553. */
  93554. protected _afterBind(mesh?: Mesh): void;
  93555. /**
  93556. * Unbinds the material from the mesh
  93557. */
  93558. unbind(): void;
  93559. /**
  93560. * Gets the active textures from the material
  93561. * @returns an array of textures
  93562. */
  93563. getActiveTextures(): BaseTexture[];
  93564. /**
  93565. * Specifies if the material uses a texture
  93566. * @param texture defines the texture to check against the material
  93567. * @returns a boolean specifying if the material uses the texture
  93568. */
  93569. hasTexture(texture: BaseTexture): boolean;
  93570. /**
  93571. * Makes a duplicate of the material, and gives it a new name
  93572. * @param name defines the new name for the duplicated material
  93573. * @returns the cloned material
  93574. */
  93575. clone(name: string): Nullable<Material>;
  93576. /**
  93577. * Gets the meshes bound to the material
  93578. * @returns an array of meshes bound to the material
  93579. */
  93580. getBindedMeshes(): AbstractMesh[];
  93581. /**
  93582. * Force shader compilation
  93583. * @param mesh defines the mesh associated with this material
  93584. * @param onCompiled defines a function to execute once the material is compiled
  93585. * @param options defines the options to configure the compilation
  93586. * @param onError defines a function to execute if the material fails compiling
  93587. */
  93588. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  93589. /**
  93590. * Force shader compilation
  93591. * @param mesh defines the mesh that will use this material
  93592. * @param options defines additional options for compiling the shaders
  93593. * @returns a promise that resolves when the compilation completes
  93594. */
  93595. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  93596. private static readonly _AllDirtyCallBack;
  93597. private static readonly _ImageProcessingDirtyCallBack;
  93598. private static readonly _TextureDirtyCallBack;
  93599. private static readonly _FresnelDirtyCallBack;
  93600. private static readonly _MiscDirtyCallBack;
  93601. private static readonly _LightsDirtyCallBack;
  93602. private static readonly _AttributeDirtyCallBack;
  93603. private static _FresnelAndMiscDirtyCallBack;
  93604. private static _TextureAndMiscDirtyCallBack;
  93605. private static readonly _DirtyCallbackArray;
  93606. private static readonly _RunDirtyCallBacks;
  93607. /**
  93608. * Marks a define in the material to indicate that it needs to be re-computed
  93609. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  93610. */
  93611. markAsDirty(flag: number): void;
  93612. /**
  93613. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  93614. * @param func defines a function which checks material defines against the submeshes
  93615. */
  93616. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  93617. /**
  93618. * Indicates that we need to re-calculated for all submeshes
  93619. */
  93620. protected _markAllSubMeshesAsAllDirty(): void;
  93621. /**
  93622. * Indicates that image processing needs to be re-calculated for all submeshes
  93623. */
  93624. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  93625. /**
  93626. * Indicates that textures need to be re-calculated for all submeshes
  93627. */
  93628. protected _markAllSubMeshesAsTexturesDirty(): void;
  93629. /**
  93630. * Indicates that fresnel needs to be re-calculated for all submeshes
  93631. */
  93632. protected _markAllSubMeshesAsFresnelDirty(): void;
  93633. /**
  93634. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  93635. */
  93636. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  93637. /**
  93638. * Indicates that lights need to be re-calculated for all submeshes
  93639. */
  93640. protected _markAllSubMeshesAsLightsDirty(): void;
  93641. /**
  93642. * Indicates that attributes need to be re-calculated for all submeshes
  93643. */
  93644. protected _markAllSubMeshesAsAttributesDirty(): void;
  93645. /**
  93646. * Indicates that misc needs to be re-calculated for all submeshes
  93647. */
  93648. protected _markAllSubMeshesAsMiscDirty(): void;
  93649. /**
  93650. * Indicates that textures and misc need to be re-calculated for all submeshes
  93651. */
  93652. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  93653. /**
  93654. * Disposes the material
  93655. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  93656. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  93657. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  93658. */
  93659. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  93660. /** @hidden */
  93661. private releaseVertexArrayObject;
  93662. /**
  93663. * Serializes this material
  93664. * @returns the serialized material object
  93665. */
  93666. serialize(): any;
  93667. /**
  93668. * Creates a material from parsed material data
  93669. * @param parsedMaterial defines parsed material data
  93670. * @param scene defines the hosting scene
  93671. * @param rootUrl defines the root URL to use to load textures
  93672. * @returns a new material
  93673. */
  93674. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  93675. }
  93676. }
  93677. declare module BABYLON {
  93678. /**
  93679. * A multi-material is used to apply different materials to different parts of the same object without the need of
  93680. * separate meshes. This can be use to improve performances.
  93681. * @see http://doc.babylonjs.com/how_to/multi_materials
  93682. */
  93683. export class MultiMaterial extends Material {
  93684. private _subMaterials;
  93685. /**
  93686. * Gets or Sets the list of Materials used within the multi material.
  93687. * They need to be ordered according to the submeshes order in the associated mesh
  93688. */
  93689. get subMaterials(): Nullable<Material>[];
  93690. set subMaterials(value: Nullable<Material>[]);
  93691. /**
  93692. * Function used to align with Node.getChildren()
  93693. * @returns the list of Materials used within the multi material
  93694. */
  93695. getChildren(): Nullable<Material>[];
  93696. /**
  93697. * Instantiates a new Multi Material
  93698. * A multi-material is used to apply different materials to different parts of the same object without the need of
  93699. * separate meshes. This can be use to improve performances.
  93700. * @see http://doc.babylonjs.com/how_to/multi_materials
  93701. * @param name Define the name in the scene
  93702. * @param scene Define the scene the material belongs to
  93703. */
  93704. constructor(name: string, scene: Scene);
  93705. private _hookArray;
  93706. /**
  93707. * Get one of the submaterial by its index in the submaterials array
  93708. * @param index The index to look the sub material at
  93709. * @returns The Material if the index has been defined
  93710. */
  93711. getSubMaterial(index: number): Nullable<Material>;
  93712. /**
  93713. * Get the list of active textures for the whole sub materials list.
  93714. * @returns All the textures that will be used during the rendering
  93715. */
  93716. getActiveTextures(): BaseTexture[];
  93717. /**
  93718. * Gets the current class name of the material e.g. "MultiMaterial"
  93719. * Mainly use in serialization.
  93720. * @returns the class name
  93721. */
  93722. getClassName(): string;
  93723. /**
  93724. * Checks if the material is ready to render the requested sub mesh
  93725. * @param mesh Define the mesh the submesh belongs to
  93726. * @param subMesh Define the sub mesh to look readyness for
  93727. * @param useInstances Define whether or not the material is used with instances
  93728. * @returns true if ready, otherwise false
  93729. */
  93730. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93731. /**
  93732. * Clones the current material and its related sub materials
  93733. * @param name Define the name of the newly cloned material
  93734. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  93735. * @returns the cloned material
  93736. */
  93737. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  93738. /**
  93739. * Serializes the materials into a JSON representation.
  93740. * @returns the JSON representation
  93741. */
  93742. serialize(): any;
  93743. /**
  93744. * Dispose the material and release its associated resources
  93745. * @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)
  93746. * @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)
  93747. * @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)
  93748. */
  93749. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  93750. /**
  93751. * Creates a MultiMaterial from parsed MultiMaterial data.
  93752. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  93753. * @param scene defines the hosting scene
  93754. * @returns a new MultiMaterial
  93755. */
  93756. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  93757. }
  93758. }
  93759. declare module BABYLON {
  93760. /**
  93761. * Base class for submeshes
  93762. */
  93763. export class BaseSubMesh {
  93764. /** @hidden */
  93765. _materialDefines: Nullable<MaterialDefines>;
  93766. /** @hidden */
  93767. _materialEffect: Nullable<Effect>;
  93768. /**
  93769. * Gets material defines used by the effect associated to the sub mesh
  93770. */
  93771. get materialDefines(): Nullable<MaterialDefines>;
  93772. /**
  93773. * Sets material defines used by the effect associated to the sub mesh
  93774. */
  93775. set materialDefines(defines: Nullable<MaterialDefines>);
  93776. /**
  93777. * Gets associated effect
  93778. */
  93779. get effect(): Nullable<Effect>;
  93780. /**
  93781. * Sets associated effect (effect used to render this submesh)
  93782. * @param effect defines the effect to associate with
  93783. * @param defines defines the set of defines used to compile this effect
  93784. */
  93785. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  93786. }
  93787. /**
  93788. * Defines a subdivision inside a mesh
  93789. */
  93790. export class SubMesh extends BaseSubMesh implements ICullable {
  93791. /** the material index to use */
  93792. materialIndex: number;
  93793. /** vertex index start */
  93794. verticesStart: number;
  93795. /** vertices count */
  93796. verticesCount: number;
  93797. /** index start */
  93798. indexStart: number;
  93799. /** indices count */
  93800. indexCount: number;
  93801. /** @hidden */
  93802. _linesIndexCount: number;
  93803. private _mesh;
  93804. private _renderingMesh;
  93805. private _boundingInfo;
  93806. private _linesIndexBuffer;
  93807. /** @hidden */
  93808. _lastColliderWorldVertices: Nullable<Vector3[]>;
  93809. /** @hidden */
  93810. _trianglePlanes: Plane[];
  93811. /** @hidden */
  93812. _lastColliderTransformMatrix: Nullable<Matrix>;
  93813. /** @hidden */
  93814. _renderId: number;
  93815. /** @hidden */
  93816. _alphaIndex: number;
  93817. /** @hidden */
  93818. _distanceToCamera: number;
  93819. /** @hidden */
  93820. _id: number;
  93821. private _currentMaterial;
  93822. /**
  93823. * Add a new submesh to a mesh
  93824. * @param materialIndex defines the material index to use
  93825. * @param verticesStart defines vertex index start
  93826. * @param verticesCount defines vertices count
  93827. * @param indexStart defines index start
  93828. * @param indexCount defines indices count
  93829. * @param mesh defines the parent mesh
  93830. * @param renderingMesh defines an optional rendering mesh
  93831. * @param createBoundingBox defines if bounding box should be created for this submesh
  93832. * @returns the new submesh
  93833. */
  93834. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  93835. /**
  93836. * Creates a new submesh
  93837. * @param materialIndex defines the material index to use
  93838. * @param verticesStart defines vertex index start
  93839. * @param verticesCount defines vertices count
  93840. * @param indexStart defines index start
  93841. * @param indexCount defines indices count
  93842. * @param mesh defines the parent mesh
  93843. * @param renderingMesh defines an optional rendering mesh
  93844. * @param createBoundingBox defines if bounding box should be created for this submesh
  93845. */
  93846. constructor(
  93847. /** the material index to use */
  93848. materialIndex: number,
  93849. /** vertex index start */
  93850. verticesStart: number,
  93851. /** vertices count */
  93852. verticesCount: number,
  93853. /** index start */
  93854. indexStart: number,
  93855. /** indices count */
  93856. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  93857. /**
  93858. * Returns true if this submesh covers the entire parent mesh
  93859. * @ignorenaming
  93860. */
  93861. get IsGlobal(): boolean;
  93862. /**
  93863. * Returns the submesh BoudingInfo object
  93864. * @returns current bounding info (or mesh's one if the submesh is global)
  93865. */
  93866. getBoundingInfo(): BoundingInfo;
  93867. /**
  93868. * Sets the submesh BoundingInfo
  93869. * @param boundingInfo defines the new bounding info to use
  93870. * @returns the SubMesh
  93871. */
  93872. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  93873. /**
  93874. * Returns the mesh of the current submesh
  93875. * @return the parent mesh
  93876. */
  93877. getMesh(): AbstractMesh;
  93878. /**
  93879. * Returns the rendering mesh of the submesh
  93880. * @returns the rendering mesh (could be different from parent mesh)
  93881. */
  93882. getRenderingMesh(): Mesh;
  93883. /**
  93884. * Returns the submesh material
  93885. * @returns null or the current material
  93886. */
  93887. getMaterial(): Nullable<Material>;
  93888. /**
  93889. * Sets a new updated BoundingInfo object to the submesh
  93890. * @param data defines an optional position array to use to determine the bounding info
  93891. * @returns the SubMesh
  93892. */
  93893. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  93894. /** @hidden */
  93895. _checkCollision(collider: Collider): boolean;
  93896. /**
  93897. * Updates the submesh BoundingInfo
  93898. * @param world defines the world matrix to use to update the bounding info
  93899. * @returns the submesh
  93900. */
  93901. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  93902. /**
  93903. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  93904. * @param frustumPlanes defines the frustum planes
  93905. * @returns true if the submesh is intersecting with the frustum
  93906. */
  93907. isInFrustum(frustumPlanes: Plane[]): boolean;
  93908. /**
  93909. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  93910. * @param frustumPlanes defines the frustum planes
  93911. * @returns true if the submesh is inside the frustum
  93912. */
  93913. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93914. /**
  93915. * Renders the submesh
  93916. * @param enableAlphaMode defines if alpha needs to be used
  93917. * @returns the submesh
  93918. */
  93919. render(enableAlphaMode: boolean): SubMesh;
  93920. /**
  93921. * @hidden
  93922. */
  93923. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  93924. /**
  93925. * Checks if the submesh intersects with a ray
  93926. * @param ray defines the ray to test
  93927. * @returns true is the passed ray intersects the submesh bounding box
  93928. */
  93929. canIntersects(ray: Ray): boolean;
  93930. /**
  93931. * Intersects current submesh with a ray
  93932. * @param ray defines the ray to test
  93933. * @param positions defines mesh's positions array
  93934. * @param indices defines mesh's indices array
  93935. * @param fastCheck defines if only bounding info should be used
  93936. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93937. * @returns intersection info or null if no intersection
  93938. */
  93939. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  93940. /** @hidden */
  93941. private _intersectLines;
  93942. /** @hidden */
  93943. private _intersectUnIndexedLines;
  93944. /** @hidden */
  93945. private _intersectTriangles;
  93946. /** @hidden */
  93947. private _intersectUnIndexedTriangles;
  93948. /** @hidden */
  93949. _rebuild(): void;
  93950. /**
  93951. * Creates a new submesh from the passed mesh
  93952. * @param newMesh defines the new hosting mesh
  93953. * @param newRenderingMesh defines an optional rendering mesh
  93954. * @returns the new submesh
  93955. */
  93956. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  93957. /**
  93958. * Release associated resources
  93959. */
  93960. dispose(): void;
  93961. /**
  93962. * Gets the class name
  93963. * @returns the string "SubMesh".
  93964. */
  93965. getClassName(): string;
  93966. /**
  93967. * Creates a new submesh from indices data
  93968. * @param materialIndex the index of the main mesh material
  93969. * @param startIndex the index where to start the copy in the mesh indices array
  93970. * @param indexCount the number of indices to copy then from the startIndex
  93971. * @param mesh the main mesh to create the submesh from
  93972. * @param renderingMesh the optional rendering mesh
  93973. * @returns a new submesh
  93974. */
  93975. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  93976. }
  93977. }
  93978. declare module BABYLON {
  93979. /**
  93980. * Class used to represent data loading progression
  93981. */
  93982. export class SceneLoaderFlags {
  93983. private static _ForceFullSceneLoadingForIncremental;
  93984. private static _ShowLoadingScreen;
  93985. private static _CleanBoneMatrixWeights;
  93986. private static _loggingLevel;
  93987. /**
  93988. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  93989. */
  93990. static get ForceFullSceneLoadingForIncremental(): boolean;
  93991. static set ForceFullSceneLoadingForIncremental(value: boolean);
  93992. /**
  93993. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  93994. */
  93995. static get ShowLoadingScreen(): boolean;
  93996. static set ShowLoadingScreen(value: boolean);
  93997. /**
  93998. * Defines the current logging level (while loading the scene)
  93999. * @ignorenaming
  94000. */
  94001. static get loggingLevel(): number;
  94002. static set loggingLevel(value: number);
  94003. /**
  94004. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94005. */
  94006. static get CleanBoneMatrixWeights(): boolean;
  94007. static set CleanBoneMatrixWeights(value: boolean);
  94008. }
  94009. }
  94010. declare module BABYLON {
  94011. /**
  94012. * Class used to store geometry data (vertex buffers + index buffer)
  94013. */
  94014. export class Geometry implements IGetSetVerticesData {
  94015. /**
  94016. * Gets or sets the ID of the geometry
  94017. */
  94018. id: string;
  94019. /**
  94020. * Gets or sets the unique ID of the geometry
  94021. */
  94022. uniqueId: number;
  94023. /**
  94024. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94025. */
  94026. delayLoadState: number;
  94027. /**
  94028. * Gets the file containing the data to load when running in delay load state
  94029. */
  94030. delayLoadingFile: Nullable<string>;
  94031. /**
  94032. * Callback called when the geometry is updated
  94033. */
  94034. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94035. private _scene;
  94036. private _engine;
  94037. private _meshes;
  94038. private _totalVertices;
  94039. /** @hidden */
  94040. _indices: IndicesArray;
  94041. /** @hidden */
  94042. _vertexBuffers: {
  94043. [key: string]: VertexBuffer;
  94044. };
  94045. private _isDisposed;
  94046. private _extend;
  94047. private _boundingBias;
  94048. /** @hidden */
  94049. _delayInfo: Array<string>;
  94050. private _indexBuffer;
  94051. private _indexBufferIsUpdatable;
  94052. /** @hidden */
  94053. _boundingInfo: Nullable<BoundingInfo>;
  94054. /** @hidden */
  94055. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94056. /** @hidden */
  94057. _softwareSkinningFrameId: number;
  94058. private _vertexArrayObjects;
  94059. private _updatable;
  94060. /** @hidden */
  94061. _positions: Nullable<Vector3[]>;
  94062. /**
  94063. * 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
  94064. */
  94065. get boundingBias(): Vector2;
  94066. /**
  94067. * 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
  94068. */
  94069. set boundingBias(value: Vector2);
  94070. /**
  94071. * Static function used to attach a new empty geometry to a mesh
  94072. * @param mesh defines the mesh to attach the geometry to
  94073. * @returns the new Geometry
  94074. */
  94075. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94076. /**
  94077. * Creates a new geometry
  94078. * @param id defines the unique ID
  94079. * @param scene defines the hosting scene
  94080. * @param vertexData defines the VertexData used to get geometry data
  94081. * @param updatable defines if geometry must be updatable (false by default)
  94082. * @param mesh defines the mesh that will be associated with the geometry
  94083. */
  94084. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94085. /**
  94086. * Gets the current extend of the geometry
  94087. */
  94088. get extend(): {
  94089. minimum: Vector3;
  94090. maximum: Vector3;
  94091. };
  94092. /**
  94093. * Gets the hosting scene
  94094. * @returns the hosting Scene
  94095. */
  94096. getScene(): Scene;
  94097. /**
  94098. * Gets the hosting engine
  94099. * @returns the hosting Engine
  94100. */
  94101. getEngine(): Engine;
  94102. /**
  94103. * Defines if the geometry is ready to use
  94104. * @returns true if the geometry is ready to be used
  94105. */
  94106. isReady(): boolean;
  94107. /**
  94108. * Gets a value indicating that the geometry should not be serialized
  94109. */
  94110. get doNotSerialize(): boolean;
  94111. /** @hidden */
  94112. _rebuild(): void;
  94113. /**
  94114. * Affects all geometry data in one call
  94115. * @param vertexData defines the geometry data
  94116. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94117. */
  94118. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94119. /**
  94120. * Set specific vertex data
  94121. * @param kind defines the data kind (Position, normal, etc...)
  94122. * @param data defines the vertex data to use
  94123. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94124. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94125. */
  94126. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  94127. /**
  94128. * Removes a specific vertex data
  94129. * @param kind defines the data kind (Position, normal, etc...)
  94130. */
  94131. removeVerticesData(kind: string): void;
  94132. /**
  94133. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  94134. * @param buffer defines the vertex buffer to use
  94135. * @param totalVertices defines the total number of vertices for position kind (could be null)
  94136. */
  94137. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  94138. /**
  94139. * Update a specific vertex buffer
  94140. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  94141. * It will do nothing if the buffer is not updatable
  94142. * @param kind defines the data kind (Position, normal, etc...)
  94143. * @param data defines the data to use
  94144. * @param offset defines the offset in the target buffer where to store the data
  94145. * @param useBytes set to true if the offset is in bytes
  94146. */
  94147. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  94148. /**
  94149. * Update a specific vertex buffer
  94150. * This function will create a new buffer if the current one is not updatable
  94151. * @param kind defines the data kind (Position, normal, etc...)
  94152. * @param data defines the data to use
  94153. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  94154. */
  94155. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  94156. private _updateBoundingInfo;
  94157. /** @hidden */
  94158. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  94159. /**
  94160. * Gets total number of vertices
  94161. * @returns the total number of vertices
  94162. */
  94163. getTotalVertices(): number;
  94164. /**
  94165. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94166. * @param kind defines the data kind (Position, normal, etc...)
  94167. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94168. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94169. * @returns a float array containing vertex data
  94170. */
  94171. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94172. /**
  94173. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  94174. * @param kind defines the data kind (Position, normal, etc...)
  94175. * @returns true if the vertex buffer with the specified kind is updatable
  94176. */
  94177. isVertexBufferUpdatable(kind: string): boolean;
  94178. /**
  94179. * Gets a specific vertex buffer
  94180. * @param kind defines the data kind (Position, normal, etc...)
  94181. * @returns a VertexBuffer
  94182. */
  94183. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94184. /**
  94185. * Returns all vertex buffers
  94186. * @return an object holding all vertex buffers indexed by kind
  94187. */
  94188. getVertexBuffers(): Nullable<{
  94189. [key: string]: VertexBuffer;
  94190. }>;
  94191. /**
  94192. * Gets a boolean indicating if specific vertex buffer is present
  94193. * @param kind defines the data kind (Position, normal, etc...)
  94194. * @returns true if data is present
  94195. */
  94196. isVerticesDataPresent(kind: string): boolean;
  94197. /**
  94198. * Gets a list of all attached data kinds (Position, normal, etc...)
  94199. * @returns a list of string containing all kinds
  94200. */
  94201. getVerticesDataKinds(): string[];
  94202. /**
  94203. * Update index buffer
  94204. * @param indices defines the indices to store in the index buffer
  94205. * @param offset defines the offset in the target buffer where to store the data
  94206. * @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)
  94207. */
  94208. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  94209. /**
  94210. * Creates a new index buffer
  94211. * @param indices defines the indices to store in the index buffer
  94212. * @param totalVertices defines the total number of vertices (could be null)
  94213. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94214. */
  94215. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  94216. /**
  94217. * Return the total number of indices
  94218. * @returns the total number of indices
  94219. */
  94220. getTotalIndices(): number;
  94221. /**
  94222. * Gets the index buffer array
  94223. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94224. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94225. * @returns the index buffer array
  94226. */
  94227. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94228. /**
  94229. * Gets the index buffer
  94230. * @return the index buffer
  94231. */
  94232. getIndexBuffer(): Nullable<DataBuffer>;
  94233. /** @hidden */
  94234. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  94235. /**
  94236. * Release the associated resources for a specific mesh
  94237. * @param mesh defines the source mesh
  94238. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  94239. */
  94240. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  94241. /**
  94242. * Apply current geometry to a given mesh
  94243. * @param mesh defines the mesh to apply geometry to
  94244. */
  94245. applyToMesh(mesh: Mesh): void;
  94246. private _updateExtend;
  94247. private _applyToMesh;
  94248. private notifyUpdate;
  94249. /**
  94250. * Load the geometry if it was flagged as delay loaded
  94251. * @param scene defines the hosting scene
  94252. * @param onLoaded defines a callback called when the geometry is loaded
  94253. */
  94254. load(scene: Scene, onLoaded?: () => void): void;
  94255. private _queueLoad;
  94256. /**
  94257. * Invert the geometry to move from a right handed system to a left handed one.
  94258. */
  94259. toLeftHanded(): void;
  94260. /** @hidden */
  94261. _resetPointsArrayCache(): void;
  94262. /** @hidden */
  94263. _generatePointsArray(): boolean;
  94264. /**
  94265. * Gets a value indicating if the geometry is disposed
  94266. * @returns true if the geometry was disposed
  94267. */
  94268. isDisposed(): boolean;
  94269. private _disposeVertexArrayObjects;
  94270. /**
  94271. * Free all associated resources
  94272. */
  94273. dispose(): void;
  94274. /**
  94275. * Clone the current geometry into a new geometry
  94276. * @param id defines the unique ID of the new geometry
  94277. * @returns a new geometry object
  94278. */
  94279. copy(id: string): Geometry;
  94280. /**
  94281. * Serialize the current geometry info (and not the vertices data) into a JSON object
  94282. * @return a JSON representation of the current geometry data (without the vertices data)
  94283. */
  94284. serialize(): any;
  94285. private toNumberArray;
  94286. /**
  94287. * Serialize all vertices data into a JSON oject
  94288. * @returns a JSON representation of the current geometry data
  94289. */
  94290. serializeVerticeData(): any;
  94291. /**
  94292. * Extracts a clone of a mesh geometry
  94293. * @param mesh defines the source mesh
  94294. * @param id defines the unique ID of the new geometry object
  94295. * @returns the new geometry object
  94296. */
  94297. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  94298. /**
  94299. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  94300. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94301. * Be aware Math.random() could cause collisions, but:
  94302. * "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"
  94303. * @returns a string containing a new GUID
  94304. */
  94305. static RandomId(): string;
  94306. /** @hidden */
  94307. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  94308. private static _CleanMatricesWeights;
  94309. /**
  94310. * Create a new geometry from persisted data (Using .babylon file format)
  94311. * @param parsedVertexData defines the persisted data
  94312. * @param scene defines the hosting scene
  94313. * @param rootUrl defines the root url to use to load assets (like delayed data)
  94314. * @returns the new geometry object
  94315. */
  94316. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  94317. }
  94318. }
  94319. declare module BABYLON {
  94320. /**
  94321. * Define an interface for all classes that will get and set the data on vertices
  94322. */
  94323. export interface IGetSetVerticesData {
  94324. /**
  94325. * Gets a boolean indicating if specific vertex data is present
  94326. * @param kind defines the vertex data kind to use
  94327. * @returns true is data kind is present
  94328. */
  94329. isVerticesDataPresent(kind: string): boolean;
  94330. /**
  94331. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94332. * @param kind defines the data kind (Position, normal, etc...)
  94333. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94334. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94335. * @returns a float array containing vertex data
  94336. */
  94337. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94338. /**
  94339. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94340. * @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.
  94341. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94342. * @returns the indices array or an empty array if the mesh has no geometry
  94343. */
  94344. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94345. /**
  94346. * Set specific vertex data
  94347. * @param kind defines the data kind (Position, normal, etc...)
  94348. * @param data defines the vertex data to use
  94349. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94350. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94351. */
  94352. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  94353. /**
  94354. * Update a specific associated vertex buffer
  94355. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94356. * - VertexBuffer.PositionKind
  94357. * - VertexBuffer.UVKind
  94358. * - VertexBuffer.UV2Kind
  94359. * - VertexBuffer.UV3Kind
  94360. * - VertexBuffer.UV4Kind
  94361. * - VertexBuffer.UV5Kind
  94362. * - VertexBuffer.UV6Kind
  94363. * - VertexBuffer.ColorKind
  94364. * - VertexBuffer.MatricesIndicesKind
  94365. * - VertexBuffer.MatricesIndicesExtraKind
  94366. * - VertexBuffer.MatricesWeightsKind
  94367. * - VertexBuffer.MatricesWeightsExtraKind
  94368. * @param data defines the data source
  94369. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  94370. * @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)
  94371. */
  94372. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  94373. /**
  94374. * Creates a new index buffer
  94375. * @param indices defines the indices to store in the index buffer
  94376. * @param totalVertices defines the total number of vertices (could be null)
  94377. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94378. */
  94379. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  94380. }
  94381. /**
  94382. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  94383. */
  94384. export class VertexData {
  94385. /**
  94386. * Mesh side orientation : usually the external or front surface
  94387. */
  94388. static readonly FRONTSIDE: number;
  94389. /**
  94390. * Mesh side orientation : usually the internal or back surface
  94391. */
  94392. static readonly BACKSIDE: number;
  94393. /**
  94394. * Mesh side orientation : both internal and external or front and back surfaces
  94395. */
  94396. static readonly DOUBLESIDE: number;
  94397. /**
  94398. * Mesh side orientation : by default, `FRONTSIDE`
  94399. */
  94400. static readonly DEFAULTSIDE: number;
  94401. /**
  94402. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  94403. */
  94404. positions: Nullable<FloatArray>;
  94405. /**
  94406. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  94407. */
  94408. normals: Nullable<FloatArray>;
  94409. /**
  94410. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  94411. */
  94412. tangents: Nullable<FloatArray>;
  94413. /**
  94414. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94415. */
  94416. uvs: Nullable<FloatArray>;
  94417. /**
  94418. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94419. */
  94420. uvs2: Nullable<FloatArray>;
  94421. /**
  94422. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94423. */
  94424. uvs3: Nullable<FloatArray>;
  94425. /**
  94426. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94427. */
  94428. uvs4: Nullable<FloatArray>;
  94429. /**
  94430. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94431. */
  94432. uvs5: Nullable<FloatArray>;
  94433. /**
  94434. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94435. */
  94436. uvs6: Nullable<FloatArray>;
  94437. /**
  94438. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  94439. */
  94440. colors: Nullable<FloatArray>;
  94441. /**
  94442. * 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).
  94443. */
  94444. matricesIndices: Nullable<FloatArray>;
  94445. /**
  94446. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  94447. */
  94448. matricesWeights: Nullable<FloatArray>;
  94449. /**
  94450. * An array extending the number of possible indices
  94451. */
  94452. matricesIndicesExtra: Nullable<FloatArray>;
  94453. /**
  94454. * An array extending the number of possible weights when the number of indices is extended
  94455. */
  94456. matricesWeightsExtra: Nullable<FloatArray>;
  94457. /**
  94458. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  94459. */
  94460. indices: Nullable<IndicesArray>;
  94461. /**
  94462. * Uses the passed data array to set the set the values for the specified kind of data
  94463. * @param data a linear array of floating numbers
  94464. * @param kind the type of data that is being set, eg positions, colors etc
  94465. */
  94466. set(data: FloatArray, kind: string): void;
  94467. /**
  94468. * Associates the vertexData to the passed Mesh.
  94469. * Sets it as updatable or not (default `false`)
  94470. * @param mesh the mesh the vertexData is applied to
  94471. * @param updatable when used and having the value true allows new data to update the vertexData
  94472. * @returns the VertexData
  94473. */
  94474. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  94475. /**
  94476. * Associates the vertexData to the passed Geometry.
  94477. * Sets it as updatable or not (default `false`)
  94478. * @param geometry the geometry the vertexData is applied to
  94479. * @param updatable when used and having the value true allows new data to update the vertexData
  94480. * @returns VertexData
  94481. */
  94482. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  94483. /**
  94484. * Updates the associated mesh
  94485. * @param mesh the mesh to be updated
  94486. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94487. * @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
  94488. * @returns VertexData
  94489. */
  94490. updateMesh(mesh: Mesh): VertexData;
  94491. /**
  94492. * Updates the associated geometry
  94493. * @param geometry the geometry to be updated
  94494. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94495. * @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
  94496. * @returns VertexData.
  94497. */
  94498. updateGeometry(geometry: Geometry): VertexData;
  94499. private _applyTo;
  94500. private _update;
  94501. /**
  94502. * Transforms each position and each normal of the vertexData according to the passed Matrix
  94503. * @param matrix the transforming matrix
  94504. * @returns the VertexData
  94505. */
  94506. transform(matrix: Matrix): VertexData;
  94507. /**
  94508. * Merges the passed VertexData into the current one
  94509. * @param other the VertexData to be merged into the current one
  94510. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  94511. * @returns the modified VertexData
  94512. */
  94513. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  94514. private _mergeElement;
  94515. private _validate;
  94516. /**
  94517. * Serializes the VertexData
  94518. * @returns a serialized object
  94519. */
  94520. serialize(): any;
  94521. /**
  94522. * Extracts the vertexData from a mesh
  94523. * @param mesh the mesh from which to extract the VertexData
  94524. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  94525. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94526. * @returns the object VertexData associated to the passed mesh
  94527. */
  94528. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94529. /**
  94530. * Extracts the vertexData from the geometry
  94531. * @param geometry the geometry from which to extract the VertexData
  94532. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  94533. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94534. * @returns the object VertexData associated to the passed mesh
  94535. */
  94536. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94537. private static _ExtractFrom;
  94538. /**
  94539. * Creates the VertexData for a Ribbon
  94540. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  94541. * * pathArray array of paths, each of which an array of successive Vector3
  94542. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  94543. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  94544. * * 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
  94545. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94546. * * 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)
  94547. * * 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)
  94548. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  94549. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  94550. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  94551. * @returns the VertexData of the ribbon
  94552. */
  94553. static CreateRibbon(options: {
  94554. pathArray: Vector3[][];
  94555. closeArray?: boolean;
  94556. closePath?: boolean;
  94557. offset?: number;
  94558. sideOrientation?: number;
  94559. frontUVs?: Vector4;
  94560. backUVs?: Vector4;
  94561. invertUV?: boolean;
  94562. uvs?: Vector2[];
  94563. colors?: Color4[];
  94564. }): VertexData;
  94565. /**
  94566. * Creates the VertexData for a box
  94567. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94568. * * size sets the width, height and depth of the box to the value of size, optional default 1
  94569. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  94570. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  94571. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  94572. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  94573. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  94574. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94575. * * 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)
  94576. * * 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)
  94577. * @returns the VertexData of the box
  94578. */
  94579. static CreateBox(options: {
  94580. size?: number;
  94581. width?: number;
  94582. height?: number;
  94583. depth?: number;
  94584. faceUV?: Vector4[];
  94585. faceColors?: Color4[];
  94586. sideOrientation?: number;
  94587. frontUVs?: Vector4;
  94588. backUVs?: Vector4;
  94589. }): VertexData;
  94590. /**
  94591. * Creates the VertexData for a tiled box
  94592. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94593. * * faceTiles sets the pattern, tile size and number of tiles for a face
  94594. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  94595. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  94596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94597. * @returns the VertexData of the box
  94598. */
  94599. static CreateTiledBox(options: {
  94600. pattern?: number;
  94601. width?: number;
  94602. height?: number;
  94603. depth?: number;
  94604. tileSize?: number;
  94605. tileWidth?: number;
  94606. tileHeight?: number;
  94607. alignHorizontal?: number;
  94608. alignVertical?: number;
  94609. faceUV?: Vector4[];
  94610. faceColors?: Color4[];
  94611. sideOrientation?: number;
  94612. }): VertexData;
  94613. /**
  94614. * Creates the VertexData for a tiled plane
  94615. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94616. * * pattern a limited pattern arrangement depending on the number
  94617. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  94618. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  94619. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  94620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94621. * * 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)
  94622. * * 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)
  94623. * @returns the VertexData of the tiled plane
  94624. */
  94625. static CreateTiledPlane(options: {
  94626. pattern?: number;
  94627. tileSize?: number;
  94628. tileWidth?: number;
  94629. tileHeight?: number;
  94630. size?: number;
  94631. width?: number;
  94632. height?: number;
  94633. alignHorizontal?: number;
  94634. alignVertical?: number;
  94635. sideOrientation?: number;
  94636. frontUVs?: Vector4;
  94637. backUVs?: Vector4;
  94638. }): VertexData;
  94639. /**
  94640. * Creates the VertexData for an ellipsoid, defaults to a sphere
  94641. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94642. * * segments sets the number of horizontal strips optional, default 32
  94643. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  94644. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  94645. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  94646. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  94647. * * 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
  94648. * * 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
  94649. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94650. * * 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)
  94651. * * 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)
  94652. * @returns the VertexData of the ellipsoid
  94653. */
  94654. static CreateSphere(options: {
  94655. segments?: number;
  94656. diameter?: number;
  94657. diameterX?: number;
  94658. diameterY?: number;
  94659. diameterZ?: number;
  94660. arc?: number;
  94661. slice?: number;
  94662. sideOrientation?: number;
  94663. frontUVs?: Vector4;
  94664. backUVs?: Vector4;
  94665. }): VertexData;
  94666. /**
  94667. * Creates the VertexData for a cylinder, cone or prism
  94668. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94669. * * height sets the height (y direction) of the cylinder, optional, default 2
  94670. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  94671. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  94672. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  94673. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  94674. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  94675. * * 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
  94676. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94677. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94678. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  94679. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  94680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94681. * * 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)
  94682. * * 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)
  94683. * @returns the VertexData of the cylinder, cone or prism
  94684. */
  94685. static CreateCylinder(options: {
  94686. height?: number;
  94687. diameterTop?: number;
  94688. diameterBottom?: number;
  94689. diameter?: number;
  94690. tessellation?: number;
  94691. subdivisions?: number;
  94692. arc?: number;
  94693. faceColors?: Color4[];
  94694. faceUV?: Vector4[];
  94695. hasRings?: boolean;
  94696. enclose?: boolean;
  94697. sideOrientation?: number;
  94698. frontUVs?: Vector4;
  94699. backUVs?: Vector4;
  94700. }): VertexData;
  94701. /**
  94702. * Creates the VertexData for a torus
  94703. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94704. * * diameter the diameter of the torus, optional default 1
  94705. * * thickness the diameter of the tube forming the torus, optional default 0.5
  94706. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  94707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94708. * * 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)
  94709. * * 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)
  94710. * @returns the VertexData of the torus
  94711. */
  94712. static CreateTorus(options: {
  94713. diameter?: number;
  94714. thickness?: number;
  94715. tessellation?: number;
  94716. sideOrientation?: number;
  94717. frontUVs?: Vector4;
  94718. backUVs?: Vector4;
  94719. }): VertexData;
  94720. /**
  94721. * Creates the VertexData of the LineSystem
  94722. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  94723. * - lines an array of lines, each line being an array of successive Vector3
  94724. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  94725. * @returns the VertexData of the LineSystem
  94726. */
  94727. static CreateLineSystem(options: {
  94728. lines: Vector3[][];
  94729. colors?: Nullable<Color4[][]>;
  94730. }): VertexData;
  94731. /**
  94732. * Create the VertexData for a DashedLines
  94733. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  94734. * - points an array successive Vector3
  94735. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  94736. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  94737. * - dashNb the intended total number of dashes, optional, default 200
  94738. * @returns the VertexData for the DashedLines
  94739. */
  94740. static CreateDashedLines(options: {
  94741. points: Vector3[];
  94742. dashSize?: number;
  94743. gapSize?: number;
  94744. dashNb?: number;
  94745. }): VertexData;
  94746. /**
  94747. * Creates the VertexData for a Ground
  94748. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  94749. * - width the width (x direction) of the ground, optional, default 1
  94750. * - height the height (z direction) of the ground, optional, default 1
  94751. * - subdivisions the number of subdivisions per side, optional, default 1
  94752. * @returns the VertexData of the Ground
  94753. */
  94754. static CreateGround(options: {
  94755. width?: number;
  94756. height?: number;
  94757. subdivisions?: number;
  94758. subdivisionsX?: number;
  94759. subdivisionsY?: number;
  94760. }): VertexData;
  94761. /**
  94762. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  94763. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  94764. * * xmin the ground minimum X coordinate, optional, default -1
  94765. * * zmin the ground minimum Z coordinate, optional, default -1
  94766. * * xmax the ground maximum X coordinate, optional, default 1
  94767. * * zmax the ground maximum Z coordinate, optional, default 1
  94768. * * 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}
  94769. * * 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}
  94770. * @returns the VertexData of the TiledGround
  94771. */
  94772. static CreateTiledGround(options: {
  94773. xmin: number;
  94774. zmin: number;
  94775. xmax: number;
  94776. zmax: number;
  94777. subdivisions?: {
  94778. w: number;
  94779. h: number;
  94780. };
  94781. precision?: {
  94782. w: number;
  94783. h: number;
  94784. };
  94785. }): VertexData;
  94786. /**
  94787. * Creates the VertexData of the Ground designed from a heightmap
  94788. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  94789. * * width the width (x direction) of the ground
  94790. * * height the height (z direction) of the ground
  94791. * * subdivisions the number of subdivisions per side
  94792. * * minHeight the minimum altitude on the ground, optional, default 0
  94793. * * maxHeight the maximum altitude on the ground, optional default 1
  94794. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  94795. * * buffer the array holding the image color data
  94796. * * bufferWidth the width of image
  94797. * * bufferHeight the height of image
  94798. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  94799. * @returns the VertexData of the Ground designed from a heightmap
  94800. */
  94801. static CreateGroundFromHeightMap(options: {
  94802. width: number;
  94803. height: number;
  94804. subdivisions: number;
  94805. minHeight: number;
  94806. maxHeight: number;
  94807. colorFilter: Color3;
  94808. buffer: Uint8Array;
  94809. bufferWidth: number;
  94810. bufferHeight: number;
  94811. alphaFilter: number;
  94812. }): VertexData;
  94813. /**
  94814. * Creates the VertexData for a Plane
  94815. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  94816. * * size sets the width and height of the plane to the value of size, optional default 1
  94817. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  94818. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  94819. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94820. * * 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)
  94821. * * 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)
  94822. * @returns the VertexData of the box
  94823. */
  94824. static CreatePlane(options: {
  94825. size?: number;
  94826. width?: number;
  94827. height?: number;
  94828. sideOrientation?: number;
  94829. frontUVs?: Vector4;
  94830. backUVs?: Vector4;
  94831. }): VertexData;
  94832. /**
  94833. * Creates the VertexData of the Disc or regular Polygon
  94834. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  94835. * * radius the radius of the disc, optional default 0.5
  94836. * * tessellation the number of polygon sides, optional, default 64
  94837. * * 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
  94838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94839. * * 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)
  94840. * * 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)
  94841. * @returns the VertexData of the box
  94842. */
  94843. static CreateDisc(options: {
  94844. radius?: number;
  94845. tessellation?: number;
  94846. arc?: number;
  94847. sideOrientation?: number;
  94848. frontUVs?: Vector4;
  94849. backUVs?: Vector4;
  94850. }): VertexData;
  94851. /**
  94852. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  94853. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  94854. * @param polygon a mesh built from polygonTriangulation.build()
  94855. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94856. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94857. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94858. * @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)
  94859. * @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)
  94860. * @returns the VertexData of the Polygon
  94861. */
  94862. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  94863. /**
  94864. * Creates the VertexData of the IcoSphere
  94865. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  94866. * * radius the radius of the IcoSphere, optional default 1
  94867. * * radiusX allows stretching in the x direction, optional, default radius
  94868. * * radiusY allows stretching in the y direction, optional, default radius
  94869. * * radiusZ allows stretching in the z direction, optional, default radius
  94870. * * flat when true creates a flat shaded mesh, optional, default true
  94871. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  94872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94873. * * 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)
  94874. * * 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)
  94875. * @returns the VertexData of the IcoSphere
  94876. */
  94877. static CreateIcoSphere(options: {
  94878. radius?: number;
  94879. radiusX?: number;
  94880. radiusY?: number;
  94881. radiusZ?: number;
  94882. flat?: boolean;
  94883. subdivisions?: number;
  94884. sideOrientation?: number;
  94885. frontUVs?: Vector4;
  94886. backUVs?: Vector4;
  94887. }): VertexData;
  94888. /**
  94889. * Creates the VertexData for a Polyhedron
  94890. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  94891. * * type provided types are:
  94892. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  94893. * * 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)
  94894. * * size the size of the IcoSphere, optional default 1
  94895. * * sizeX allows stretching in the x direction, optional, default size
  94896. * * sizeY allows stretching in the y direction, optional, default size
  94897. * * sizeZ allows stretching in the z direction, optional, default size
  94898. * * 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
  94899. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  94900. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  94901. * * flat when true creates a flat shaded mesh, optional, default true
  94902. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  94903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94904. * * 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)
  94905. * * 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)
  94906. * @returns the VertexData of the Polyhedron
  94907. */
  94908. static CreatePolyhedron(options: {
  94909. type?: number;
  94910. size?: number;
  94911. sizeX?: number;
  94912. sizeY?: number;
  94913. sizeZ?: number;
  94914. custom?: any;
  94915. faceUV?: Vector4[];
  94916. faceColors?: Color4[];
  94917. flat?: boolean;
  94918. sideOrientation?: number;
  94919. frontUVs?: Vector4;
  94920. backUVs?: Vector4;
  94921. }): VertexData;
  94922. /**
  94923. * Creates the VertexData for a TorusKnot
  94924. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  94925. * * radius the radius of the torus knot, optional, default 2
  94926. * * tube the thickness of the tube, optional, default 0.5
  94927. * * radialSegments the number of sides on each tube segments, optional, default 32
  94928. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  94929. * * p the number of windings around the z axis, optional, default 2
  94930. * * q the number of windings around the x axis, optional, default 3
  94931. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94932. * * 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)
  94933. * * 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)
  94934. * @returns the VertexData of the Torus Knot
  94935. */
  94936. static CreateTorusKnot(options: {
  94937. radius?: number;
  94938. tube?: number;
  94939. radialSegments?: number;
  94940. tubularSegments?: number;
  94941. p?: number;
  94942. q?: number;
  94943. sideOrientation?: number;
  94944. frontUVs?: Vector4;
  94945. backUVs?: Vector4;
  94946. }): VertexData;
  94947. /**
  94948. * Compute normals for given positions and indices
  94949. * @param positions an array of vertex positions, [...., x, y, z, ......]
  94950. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  94951. * @param normals an array of vertex normals, [...., x, y, z, ......]
  94952. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  94953. * * facetNormals : optional array of facet normals (vector3)
  94954. * * facetPositions : optional array of facet positions (vector3)
  94955. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  94956. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  94957. * * bInfo : optional bounding info, required for facetPartitioning computation
  94958. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  94959. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  94960. * * useRightHandedSystem: optional boolean to for right handed system computation
  94961. * * depthSort : optional boolean to enable the facet depth sort computation
  94962. * * distanceTo : optional Vector3 to compute the facet depth from this location
  94963. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  94964. */
  94965. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  94966. facetNormals?: any;
  94967. facetPositions?: any;
  94968. facetPartitioning?: any;
  94969. ratio?: number;
  94970. bInfo?: any;
  94971. bbSize?: Vector3;
  94972. subDiv?: any;
  94973. useRightHandedSystem?: boolean;
  94974. depthSort?: boolean;
  94975. distanceTo?: Vector3;
  94976. depthSortedFacets?: any;
  94977. }): void;
  94978. /** @hidden */
  94979. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  94980. /**
  94981. * Applies VertexData created from the imported parameters to the geometry
  94982. * @param parsedVertexData the parsed data from an imported file
  94983. * @param geometry the geometry to apply the VertexData to
  94984. */
  94985. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  94986. }
  94987. }
  94988. declare module BABYLON {
  94989. /**
  94990. * Defines a target to use with MorphTargetManager
  94991. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94992. */
  94993. export class MorphTarget implements IAnimatable {
  94994. /** defines the name of the target */
  94995. name: string;
  94996. /**
  94997. * Gets or sets the list of animations
  94998. */
  94999. animations: Animation[];
  95000. private _scene;
  95001. private _positions;
  95002. private _normals;
  95003. private _tangents;
  95004. private _uvs;
  95005. private _influence;
  95006. private _uniqueId;
  95007. /**
  95008. * Observable raised when the influence changes
  95009. */
  95010. onInfluenceChanged: Observable<boolean>;
  95011. /** @hidden */
  95012. _onDataLayoutChanged: Observable<void>;
  95013. /**
  95014. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95015. */
  95016. get influence(): number;
  95017. set influence(influence: number);
  95018. /**
  95019. * Gets or sets the id of the morph Target
  95020. */
  95021. id: string;
  95022. private _animationPropertiesOverride;
  95023. /**
  95024. * Gets or sets the animation properties override
  95025. */
  95026. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95027. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95028. /**
  95029. * Creates a new MorphTarget
  95030. * @param name defines the name of the target
  95031. * @param influence defines the influence to use
  95032. * @param scene defines the scene the morphtarget belongs to
  95033. */
  95034. constructor(
  95035. /** defines the name of the target */
  95036. name: string, influence?: number, scene?: Nullable<Scene>);
  95037. /**
  95038. * Gets the unique ID of this manager
  95039. */
  95040. get uniqueId(): number;
  95041. /**
  95042. * Gets a boolean defining if the target contains position data
  95043. */
  95044. get hasPositions(): boolean;
  95045. /**
  95046. * Gets a boolean defining if the target contains normal data
  95047. */
  95048. get hasNormals(): boolean;
  95049. /**
  95050. * Gets a boolean defining if the target contains tangent data
  95051. */
  95052. get hasTangents(): boolean;
  95053. /**
  95054. * Gets a boolean defining if the target contains texture coordinates data
  95055. */
  95056. get hasUVs(): boolean;
  95057. /**
  95058. * Affects position data to this target
  95059. * @param data defines the position data to use
  95060. */
  95061. setPositions(data: Nullable<FloatArray>): void;
  95062. /**
  95063. * Gets the position data stored in this target
  95064. * @returns a FloatArray containing the position data (or null if not present)
  95065. */
  95066. getPositions(): Nullable<FloatArray>;
  95067. /**
  95068. * Affects normal data to this target
  95069. * @param data defines the normal data to use
  95070. */
  95071. setNormals(data: Nullable<FloatArray>): void;
  95072. /**
  95073. * Gets the normal data stored in this target
  95074. * @returns a FloatArray containing the normal data (or null if not present)
  95075. */
  95076. getNormals(): Nullable<FloatArray>;
  95077. /**
  95078. * Affects tangent data to this target
  95079. * @param data defines the tangent data to use
  95080. */
  95081. setTangents(data: Nullable<FloatArray>): void;
  95082. /**
  95083. * Gets the tangent data stored in this target
  95084. * @returns a FloatArray containing the tangent data (or null if not present)
  95085. */
  95086. getTangents(): Nullable<FloatArray>;
  95087. /**
  95088. * Affects texture coordinates data to this target
  95089. * @param data defines the texture coordinates data to use
  95090. */
  95091. setUVs(data: Nullable<FloatArray>): void;
  95092. /**
  95093. * Gets the texture coordinates data stored in this target
  95094. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95095. */
  95096. getUVs(): Nullable<FloatArray>;
  95097. /**
  95098. * Clone the current target
  95099. * @returns a new MorphTarget
  95100. */
  95101. clone(): MorphTarget;
  95102. /**
  95103. * Serializes the current target into a Serialization object
  95104. * @returns the serialized object
  95105. */
  95106. serialize(): any;
  95107. /**
  95108. * Returns the string "MorphTarget"
  95109. * @returns "MorphTarget"
  95110. */
  95111. getClassName(): string;
  95112. /**
  95113. * Creates a new target from serialized data
  95114. * @param serializationObject defines the serialized data to use
  95115. * @returns a new MorphTarget
  95116. */
  95117. static Parse(serializationObject: any): MorphTarget;
  95118. /**
  95119. * Creates a MorphTarget from mesh data
  95120. * @param mesh defines the source mesh
  95121. * @param name defines the name to use for the new target
  95122. * @param influence defines the influence to attach to the target
  95123. * @returns a new MorphTarget
  95124. */
  95125. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  95126. }
  95127. }
  95128. declare module BABYLON {
  95129. /**
  95130. * This class is used to deform meshes using morphing between different targets
  95131. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95132. */
  95133. export class MorphTargetManager {
  95134. private _targets;
  95135. private _targetInfluenceChangedObservers;
  95136. private _targetDataLayoutChangedObservers;
  95137. private _activeTargets;
  95138. private _scene;
  95139. private _influences;
  95140. private _supportsNormals;
  95141. private _supportsTangents;
  95142. private _supportsUVs;
  95143. private _vertexCount;
  95144. private _uniqueId;
  95145. private _tempInfluences;
  95146. /**
  95147. * Gets or sets a boolean indicating if normals must be morphed
  95148. */
  95149. enableNormalMorphing: boolean;
  95150. /**
  95151. * Gets or sets a boolean indicating if tangents must be morphed
  95152. */
  95153. enableTangentMorphing: boolean;
  95154. /**
  95155. * Gets or sets a boolean indicating if UV must be morphed
  95156. */
  95157. enableUVMorphing: boolean;
  95158. /**
  95159. * Creates a new MorphTargetManager
  95160. * @param scene defines the current scene
  95161. */
  95162. constructor(scene?: Nullable<Scene>);
  95163. /**
  95164. * Gets the unique ID of this manager
  95165. */
  95166. get uniqueId(): number;
  95167. /**
  95168. * Gets the number of vertices handled by this manager
  95169. */
  95170. get vertexCount(): number;
  95171. /**
  95172. * Gets a boolean indicating if this manager supports morphing of normals
  95173. */
  95174. get supportsNormals(): boolean;
  95175. /**
  95176. * Gets a boolean indicating if this manager supports morphing of tangents
  95177. */
  95178. get supportsTangents(): boolean;
  95179. /**
  95180. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  95181. */
  95182. get supportsUVs(): boolean;
  95183. /**
  95184. * Gets the number of targets stored in this manager
  95185. */
  95186. get numTargets(): number;
  95187. /**
  95188. * Gets the number of influencers (ie. the number of targets with influences > 0)
  95189. */
  95190. get numInfluencers(): number;
  95191. /**
  95192. * Gets the list of influences (one per target)
  95193. */
  95194. get influences(): Float32Array;
  95195. /**
  95196. * Gets the active target at specified index. An active target is a target with an influence > 0
  95197. * @param index defines the index to check
  95198. * @returns the requested target
  95199. */
  95200. getActiveTarget(index: number): MorphTarget;
  95201. /**
  95202. * Gets the target at specified index
  95203. * @param index defines the index to check
  95204. * @returns the requested target
  95205. */
  95206. getTarget(index: number): MorphTarget;
  95207. /**
  95208. * Add a new target to this manager
  95209. * @param target defines the target to add
  95210. */
  95211. addTarget(target: MorphTarget): void;
  95212. /**
  95213. * Removes a target from the manager
  95214. * @param target defines the target to remove
  95215. */
  95216. removeTarget(target: MorphTarget): void;
  95217. /**
  95218. * Clone the current manager
  95219. * @returns a new MorphTargetManager
  95220. */
  95221. clone(): MorphTargetManager;
  95222. /**
  95223. * Serializes the current manager into a Serialization object
  95224. * @returns the serialized object
  95225. */
  95226. serialize(): any;
  95227. private _syncActiveTargets;
  95228. /**
  95229. * Syncrhonize the targets with all the meshes using this morph target manager
  95230. */
  95231. synchronize(): void;
  95232. /**
  95233. * Creates a new MorphTargetManager from serialized data
  95234. * @param serializationObject defines the serialized data
  95235. * @param scene defines the hosting scene
  95236. * @returns the new MorphTargetManager
  95237. */
  95238. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  95239. }
  95240. }
  95241. declare module BABYLON {
  95242. /**
  95243. * Class used to represent a specific level of detail of a mesh
  95244. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  95245. */
  95246. export class MeshLODLevel {
  95247. /** Defines the distance where this level should start being displayed */
  95248. distance: number;
  95249. /** Defines the mesh to use to render this level */
  95250. mesh: Nullable<Mesh>;
  95251. /**
  95252. * Creates a new LOD level
  95253. * @param distance defines the distance where this level should star being displayed
  95254. * @param mesh defines the mesh to use to render this level
  95255. */
  95256. constructor(
  95257. /** Defines the distance where this level should start being displayed */
  95258. distance: number,
  95259. /** Defines the mesh to use to render this level */
  95260. mesh: Nullable<Mesh>);
  95261. }
  95262. }
  95263. declare module BABYLON {
  95264. /**
  95265. * Mesh representing the gorund
  95266. */
  95267. export class GroundMesh extends Mesh {
  95268. /** If octree should be generated */
  95269. generateOctree: boolean;
  95270. private _heightQuads;
  95271. /** @hidden */
  95272. _subdivisionsX: number;
  95273. /** @hidden */
  95274. _subdivisionsY: number;
  95275. /** @hidden */
  95276. _width: number;
  95277. /** @hidden */
  95278. _height: number;
  95279. /** @hidden */
  95280. _minX: number;
  95281. /** @hidden */
  95282. _maxX: number;
  95283. /** @hidden */
  95284. _minZ: number;
  95285. /** @hidden */
  95286. _maxZ: number;
  95287. constructor(name: string, scene: Scene);
  95288. /**
  95289. * "GroundMesh"
  95290. * @returns "GroundMesh"
  95291. */
  95292. getClassName(): string;
  95293. /**
  95294. * The minimum of x and y subdivisions
  95295. */
  95296. get subdivisions(): number;
  95297. /**
  95298. * X subdivisions
  95299. */
  95300. get subdivisionsX(): number;
  95301. /**
  95302. * Y subdivisions
  95303. */
  95304. get subdivisionsY(): number;
  95305. /**
  95306. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  95307. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95308. * @param chunksCount the number of subdivisions for x and y
  95309. * @param octreeBlocksSize (Default: 32)
  95310. */
  95311. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  95312. /**
  95313. * Returns a height (y) value in the Worl system :
  95314. * the ground altitude at the coordinates (x, z) expressed in the World system.
  95315. * @param x x coordinate
  95316. * @param z z coordinate
  95317. * @returns the ground y position if (x, z) are outside the ground surface.
  95318. */
  95319. getHeightAtCoordinates(x: number, z: number): number;
  95320. /**
  95321. * Returns a normalized vector (Vector3) orthogonal to the ground
  95322. * at the ground coordinates (x, z) expressed in the World system.
  95323. * @param x x coordinate
  95324. * @param z z coordinate
  95325. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  95326. */
  95327. getNormalAtCoordinates(x: number, z: number): Vector3;
  95328. /**
  95329. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  95330. * at the ground coordinates (x, z) expressed in the World system.
  95331. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  95332. * @param x x coordinate
  95333. * @param z z coordinate
  95334. * @param ref vector to store the result
  95335. * @returns the GroundMesh.
  95336. */
  95337. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  95338. /**
  95339. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  95340. * if the ground has been updated.
  95341. * This can be used in the render loop.
  95342. * @returns the GroundMesh.
  95343. */
  95344. updateCoordinateHeights(): GroundMesh;
  95345. private _getFacetAt;
  95346. private _initHeightQuads;
  95347. private _computeHeightQuads;
  95348. /**
  95349. * Serializes this ground mesh
  95350. * @param serializationObject object to write serialization to
  95351. */
  95352. serialize(serializationObject: any): void;
  95353. /**
  95354. * Parses a serialized ground mesh
  95355. * @param parsedMesh the serialized mesh
  95356. * @param scene the scene to create the ground mesh in
  95357. * @returns the created ground mesh
  95358. */
  95359. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  95360. }
  95361. }
  95362. declare module BABYLON {
  95363. /**
  95364. * Interface for Physics-Joint data
  95365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95366. */
  95367. export interface PhysicsJointData {
  95368. /**
  95369. * The main pivot of the joint
  95370. */
  95371. mainPivot?: Vector3;
  95372. /**
  95373. * The connected pivot of the joint
  95374. */
  95375. connectedPivot?: Vector3;
  95376. /**
  95377. * The main axis of the joint
  95378. */
  95379. mainAxis?: Vector3;
  95380. /**
  95381. * The connected axis of the joint
  95382. */
  95383. connectedAxis?: Vector3;
  95384. /**
  95385. * The collision of the joint
  95386. */
  95387. collision?: boolean;
  95388. /**
  95389. * Native Oimo/Cannon/Energy data
  95390. */
  95391. nativeParams?: any;
  95392. }
  95393. /**
  95394. * This is a holder class for the physics joint created by the physics plugin
  95395. * It holds a set of functions to control the underlying joint
  95396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95397. */
  95398. export class PhysicsJoint {
  95399. /**
  95400. * The type of the physics joint
  95401. */
  95402. type: number;
  95403. /**
  95404. * The data for the physics joint
  95405. */
  95406. jointData: PhysicsJointData;
  95407. private _physicsJoint;
  95408. protected _physicsPlugin: IPhysicsEnginePlugin;
  95409. /**
  95410. * Initializes the physics joint
  95411. * @param type The type of the physics joint
  95412. * @param jointData The data for the physics joint
  95413. */
  95414. constructor(
  95415. /**
  95416. * The type of the physics joint
  95417. */
  95418. type: number,
  95419. /**
  95420. * The data for the physics joint
  95421. */
  95422. jointData: PhysicsJointData);
  95423. /**
  95424. * Gets the physics joint
  95425. */
  95426. get physicsJoint(): any;
  95427. /**
  95428. * Sets the physics joint
  95429. */
  95430. set physicsJoint(newJoint: any);
  95431. /**
  95432. * Sets the physics plugin
  95433. */
  95434. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  95435. /**
  95436. * Execute a function that is physics-plugin specific.
  95437. * @param {Function} func the function that will be executed.
  95438. * It accepts two parameters: the physics world and the physics joint
  95439. */
  95440. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  95441. /**
  95442. * Distance-Joint type
  95443. */
  95444. static DistanceJoint: number;
  95445. /**
  95446. * Hinge-Joint type
  95447. */
  95448. static HingeJoint: number;
  95449. /**
  95450. * Ball-and-Socket joint type
  95451. */
  95452. static BallAndSocketJoint: number;
  95453. /**
  95454. * Wheel-Joint type
  95455. */
  95456. static WheelJoint: number;
  95457. /**
  95458. * Slider-Joint type
  95459. */
  95460. static SliderJoint: number;
  95461. /**
  95462. * Prismatic-Joint type
  95463. */
  95464. static PrismaticJoint: number;
  95465. /**
  95466. * Universal-Joint type
  95467. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  95468. */
  95469. static UniversalJoint: number;
  95470. /**
  95471. * Hinge-Joint 2 type
  95472. */
  95473. static Hinge2Joint: number;
  95474. /**
  95475. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  95476. */
  95477. static PointToPointJoint: number;
  95478. /**
  95479. * Spring-Joint type
  95480. */
  95481. static SpringJoint: number;
  95482. /**
  95483. * Lock-Joint type
  95484. */
  95485. static LockJoint: number;
  95486. }
  95487. /**
  95488. * A class representing a physics distance joint
  95489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95490. */
  95491. export class DistanceJoint extends PhysicsJoint {
  95492. /**
  95493. *
  95494. * @param jointData The data for the Distance-Joint
  95495. */
  95496. constructor(jointData: DistanceJointData);
  95497. /**
  95498. * Update the predefined distance.
  95499. * @param maxDistance The maximum preferred distance
  95500. * @param minDistance The minimum preferred distance
  95501. */
  95502. updateDistance(maxDistance: number, minDistance?: number): void;
  95503. }
  95504. /**
  95505. * Represents a Motor-Enabled Joint
  95506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95507. */
  95508. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  95509. /**
  95510. * Initializes the Motor-Enabled Joint
  95511. * @param type The type of the joint
  95512. * @param jointData The physica joint data for the joint
  95513. */
  95514. constructor(type: number, jointData: PhysicsJointData);
  95515. /**
  95516. * Set the motor values.
  95517. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95518. * @param force the force to apply
  95519. * @param maxForce max force for this motor.
  95520. */
  95521. setMotor(force?: number, maxForce?: number): void;
  95522. /**
  95523. * Set the motor's limits.
  95524. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95525. * @param upperLimit The upper limit of the motor
  95526. * @param lowerLimit The lower limit of the motor
  95527. */
  95528. setLimit(upperLimit: number, lowerLimit?: number): void;
  95529. }
  95530. /**
  95531. * This class represents a single physics Hinge-Joint
  95532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95533. */
  95534. export class HingeJoint extends MotorEnabledJoint {
  95535. /**
  95536. * Initializes the Hinge-Joint
  95537. * @param jointData The joint data for the Hinge-Joint
  95538. */
  95539. constructor(jointData: PhysicsJointData);
  95540. /**
  95541. * Set the motor values.
  95542. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95543. * @param {number} force the force to apply
  95544. * @param {number} maxForce max force for this motor.
  95545. */
  95546. setMotor(force?: number, maxForce?: number): void;
  95547. /**
  95548. * Set the motor's limits.
  95549. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95550. * @param upperLimit The upper limit of the motor
  95551. * @param lowerLimit The lower limit of the motor
  95552. */
  95553. setLimit(upperLimit: number, lowerLimit?: number): void;
  95554. }
  95555. /**
  95556. * This class represents a dual hinge physics joint (same as wheel joint)
  95557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95558. */
  95559. export class Hinge2Joint extends MotorEnabledJoint {
  95560. /**
  95561. * Initializes the Hinge2-Joint
  95562. * @param jointData The joint data for the Hinge2-Joint
  95563. */
  95564. constructor(jointData: PhysicsJointData);
  95565. /**
  95566. * Set the motor values.
  95567. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95568. * @param {number} targetSpeed the speed the motor is to reach
  95569. * @param {number} maxForce max force for this motor.
  95570. * @param {motorIndex} the motor's index, 0 or 1.
  95571. */
  95572. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  95573. /**
  95574. * Set the motor limits.
  95575. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95576. * @param {number} upperLimit the upper limit
  95577. * @param {number} lowerLimit lower limit
  95578. * @param {motorIndex} the motor's index, 0 or 1.
  95579. */
  95580. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95581. }
  95582. /**
  95583. * Interface for a motor enabled joint
  95584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95585. */
  95586. export interface IMotorEnabledJoint {
  95587. /**
  95588. * Physics joint
  95589. */
  95590. physicsJoint: any;
  95591. /**
  95592. * Sets the motor of the motor-enabled joint
  95593. * @param force The force of the motor
  95594. * @param maxForce The maximum force of the motor
  95595. * @param motorIndex The index of the motor
  95596. */
  95597. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  95598. /**
  95599. * Sets the limit of the motor
  95600. * @param upperLimit The upper limit of the motor
  95601. * @param lowerLimit The lower limit of the motor
  95602. * @param motorIndex The index of the motor
  95603. */
  95604. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95605. }
  95606. /**
  95607. * Joint data for a Distance-Joint
  95608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95609. */
  95610. export interface DistanceJointData extends PhysicsJointData {
  95611. /**
  95612. * Max distance the 2 joint objects can be apart
  95613. */
  95614. maxDistance: number;
  95615. }
  95616. /**
  95617. * Joint data from a spring joint
  95618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95619. */
  95620. export interface SpringJointData extends PhysicsJointData {
  95621. /**
  95622. * Length of the spring
  95623. */
  95624. length: number;
  95625. /**
  95626. * Stiffness of the spring
  95627. */
  95628. stiffness: number;
  95629. /**
  95630. * Damping of the spring
  95631. */
  95632. damping: number;
  95633. /** this callback will be called when applying the force to the impostors. */
  95634. forceApplicationCallback: () => void;
  95635. }
  95636. }
  95637. declare module BABYLON {
  95638. /**
  95639. * Holds the data for the raycast result
  95640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95641. */
  95642. export class PhysicsRaycastResult {
  95643. private _hasHit;
  95644. private _hitDistance;
  95645. private _hitNormalWorld;
  95646. private _hitPointWorld;
  95647. private _rayFromWorld;
  95648. private _rayToWorld;
  95649. /**
  95650. * Gets if there was a hit
  95651. */
  95652. get hasHit(): boolean;
  95653. /**
  95654. * Gets the distance from the hit
  95655. */
  95656. get hitDistance(): number;
  95657. /**
  95658. * Gets the hit normal/direction in the world
  95659. */
  95660. get hitNormalWorld(): Vector3;
  95661. /**
  95662. * Gets the hit point in the world
  95663. */
  95664. get hitPointWorld(): Vector3;
  95665. /**
  95666. * Gets the ray "start point" of the ray in the world
  95667. */
  95668. get rayFromWorld(): Vector3;
  95669. /**
  95670. * Gets the ray "end point" of the ray in the world
  95671. */
  95672. get rayToWorld(): Vector3;
  95673. /**
  95674. * Sets the hit data (normal & point in world space)
  95675. * @param hitNormalWorld defines the normal in world space
  95676. * @param hitPointWorld defines the point in world space
  95677. */
  95678. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  95679. /**
  95680. * Sets the distance from the start point to the hit point
  95681. * @param distance
  95682. */
  95683. setHitDistance(distance: number): void;
  95684. /**
  95685. * Calculates the distance manually
  95686. */
  95687. calculateHitDistance(): void;
  95688. /**
  95689. * Resets all the values to default
  95690. * @param from The from point on world space
  95691. * @param to The to point on world space
  95692. */
  95693. reset(from?: Vector3, to?: Vector3): void;
  95694. }
  95695. /**
  95696. * Interface for the size containing width and height
  95697. */
  95698. interface IXYZ {
  95699. /**
  95700. * X
  95701. */
  95702. x: number;
  95703. /**
  95704. * Y
  95705. */
  95706. y: number;
  95707. /**
  95708. * Z
  95709. */
  95710. z: number;
  95711. }
  95712. }
  95713. declare module BABYLON {
  95714. /**
  95715. * Interface used to describe a physics joint
  95716. */
  95717. export interface PhysicsImpostorJoint {
  95718. /** Defines the main impostor to which the joint is linked */
  95719. mainImpostor: PhysicsImpostor;
  95720. /** Defines the impostor that is connected to the main impostor using this joint */
  95721. connectedImpostor: PhysicsImpostor;
  95722. /** Defines the joint itself */
  95723. joint: PhysicsJoint;
  95724. }
  95725. /** @hidden */
  95726. export interface IPhysicsEnginePlugin {
  95727. world: any;
  95728. name: string;
  95729. setGravity(gravity: Vector3): void;
  95730. setTimeStep(timeStep: number): void;
  95731. getTimeStep(): number;
  95732. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  95733. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  95734. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  95735. generatePhysicsBody(impostor: PhysicsImpostor): void;
  95736. removePhysicsBody(impostor: PhysicsImpostor): void;
  95737. generateJoint(joint: PhysicsImpostorJoint): void;
  95738. removeJoint(joint: PhysicsImpostorJoint): void;
  95739. isSupported(): boolean;
  95740. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  95741. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  95742. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  95743. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  95744. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  95745. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  95746. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  95747. getBodyMass(impostor: PhysicsImpostor): number;
  95748. getBodyFriction(impostor: PhysicsImpostor): number;
  95749. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  95750. getBodyRestitution(impostor: PhysicsImpostor): number;
  95751. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  95752. getBodyPressure?(impostor: PhysicsImpostor): number;
  95753. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  95754. getBodyStiffness?(impostor: PhysicsImpostor): number;
  95755. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  95756. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  95757. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  95758. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  95759. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  95760. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  95761. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  95762. sleepBody(impostor: PhysicsImpostor): void;
  95763. wakeUpBody(impostor: PhysicsImpostor): void;
  95764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  95765. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  95766. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  95767. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  95768. getRadius(impostor: PhysicsImpostor): number;
  95769. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  95770. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  95771. dispose(): void;
  95772. }
  95773. /**
  95774. * Interface used to define a physics engine
  95775. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  95776. */
  95777. export interface IPhysicsEngine {
  95778. /**
  95779. * Gets the gravity vector used by the simulation
  95780. */
  95781. gravity: Vector3;
  95782. /**
  95783. * Sets the gravity vector used by the simulation
  95784. * @param gravity defines the gravity vector to use
  95785. */
  95786. setGravity(gravity: Vector3): void;
  95787. /**
  95788. * Set the time step of the physics engine.
  95789. * Default is 1/60.
  95790. * To slow it down, enter 1/600 for example.
  95791. * To speed it up, 1/30
  95792. * @param newTimeStep the new timestep to apply to this world.
  95793. */
  95794. setTimeStep(newTimeStep: number): void;
  95795. /**
  95796. * Get the time step of the physics engine.
  95797. * @returns the current time step
  95798. */
  95799. getTimeStep(): number;
  95800. /**
  95801. * Set the sub time step of the physics engine.
  95802. * Default is 0 meaning there is no sub steps
  95803. * To increase physics resolution precision, set a small value (like 1 ms)
  95804. * @param subTimeStep defines the new sub timestep used for physics resolution.
  95805. */
  95806. setSubTimeStep(subTimeStep: number): void;
  95807. /**
  95808. * Get the sub time step of the physics engine.
  95809. * @returns the current sub time step
  95810. */
  95811. getSubTimeStep(): number;
  95812. /**
  95813. * Release all resources
  95814. */
  95815. dispose(): void;
  95816. /**
  95817. * Gets the name of the current physics plugin
  95818. * @returns the name of the plugin
  95819. */
  95820. getPhysicsPluginName(): string;
  95821. /**
  95822. * Adding a new impostor for the impostor tracking.
  95823. * This will be done by the impostor itself.
  95824. * @param impostor the impostor to add
  95825. */
  95826. addImpostor(impostor: PhysicsImpostor): void;
  95827. /**
  95828. * Remove an impostor from the engine.
  95829. * This impostor and its mesh will not longer be updated by the physics engine.
  95830. * @param impostor the impostor to remove
  95831. */
  95832. removeImpostor(impostor: PhysicsImpostor): void;
  95833. /**
  95834. * Add a joint to the physics engine
  95835. * @param mainImpostor defines the main impostor to which the joint is added.
  95836. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  95837. * @param joint defines the joint that will connect both impostors.
  95838. */
  95839. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  95840. /**
  95841. * Removes a joint from the simulation
  95842. * @param mainImpostor defines the impostor used with the joint
  95843. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  95844. * @param joint defines the joint to remove
  95845. */
  95846. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  95847. /**
  95848. * Gets the current plugin used to run the simulation
  95849. * @returns current plugin
  95850. */
  95851. getPhysicsPlugin(): IPhysicsEnginePlugin;
  95852. /**
  95853. * Gets the list of physic impostors
  95854. * @returns an array of PhysicsImpostor
  95855. */
  95856. getImpostors(): Array<PhysicsImpostor>;
  95857. /**
  95858. * Gets the impostor for a physics enabled object
  95859. * @param object defines the object impersonated by the impostor
  95860. * @returns the PhysicsImpostor or null if not found
  95861. */
  95862. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  95863. /**
  95864. * Gets the impostor for a physics body object
  95865. * @param body defines physics body used by the impostor
  95866. * @returns the PhysicsImpostor or null if not found
  95867. */
  95868. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  95869. /**
  95870. * Does a raycast in the physics world
  95871. * @param from when should the ray start?
  95872. * @param to when should the ray end?
  95873. * @returns PhysicsRaycastResult
  95874. */
  95875. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  95876. /**
  95877. * Called by the scene. No need to call it.
  95878. * @param delta defines the timespam between frames
  95879. */
  95880. _step(delta: number): void;
  95881. }
  95882. }
  95883. declare module BABYLON {
  95884. /**
  95885. * The interface for the physics imposter parameters
  95886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95887. */
  95888. export interface PhysicsImpostorParameters {
  95889. /**
  95890. * The mass of the physics imposter
  95891. */
  95892. mass: number;
  95893. /**
  95894. * The friction of the physics imposter
  95895. */
  95896. friction?: number;
  95897. /**
  95898. * The coefficient of restitution of the physics imposter
  95899. */
  95900. restitution?: number;
  95901. /**
  95902. * The native options of the physics imposter
  95903. */
  95904. nativeOptions?: any;
  95905. /**
  95906. * Specifies if the parent should be ignored
  95907. */
  95908. ignoreParent?: boolean;
  95909. /**
  95910. * Specifies if bi-directional transformations should be disabled
  95911. */
  95912. disableBidirectionalTransformation?: boolean;
  95913. /**
  95914. * The pressure inside the physics imposter, soft object only
  95915. */
  95916. pressure?: number;
  95917. /**
  95918. * The stiffness the physics imposter, soft object only
  95919. */
  95920. stiffness?: number;
  95921. /**
  95922. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  95923. */
  95924. velocityIterations?: number;
  95925. /**
  95926. * The number of iterations used in maintaining consistent vertex positions, soft object only
  95927. */
  95928. positionIterations?: number;
  95929. /**
  95930. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  95931. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  95932. * Add to fix multiple points
  95933. */
  95934. fixedPoints?: number;
  95935. /**
  95936. * The collision margin around a soft object
  95937. */
  95938. margin?: number;
  95939. /**
  95940. * The collision margin around a soft object
  95941. */
  95942. damping?: number;
  95943. /**
  95944. * The path for a rope based on an extrusion
  95945. */
  95946. path?: any;
  95947. /**
  95948. * The shape of an extrusion used for a rope based on an extrusion
  95949. */
  95950. shape?: any;
  95951. }
  95952. /**
  95953. * Interface for a physics-enabled object
  95954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95955. */
  95956. export interface IPhysicsEnabledObject {
  95957. /**
  95958. * The position of the physics-enabled object
  95959. */
  95960. position: Vector3;
  95961. /**
  95962. * The rotation of the physics-enabled object
  95963. */
  95964. rotationQuaternion: Nullable<Quaternion>;
  95965. /**
  95966. * The scale of the physics-enabled object
  95967. */
  95968. scaling: Vector3;
  95969. /**
  95970. * The rotation of the physics-enabled object
  95971. */
  95972. rotation?: Vector3;
  95973. /**
  95974. * The parent of the physics-enabled object
  95975. */
  95976. parent?: any;
  95977. /**
  95978. * The bounding info of the physics-enabled object
  95979. * @returns The bounding info of the physics-enabled object
  95980. */
  95981. getBoundingInfo(): BoundingInfo;
  95982. /**
  95983. * Computes the world matrix
  95984. * @param force Specifies if the world matrix should be computed by force
  95985. * @returns A world matrix
  95986. */
  95987. computeWorldMatrix(force: boolean): Matrix;
  95988. /**
  95989. * Gets the world matrix
  95990. * @returns A world matrix
  95991. */
  95992. getWorldMatrix?(): Matrix;
  95993. /**
  95994. * Gets the child meshes
  95995. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  95996. * @returns An array of abstract meshes
  95997. */
  95998. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  95999. /**
  96000. * Gets the vertex data
  96001. * @param kind The type of vertex data
  96002. * @returns A nullable array of numbers, or a float32 array
  96003. */
  96004. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96005. /**
  96006. * Gets the indices from the mesh
  96007. * @returns A nullable array of index arrays
  96008. */
  96009. getIndices?(): Nullable<IndicesArray>;
  96010. /**
  96011. * Gets the scene from the mesh
  96012. * @returns the indices array or null
  96013. */
  96014. getScene?(): Scene;
  96015. /**
  96016. * Gets the absolute position from the mesh
  96017. * @returns the absolute position
  96018. */
  96019. getAbsolutePosition(): Vector3;
  96020. /**
  96021. * Gets the absolute pivot point from the mesh
  96022. * @returns the absolute pivot point
  96023. */
  96024. getAbsolutePivotPoint(): Vector3;
  96025. /**
  96026. * Rotates the mesh
  96027. * @param axis The axis of rotation
  96028. * @param amount The amount of rotation
  96029. * @param space The space of the rotation
  96030. * @returns The rotation transform node
  96031. */
  96032. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96033. /**
  96034. * Translates the mesh
  96035. * @param axis The axis of translation
  96036. * @param distance The distance of translation
  96037. * @param space The space of the translation
  96038. * @returns The transform node
  96039. */
  96040. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96041. /**
  96042. * Sets the absolute position of the mesh
  96043. * @param absolutePosition The absolute position of the mesh
  96044. * @returns The transform node
  96045. */
  96046. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96047. /**
  96048. * Gets the class name of the mesh
  96049. * @returns The class name
  96050. */
  96051. getClassName(): string;
  96052. }
  96053. /**
  96054. * Represents a physics imposter
  96055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96056. */
  96057. export class PhysicsImpostor {
  96058. /**
  96059. * The physics-enabled object used as the physics imposter
  96060. */
  96061. object: IPhysicsEnabledObject;
  96062. /**
  96063. * The type of the physics imposter
  96064. */
  96065. type: number;
  96066. private _options;
  96067. private _scene?;
  96068. /**
  96069. * The default object size of the imposter
  96070. */
  96071. static DEFAULT_OBJECT_SIZE: Vector3;
  96072. /**
  96073. * The identity quaternion of the imposter
  96074. */
  96075. static IDENTITY_QUATERNION: Quaternion;
  96076. /** @hidden */
  96077. _pluginData: any;
  96078. private _physicsEngine;
  96079. private _physicsBody;
  96080. private _bodyUpdateRequired;
  96081. private _onBeforePhysicsStepCallbacks;
  96082. private _onAfterPhysicsStepCallbacks;
  96083. /** @hidden */
  96084. _onPhysicsCollideCallbacks: Array<{
  96085. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96086. otherImpostors: Array<PhysicsImpostor>;
  96087. }>;
  96088. private _deltaPosition;
  96089. private _deltaRotation;
  96090. private _deltaRotationConjugated;
  96091. /** @hidden */
  96092. _isFromLine: boolean;
  96093. private _parent;
  96094. private _isDisposed;
  96095. private static _tmpVecs;
  96096. private static _tmpQuat;
  96097. /**
  96098. * Specifies if the physics imposter is disposed
  96099. */
  96100. get isDisposed(): boolean;
  96101. /**
  96102. * Gets the mass of the physics imposter
  96103. */
  96104. get mass(): number;
  96105. set mass(value: number);
  96106. /**
  96107. * Gets the coefficient of friction
  96108. */
  96109. get friction(): number;
  96110. /**
  96111. * Sets the coefficient of friction
  96112. */
  96113. set friction(value: number);
  96114. /**
  96115. * Gets the coefficient of restitution
  96116. */
  96117. get restitution(): number;
  96118. /**
  96119. * Sets the coefficient of restitution
  96120. */
  96121. set restitution(value: number);
  96122. /**
  96123. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96124. */
  96125. get pressure(): number;
  96126. /**
  96127. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  96128. */
  96129. set pressure(value: number);
  96130. /**
  96131. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96132. */
  96133. get stiffness(): number;
  96134. /**
  96135. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96136. */
  96137. set stiffness(value: number);
  96138. /**
  96139. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96140. */
  96141. get velocityIterations(): number;
  96142. /**
  96143. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96144. */
  96145. set velocityIterations(value: number);
  96146. /**
  96147. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96148. */
  96149. get positionIterations(): number;
  96150. /**
  96151. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96152. */
  96153. set positionIterations(value: number);
  96154. /**
  96155. * The unique id of the physics imposter
  96156. * set by the physics engine when adding this impostor to the array
  96157. */
  96158. uniqueId: number;
  96159. /**
  96160. * @hidden
  96161. */
  96162. soft: boolean;
  96163. /**
  96164. * @hidden
  96165. */
  96166. segments: number;
  96167. private _joints;
  96168. /**
  96169. * Initializes the physics imposter
  96170. * @param object The physics-enabled object used as the physics imposter
  96171. * @param type The type of the physics imposter
  96172. * @param _options The options for the physics imposter
  96173. * @param _scene The Babylon scene
  96174. */
  96175. constructor(
  96176. /**
  96177. * The physics-enabled object used as the physics imposter
  96178. */
  96179. object: IPhysicsEnabledObject,
  96180. /**
  96181. * The type of the physics imposter
  96182. */
  96183. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  96184. /**
  96185. * This function will completly initialize this impostor.
  96186. * It will create a new body - but only if this mesh has no parent.
  96187. * If it has, this impostor will not be used other than to define the impostor
  96188. * of the child mesh.
  96189. * @hidden
  96190. */
  96191. _init(): void;
  96192. private _getPhysicsParent;
  96193. /**
  96194. * Should a new body be generated.
  96195. * @returns boolean specifying if body initialization is required
  96196. */
  96197. isBodyInitRequired(): boolean;
  96198. /**
  96199. * Sets the updated scaling
  96200. * @param updated Specifies if the scaling is updated
  96201. */
  96202. setScalingUpdated(): void;
  96203. /**
  96204. * Force a regeneration of this or the parent's impostor's body.
  96205. * Use under cautious - This will remove all joints already implemented.
  96206. */
  96207. forceUpdate(): void;
  96208. /**
  96209. * Gets the body that holds this impostor. Either its own, or its parent.
  96210. */
  96211. get physicsBody(): any;
  96212. /**
  96213. * Get the parent of the physics imposter
  96214. * @returns Physics imposter or null
  96215. */
  96216. get parent(): Nullable<PhysicsImpostor>;
  96217. /**
  96218. * Sets the parent of the physics imposter
  96219. */
  96220. set parent(value: Nullable<PhysicsImpostor>);
  96221. /**
  96222. * Set the physics body. Used mainly by the physics engine/plugin
  96223. */
  96224. set physicsBody(physicsBody: any);
  96225. /**
  96226. * Resets the update flags
  96227. */
  96228. resetUpdateFlags(): void;
  96229. /**
  96230. * Gets the object extend size
  96231. * @returns the object extend size
  96232. */
  96233. getObjectExtendSize(): Vector3;
  96234. /**
  96235. * Gets the object center
  96236. * @returns The object center
  96237. */
  96238. getObjectCenter(): Vector3;
  96239. /**
  96240. * Get a specific parameter from the options parameters
  96241. * @param paramName The object parameter name
  96242. * @returns The object parameter
  96243. */
  96244. getParam(paramName: string): any;
  96245. /**
  96246. * Sets a specific parameter in the options given to the physics plugin
  96247. * @param paramName The parameter name
  96248. * @param value The value of the parameter
  96249. */
  96250. setParam(paramName: string, value: number): void;
  96251. /**
  96252. * Specifically change the body's mass option. Won't recreate the physics body object
  96253. * @param mass The mass of the physics imposter
  96254. */
  96255. setMass(mass: number): void;
  96256. /**
  96257. * Gets the linear velocity
  96258. * @returns linear velocity or null
  96259. */
  96260. getLinearVelocity(): Nullable<Vector3>;
  96261. /**
  96262. * Sets the linear velocity
  96263. * @param velocity linear velocity or null
  96264. */
  96265. setLinearVelocity(velocity: Nullable<Vector3>): void;
  96266. /**
  96267. * Gets the angular velocity
  96268. * @returns angular velocity or null
  96269. */
  96270. getAngularVelocity(): Nullable<Vector3>;
  96271. /**
  96272. * Sets the angular velocity
  96273. * @param velocity The velocity or null
  96274. */
  96275. setAngularVelocity(velocity: Nullable<Vector3>): void;
  96276. /**
  96277. * Execute a function with the physics plugin native code
  96278. * Provide a function the will have two variables - the world object and the physics body object
  96279. * @param func The function to execute with the physics plugin native code
  96280. */
  96281. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  96282. /**
  96283. * Register a function that will be executed before the physics world is stepping forward
  96284. * @param func The function to execute before the physics world is stepped forward
  96285. */
  96286. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96287. /**
  96288. * Unregister a function that will be executed before the physics world is stepping forward
  96289. * @param func The function to execute before the physics world is stepped forward
  96290. */
  96291. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96292. /**
  96293. * Register a function that will be executed after the physics step
  96294. * @param func The function to execute after physics step
  96295. */
  96296. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96297. /**
  96298. * Unregisters a function that will be executed after the physics step
  96299. * @param func The function to execute after physics step
  96300. */
  96301. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96302. /**
  96303. * register a function that will be executed when this impostor collides against a different body
  96304. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  96305. * @param func Callback that is executed on collision
  96306. */
  96307. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  96308. /**
  96309. * Unregisters the physics imposter on contact
  96310. * @param collideAgainst The physics object to collide against
  96311. * @param func Callback to execute on collision
  96312. */
  96313. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  96314. private _tmpQuat;
  96315. private _tmpQuat2;
  96316. /**
  96317. * Get the parent rotation
  96318. * @returns The parent rotation
  96319. */
  96320. getParentsRotation(): Quaternion;
  96321. /**
  96322. * this function is executed by the physics engine.
  96323. */
  96324. beforeStep: () => void;
  96325. /**
  96326. * this function is executed by the physics engine
  96327. */
  96328. afterStep: () => void;
  96329. /**
  96330. * Legacy collision detection event support
  96331. */
  96332. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  96333. /**
  96334. * event and body object due to cannon's event-based architecture.
  96335. */
  96336. onCollide: (e: {
  96337. body: any;
  96338. }) => void;
  96339. /**
  96340. * Apply a force
  96341. * @param force The force to apply
  96342. * @param contactPoint The contact point for the force
  96343. * @returns The physics imposter
  96344. */
  96345. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96346. /**
  96347. * Apply an impulse
  96348. * @param force The impulse force
  96349. * @param contactPoint The contact point for the impulse force
  96350. * @returns The physics imposter
  96351. */
  96352. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96353. /**
  96354. * A help function to create a joint
  96355. * @param otherImpostor A physics imposter used to create a joint
  96356. * @param jointType The type of joint
  96357. * @param jointData The data for the joint
  96358. * @returns The physics imposter
  96359. */
  96360. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  96361. /**
  96362. * Add a joint to this impostor with a different impostor
  96363. * @param otherImpostor A physics imposter used to add a joint
  96364. * @param joint The joint to add
  96365. * @returns The physics imposter
  96366. */
  96367. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  96368. /**
  96369. * Add an anchor to a cloth impostor
  96370. * @param otherImpostor rigid impostor to anchor to
  96371. * @param width ratio across width from 0 to 1
  96372. * @param height ratio up height from 0 to 1
  96373. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  96374. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  96375. * @returns impostor the soft imposter
  96376. */
  96377. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96378. /**
  96379. * Add a hook to a rope impostor
  96380. * @param otherImpostor rigid impostor to anchor to
  96381. * @param length ratio across rope from 0 to 1
  96382. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  96383. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  96384. * @returns impostor the rope imposter
  96385. */
  96386. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96387. /**
  96388. * Will keep this body still, in a sleep mode.
  96389. * @returns the physics imposter
  96390. */
  96391. sleep(): PhysicsImpostor;
  96392. /**
  96393. * Wake the body up.
  96394. * @returns The physics imposter
  96395. */
  96396. wakeUp(): PhysicsImpostor;
  96397. /**
  96398. * Clones the physics imposter
  96399. * @param newObject The physics imposter clones to this physics-enabled object
  96400. * @returns A nullable physics imposter
  96401. */
  96402. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96403. /**
  96404. * Disposes the physics imposter
  96405. */
  96406. dispose(): void;
  96407. /**
  96408. * Sets the delta position
  96409. * @param position The delta position amount
  96410. */
  96411. setDeltaPosition(position: Vector3): void;
  96412. /**
  96413. * Sets the delta rotation
  96414. * @param rotation The delta rotation amount
  96415. */
  96416. setDeltaRotation(rotation: Quaternion): void;
  96417. /**
  96418. * Gets the box size of the physics imposter and stores the result in the input parameter
  96419. * @param result Stores the box size
  96420. * @returns The physics imposter
  96421. */
  96422. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  96423. /**
  96424. * Gets the radius of the physics imposter
  96425. * @returns Radius of the physics imposter
  96426. */
  96427. getRadius(): number;
  96428. /**
  96429. * Sync a bone with this impostor
  96430. * @param bone The bone to sync to the impostor.
  96431. * @param boneMesh The mesh that the bone is influencing.
  96432. * @param jointPivot The pivot of the joint / bone in local space.
  96433. * @param distToJoint Optional distance from the impostor to the joint.
  96434. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96435. */
  96436. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  96437. /**
  96438. * Sync impostor to a bone
  96439. * @param bone The bone that the impostor will be synced to.
  96440. * @param boneMesh The mesh that the bone is influencing.
  96441. * @param jointPivot The pivot of the joint / bone in local space.
  96442. * @param distToJoint Optional distance from the impostor to the joint.
  96443. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96444. * @param boneAxis Optional vector3 axis the bone is aligned with
  96445. */
  96446. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  96447. /**
  96448. * No-Imposter type
  96449. */
  96450. static NoImpostor: number;
  96451. /**
  96452. * Sphere-Imposter type
  96453. */
  96454. static SphereImpostor: number;
  96455. /**
  96456. * Box-Imposter type
  96457. */
  96458. static BoxImpostor: number;
  96459. /**
  96460. * Plane-Imposter type
  96461. */
  96462. static PlaneImpostor: number;
  96463. /**
  96464. * Mesh-imposter type
  96465. */
  96466. static MeshImpostor: number;
  96467. /**
  96468. * Capsule-Impostor type (Ammo.js plugin only)
  96469. */
  96470. static CapsuleImpostor: number;
  96471. /**
  96472. * Cylinder-Imposter type
  96473. */
  96474. static CylinderImpostor: number;
  96475. /**
  96476. * Particle-Imposter type
  96477. */
  96478. static ParticleImpostor: number;
  96479. /**
  96480. * Heightmap-Imposter type
  96481. */
  96482. static HeightmapImpostor: number;
  96483. /**
  96484. * ConvexHull-Impostor type (Ammo.js plugin only)
  96485. */
  96486. static ConvexHullImpostor: number;
  96487. /**
  96488. * Custom-Imposter type (Ammo.js plugin only)
  96489. */
  96490. static CustomImpostor: number;
  96491. /**
  96492. * Rope-Imposter type
  96493. */
  96494. static RopeImpostor: number;
  96495. /**
  96496. * Cloth-Imposter type
  96497. */
  96498. static ClothImpostor: number;
  96499. /**
  96500. * Softbody-Imposter type
  96501. */
  96502. static SoftbodyImpostor: number;
  96503. }
  96504. }
  96505. declare module BABYLON {
  96506. /**
  96507. * @hidden
  96508. **/
  96509. export class _CreationDataStorage {
  96510. closePath?: boolean;
  96511. closeArray?: boolean;
  96512. idx: number[];
  96513. dashSize: number;
  96514. gapSize: number;
  96515. path3D: Path3D;
  96516. pathArray: Vector3[][];
  96517. arc: number;
  96518. radius: number;
  96519. cap: number;
  96520. tessellation: number;
  96521. }
  96522. /**
  96523. * @hidden
  96524. **/
  96525. class _InstanceDataStorage {
  96526. visibleInstances: any;
  96527. batchCache: _InstancesBatch;
  96528. instancesBufferSize: number;
  96529. instancesBuffer: Nullable<Buffer>;
  96530. instancesData: Float32Array;
  96531. overridenInstanceCount: number;
  96532. isFrozen: boolean;
  96533. previousBatch: Nullable<_InstancesBatch>;
  96534. hardwareInstancedRendering: boolean;
  96535. sideOrientation: number;
  96536. manualUpdate: boolean;
  96537. }
  96538. /**
  96539. * @hidden
  96540. **/
  96541. export class _InstancesBatch {
  96542. mustReturn: boolean;
  96543. visibleInstances: Nullable<InstancedMesh[]>[];
  96544. renderSelf: boolean[];
  96545. hardwareInstancedRendering: boolean[];
  96546. }
  96547. /**
  96548. * Class used to represent renderable models
  96549. */
  96550. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  96551. /**
  96552. * Mesh side orientation : usually the external or front surface
  96553. */
  96554. static readonly FRONTSIDE: number;
  96555. /**
  96556. * Mesh side orientation : usually the internal or back surface
  96557. */
  96558. static readonly BACKSIDE: number;
  96559. /**
  96560. * Mesh side orientation : both internal and external or front and back surfaces
  96561. */
  96562. static readonly DOUBLESIDE: number;
  96563. /**
  96564. * Mesh side orientation : by default, `FRONTSIDE`
  96565. */
  96566. static readonly DEFAULTSIDE: number;
  96567. /**
  96568. * Mesh cap setting : no cap
  96569. */
  96570. static readonly NO_CAP: number;
  96571. /**
  96572. * Mesh cap setting : one cap at the beginning of the mesh
  96573. */
  96574. static readonly CAP_START: number;
  96575. /**
  96576. * Mesh cap setting : one cap at the end of the mesh
  96577. */
  96578. static readonly CAP_END: number;
  96579. /**
  96580. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  96581. */
  96582. static readonly CAP_ALL: number;
  96583. /**
  96584. * Mesh pattern setting : no flip or rotate
  96585. */
  96586. static readonly NO_FLIP: number;
  96587. /**
  96588. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  96589. */
  96590. static readonly FLIP_TILE: number;
  96591. /**
  96592. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  96593. */
  96594. static readonly ROTATE_TILE: number;
  96595. /**
  96596. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  96597. */
  96598. static readonly FLIP_ROW: number;
  96599. /**
  96600. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  96601. */
  96602. static readonly ROTATE_ROW: number;
  96603. /**
  96604. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  96605. */
  96606. static readonly FLIP_N_ROTATE_TILE: number;
  96607. /**
  96608. * Mesh pattern setting : rotate pattern and rotate
  96609. */
  96610. static readonly FLIP_N_ROTATE_ROW: number;
  96611. /**
  96612. * Mesh tile positioning : part tiles same on left/right or top/bottom
  96613. */
  96614. static readonly CENTER: number;
  96615. /**
  96616. * Mesh tile positioning : part tiles on left
  96617. */
  96618. static readonly LEFT: number;
  96619. /**
  96620. * Mesh tile positioning : part tiles on right
  96621. */
  96622. static readonly RIGHT: number;
  96623. /**
  96624. * Mesh tile positioning : part tiles on top
  96625. */
  96626. static readonly TOP: number;
  96627. /**
  96628. * Mesh tile positioning : part tiles on bottom
  96629. */
  96630. static readonly BOTTOM: number;
  96631. /**
  96632. * Gets the default side orientation.
  96633. * @param orientation the orientation to value to attempt to get
  96634. * @returns the default orientation
  96635. * @hidden
  96636. */
  96637. static _GetDefaultSideOrientation(orientation?: number): number;
  96638. private _internalMeshDataInfo;
  96639. /**
  96640. * An event triggered before rendering the mesh
  96641. */
  96642. get onBeforeRenderObservable(): Observable<Mesh>;
  96643. /**
  96644. * An event triggered before binding the mesh
  96645. */
  96646. get onBeforeBindObservable(): Observable<Mesh>;
  96647. /**
  96648. * An event triggered after rendering the mesh
  96649. */
  96650. get onAfterRenderObservable(): Observable<Mesh>;
  96651. /**
  96652. * An event triggered before drawing the mesh
  96653. */
  96654. get onBeforeDrawObservable(): Observable<Mesh>;
  96655. private _onBeforeDrawObserver;
  96656. /**
  96657. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  96658. */
  96659. set onBeforeDraw(callback: () => void);
  96660. get hasInstances(): boolean;
  96661. /**
  96662. * Gets the delay loading state of the mesh (when delay loading is turned on)
  96663. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  96664. */
  96665. delayLoadState: number;
  96666. /**
  96667. * Gets the list of instances created from this mesh
  96668. * it is not supposed to be modified manually.
  96669. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  96670. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  96671. */
  96672. instances: InstancedMesh[];
  96673. /**
  96674. * Gets the file containing delay loading data for this mesh
  96675. */
  96676. delayLoadingFile: string;
  96677. /** @hidden */
  96678. _binaryInfo: any;
  96679. /**
  96680. * User defined function used to change how LOD level selection is done
  96681. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96682. */
  96683. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  96684. /**
  96685. * Gets or sets the morph target manager
  96686. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96687. */
  96688. get morphTargetManager(): Nullable<MorphTargetManager>;
  96689. set morphTargetManager(value: Nullable<MorphTargetManager>);
  96690. /** @hidden */
  96691. _creationDataStorage: Nullable<_CreationDataStorage>;
  96692. /** @hidden */
  96693. _geometry: Nullable<Geometry>;
  96694. /** @hidden */
  96695. _delayInfo: Array<string>;
  96696. /** @hidden */
  96697. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  96698. /** @hidden */
  96699. _instanceDataStorage: _InstanceDataStorage;
  96700. private _effectiveMaterial;
  96701. /** @hidden */
  96702. _shouldGenerateFlatShading: boolean;
  96703. /** @hidden */
  96704. _originalBuilderSideOrientation: number;
  96705. /**
  96706. * Use this property to change the original side orientation defined at construction time
  96707. */
  96708. overrideMaterialSideOrientation: Nullable<number>;
  96709. /**
  96710. * Gets the source mesh (the one used to clone this one from)
  96711. */
  96712. get source(): Nullable<Mesh>;
  96713. /**
  96714. * Gets or sets a boolean indicating that this mesh does not use index buffer
  96715. */
  96716. get isUnIndexed(): boolean;
  96717. set isUnIndexed(value: boolean);
  96718. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  96719. get worldMatrixInstancedBuffer(): Float32Array;
  96720. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  96721. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  96722. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  96723. /**
  96724. * @constructor
  96725. * @param name The value used by scene.getMeshByName() to do a lookup.
  96726. * @param scene The scene to add this mesh to.
  96727. * @param parent The parent of this mesh, if it has one
  96728. * @param source An optional Mesh from which geometry is shared, cloned.
  96729. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96730. * When false, achieved by calling a clone(), also passing False.
  96731. * This will make creation of children, recursive.
  96732. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  96733. */
  96734. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  96735. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  96736. doNotInstantiate: boolean;
  96737. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  96738. /**
  96739. * Gets the class name
  96740. * @returns the string "Mesh".
  96741. */
  96742. getClassName(): string;
  96743. /** @hidden */
  96744. get _isMesh(): boolean;
  96745. /**
  96746. * Returns a description of this mesh
  96747. * @param fullDetails define if full details about this mesh must be used
  96748. * @returns a descriptive string representing this mesh
  96749. */
  96750. toString(fullDetails?: boolean): string;
  96751. /** @hidden */
  96752. _unBindEffect(): void;
  96753. /**
  96754. * Gets a boolean indicating if this mesh has LOD
  96755. */
  96756. get hasLODLevels(): boolean;
  96757. /**
  96758. * Gets the list of MeshLODLevel associated with the current mesh
  96759. * @returns an array of MeshLODLevel
  96760. */
  96761. getLODLevels(): MeshLODLevel[];
  96762. private _sortLODLevels;
  96763. /**
  96764. * Add a mesh as LOD level triggered at the given distance.
  96765. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96766. * @param distance The distance from the center of the object to show this level
  96767. * @param mesh The mesh to be added as LOD level (can be null)
  96768. * @return This mesh (for chaining)
  96769. */
  96770. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  96771. /**
  96772. * Returns the LOD level mesh at the passed distance or null if not found.
  96773. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96774. * @param distance The distance from the center of the object to show this level
  96775. * @returns a Mesh or `null`
  96776. */
  96777. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  96778. /**
  96779. * Remove a mesh from the LOD array
  96780. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96781. * @param mesh defines the mesh to be removed
  96782. * @return This mesh (for chaining)
  96783. */
  96784. removeLODLevel(mesh: Mesh): Mesh;
  96785. /**
  96786. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  96787. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  96788. * @param camera defines the camera to use to compute distance
  96789. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  96790. * @return This mesh (for chaining)
  96791. */
  96792. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  96793. /**
  96794. * Gets the mesh internal Geometry object
  96795. */
  96796. get geometry(): Nullable<Geometry>;
  96797. /**
  96798. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  96799. * @returns the total number of vertices
  96800. */
  96801. getTotalVertices(): number;
  96802. /**
  96803. * Returns the content of an associated vertex buffer
  96804. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  96805. * - VertexBuffer.PositionKind
  96806. * - VertexBuffer.UVKind
  96807. * - VertexBuffer.UV2Kind
  96808. * - VertexBuffer.UV3Kind
  96809. * - VertexBuffer.UV4Kind
  96810. * - VertexBuffer.UV5Kind
  96811. * - VertexBuffer.UV6Kind
  96812. * - VertexBuffer.ColorKind
  96813. * - VertexBuffer.MatricesIndicesKind
  96814. * - VertexBuffer.MatricesIndicesExtraKind
  96815. * - VertexBuffer.MatricesWeightsKind
  96816. * - VertexBuffer.MatricesWeightsExtraKind
  96817. * @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
  96818. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  96819. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  96820. */
  96821. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96822. /**
  96823. * Returns the mesh VertexBuffer object from the requested `kind`
  96824. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  96825. * - VertexBuffer.PositionKind
  96826. * - VertexBuffer.NormalKind
  96827. * - VertexBuffer.UVKind
  96828. * - VertexBuffer.UV2Kind
  96829. * - VertexBuffer.UV3Kind
  96830. * - VertexBuffer.UV4Kind
  96831. * - VertexBuffer.UV5Kind
  96832. * - VertexBuffer.UV6Kind
  96833. * - VertexBuffer.ColorKind
  96834. * - VertexBuffer.MatricesIndicesKind
  96835. * - VertexBuffer.MatricesIndicesExtraKind
  96836. * - VertexBuffer.MatricesWeightsKind
  96837. * - VertexBuffer.MatricesWeightsExtraKind
  96838. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  96839. */
  96840. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96841. /**
  96842. * Tests if a specific vertex buffer is associated with this mesh
  96843. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  96844. * - VertexBuffer.PositionKind
  96845. * - VertexBuffer.NormalKind
  96846. * - VertexBuffer.UVKind
  96847. * - VertexBuffer.UV2Kind
  96848. * - VertexBuffer.UV3Kind
  96849. * - VertexBuffer.UV4Kind
  96850. * - VertexBuffer.UV5Kind
  96851. * - VertexBuffer.UV6Kind
  96852. * - VertexBuffer.ColorKind
  96853. * - VertexBuffer.MatricesIndicesKind
  96854. * - VertexBuffer.MatricesIndicesExtraKind
  96855. * - VertexBuffer.MatricesWeightsKind
  96856. * - VertexBuffer.MatricesWeightsExtraKind
  96857. * @returns a boolean
  96858. */
  96859. isVerticesDataPresent(kind: string): boolean;
  96860. /**
  96861. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  96862. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  96863. * - VertexBuffer.PositionKind
  96864. * - VertexBuffer.UVKind
  96865. * - VertexBuffer.UV2Kind
  96866. * - VertexBuffer.UV3Kind
  96867. * - VertexBuffer.UV4Kind
  96868. * - VertexBuffer.UV5Kind
  96869. * - VertexBuffer.UV6Kind
  96870. * - VertexBuffer.ColorKind
  96871. * - VertexBuffer.MatricesIndicesKind
  96872. * - VertexBuffer.MatricesIndicesExtraKind
  96873. * - VertexBuffer.MatricesWeightsKind
  96874. * - VertexBuffer.MatricesWeightsExtraKind
  96875. * @returns a boolean
  96876. */
  96877. isVertexBufferUpdatable(kind: string): boolean;
  96878. /**
  96879. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  96880. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  96881. * - VertexBuffer.PositionKind
  96882. * - VertexBuffer.NormalKind
  96883. * - VertexBuffer.UVKind
  96884. * - VertexBuffer.UV2Kind
  96885. * - VertexBuffer.UV3Kind
  96886. * - VertexBuffer.UV4Kind
  96887. * - VertexBuffer.UV5Kind
  96888. * - VertexBuffer.UV6Kind
  96889. * - VertexBuffer.ColorKind
  96890. * - VertexBuffer.MatricesIndicesKind
  96891. * - VertexBuffer.MatricesIndicesExtraKind
  96892. * - VertexBuffer.MatricesWeightsKind
  96893. * - VertexBuffer.MatricesWeightsExtraKind
  96894. * @returns an array of strings
  96895. */
  96896. getVerticesDataKinds(): string[];
  96897. /**
  96898. * Returns a positive integer : the total number of indices in this mesh geometry.
  96899. * @returns the numner of indices or zero if the mesh has no geometry.
  96900. */
  96901. getTotalIndices(): number;
  96902. /**
  96903. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96904. * @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.
  96905. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96906. * @returns the indices array or an empty array if the mesh has no geometry
  96907. */
  96908. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96909. get isBlocked(): boolean;
  96910. /**
  96911. * Determine if the current mesh is ready to be rendered
  96912. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96913. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  96914. * @returns true if all associated assets are ready (material, textures, shaders)
  96915. */
  96916. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  96917. /**
  96918. * 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.
  96919. */
  96920. get areNormalsFrozen(): boolean;
  96921. /**
  96922. * 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.
  96923. * @returns the current mesh
  96924. */
  96925. freezeNormals(): Mesh;
  96926. /**
  96927. * 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
  96928. * @returns the current mesh
  96929. */
  96930. unfreezeNormals(): Mesh;
  96931. /**
  96932. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  96933. */
  96934. set overridenInstanceCount(count: number);
  96935. /** @hidden */
  96936. _preActivate(): Mesh;
  96937. /** @hidden */
  96938. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96939. /** @hidden */
  96940. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  96941. /**
  96942. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96943. * This means the mesh underlying bounding box and sphere are recomputed.
  96944. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96945. * @returns the current mesh
  96946. */
  96947. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  96948. /** @hidden */
  96949. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  96950. /**
  96951. * This function will subdivide the mesh into multiple submeshes
  96952. * @param count defines the expected number of submeshes
  96953. */
  96954. subdivide(count: number): void;
  96955. /**
  96956. * Copy a FloatArray into a specific associated vertex buffer
  96957. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96958. * - VertexBuffer.PositionKind
  96959. * - VertexBuffer.UVKind
  96960. * - VertexBuffer.UV2Kind
  96961. * - VertexBuffer.UV3Kind
  96962. * - VertexBuffer.UV4Kind
  96963. * - VertexBuffer.UV5Kind
  96964. * - VertexBuffer.UV6Kind
  96965. * - VertexBuffer.ColorKind
  96966. * - VertexBuffer.MatricesIndicesKind
  96967. * - VertexBuffer.MatricesIndicesExtraKind
  96968. * - VertexBuffer.MatricesWeightsKind
  96969. * - VertexBuffer.MatricesWeightsExtraKind
  96970. * @param data defines the data source
  96971. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  96972. * @param stride defines the data stride size (can be null)
  96973. * @returns the current mesh
  96974. */
  96975. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96976. /**
  96977. * Delete a vertex buffer associated with this mesh
  96978. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  96979. * - VertexBuffer.PositionKind
  96980. * - VertexBuffer.UVKind
  96981. * - VertexBuffer.UV2Kind
  96982. * - VertexBuffer.UV3Kind
  96983. * - VertexBuffer.UV4Kind
  96984. * - VertexBuffer.UV5Kind
  96985. * - VertexBuffer.UV6Kind
  96986. * - VertexBuffer.ColorKind
  96987. * - VertexBuffer.MatricesIndicesKind
  96988. * - VertexBuffer.MatricesIndicesExtraKind
  96989. * - VertexBuffer.MatricesWeightsKind
  96990. * - VertexBuffer.MatricesWeightsExtraKind
  96991. */
  96992. removeVerticesData(kind: string): void;
  96993. /**
  96994. * Flags an associated vertex buffer as updatable
  96995. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  96996. * - VertexBuffer.PositionKind
  96997. * - VertexBuffer.UVKind
  96998. * - VertexBuffer.UV2Kind
  96999. * - VertexBuffer.UV3Kind
  97000. * - VertexBuffer.UV4Kind
  97001. * - VertexBuffer.UV5Kind
  97002. * - VertexBuffer.UV6Kind
  97003. * - VertexBuffer.ColorKind
  97004. * - VertexBuffer.MatricesIndicesKind
  97005. * - VertexBuffer.MatricesIndicesExtraKind
  97006. * - VertexBuffer.MatricesWeightsKind
  97007. * - VertexBuffer.MatricesWeightsExtraKind
  97008. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97009. */
  97010. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97011. /**
  97012. * Sets the mesh global Vertex Buffer
  97013. * @param buffer defines the buffer to use
  97014. * @returns the current mesh
  97015. */
  97016. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97017. /**
  97018. * Update a specific associated vertex buffer
  97019. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97020. * - VertexBuffer.PositionKind
  97021. * - VertexBuffer.UVKind
  97022. * - VertexBuffer.UV2Kind
  97023. * - VertexBuffer.UV3Kind
  97024. * - VertexBuffer.UV4Kind
  97025. * - VertexBuffer.UV5Kind
  97026. * - VertexBuffer.UV6Kind
  97027. * - VertexBuffer.ColorKind
  97028. * - VertexBuffer.MatricesIndicesKind
  97029. * - VertexBuffer.MatricesIndicesExtraKind
  97030. * - VertexBuffer.MatricesWeightsKind
  97031. * - VertexBuffer.MatricesWeightsExtraKind
  97032. * @param data defines the data source
  97033. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97034. * @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)
  97035. * @returns the current mesh
  97036. */
  97037. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97038. /**
  97039. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97040. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97041. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97042. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97043. * @returns the current mesh
  97044. */
  97045. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97046. /**
  97047. * Creates a un-shared specific occurence of the geometry for the mesh.
  97048. * @returns the current mesh
  97049. */
  97050. makeGeometryUnique(): Mesh;
  97051. /**
  97052. * Set the index buffer of this mesh
  97053. * @param indices defines the source data
  97054. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97055. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97056. * @returns the current mesh
  97057. */
  97058. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97059. /**
  97060. * Update the current index buffer
  97061. * @param indices defines the source data
  97062. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97063. * @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)
  97064. * @returns the current mesh
  97065. */
  97066. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97067. /**
  97068. * Invert the geometry to move from a right handed system to a left handed one.
  97069. * @returns the current mesh
  97070. */
  97071. toLeftHanded(): Mesh;
  97072. /** @hidden */
  97073. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97074. /** @hidden */
  97075. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97076. /**
  97077. * Registers for this mesh a javascript function called just before the rendering process
  97078. * @param func defines the function to call before rendering this mesh
  97079. * @returns the current mesh
  97080. */
  97081. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97082. /**
  97083. * Disposes a previously registered javascript function called before the rendering
  97084. * @param func defines the function to remove
  97085. * @returns the current mesh
  97086. */
  97087. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97088. /**
  97089. * Registers for this mesh a javascript function called just after the rendering is complete
  97090. * @param func defines the function to call after rendering this mesh
  97091. * @returns the current mesh
  97092. */
  97093. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97094. /**
  97095. * Disposes a previously registered javascript function called after the rendering.
  97096. * @param func defines the function to remove
  97097. * @returns the current mesh
  97098. */
  97099. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97100. /** @hidden */
  97101. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97102. /** @hidden */
  97103. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97104. /** @hidden */
  97105. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97106. /** @hidden */
  97107. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97108. /** @hidden */
  97109. _rebuild(): void;
  97110. /** @hidden */
  97111. _freeze(): void;
  97112. /** @hidden */
  97113. _unFreeze(): void;
  97114. /**
  97115. * 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
  97116. * @param subMesh defines the subMesh to render
  97117. * @param enableAlphaMode defines if alpha mode can be changed
  97118. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97119. * @returns the current mesh
  97120. */
  97121. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97122. private _onBeforeDraw;
  97123. /**
  97124. * Renormalize the mesh and patch it up if there are no weights
  97125. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  97126. * However in the case of zero weights then we set just a single influence to 1.
  97127. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  97128. */
  97129. cleanMatrixWeights(): void;
  97130. private normalizeSkinFourWeights;
  97131. private normalizeSkinWeightsAndExtra;
  97132. /**
  97133. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  97134. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  97135. * the user know there was an issue with importing the mesh
  97136. * @returns a validation object with skinned, valid and report string
  97137. */
  97138. validateSkinning(): {
  97139. skinned: boolean;
  97140. valid: boolean;
  97141. report: string;
  97142. };
  97143. /** @hidden */
  97144. _checkDelayState(): Mesh;
  97145. private _queueLoad;
  97146. /**
  97147. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97148. * A mesh is in the frustum if its bounding box intersects the frustum
  97149. * @param frustumPlanes defines the frustum to test
  97150. * @returns true if the mesh is in the frustum planes
  97151. */
  97152. isInFrustum(frustumPlanes: Plane[]): boolean;
  97153. /**
  97154. * Sets the mesh material by the material or multiMaterial `id` property
  97155. * @param id is a string identifying the material or the multiMaterial
  97156. * @returns the current mesh
  97157. */
  97158. setMaterialByID(id: string): Mesh;
  97159. /**
  97160. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  97161. * @returns an array of IAnimatable
  97162. */
  97163. getAnimatables(): IAnimatable[];
  97164. /**
  97165. * Modifies the mesh geometry according to the passed transformation matrix.
  97166. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  97167. * The mesh normals are modified using the same transformation.
  97168. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97169. * @param transform defines the transform matrix to use
  97170. * @see http://doc.babylonjs.com/resources/baking_transformations
  97171. * @returns the current mesh
  97172. */
  97173. bakeTransformIntoVertices(transform: Matrix): Mesh;
  97174. /**
  97175. * Modifies the mesh geometry according to its own current World Matrix.
  97176. * The mesh World Matrix is then reset.
  97177. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  97178. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97179. * @see http://doc.babylonjs.com/resources/baking_transformations
  97180. * @returns the current mesh
  97181. */
  97182. bakeCurrentTransformIntoVertices(): Mesh;
  97183. /** @hidden */
  97184. get _positions(): Nullable<Vector3[]>;
  97185. /** @hidden */
  97186. _resetPointsArrayCache(): Mesh;
  97187. /** @hidden */
  97188. _generatePointsArray(): boolean;
  97189. /**
  97190. * Returns a new Mesh object generated from the current mesh properties.
  97191. * This method must not get confused with createInstance()
  97192. * @param name is a string, the name given to the new mesh
  97193. * @param newParent can be any Node object (default `null`)
  97194. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  97195. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  97196. * @returns a new mesh
  97197. */
  97198. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  97199. /**
  97200. * Releases resources associated with this mesh.
  97201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97203. */
  97204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97205. /** @hidden */
  97206. _disposeInstanceSpecificData(): void;
  97207. /**
  97208. * Modifies the mesh geometry according to a displacement map.
  97209. * 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.
  97210. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97211. * @param url is a string, the URL from the image file is to be downloaded.
  97212. * @param minHeight is the lower limit of the displacement.
  97213. * @param maxHeight is the upper limit of the displacement.
  97214. * @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.
  97215. * @param uvOffset is an optional vector2 used to offset UV.
  97216. * @param uvScale is an optional vector2 used to scale UV.
  97217. * @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.
  97218. * @returns the Mesh.
  97219. */
  97220. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97221. /**
  97222. * Modifies the mesh geometry according to a displacementMap buffer.
  97223. * 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.
  97224. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97225. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  97226. * @param heightMapWidth is the width of the buffer image.
  97227. * @param heightMapHeight is the height of the buffer image.
  97228. * @param minHeight is the lower limit of the displacement.
  97229. * @param maxHeight is the upper limit of the displacement.
  97230. * @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.
  97231. * @param uvOffset is an optional vector2 used to offset UV.
  97232. * @param uvScale is an optional vector2 used to scale UV.
  97233. * @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.
  97234. * @returns the Mesh.
  97235. */
  97236. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97237. /**
  97238. * Modify the mesh to get a flat shading rendering.
  97239. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  97240. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  97241. * @returns current mesh
  97242. */
  97243. convertToFlatShadedMesh(): Mesh;
  97244. /**
  97245. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  97246. * In other words, more vertices, no more indices and a single bigger VBO.
  97247. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  97248. * @returns current mesh
  97249. */
  97250. convertToUnIndexedMesh(): Mesh;
  97251. /**
  97252. * Inverses facet orientations.
  97253. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97254. * @param flipNormals will also inverts the normals
  97255. * @returns current mesh
  97256. */
  97257. flipFaces(flipNormals?: boolean): Mesh;
  97258. /**
  97259. * Increase the number of facets and hence vertices in a mesh
  97260. * Vertex normals are interpolated from existing vertex normals
  97261. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97262. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  97263. */
  97264. increaseVertices(numberPerEdge: number): void;
  97265. /**
  97266. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  97267. * This will undo any application of covertToFlatShadedMesh
  97268. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97269. */
  97270. forceSharedVertices(): void;
  97271. /** @hidden */
  97272. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  97273. /** @hidden */
  97274. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  97275. /**
  97276. * Creates a new InstancedMesh object from the mesh model.
  97277. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97278. * @param name defines the name of the new instance
  97279. * @returns a new InstancedMesh
  97280. */
  97281. createInstance(name: string): InstancedMesh;
  97282. /**
  97283. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  97284. * After this call, all the mesh instances have the same submeshes than the current mesh.
  97285. * @returns the current mesh
  97286. */
  97287. synchronizeInstances(): Mesh;
  97288. /**
  97289. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  97290. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  97291. * This should be used together with the simplification to avoid disappearing triangles.
  97292. * @param successCallback an optional success callback to be called after the optimization finished.
  97293. * @returns the current mesh
  97294. */
  97295. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  97296. /**
  97297. * Serialize current mesh
  97298. * @param serializationObject defines the object which will receive the serialization data
  97299. */
  97300. serialize(serializationObject: any): void;
  97301. /** @hidden */
  97302. _syncGeometryWithMorphTargetManager(): void;
  97303. /** @hidden */
  97304. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  97305. /**
  97306. * Returns a new Mesh object parsed from the source provided.
  97307. * @param parsedMesh is the source
  97308. * @param scene defines the hosting scene
  97309. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  97310. * @returns a new Mesh
  97311. */
  97312. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  97313. /**
  97314. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  97315. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97316. * @param name defines the name of the mesh to create
  97317. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  97318. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  97319. * @param closePath creates a seam between the first and the last points of each path of the path array
  97320. * @param offset is taken in account only if the `pathArray` is containing a single path
  97321. * @param scene defines the hosting scene
  97322. * @param updatable defines if the mesh must be flagged as updatable
  97323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97324. * @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)
  97325. * @returns a new Mesh
  97326. */
  97327. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97328. /**
  97329. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  97330. * @param name defines the name of the mesh to create
  97331. * @param radius sets the radius size (float) of the polygon (default 0.5)
  97332. * @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
  97333. * @param scene defines the hosting scene
  97334. * @param updatable defines if the mesh must be flagged as updatable
  97335. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97336. * @returns a new Mesh
  97337. */
  97338. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97339. /**
  97340. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  97341. * @param name defines the name of the mesh to create
  97342. * @param size sets the size (float) of each box side (default 1)
  97343. * @param scene defines the hosting scene
  97344. * @param updatable defines if the mesh must be flagged as updatable
  97345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97346. * @returns a new Mesh
  97347. */
  97348. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97349. /**
  97350. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  97351. * @param name defines the name of the mesh to create
  97352. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97353. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97354. * @param scene defines the hosting scene
  97355. * @param updatable defines if the mesh must be flagged as updatable
  97356. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97357. * @returns a new Mesh
  97358. */
  97359. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97360. /**
  97361. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  97362. * @param name defines the name of the mesh to create
  97363. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97364. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97365. * @param scene defines the hosting scene
  97366. * @returns a new Mesh
  97367. */
  97368. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  97369. /**
  97370. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  97371. * @param name defines the name of the mesh to create
  97372. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  97373. * @param diameterTop set the top cap diameter (floats, default 1)
  97374. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  97375. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  97376. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  97377. * @param scene defines the hosting scene
  97378. * @param updatable defines if the mesh must be flagged as updatable
  97379. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97380. * @returns a new Mesh
  97381. */
  97382. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  97383. /**
  97384. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  97385. * @param name defines the name of the mesh to create
  97386. * @param diameter sets the diameter size (float) of the torus (default 1)
  97387. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  97388. * @param tessellation sets the number of torus sides (postive integer, default 16)
  97389. * @param scene defines the hosting scene
  97390. * @param updatable defines if the mesh must be flagged as updatable
  97391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97392. * @returns a new Mesh
  97393. */
  97394. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97395. /**
  97396. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  97397. * @param name defines the name of the mesh to create
  97398. * @param radius sets the global radius size (float) of the torus knot (default 2)
  97399. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  97400. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  97401. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  97402. * @param p the number of windings on X axis (positive integers, default 2)
  97403. * @param q the number of windings on Y axis (positive integers, default 3)
  97404. * @param scene defines the hosting scene
  97405. * @param updatable defines if the mesh must be flagged as updatable
  97406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97407. * @returns a new Mesh
  97408. */
  97409. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97410. /**
  97411. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  97412. * @param name defines the name of the mesh to create
  97413. * @param points is an array successive Vector3
  97414. * @param scene defines the hosting scene
  97415. * @param updatable defines if the mesh must be flagged as updatable
  97416. * @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).
  97417. * @returns a new Mesh
  97418. */
  97419. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  97420. /**
  97421. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  97422. * @param name defines the name of the mesh to create
  97423. * @param points is an array successive Vector3
  97424. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  97425. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97426. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  97427. * @param scene defines the hosting scene
  97428. * @param updatable defines if the mesh must be flagged as updatable
  97429. * @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)
  97430. * @returns a new Mesh
  97431. */
  97432. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  97433. /**
  97434. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  97435. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  97436. * 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.
  97437. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97438. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97439. * Remember you can only change the shape positions, not their number when updating a polygon.
  97440. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  97441. * @param name defines the name of the mesh to create
  97442. * @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
  97443. * @param scene defines the hosting scene
  97444. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97445. * @param updatable defines if the mesh must be flagged as updatable
  97446. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97447. * @param earcutInjection can be used to inject your own earcut reference
  97448. * @returns a new Mesh
  97449. */
  97450. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97451. /**
  97452. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  97453. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  97454. * @param name defines the name of the mesh to create
  97455. * @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
  97456. * @param depth defines the height of extrusion
  97457. * @param scene defines the hosting scene
  97458. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97459. * @param updatable defines if the mesh must be flagged as updatable
  97460. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97461. * @param earcutInjection can be used to inject your own earcut reference
  97462. * @returns a new Mesh
  97463. */
  97464. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97465. /**
  97466. * Creates an extruded shape mesh.
  97467. * 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
  97468. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97469. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97470. * @param name defines the name of the mesh to create
  97471. * @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
  97472. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97473. * @param scale is the value to scale the shape
  97474. * @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
  97475. * @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
  97476. * @param scene defines the hosting scene
  97477. * @param updatable defines if the mesh must be flagged as updatable
  97478. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97479. * @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)
  97480. * @returns a new Mesh
  97481. */
  97482. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97483. /**
  97484. * Creates an custom extruded shape mesh.
  97485. * The custom extrusion is a parametric shape.
  97486. * It has no predefined shape. Its final shape will depend on the input parameters.
  97487. * Please consider using the same method from the MeshBuilder class instead
  97488. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97489. * @param name defines the name of the mesh to create
  97490. * @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
  97491. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97492. * @param scaleFunction is a custom Javascript function called on each path point
  97493. * @param rotationFunction is a custom Javascript function called on each path point
  97494. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  97495. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  97496. * @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
  97497. * @param scene defines the hosting scene
  97498. * @param updatable defines if the mesh must be flagged as updatable
  97499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97500. * @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)
  97501. * @returns a new Mesh
  97502. */
  97503. 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;
  97504. /**
  97505. * Creates lathe mesh.
  97506. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  97507. * Please consider using the same method from the MeshBuilder class instead
  97508. * @param name defines the name of the mesh to create
  97509. * @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
  97510. * @param radius is the radius value of the lathe
  97511. * @param tessellation is the side number of the lathe.
  97512. * @param scene defines the hosting scene
  97513. * @param updatable defines if the mesh must be flagged as updatable
  97514. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97515. * @returns a new Mesh
  97516. */
  97517. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97518. /**
  97519. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  97520. * @param name defines the name of the mesh to create
  97521. * @param size sets the size (float) of both sides of the plane at once (default 1)
  97522. * @param scene defines the hosting scene
  97523. * @param updatable defines if the mesh must be flagged as updatable
  97524. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97525. * @returns a new Mesh
  97526. */
  97527. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97528. /**
  97529. * Creates a ground mesh.
  97530. * Please consider using the same method from the MeshBuilder class instead
  97531. * @param name defines the name of the mesh to create
  97532. * @param width set the width of the ground
  97533. * @param height set the height of the ground
  97534. * @param subdivisions sets the number of subdivisions per side
  97535. * @param scene defines the hosting scene
  97536. * @param updatable defines if the mesh must be flagged as updatable
  97537. * @returns a new Mesh
  97538. */
  97539. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  97540. /**
  97541. * Creates a tiled ground mesh.
  97542. * Please consider using the same method from the MeshBuilder class instead
  97543. * @param name defines the name of the mesh to create
  97544. * @param xmin set the ground minimum X coordinate
  97545. * @param zmin set the ground minimum Y coordinate
  97546. * @param xmax set the ground maximum X coordinate
  97547. * @param zmax set the ground maximum Z coordinate
  97548. * @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
  97549. * @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
  97550. * @param scene defines the hosting scene
  97551. * @param updatable defines if the mesh must be flagged as updatable
  97552. * @returns a new Mesh
  97553. */
  97554. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  97555. w: number;
  97556. h: number;
  97557. }, precision: {
  97558. w: number;
  97559. h: number;
  97560. }, scene: Scene, updatable?: boolean): Mesh;
  97561. /**
  97562. * Creates a ground mesh from a height map.
  97563. * Please consider using the same method from the MeshBuilder class instead
  97564. * @see http://doc.babylonjs.com/babylon101/height_map
  97565. * @param name defines the name of the mesh to create
  97566. * @param url sets the URL of the height map image resource
  97567. * @param width set the ground width size
  97568. * @param height set the ground height size
  97569. * @param subdivisions sets the number of subdivision per side
  97570. * @param minHeight is the minimum altitude on the ground
  97571. * @param maxHeight is the maximum altitude on the ground
  97572. * @param scene defines the hosting scene
  97573. * @param updatable defines if the mesh must be flagged as updatable
  97574. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  97575. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97576. * @returns a new Mesh
  97577. */
  97578. 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;
  97579. /**
  97580. * Creates a tube mesh.
  97581. * The tube is a parametric shape.
  97582. * It has no predefined shape. Its final shape will depend on the input parameters.
  97583. * Please consider using the same method from the MeshBuilder class instead
  97584. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97585. * @param name defines the name of the mesh to create
  97586. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  97587. * @param radius sets the tube radius size
  97588. * @param tessellation is the number of sides on the tubular surface
  97589. * @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
  97590. * @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
  97591. * @param scene defines the hosting scene
  97592. * @param updatable defines if the mesh must be flagged as updatable
  97593. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97594. * @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)
  97595. * @returns a new Mesh
  97596. */
  97597. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  97598. (i: number, distance: number): number;
  97599. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97600. /**
  97601. * Creates a polyhedron mesh.
  97602. * Please consider using the same method from the MeshBuilder class instead.
  97603. * * 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
  97604. * * The parameter `size` (positive float, default 1) sets the polygon size
  97605. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97606. * * 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`
  97607. * * 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
  97608. * * 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)`)
  97609. * * 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
  97610. * * 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
  97611. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97612. * * If you create a double-sided mesh, you can choose what parts of 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
  97613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97614. * @param name defines the name of the mesh to create
  97615. * @param options defines the options used to create the mesh
  97616. * @param scene defines the hosting scene
  97617. * @returns a new Mesh
  97618. */
  97619. static CreatePolyhedron(name: string, options: {
  97620. type?: number;
  97621. size?: number;
  97622. sizeX?: number;
  97623. sizeY?: number;
  97624. sizeZ?: number;
  97625. custom?: any;
  97626. faceUV?: Vector4[];
  97627. faceColors?: Color4[];
  97628. updatable?: boolean;
  97629. sideOrientation?: number;
  97630. }, scene: Scene): Mesh;
  97631. /**
  97632. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  97633. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  97634. * * 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`)
  97635. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  97636. * * 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
  97637. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97638. * * If you create a double-sided mesh, you can choose what parts of 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
  97639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97640. * @param name defines the name of the mesh
  97641. * @param options defines the options used to create the mesh
  97642. * @param scene defines the hosting scene
  97643. * @returns a new Mesh
  97644. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  97645. */
  97646. static CreateIcoSphere(name: string, options: {
  97647. radius?: number;
  97648. flat?: boolean;
  97649. subdivisions?: number;
  97650. sideOrientation?: number;
  97651. updatable?: boolean;
  97652. }, scene: Scene): Mesh;
  97653. /**
  97654. * Creates a decal mesh.
  97655. * Please consider using the same method from the MeshBuilder class instead.
  97656. * A decal is a mesh usually applied as a model onto the surface of another mesh
  97657. * @param name defines the name of the mesh
  97658. * @param sourceMesh defines the mesh receiving the decal
  97659. * @param position sets the position of the decal in world coordinates
  97660. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  97661. * @param size sets the decal scaling
  97662. * @param angle sets the angle to rotate the decal
  97663. * @returns a new Mesh
  97664. */
  97665. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  97666. /**
  97667. * Prepare internal position array for software CPU skinning
  97668. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  97669. */
  97670. setPositionsForCPUSkinning(): Float32Array;
  97671. /**
  97672. * Prepare internal normal array for software CPU skinning
  97673. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  97674. */
  97675. setNormalsForCPUSkinning(): Float32Array;
  97676. /**
  97677. * Updates the vertex buffer by applying transformation from the bones
  97678. * @param skeleton defines the skeleton to apply to current mesh
  97679. * @returns the current mesh
  97680. */
  97681. applySkeleton(skeleton: Skeleton): Mesh;
  97682. /**
  97683. * 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
  97684. * @param meshes defines the list of meshes to scan
  97685. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  97686. */
  97687. static MinMax(meshes: AbstractMesh[]): {
  97688. min: Vector3;
  97689. max: Vector3;
  97690. };
  97691. /**
  97692. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  97693. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  97694. * @returns a vector3
  97695. */
  97696. static Center(meshesOrMinMaxVector: {
  97697. min: Vector3;
  97698. max: Vector3;
  97699. } | AbstractMesh[]): Vector3;
  97700. /**
  97701. * Merge the array of meshes into a single mesh for performance reasons.
  97702. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  97703. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  97704. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  97705. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  97706. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  97707. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  97708. * @returns a new mesh
  97709. */
  97710. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  97711. /** @hidden */
  97712. addInstance(instance: InstancedMesh): void;
  97713. /** @hidden */
  97714. removeInstance(instance: InstancedMesh): void;
  97715. }
  97716. }
  97717. declare module BABYLON {
  97718. /**
  97719. * This is the base class of all the camera used in the application.
  97720. * @see http://doc.babylonjs.com/features/cameras
  97721. */
  97722. export class Camera extends Node {
  97723. /** @hidden */
  97724. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  97725. /**
  97726. * This is the default projection mode used by the cameras.
  97727. * It helps recreating a feeling of perspective and better appreciate depth.
  97728. * This is the best way to simulate real life cameras.
  97729. */
  97730. static readonly PERSPECTIVE_CAMERA: number;
  97731. /**
  97732. * This helps creating camera with an orthographic mode.
  97733. * 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.
  97734. */
  97735. static readonly ORTHOGRAPHIC_CAMERA: number;
  97736. /**
  97737. * This is the default FOV mode for perspective cameras.
  97738. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  97739. */
  97740. static readonly FOVMODE_VERTICAL_FIXED: number;
  97741. /**
  97742. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  97743. */
  97744. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  97745. /**
  97746. * This specifies ther is no need for a camera rig.
  97747. * Basically only one eye is rendered corresponding to the camera.
  97748. */
  97749. static readonly RIG_MODE_NONE: number;
  97750. /**
  97751. * Simulates a camera Rig with one blue eye and one red eye.
  97752. * This can be use with 3d blue and red glasses.
  97753. */
  97754. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  97755. /**
  97756. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  97757. */
  97758. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  97759. /**
  97760. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  97761. */
  97762. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  97763. /**
  97764. * Defines that both eyes of the camera will be rendered over under each other.
  97765. */
  97766. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  97767. /**
  97768. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  97769. */
  97770. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  97771. /**
  97772. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  97773. */
  97774. static readonly RIG_MODE_VR: number;
  97775. /**
  97776. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  97777. */
  97778. static readonly RIG_MODE_WEBVR: number;
  97779. /**
  97780. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  97781. */
  97782. static readonly RIG_MODE_CUSTOM: number;
  97783. /**
  97784. * Defines if by default attaching controls should prevent the default javascript event to continue.
  97785. */
  97786. static ForceAttachControlToAlwaysPreventDefault: boolean;
  97787. /**
  97788. * Define the input manager associated with the camera.
  97789. */
  97790. inputs: CameraInputsManager<Camera>;
  97791. /** @hidden */
  97792. _position: Vector3;
  97793. /**
  97794. * Define the current local position of the camera in the scene
  97795. */
  97796. get position(): Vector3;
  97797. set position(newPosition: Vector3);
  97798. /**
  97799. * The vector the camera should consider as up.
  97800. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  97801. */
  97802. upVector: Vector3;
  97803. /**
  97804. * Define the current limit on the left side for an orthographic camera
  97805. * In scene unit
  97806. */
  97807. orthoLeft: Nullable<number>;
  97808. /**
  97809. * Define the current limit on the right side for an orthographic camera
  97810. * In scene unit
  97811. */
  97812. orthoRight: Nullable<number>;
  97813. /**
  97814. * Define the current limit on the bottom side for an orthographic camera
  97815. * In scene unit
  97816. */
  97817. orthoBottom: Nullable<number>;
  97818. /**
  97819. * Define the current limit on the top side for an orthographic camera
  97820. * In scene unit
  97821. */
  97822. orthoTop: Nullable<number>;
  97823. /**
  97824. * Field Of View is set in Radians. (default is 0.8)
  97825. */
  97826. fov: number;
  97827. /**
  97828. * Define the minimum distance the camera can see from.
  97829. * This is important to note that the depth buffer are not infinite and the closer it starts
  97830. * the more your scene might encounter depth fighting issue.
  97831. */
  97832. minZ: number;
  97833. /**
  97834. * Define the maximum distance the camera can see to.
  97835. * This is important to note that the depth buffer are not infinite and the further it end
  97836. * the more your scene might encounter depth fighting issue.
  97837. */
  97838. maxZ: number;
  97839. /**
  97840. * Define the default inertia of the camera.
  97841. * This helps giving a smooth feeling to the camera movement.
  97842. */
  97843. inertia: number;
  97844. /**
  97845. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  97846. */
  97847. mode: number;
  97848. /**
  97849. * Define wether the camera is intermediate.
  97850. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  97851. */
  97852. isIntermediate: boolean;
  97853. /**
  97854. * Define the viewport of the camera.
  97855. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  97856. */
  97857. viewport: Viewport;
  97858. /**
  97859. * Restricts the camera to viewing objects with the same layerMask.
  97860. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  97861. */
  97862. layerMask: number;
  97863. /**
  97864. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  97865. */
  97866. fovMode: number;
  97867. /**
  97868. * Rig mode of the camera.
  97869. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  97870. * This is normally controlled byt the camera themselves as internal use.
  97871. */
  97872. cameraRigMode: number;
  97873. /**
  97874. * Defines the distance between both "eyes" in case of a RIG
  97875. */
  97876. interaxialDistance: number;
  97877. /**
  97878. * Defines if stereoscopic rendering is done side by side or over under.
  97879. */
  97880. isStereoscopicSideBySide: boolean;
  97881. /**
  97882. * 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
  97883. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  97884. * else in the scene. (Eg. security camera)
  97885. *
  97886. * 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)
  97887. */
  97888. customRenderTargets: RenderTargetTexture[];
  97889. /**
  97890. * When set, the camera will render to this render target instead of the default canvas
  97891. *
  97892. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  97893. */
  97894. outputRenderTarget: Nullable<RenderTargetTexture>;
  97895. /**
  97896. * Observable triggered when the camera view matrix has changed.
  97897. */
  97898. onViewMatrixChangedObservable: Observable<Camera>;
  97899. /**
  97900. * Observable triggered when the camera Projection matrix has changed.
  97901. */
  97902. onProjectionMatrixChangedObservable: Observable<Camera>;
  97903. /**
  97904. * Observable triggered when the inputs have been processed.
  97905. */
  97906. onAfterCheckInputsObservable: Observable<Camera>;
  97907. /**
  97908. * Observable triggered when reset has been called and applied to the camera.
  97909. */
  97910. onRestoreStateObservable: Observable<Camera>;
  97911. /** @hidden */
  97912. _cameraRigParams: any;
  97913. /** @hidden */
  97914. _rigCameras: Camera[];
  97915. /** @hidden */
  97916. _rigPostProcess: Nullable<PostProcess>;
  97917. protected _webvrViewMatrix: Matrix;
  97918. /** @hidden */
  97919. _skipRendering: boolean;
  97920. /** @hidden */
  97921. _projectionMatrix: Matrix;
  97922. /** @hidden */
  97923. _postProcesses: Nullable<PostProcess>[];
  97924. /** @hidden */
  97925. _activeMeshes: SmartArray<AbstractMesh>;
  97926. protected _globalPosition: Vector3;
  97927. /** @hidden */
  97928. _computedViewMatrix: Matrix;
  97929. private _doNotComputeProjectionMatrix;
  97930. private _transformMatrix;
  97931. private _frustumPlanes;
  97932. private _refreshFrustumPlanes;
  97933. private _storedFov;
  97934. private _stateStored;
  97935. /**
  97936. * Instantiates a new camera object.
  97937. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  97938. * @see http://doc.babylonjs.com/features/cameras
  97939. * @param name Defines the name of the camera in the scene
  97940. * @param position Defines the position of the camera
  97941. * @param scene Defines the scene the camera belongs too
  97942. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  97943. */
  97944. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97945. /**
  97946. * Store current camera state (fov, position, etc..)
  97947. * @returns the camera
  97948. */
  97949. storeState(): Camera;
  97950. /**
  97951. * Restores the camera state values if it has been stored. You must call storeState() first
  97952. */
  97953. protected _restoreStateValues(): boolean;
  97954. /**
  97955. * Restored camera state. You must call storeState() first.
  97956. * @returns true if restored and false otherwise
  97957. */
  97958. restoreState(): boolean;
  97959. /**
  97960. * Gets the class name of the camera.
  97961. * @returns the class name
  97962. */
  97963. getClassName(): string;
  97964. /** @hidden */
  97965. readonly _isCamera: boolean;
  97966. /**
  97967. * Gets a string representation of the camera useful for debug purpose.
  97968. * @param fullDetails Defines that a more verboe level of logging is required
  97969. * @returns the string representation
  97970. */
  97971. toString(fullDetails?: boolean): string;
  97972. /**
  97973. * Gets the current world space position of the camera.
  97974. */
  97975. get globalPosition(): Vector3;
  97976. /**
  97977. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  97978. * @returns the active meshe list
  97979. */
  97980. getActiveMeshes(): SmartArray<AbstractMesh>;
  97981. /**
  97982. * Check wether a mesh is part of the current active mesh list of the camera
  97983. * @param mesh Defines the mesh to check
  97984. * @returns true if active, false otherwise
  97985. */
  97986. isActiveMesh(mesh: Mesh): boolean;
  97987. /**
  97988. * Is this camera ready to be used/rendered
  97989. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  97990. * @return true if the camera is ready
  97991. */
  97992. isReady(completeCheck?: boolean): boolean;
  97993. /** @hidden */
  97994. _initCache(): void;
  97995. /** @hidden */
  97996. _updateCache(ignoreParentClass?: boolean): void;
  97997. /** @hidden */
  97998. _isSynchronized(): boolean;
  97999. /** @hidden */
  98000. _isSynchronizedViewMatrix(): boolean;
  98001. /** @hidden */
  98002. _isSynchronizedProjectionMatrix(): boolean;
  98003. /**
  98004. * Attach the input controls to a specific dom element to get the input from.
  98005. * @param element Defines the element the controls should be listened from
  98006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98007. */
  98008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98009. /**
  98010. * Detach the current controls from the specified dom element.
  98011. * @param element Defines the element to stop listening the inputs from
  98012. */
  98013. detachControl(element: HTMLElement): void;
  98014. /**
  98015. * Update the camera state according to the different inputs gathered during the frame.
  98016. */
  98017. update(): void;
  98018. /** @hidden */
  98019. _checkInputs(): void;
  98020. /** @hidden */
  98021. get rigCameras(): Camera[];
  98022. /**
  98023. * Gets the post process used by the rig cameras
  98024. */
  98025. get rigPostProcess(): Nullable<PostProcess>;
  98026. /**
  98027. * Internal, gets the first post proces.
  98028. * @returns the first post process to be run on this camera.
  98029. */
  98030. _getFirstPostProcess(): Nullable<PostProcess>;
  98031. private _cascadePostProcessesToRigCams;
  98032. /**
  98033. * Attach a post process to the camera.
  98034. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98035. * @param postProcess The post process to attach to the camera
  98036. * @param insertAt The position of the post process in case several of them are in use in the scene
  98037. * @returns the position the post process has been inserted at
  98038. */
  98039. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98040. /**
  98041. * Detach a post process to the camera.
  98042. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98043. * @param postProcess The post process to detach from the camera
  98044. */
  98045. detachPostProcess(postProcess: PostProcess): void;
  98046. /**
  98047. * Gets the current world matrix of the camera
  98048. */
  98049. getWorldMatrix(): Matrix;
  98050. /** @hidden */
  98051. _getViewMatrix(): Matrix;
  98052. /**
  98053. * Gets the current view matrix of the camera.
  98054. * @param force forces the camera to recompute the matrix without looking at the cached state
  98055. * @returns the view matrix
  98056. */
  98057. getViewMatrix(force?: boolean): Matrix;
  98058. /**
  98059. * Freeze the projection matrix.
  98060. * It will prevent the cache check of the camera projection compute and can speed up perf
  98061. * if no parameter of the camera are meant to change
  98062. * @param projection Defines manually a projection if necessary
  98063. */
  98064. freezeProjectionMatrix(projection?: Matrix): void;
  98065. /**
  98066. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98067. */
  98068. unfreezeProjectionMatrix(): void;
  98069. /**
  98070. * Gets the current projection matrix of the camera.
  98071. * @param force forces the camera to recompute the matrix without looking at the cached state
  98072. * @returns the projection matrix
  98073. */
  98074. getProjectionMatrix(force?: boolean): Matrix;
  98075. /**
  98076. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98077. * @returns a Matrix
  98078. */
  98079. getTransformationMatrix(): Matrix;
  98080. private _updateFrustumPlanes;
  98081. /**
  98082. * Checks if a cullable object (mesh...) is in the camera frustum
  98083. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98084. * @param target The object to check
  98085. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98086. * @returns true if the object is in frustum otherwise false
  98087. */
  98088. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98089. /**
  98090. * Checks if a cullable object (mesh...) is in the camera frustum
  98091. * Unlike isInFrustum this cheks the full bounding box
  98092. * @param target The object to check
  98093. * @returns true if the object is in frustum otherwise false
  98094. */
  98095. isCompletelyInFrustum(target: ICullable): boolean;
  98096. /**
  98097. * Gets a ray in the forward direction from the camera.
  98098. * @param length Defines the length of the ray to create
  98099. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98100. * @param origin Defines the start point of the ray which defaults to the camera position
  98101. * @returns the forward ray
  98102. */
  98103. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98104. /**
  98105. * Releases resources associated with this node.
  98106. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98107. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98108. */
  98109. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98110. /** @hidden */
  98111. _isLeftCamera: boolean;
  98112. /**
  98113. * Gets the left camera of a rig setup in case of Rigged Camera
  98114. */
  98115. get isLeftCamera(): boolean;
  98116. /** @hidden */
  98117. _isRightCamera: boolean;
  98118. /**
  98119. * Gets the right camera of a rig setup in case of Rigged Camera
  98120. */
  98121. get isRightCamera(): boolean;
  98122. /**
  98123. * Gets the left camera of a rig setup in case of Rigged Camera
  98124. */
  98125. get leftCamera(): Nullable<FreeCamera>;
  98126. /**
  98127. * Gets the right camera of a rig setup in case of Rigged Camera
  98128. */
  98129. get rightCamera(): Nullable<FreeCamera>;
  98130. /**
  98131. * Gets the left camera target of a rig setup in case of Rigged Camera
  98132. * @returns the target position
  98133. */
  98134. getLeftTarget(): Nullable<Vector3>;
  98135. /**
  98136. * Gets the right camera target of a rig setup in case of Rigged Camera
  98137. * @returns the target position
  98138. */
  98139. getRightTarget(): Nullable<Vector3>;
  98140. /**
  98141. * @hidden
  98142. */
  98143. setCameraRigMode(mode: number, rigParams: any): void;
  98144. /** @hidden */
  98145. static _setStereoscopicRigMode(camera: Camera): void;
  98146. /** @hidden */
  98147. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  98148. /** @hidden */
  98149. static _setVRRigMode(camera: Camera, rigParams: any): void;
  98150. /** @hidden */
  98151. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  98152. /** @hidden */
  98153. _getVRProjectionMatrix(): Matrix;
  98154. protected _updateCameraRotationMatrix(): void;
  98155. protected _updateWebVRCameraRotationMatrix(): void;
  98156. /**
  98157. * This function MUST be overwritten by the different WebVR cameras available.
  98158. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98159. * @hidden
  98160. */
  98161. _getWebVRProjectionMatrix(): Matrix;
  98162. /**
  98163. * This function MUST be overwritten by the different WebVR cameras available.
  98164. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98165. * @hidden
  98166. */
  98167. _getWebVRViewMatrix(): Matrix;
  98168. /** @hidden */
  98169. setCameraRigParameter(name: string, value: any): void;
  98170. /**
  98171. * needs to be overridden by children so sub has required properties to be copied
  98172. * @hidden
  98173. */
  98174. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98175. /**
  98176. * May need to be overridden by children
  98177. * @hidden
  98178. */
  98179. _updateRigCameras(): void;
  98180. /** @hidden */
  98181. _setupInputs(): void;
  98182. /**
  98183. * Serialiaze the camera setup to a json represention
  98184. * @returns the JSON representation
  98185. */
  98186. serialize(): any;
  98187. /**
  98188. * Clones the current camera.
  98189. * @param name The cloned camera name
  98190. * @returns the cloned camera
  98191. */
  98192. clone(name: string): Camera;
  98193. /**
  98194. * Gets the direction of the camera relative to a given local axis.
  98195. * @param localAxis Defines the reference axis to provide a relative direction.
  98196. * @return the direction
  98197. */
  98198. getDirection(localAxis: Vector3): Vector3;
  98199. /**
  98200. * Returns the current camera absolute rotation
  98201. */
  98202. get absoluteRotation(): Quaternion;
  98203. /**
  98204. * Gets the direction of the camera relative to a given local axis into a passed vector.
  98205. * @param localAxis Defines the reference axis to provide a relative direction.
  98206. * @param result Defines the vector to store the result in
  98207. */
  98208. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  98209. /**
  98210. * Gets a camera constructor for a given camera type
  98211. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  98212. * @param name The name of the camera the result will be able to instantiate
  98213. * @param scene The scene the result will construct the camera in
  98214. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  98215. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  98216. * @returns a factory method to construc the camera
  98217. */
  98218. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  98219. /**
  98220. * Compute the world matrix of the camera.
  98221. * @returns the camera world matrix
  98222. */
  98223. computeWorldMatrix(): Matrix;
  98224. /**
  98225. * Parse a JSON and creates the camera from the parsed information
  98226. * @param parsedCamera The JSON to parse
  98227. * @param scene The scene to instantiate the camera in
  98228. * @returns the newly constructed camera
  98229. */
  98230. static Parse(parsedCamera: any, scene: Scene): Camera;
  98231. }
  98232. }
  98233. declare module BABYLON {
  98234. /**
  98235. * Class containing static functions to help procedurally build meshes
  98236. */
  98237. export class DiscBuilder {
  98238. /**
  98239. * Creates a plane polygonal mesh. By default, this is a disc
  98240. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  98241. * * 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
  98242. * * 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
  98243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98246. * @param name defines the name of the mesh
  98247. * @param options defines the options used to create the mesh
  98248. * @param scene defines the hosting scene
  98249. * @returns the plane polygonal mesh
  98250. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  98251. */
  98252. static CreateDisc(name: string, options: {
  98253. radius?: number;
  98254. tessellation?: number;
  98255. arc?: number;
  98256. updatable?: boolean;
  98257. sideOrientation?: number;
  98258. frontUVs?: Vector4;
  98259. backUVs?: Vector4;
  98260. }, scene?: Nullable<Scene>): Mesh;
  98261. }
  98262. }
  98263. declare module BABYLON {
  98264. /**
  98265. * This represents all the required information to add a fresnel effect on a material:
  98266. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98267. */
  98268. export class FresnelParameters {
  98269. private _isEnabled;
  98270. /**
  98271. * Define if the fresnel effect is enable or not.
  98272. */
  98273. get isEnabled(): boolean;
  98274. set isEnabled(value: boolean);
  98275. /**
  98276. * Define the color used on edges (grazing angle)
  98277. */
  98278. leftColor: Color3;
  98279. /**
  98280. * Define the color used on center
  98281. */
  98282. rightColor: Color3;
  98283. /**
  98284. * Define bias applied to computed fresnel term
  98285. */
  98286. bias: number;
  98287. /**
  98288. * Defined the power exponent applied to fresnel term
  98289. */
  98290. power: number;
  98291. /**
  98292. * Clones the current fresnel and its valuues
  98293. * @returns a clone fresnel configuration
  98294. */
  98295. clone(): FresnelParameters;
  98296. /**
  98297. * Serializes the current fresnel parameters to a JSON representation.
  98298. * @return the JSON serialization
  98299. */
  98300. serialize(): any;
  98301. /**
  98302. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  98303. * @param parsedFresnelParameters Define the JSON representation
  98304. * @returns the parsed parameters
  98305. */
  98306. static Parse(parsedFresnelParameters: any): FresnelParameters;
  98307. }
  98308. }
  98309. declare module BABYLON {
  98310. /**
  98311. * Base class of materials working in push mode in babylon JS
  98312. * @hidden
  98313. */
  98314. export class PushMaterial extends Material {
  98315. protected _activeEffect: Effect;
  98316. protected _normalMatrix: Matrix;
  98317. /**
  98318. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98319. * This means that the material can keep using a previous shader while a new one is being compiled.
  98320. * This is mostly used when shader parallel compilation is supported (true by default)
  98321. */
  98322. allowShaderHotSwapping: boolean;
  98323. constructor(name: string, scene: Scene);
  98324. getEffect(): Effect;
  98325. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98326. /**
  98327. * Binds the given world matrix to the active effect
  98328. *
  98329. * @param world the matrix to bind
  98330. */
  98331. bindOnlyWorldMatrix(world: Matrix): void;
  98332. /**
  98333. * Binds the given normal matrix to the active effect
  98334. *
  98335. * @param normalMatrix the matrix to bind
  98336. */
  98337. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98338. bind(world: Matrix, mesh?: Mesh): void;
  98339. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98340. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98341. }
  98342. }
  98343. declare module BABYLON {
  98344. /**
  98345. * This groups all the flags used to control the materials channel.
  98346. */
  98347. export class MaterialFlags {
  98348. private static _DiffuseTextureEnabled;
  98349. /**
  98350. * Are diffuse textures enabled in the application.
  98351. */
  98352. static get DiffuseTextureEnabled(): boolean;
  98353. static set DiffuseTextureEnabled(value: boolean);
  98354. private static _AmbientTextureEnabled;
  98355. /**
  98356. * Are ambient textures enabled in the application.
  98357. */
  98358. static get AmbientTextureEnabled(): boolean;
  98359. static set AmbientTextureEnabled(value: boolean);
  98360. private static _OpacityTextureEnabled;
  98361. /**
  98362. * Are opacity textures enabled in the application.
  98363. */
  98364. static get OpacityTextureEnabled(): boolean;
  98365. static set OpacityTextureEnabled(value: boolean);
  98366. private static _ReflectionTextureEnabled;
  98367. /**
  98368. * Are reflection textures enabled in the application.
  98369. */
  98370. static get ReflectionTextureEnabled(): boolean;
  98371. static set ReflectionTextureEnabled(value: boolean);
  98372. private static _EmissiveTextureEnabled;
  98373. /**
  98374. * Are emissive textures enabled in the application.
  98375. */
  98376. static get EmissiveTextureEnabled(): boolean;
  98377. static set EmissiveTextureEnabled(value: boolean);
  98378. private static _SpecularTextureEnabled;
  98379. /**
  98380. * Are specular textures enabled in the application.
  98381. */
  98382. static get SpecularTextureEnabled(): boolean;
  98383. static set SpecularTextureEnabled(value: boolean);
  98384. private static _BumpTextureEnabled;
  98385. /**
  98386. * Are bump textures enabled in the application.
  98387. */
  98388. static get BumpTextureEnabled(): boolean;
  98389. static set BumpTextureEnabled(value: boolean);
  98390. private static _LightmapTextureEnabled;
  98391. /**
  98392. * Are lightmap textures enabled in the application.
  98393. */
  98394. static get LightmapTextureEnabled(): boolean;
  98395. static set LightmapTextureEnabled(value: boolean);
  98396. private static _RefractionTextureEnabled;
  98397. /**
  98398. * Are refraction textures enabled in the application.
  98399. */
  98400. static get RefractionTextureEnabled(): boolean;
  98401. static set RefractionTextureEnabled(value: boolean);
  98402. private static _ColorGradingTextureEnabled;
  98403. /**
  98404. * Are color grading textures enabled in the application.
  98405. */
  98406. static get ColorGradingTextureEnabled(): boolean;
  98407. static set ColorGradingTextureEnabled(value: boolean);
  98408. private static _FresnelEnabled;
  98409. /**
  98410. * Are fresnels enabled in the application.
  98411. */
  98412. static get FresnelEnabled(): boolean;
  98413. static set FresnelEnabled(value: boolean);
  98414. private static _ClearCoatTextureEnabled;
  98415. /**
  98416. * Are clear coat textures enabled in the application.
  98417. */
  98418. static get ClearCoatTextureEnabled(): boolean;
  98419. static set ClearCoatTextureEnabled(value: boolean);
  98420. private static _ClearCoatBumpTextureEnabled;
  98421. /**
  98422. * Are clear coat bump textures enabled in the application.
  98423. */
  98424. static get ClearCoatBumpTextureEnabled(): boolean;
  98425. static set ClearCoatBumpTextureEnabled(value: boolean);
  98426. private static _ClearCoatTintTextureEnabled;
  98427. /**
  98428. * Are clear coat tint textures enabled in the application.
  98429. */
  98430. static get ClearCoatTintTextureEnabled(): boolean;
  98431. static set ClearCoatTintTextureEnabled(value: boolean);
  98432. private static _SheenTextureEnabled;
  98433. /**
  98434. * Are sheen textures enabled in the application.
  98435. */
  98436. static get SheenTextureEnabled(): boolean;
  98437. static set SheenTextureEnabled(value: boolean);
  98438. private static _AnisotropicTextureEnabled;
  98439. /**
  98440. * Are anisotropic textures enabled in the application.
  98441. */
  98442. static get AnisotropicTextureEnabled(): boolean;
  98443. static set AnisotropicTextureEnabled(value: boolean);
  98444. private static _ThicknessTextureEnabled;
  98445. /**
  98446. * Are thickness textures enabled in the application.
  98447. */
  98448. static get ThicknessTextureEnabled(): boolean;
  98449. static set ThicknessTextureEnabled(value: boolean);
  98450. }
  98451. }
  98452. declare module BABYLON {
  98453. /** @hidden */
  98454. export var defaultFragmentDeclaration: {
  98455. name: string;
  98456. shader: string;
  98457. };
  98458. }
  98459. declare module BABYLON {
  98460. /** @hidden */
  98461. export var defaultUboDeclaration: {
  98462. name: string;
  98463. shader: string;
  98464. };
  98465. }
  98466. declare module BABYLON {
  98467. /** @hidden */
  98468. export var lightFragmentDeclaration: {
  98469. name: string;
  98470. shader: string;
  98471. };
  98472. }
  98473. declare module BABYLON {
  98474. /** @hidden */
  98475. export var lightUboDeclaration: {
  98476. name: string;
  98477. shader: string;
  98478. };
  98479. }
  98480. declare module BABYLON {
  98481. /** @hidden */
  98482. export var lightsFragmentFunctions: {
  98483. name: string;
  98484. shader: string;
  98485. };
  98486. }
  98487. declare module BABYLON {
  98488. /** @hidden */
  98489. export var shadowsFragmentFunctions: {
  98490. name: string;
  98491. shader: string;
  98492. };
  98493. }
  98494. declare module BABYLON {
  98495. /** @hidden */
  98496. export var fresnelFunction: {
  98497. name: string;
  98498. shader: string;
  98499. };
  98500. }
  98501. declare module BABYLON {
  98502. /** @hidden */
  98503. export var reflectionFunction: {
  98504. name: string;
  98505. shader: string;
  98506. };
  98507. }
  98508. declare module BABYLON {
  98509. /** @hidden */
  98510. export var bumpFragmentFunctions: {
  98511. name: string;
  98512. shader: string;
  98513. };
  98514. }
  98515. declare module BABYLON {
  98516. /** @hidden */
  98517. export var logDepthDeclaration: {
  98518. name: string;
  98519. shader: string;
  98520. };
  98521. }
  98522. declare module BABYLON {
  98523. /** @hidden */
  98524. export var bumpFragment: {
  98525. name: string;
  98526. shader: string;
  98527. };
  98528. }
  98529. declare module BABYLON {
  98530. /** @hidden */
  98531. export var depthPrePass: {
  98532. name: string;
  98533. shader: string;
  98534. };
  98535. }
  98536. declare module BABYLON {
  98537. /** @hidden */
  98538. export var lightFragment: {
  98539. name: string;
  98540. shader: string;
  98541. };
  98542. }
  98543. declare module BABYLON {
  98544. /** @hidden */
  98545. export var logDepthFragment: {
  98546. name: string;
  98547. shader: string;
  98548. };
  98549. }
  98550. declare module BABYLON {
  98551. /** @hidden */
  98552. export var defaultPixelShader: {
  98553. name: string;
  98554. shader: string;
  98555. };
  98556. }
  98557. declare module BABYLON {
  98558. /** @hidden */
  98559. export var defaultVertexDeclaration: {
  98560. name: string;
  98561. shader: string;
  98562. };
  98563. }
  98564. declare module BABYLON {
  98565. /** @hidden */
  98566. export var bumpVertexDeclaration: {
  98567. name: string;
  98568. shader: string;
  98569. };
  98570. }
  98571. declare module BABYLON {
  98572. /** @hidden */
  98573. export var bumpVertex: {
  98574. name: string;
  98575. shader: string;
  98576. };
  98577. }
  98578. declare module BABYLON {
  98579. /** @hidden */
  98580. export var fogVertex: {
  98581. name: string;
  98582. shader: string;
  98583. };
  98584. }
  98585. declare module BABYLON {
  98586. /** @hidden */
  98587. export var shadowsVertex: {
  98588. name: string;
  98589. shader: string;
  98590. };
  98591. }
  98592. declare module BABYLON {
  98593. /** @hidden */
  98594. export var pointCloudVertex: {
  98595. name: string;
  98596. shader: string;
  98597. };
  98598. }
  98599. declare module BABYLON {
  98600. /** @hidden */
  98601. export var logDepthVertex: {
  98602. name: string;
  98603. shader: string;
  98604. };
  98605. }
  98606. declare module BABYLON {
  98607. /** @hidden */
  98608. export var defaultVertexShader: {
  98609. name: string;
  98610. shader: string;
  98611. };
  98612. }
  98613. declare module BABYLON {
  98614. /** @hidden */
  98615. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98616. MAINUV1: boolean;
  98617. MAINUV2: boolean;
  98618. DIFFUSE: boolean;
  98619. DIFFUSEDIRECTUV: number;
  98620. AMBIENT: boolean;
  98621. AMBIENTDIRECTUV: number;
  98622. OPACITY: boolean;
  98623. OPACITYDIRECTUV: number;
  98624. OPACITYRGB: boolean;
  98625. REFLECTION: boolean;
  98626. EMISSIVE: boolean;
  98627. EMISSIVEDIRECTUV: number;
  98628. SPECULAR: boolean;
  98629. SPECULARDIRECTUV: number;
  98630. BUMP: boolean;
  98631. BUMPDIRECTUV: number;
  98632. PARALLAX: boolean;
  98633. PARALLAXOCCLUSION: boolean;
  98634. SPECULAROVERALPHA: boolean;
  98635. CLIPPLANE: boolean;
  98636. CLIPPLANE2: boolean;
  98637. CLIPPLANE3: boolean;
  98638. CLIPPLANE4: boolean;
  98639. CLIPPLANE5: boolean;
  98640. CLIPPLANE6: boolean;
  98641. ALPHATEST: boolean;
  98642. DEPTHPREPASS: boolean;
  98643. ALPHAFROMDIFFUSE: boolean;
  98644. POINTSIZE: boolean;
  98645. FOG: boolean;
  98646. SPECULARTERM: boolean;
  98647. DIFFUSEFRESNEL: boolean;
  98648. OPACITYFRESNEL: boolean;
  98649. REFLECTIONFRESNEL: boolean;
  98650. REFRACTIONFRESNEL: boolean;
  98651. EMISSIVEFRESNEL: boolean;
  98652. FRESNEL: boolean;
  98653. NORMAL: boolean;
  98654. UV1: boolean;
  98655. UV2: boolean;
  98656. VERTEXCOLOR: boolean;
  98657. VERTEXALPHA: boolean;
  98658. NUM_BONE_INFLUENCERS: number;
  98659. BonesPerMesh: number;
  98660. BONETEXTURE: boolean;
  98661. INSTANCES: boolean;
  98662. GLOSSINESS: boolean;
  98663. ROUGHNESS: boolean;
  98664. EMISSIVEASILLUMINATION: boolean;
  98665. LINKEMISSIVEWITHDIFFUSE: boolean;
  98666. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98667. LIGHTMAP: boolean;
  98668. LIGHTMAPDIRECTUV: number;
  98669. OBJECTSPACE_NORMALMAP: boolean;
  98670. USELIGHTMAPASSHADOWMAP: boolean;
  98671. REFLECTIONMAP_3D: boolean;
  98672. REFLECTIONMAP_SPHERICAL: boolean;
  98673. REFLECTIONMAP_PLANAR: boolean;
  98674. REFLECTIONMAP_CUBIC: boolean;
  98675. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98676. REFLECTIONMAP_PROJECTION: boolean;
  98677. REFLECTIONMAP_SKYBOX: boolean;
  98678. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98679. REFLECTIONMAP_EXPLICIT: boolean;
  98680. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98681. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98682. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98683. INVERTCUBICMAP: boolean;
  98684. LOGARITHMICDEPTH: boolean;
  98685. REFRACTION: boolean;
  98686. REFRACTIONMAP_3D: boolean;
  98687. REFLECTIONOVERALPHA: boolean;
  98688. TWOSIDEDLIGHTING: boolean;
  98689. SHADOWFLOAT: boolean;
  98690. MORPHTARGETS: boolean;
  98691. MORPHTARGETS_NORMAL: boolean;
  98692. MORPHTARGETS_TANGENT: boolean;
  98693. MORPHTARGETS_UV: boolean;
  98694. NUM_MORPH_INFLUENCERS: number;
  98695. NONUNIFORMSCALING: boolean;
  98696. PREMULTIPLYALPHA: boolean;
  98697. IMAGEPROCESSING: boolean;
  98698. VIGNETTE: boolean;
  98699. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98700. VIGNETTEBLENDMODEOPAQUE: boolean;
  98701. TONEMAPPING: boolean;
  98702. TONEMAPPING_ACES: boolean;
  98703. CONTRAST: boolean;
  98704. COLORCURVES: boolean;
  98705. COLORGRADING: boolean;
  98706. COLORGRADING3D: boolean;
  98707. SAMPLER3DGREENDEPTH: boolean;
  98708. SAMPLER3DBGRMAP: boolean;
  98709. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98710. MULTIVIEW: boolean;
  98711. /**
  98712. * If the reflection texture on this material is in linear color space
  98713. * @hidden
  98714. */
  98715. IS_REFLECTION_LINEAR: boolean;
  98716. /**
  98717. * If the refraction texture on this material is in linear color space
  98718. * @hidden
  98719. */
  98720. IS_REFRACTION_LINEAR: boolean;
  98721. EXPOSURE: boolean;
  98722. constructor();
  98723. setReflectionMode(modeToEnable: string): void;
  98724. }
  98725. /**
  98726. * This is the default material used in Babylon. It is the best trade off between quality
  98727. * and performances.
  98728. * @see http://doc.babylonjs.com/babylon101/materials
  98729. */
  98730. export class StandardMaterial extends PushMaterial {
  98731. private _diffuseTexture;
  98732. /**
  98733. * The basic texture of the material as viewed under a light.
  98734. */
  98735. diffuseTexture: Nullable<BaseTexture>;
  98736. private _ambientTexture;
  98737. /**
  98738. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98739. */
  98740. ambientTexture: Nullable<BaseTexture>;
  98741. private _opacityTexture;
  98742. /**
  98743. * Define the transparency of the material from a texture.
  98744. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98745. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98746. */
  98747. opacityTexture: Nullable<BaseTexture>;
  98748. private _reflectionTexture;
  98749. /**
  98750. * Define the texture used to display the reflection.
  98751. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98752. */
  98753. reflectionTexture: Nullable<BaseTexture>;
  98754. private _emissiveTexture;
  98755. /**
  98756. * Define texture of the material as if self lit.
  98757. * This will be mixed in the final result even in the absence of light.
  98758. */
  98759. emissiveTexture: Nullable<BaseTexture>;
  98760. private _specularTexture;
  98761. /**
  98762. * Define how the color and intensity of the highlight given by the light in the material.
  98763. */
  98764. specularTexture: Nullable<BaseTexture>;
  98765. private _bumpTexture;
  98766. /**
  98767. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98768. * 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.
  98769. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98770. */
  98771. bumpTexture: Nullable<BaseTexture>;
  98772. private _lightmapTexture;
  98773. /**
  98774. * Complex lighting can be computationally expensive to compute at runtime.
  98775. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98776. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98777. */
  98778. lightmapTexture: Nullable<BaseTexture>;
  98779. private _refractionTexture;
  98780. /**
  98781. * Define the texture used to display the refraction.
  98782. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98783. */
  98784. refractionTexture: Nullable<BaseTexture>;
  98785. /**
  98786. * The color of the material lit by the environmental background lighting.
  98787. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98788. */
  98789. ambientColor: Color3;
  98790. /**
  98791. * The basic color of the material as viewed under a light.
  98792. */
  98793. diffuseColor: Color3;
  98794. /**
  98795. * Define how the color and intensity of the highlight given by the light in the material.
  98796. */
  98797. specularColor: Color3;
  98798. /**
  98799. * Define the color of the material as if self lit.
  98800. * This will be mixed in the final result even in the absence of light.
  98801. */
  98802. emissiveColor: Color3;
  98803. /**
  98804. * Defines how sharp are the highlights in the material.
  98805. * The bigger the value the sharper giving a more glossy feeling to the result.
  98806. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98807. */
  98808. specularPower: number;
  98809. private _useAlphaFromDiffuseTexture;
  98810. /**
  98811. * Does the transparency come from the diffuse texture alpha channel.
  98812. */
  98813. useAlphaFromDiffuseTexture: boolean;
  98814. private _useEmissiveAsIllumination;
  98815. /**
  98816. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98817. */
  98818. useEmissiveAsIllumination: boolean;
  98819. private _linkEmissiveWithDiffuse;
  98820. /**
  98821. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98822. * the emissive level when the final color is close to one.
  98823. */
  98824. linkEmissiveWithDiffuse: boolean;
  98825. private _useSpecularOverAlpha;
  98826. /**
  98827. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98828. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98829. */
  98830. useSpecularOverAlpha: boolean;
  98831. private _useReflectionOverAlpha;
  98832. /**
  98833. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98834. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98835. */
  98836. useReflectionOverAlpha: boolean;
  98837. private _disableLighting;
  98838. /**
  98839. * Does lights from the scene impacts this material.
  98840. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98841. */
  98842. disableLighting: boolean;
  98843. private _useObjectSpaceNormalMap;
  98844. /**
  98845. * Allows using an object space normal map (instead of tangent space).
  98846. */
  98847. useObjectSpaceNormalMap: boolean;
  98848. private _useParallax;
  98849. /**
  98850. * Is parallax enabled or not.
  98851. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98852. */
  98853. useParallax: boolean;
  98854. private _useParallaxOcclusion;
  98855. /**
  98856. * Is parallax occlusion enabled or not.
  98857. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98858. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98859. */
  98860. useParallaxOcclusion: boolean;
  98861. /**
  98862. * 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.
  98863. */
  98864. parallaxScaleBias: number;
  98865. private _roughness;
  98866. /**
  98867. * Helps to define how blurry the reflections should appears in the material.
  98868. */
  98869. roughness: number;
  98870. /**
  98871. * In case of refraction, define the value of the index of refraction.
  98872. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98873. */
  98874. indexOfRefraction: number;
  98875. /**
  98876. * Invert the refraction texture alongside the y axis.
  98877. * It can be useful with procedural textures or probe for instance.
  98878. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98879. */
  98880. invertRefractionY: boolean;
  98881. /**
  98882. * Defines the alpha limits in alpha test mode.
  98883. */
  98884. alphaCutOff: number;
  98885. private _useLightmapAsShadowmap;
  98886. /**
  98887. * In case of light mapping, define whether the map contains light or shadow informations.
  98888. */
  98889. useLightmapAsShadowmap: boolean;
  98890. private _diffuseFresnelParameters;
  98891. /**
  98892. * Define the diffuse fresnel parameters of the material.
  98893. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98894. */
  98895. diffuseFresnelParameters: FresnelParameters;
  98896. private _opacityFresnelParameters;
  98897. /**
  98898. * Define the opacity fresnel parameters of the material.
  98899. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98900. */
  98901. opacityFresnelParameters: FresnelParameters;
  98902. private _reflectionFresnelParameters;
  98903. /**
  98904. * Define the reflection fresnel parameters of the material.
  98905. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98906. */
  98907. reflectionFresnelParameters: FresnelParameters;
  98908. private _refractionFresnelParameters;
  98909. /**
  98910. * Define the refraction fresnel parameters of the material.
  98911. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98912. */
  98913. refractionFresnelParameters: FresnelParameters;
  98914. private _emissiveFresnelParameters;
  98915. /**
  98916. * Define the emissive fresnel parameters of the material.
  98917. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98918. */
  98919. emissiveFresnelParameters: FresnelParameters;
  98920. private _useReflectionFresnelFromSpecular;
  98921. /**
  98922. * If true automatically deducts the fresnels values from the material specularity.
  98923. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98924. */
  98925. useReflectionFresnelFromSpecular: boolean;
  98926. private _useGlossinessFromSpecularMapAlpha;
  98927. /**
  98928. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98929. */
  98930. useGlossinessFromSpecularMapAlpha: boolean;
  98931. private _maxSimultaneousLights;
  98932. /**
  98933. * Defines the maximum number of lights that can be used in the material
  98934. */
  98935. maxSimultaneousLights: number;
  98936. private _invertNormalMapX;
  98937. /**
  98938. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98939. */
  98940. invertNormalMapX: boolean;
  98941. private _invertNormalMapY;
  98942. /**
  98943. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98944. */
  98945. invertNormalMapY: boolean;
  98946. private _twoSidedLighting;
  98947. /**
  98948. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98949. */
  98950. twoSidedLighting: boolean;
  98951. /**
  98952. * Default configuration related to image processing available in the standard Material.
  98953. */
  98954. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98955. /**
  98956. * Gets the image processing configuration used either in this material.
  98957. */
  98958. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  98959. /**
  98960. * Sets the Default image processing configuration used either in the this material.
  98961. *
  98962. * If sets to null, the scene one is in use.
  98963. */
  98964. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  98965. /**
  98966. * Keep track of the image processing observer to allow dispose and replace.
  98967. */
  98968. private _imageProcessingObserver;
  98969. /**
  98970. * Attaches a new image processing configuration to the Standard Material.
  98971. * @param configuration
  98972. */
  98973. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98974. /**
  98975. * Gets wether the color curves effect is enabled.
  98976. */
  98977. get cameraColorCurvesEnabled(): boolean;
  98978. /**
  98979. * Sets wether the color curves effect is enabled.
  98980. */
  98981. set cameraColorCurvesEnabled(value: boolean);
  98982. /**
  98983. * Gets wether the color grading effect is enabled.
  98984. */
  98985. get cameraColorGradingEnabled(): boolean;
  98986. /**
  98987. * Gets wether the color grading effect is enabled.
  98988. */
  98989. set cameraColorGradingEnabled(value: boolean);
  98990. /**
  98991. * Gets wether tonemapping is enabled or not.
  98992. */
  98993. get cameraToneMappingEnabled(): boolean;
  98994. /**
  98995. * Sets wether tonemapping is enabled or not
  98996. */
  98997. set cameraToneMappingEnabled(value: boolean);
  98998. /**
  98999. * The camera exposure used on this material.
  99000. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99001. * This corresponds to a photographic exposure.
  99002. */
  99003. get cameraExposure(): number;
  99004. /**
  99005. * The camera exposure used on this material.
  99006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99007. * This corresponds to a photographic exposure.
  99008. */
  99009. set cameraExposure(value: number);
  99010. /**
  99011. * Gets The camera contrast used on this material.
  99012. */
  99013. get cameraContrast(): number;
  99014. /**
  99015. * Sets The camera contrast used on this material.
  99016. */
  99017. set cameraContrast(value: number);
  99018. /**
  99019. * Gets the Color Grading 2D Lookup Texture.
  99020. */
  99021. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99022. /**
  99023. * Sets the Color Grading 2D Lookup Texture.
  99024. */
  99025. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99026. /**
  99027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99029. * 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;
  99030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99031. */
  99032. get cameraColorCurves(): Nullable<ColorCurves>;
  99033. /**
  99034. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99035. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99036. * 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;
  99037. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99038. */
  99039. set cameraColorCurves(value: Nullable<ColorCurves>);
  99040. /**
  99041. * Custom callback helping to override the default shader used in the material.
  99042. */
  99043. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99044. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99045. protected _worldViewProjectionMatrix: Matrix;
  99046. protected _globalAmbientColor: Color3;
  99047. protected _useLogarithmicDepth: boolean;
  99048. protected _rebuildInParallel: boolean;
  99049. /**
  99050. * Instantiates a new standard material.
  99051. * This is the default material used in Babylon. It is the best trade off between quality
  99052. * and performances.
  99053. * @see http://doc.babylonjs.com/babylon101/materials
  99054. * @param name Define the name of the material in the scene
  99055. * @param scene Define the scene the material belong to
  99056. */
  99057. constructor(name: string, scene: Scene);
  99058. /**
  99059. * Gets a boolean indicating that current material needs to register RTT
  99060. */
  99061. get hasRenderTargetTextures(): boolean;
  99062. /**
  99063. * Gets the current class name of the material e.g. "StandardMaterial"
  99064. * Mainly use in serialization.
  99065. * @returns the class name
  99066. */
  99067. getClassName(): string;
  99068. /**
  99069. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99070. * You can try switching to logarithmic depth.
  99071. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99072. */
  99073. get useLogarithmicDepth(): boolean;
  99074. set useLogarithmicDepth(value: boolean);
  99075. /**
  99076. * Specifies if the material will require alpha blending
  99077. * @returns a boolean specifying if alpha blending is needed
  99078. */
  99079. needAlphaBlending(): boolean;
  99080. /**
  99081. * Specifies if this material should be rendered in alpha test mode
  99082. * @returns a boolean specifying if an alpha test is needed.
  99083. */
  99084. needAlphaTesting(): boolean;
  99085. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99086. /**
  99087. * Get the texture used for alpha test purpose.
  99088. * @returns the diffuse texture in case of the standard material.
  99089. */
  99090. getAlphaTestTexture(): Nullable<BaseTexture>;
  99091. /**
  99092. * Get if the submesh is ready to be used and all its information available.
  99093. * Child classes can use it to update shaders
  99094. * @param mesh defines the mesh to check
  99095. * @param subMesh defines which submesh to check
  99096. * @param useInstances specifies that instances should be used
  99097. * @returns a boolean indicating that the submesh is ready or not
  99098. */
  99099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99100. /**
  99101. * Builds the material UBO layouts.
  99102. * Used internally during the effect preparation.
  99103. */
  99104. buildUniformLayout(): void;
  99105. /**
  99106. * Unbinds the material from the mesh
  99107. */
  99108. unbind(): void;
  99109. /**
  99110. * Binds the submesh to this material by preparing the effect and shader to draw
  99111. * @param world defines the world transformation matrix
  99112. * @param mesh defines the mesh containing the submesh
  99113. * @param subMesh defines the submesh to bind the material to
  99114. */
  99115. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99116. /**
  99117. * Get the list of animatables in the material.
  99118. * @returns the list of animatables object used in the material
  99119. */
  99120. getAnimatables(): IAnimatable[];
  99121. /**
  99122. * Gets the active textures from the material
  99123. * @returns an array of textures
  99124. */
  99125. getActiveTextures(): BaseTexture[];
  99126. /**
  99127. * Specifies if the material uses a texture
  99128. * @param texture defines the texture to check against the material
  99129. * @returns a boolean specifying if the material uses the texture
  99130. */
  99131. hasTexture(texture: BaseTexture): boolean;
  99132. /**
  99133. * Disposes the material
  99134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99136. */
  99137. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99138. /**
  99139. * Makes a duplicate of the material, and gives it a new name
  99140. * @param name defines the new name for the duplicated material
  99141. * @returns the cloned material
  99142. */
  99143. clone(name: string): StandardMaterial;
  99144. /**
  99145. * Serializes this material in a JSON representation
  99146. * @returns the serialized material object
  99147. */
  99148. serialize(): any;
  99149. /**
  99150. * Creates a standard material from parsed material data
  99151. * @param source defines the JSON representation of the material
  99152. * @param scene defines the hosting scene
  99153. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99154. * @returns a new standard material
  99155. */
  99156. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99157. /**
  99158. * Are diffuse textures enabled in the application.
  99159. */
  99160. static get DiffuseTextureEnabled(): boolean;
  99161. static set DiffuseTextureEnabled(value: boolean);
  99162. /**
  99163. * Are ambient textures enabled in the application.
  99164. */
  99165. static get AmbientTextureEnabled(): boolean;
  99166. static set AmbientTextureEnabled(value: boolean);
  99167. /**
  99168. * Are opacity textures enabled in the application.
  99169. */
  99170. static get OpacityTextureEnabled(): boolean;
  99171. static set OpacityTextureEnabled(value: boolean);
  99172. /**
  99173. * Are reflection textures enabled in the application.
  99174. */
  99175. static get ReflectionTextureEnabled(): boolean;
  99176. static set ReflectionTextureEnabled(value: boolean);
  99177. /**
  99178. * Are emissive textures enabled in the application.
  99179. */
  99180. static get EmissiveTextureEnabled(): boolean;
  99181. static set EmissiveTextureEnabled(value: boolean);
  99182. /**
  99183. * Are specular textures enabled in the application.
  99184. */
  99185. static get SpecularTextureEnabled(): boolean;
  99186. static set SpecularTextureEnabled(value: boolean);
  99187. /**
  99188. * Are bump textures enabled in the application.
  99189. */
  99190. static get BumpTextureEnabled(): boolean;
  99191. static set BumpTextureEnabled(value: boolean);
  99192. /**
  99193. * Are lightmap textures enabled in the application.
  99194. */
  99195. static get LightmapTextureEnabled(): boolean;
  99196. static set LightmapTextureEnabled(value: boolean);
  99197. /**
  99198. * Are refraction textures enabled in the application.
  99199. */
  99200. static get RefractionTextureEnabled(): boolean;
  99201. static set RefractionTextureEnabled(value: boolean);
  99202. /**
  99203. * Are color grading textures enabled in the application.
  99204. */
  99205. static get ColorGradingTextureEnabled(): boolean;
  99206. static set ColorGradingTextureEnabled(value: boolean);
  99207. /**
  99208. * Are fresnels enabled in the application.
  99209. */
  99210. static get FresnelEnabled(): boolean;
  99211. static set FresnelEnabled(value: boolean);
  99212. }
  99213. }
  99214. declare module BABYLON {
  99215. /**
  99216. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  99217. *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.
  99218. * The SPS is also a particle system. It provides some methods to manage the particles.
  99219. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  99220. *
  99221. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  99222. */
  99223. export class SolidParticleSystem implements IDisposable {
  99224. /**
  99225. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  99226. * Example : var p = SPS.particles[i];
  99227. */
  99228. particles: SolidParticle[];
  99229. /**
  99230. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  99231. */
  99232. nbParticles: number;
  99233. /**
  99234. * If the particles must ever face the camera (default false). Useful for planar particles.
  99235. */
  99236. billboard: boolean;
  99237. /**
  99238. * Recompute normals when adding a shape
  99239. */
  99240. recomputeNormals: boolean;
  99241. /**
  99242. * This a counter ofr your own usage. It's not set by any SPS functions.
  99243. */
  99244. counter: number;
  99245. /**
  99246. * The SPS name. This name is also given to the underlying mesh.
  99247. */
  99248. name: string;
  99249. /**
  99250. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  99251. */
  99252. mesh: Mesh;
  99253. /**
  99254. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  99255. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  99256. */
  99257. vars: any;
  99258. /**
  99259. * This array is populated when the SPS is set as 'pickable'.
  99260. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  99261. * Each element of this array is an object `{idx: int, faceId: int}`.
  99262. * `idx` is the picked particle index in the `SPS.particles` array
  99263. * `faceId` is the picked face index counted within this particle.
  99264. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  99265. */
  99266. pickedParticles: {
  99267. idx: number;
  99268. faceId: number;
  99269. }[];
  99270. /**
  99271. * This array is populated when `enableDepthSort` is set to true.
  99272. * Each element of this array is an instance of the class DepthSortedParticle.
  99273. */
  99274. depthSortedParticles: DepthSortedParticle[];
  99275. /**
  99276. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  99277. * @hidden
  99278. */
  99279. _bSphereOnly: boolean;
  99280. /**
  99281. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  99282. * @hidden
  99283. */
  99284. _bSphereRadiusFactor: number;
  99285. private _scene;
  99286. private _positions;
  99287. private _indices;
  99288. private _normals;
  99289. private _colors;
  99290. private _uvs;
  99291. private _indices32;
  99292. private _positions32;
  99293. private _normals32;
  99294. private _fixedNormal32;
  99295. private _colors32;
  99296. private _uvs32;
  99297. private _index;
  99298. private _updatable;
  99299. private _pickable;
  99300. private _isVisibilityBoxLocked;
  99301. private _alwaysVisible;
  99302. private _depthSort;
  99303. private _expandable;
  99304. private _shapeCounter;
  99305. private _copy;
  99306. private _color;
  99307. private _computeParticleColor;
  99308. private _computeParticleTexture;
  99309. private _computeParticleRotation;
  99310. private _computeParticleVertex;
  99311. private _computeBoundingBox;
  99312. private _depthSortParticles;
  99313. private _camera;
  99314. private _mustUnrotateFixedNormals;
  99315. private _particlesIntersect;
  99316. private _needs32Bits;
  99317. private _isNotBuilt;
  99318. private _lastParticleId;
  99319. private _idxOfId;
  99320. private _multimaterialEnabled;
  99321. private _useModelMaterial;
  99322. private _indicesByMaterial;
  99323. private _materialIndexes;
  99324. private _depthSortFunction;
  99325. private _materialSortFunction;
  99326. private _materials;
  99327. private _multimaterial;
  99328. private _materialIndexesById;
  99329. private _defaultMaterial;
  99330. private _autoUpdateSubMeshes;
  99331. /**
  99332. * Creates a SPS (Solid Particle System) object.
  99333. * @param name (String) is the SPS name, this will be the underlying mesh name.
  99334. * @param scene (Scene) is the scene in which the SPS is added.
  99335. * @param options defines the options of the sps e.g.
  99336. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  99337. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  99338. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  99339. * * 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.
  99340. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  99341. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  99342. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  99343. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  99344. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  99345. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  99346. */
  99347. constructor(name: string, scene: Scene, options?: {
  99348. updatable?: boolean;
  99349. isPickable?: boolean;
  99350. enableDepthSort?: boolean;
  99351. particleIntersection?: boolean;
  99352. boundingSphereOnly?: boolean;
  99353. bSphereRadiusFactor?: number;
  99354. expandable?: boolean;
  99355. useModelMaterial?: boolean;
  99356. enableMultiMaterial?: boolean;
  99357. });
  99358. /**
  99359. * Builds the SPS underlying mesh. Returns a standard Mesh.
  99360. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  99361. * @returns the created mesh
  99362. */
  99363. buildMesh(): Mesh;
  99364. /**
  99365. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  99366. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  99367. * Thus the particles generated from `digest()` have their property `position` set yet.
  99368. * @param mesh ( Mesh ) is the mesh to be digested
  99369. * @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
  99370. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  99371. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  99372. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99373. * @returns the current SPS
  99374. */
  99375. digest(mesh: Mesh, options?: {
  99376. facetNb?: number;
  99377. number?: number;
  99378. delta?: number;
  99379. storage?: [];
  99380. }): SolidParticleSystem;
  99381. /**
  99382. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  99383. * @hidden
  99384. */
  99385. private _unrotateFixedNormals;
  99386. /**
  99387. * Resets the temporary working copy particle
  99388. * @hidden
  99389. */
  99390. private _resetCopy;
  99391. /**
  99392. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  99393. * @param p the current index in the positions array to be updated
  99394. * @param ind the current index in the indices array
  99395. * @param shape a Vector3 array, the shape geometry
  99396. * @param positions the positions array to be updated
  99397. * @param meshInd the shape indices array
  99398. * @param indices the indices array to be updated
  99399. * @param meshUV the shape uv array
  99400. * @param uvs the uv array to be updated
  99401. * @param meshCol the shape color array
  99402. * @param colors the color array to be updated
  99403. * @param meshNor the shape normals array
  99404. * @param normals the normals array to be updated
  99405. * @param idx the particle index
  99406. * @param idxInShape the particle index in its shape
  99407. * @param options the addShape() method passed options
  99408. * @model the particle model
  99409. * @hidden
  99410. */
  99411. private _meshBuilder;
  99412. /**
  99413. * Returns a shape Vector3 array from positions float array
  99414. * @param positions float array
  99415. * @returns a vector3 array
  99416. * @hidden
  99417. */
  99418. private _posToShape;
  99419. /**
  99420. * Returns a shapeUV array from a float uvs (array deep copy)
  99421. * @param uvs as a float array
  99422. * @returns a shapeUV array
  99423. * @hidden
  99424. */
  99425. private _uvsToShapeUV;
  99426. /**
  99427. * Adds a new particle object in the particles array
  99428. * @param idx particle index in particles array
  99429. * @param id particle id
  99430. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  99431. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  99432. * @param model particle ModelShape object
  99433. * @param shapeId model shape identifier
  99434. * @param idxInShape index of the particle in the current model
  99435. * @param bInfo model bounding info object
  99436. * @param storage target storage array, if any
  99437. * @hidden
  99438. */
  99439. private _addParticle;
  99440. /**
  99441. * Adds some particles to the SPS from the model shape. Returns the shape id.
  99442. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  99443. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  99444. * @param nb (positive integer) the number of particles to be created from this model
  99445. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  99446. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  99447. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99448. * @returns the number of shapes in the system
  99449. */
  99450. addShape(mesh: Mesh, nb: number, options?: {
  99451. positionFunction?: any;
  99452. vertexFunction?: any;
  99453. storage?: [];
  99454. }): number;
  99455. /**
  99456. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  99457. * @hidden
  99458. */
  99459. private _rebuildParticle;
  99460. /**
  99461. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  99462. * @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.
  99463. * @returns the SPS.
  99464. */
  99465. rebuildMesh(reset?: boolean): SolidParticleSystem;
  99466. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  99467. * Returns an array with the removed particles.
  99468. * 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.
  99469. * The SPS can't be empty so at least one particle needs to remain in place.
  99470. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  99471. * @param start index of the first particle to remove
  99472. * @param end index of the last particle to remove (included)
  99473. * @returns an array populated with the removed particles
  99474. */
  99475. removeParticles(start: number, end: number): SolidParticle[];
  99476. /**
  99477. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  99478. * @param solidParticleArray an array populated with Solid Particles objects
  99479. * @returns the SPS
  99480. */
  99481. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  99482. /**
  99483. * Creates a new particle and modifies the SPS mesh geometry :
  99484. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  99485. * - calls _addParticle() to populate the particle array
  99486. * factorized code from addShape() and insertParticlesFromArray()
  99487. * @param idx particle index in the particles array
  99488. * @param i particle index in its shape
  99489. * @param modelShape particle ModelShape object
  99490. * @param shape shape vertex array
  99491. * @param meshInd shape indices array
  99492. * @param meshUV shape uv array
  99493. * @param meshCol shape color array
  99494. * @param meshNor shape normals array
  99495. * @param bbInfo shape bounding info
  99496. * @param storage target particle storage
  99497. * @options addShape() passed options
  99498. * @hidden
  99499. */
  99500. private _insertNewParticle;
  99501. /**
  99502. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  99503. * This method calls `updateParticle()` for each particle of the SPS.
  99504. * For an animated SPS, it is usually called within the render loop.
  99505. * 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.
  99506. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  99507. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  99508. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  99509. * @returns the SPS.
  99510. */
  99511. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  99512. /**
  99513. * Disposes the SPS.
  99514. */
  99515. dispose(): void;
  99516. /**
  99517. * Returns a SolidParticle object from its identifier : particle.id
  99518. * @param id (integer) the particle Id
  99519. * @returns the searched particle or null if not found in the SPS.
  99520. */
  99521. getParticleById(id: number): Nullable<SolidParticle>;
  99522. /**
  99523. * Returns a new array populated with the particles having the passed shapeId.
  99524. * @param shapeId (integer) the shape identifier
  99525. * @returns a new solid particle array
  99526. */
  99527. getParticlesByShapeId(shapeId: number): SolidParticle[];
  99528. /**
  99529. * Populates the passed array "ref" with the particles having the passed shapeId.
  99530. * @param shapeId the shape identifier
  99531. * @returns the SPS
  99532. * @param ref
  99533. */
  99534. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  99535. /**
  99536. * Computes the required SubMeshes according the materials assigned to the particles.
  99537. * @returns the solid particle system.
  99538. * Does nothing if called before the SPS mesh is built.
  99539. */
  99540. computeSubMeshes(): SolidParticleSystem;
  99541. /**
  99542. * Sorts the solid particles by material when MultiMaterial is enabled.
  99543. * Updates the indices32 array.
  99544. * Updates the indicesByMaterial array.
  99545. * Updates the mesh indices array.
  99546. * @returns the SPS
  99547. * @hidden
  99548. */
  99549. private _sortParticlesByMaterial;
  99550. /**
  99551. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  99552. * @hidden
  99553. */
  99554. private _setMaterialIndexesById;
  99555. /**
  99556. * Returns an array with unique values of Materials from the passed array
  99557. * @param array the material array to be checked and filtered
  99558. * @hidden
  99559. */
  99560. private _filterUniqueMaterialId;
  99561. /**
  99562. * Sets a new Standard Material as _defaultMaterial if not already set.
  99563. * @hidden
  99564. */
  99565. private _setDefaultMaterial;
  99566. /**
  99567. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  99568. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99569. * @returns the SPS.
  99570. */
  99571. refreshVisibleSize(): SolidParticleSystem;
  99572. /**
  99573. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  99574. * @param size the size (float) of the visibility box
  99575. * note : this doesn't lock the SPS mesh bounding box.
  99576. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99577. */
  99578. setVisibilityBox(size: number): void;
  99579. /**
  99580. * Gets whether the SPS as always visible or not
  99581. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99582. */
  99583. get isAlwaysVisible(): boolean;
  99584. /**
  99585. * Sets the SPS as always visible or not
  99586. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99587. */
  99588. set isAlwaysVisible(val: boolean);
  99589. /**
  99590. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  99591. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99592. */
  99593. set isVisibilityBoxLocked(val: boolean);
  99594. /**
  99595. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  99596. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  99597. */
  99598. get isVisibilityBoxLocked(): boolean;
  99599. /**
  99600. * Tells to `setParticles()` to compute the particle rotations or not.
  99601. * Default value : true. The SPS is faster when it's set to false.
  99602. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  99603. */
  99604. set computeParticleRotation(val: boolean);
  99605. /**
  99606. * Tells to `setParticles()` to compute the particle colors or not.
  99607. * Default value : true. The SPS is faster when it's set to false.
  99608. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  99609. */
  99610. set computeParticleColor(val: boolean);
  99611. set computeParticleTexture(val: boolean);
  99612. /**
  99613. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  99614. * Default value : false. The SPS is faster when it's set to false.
  99615. * Note : the particle custom vertex positions aren't stored values.
  99616. */
  99617. set computeParticleVertex(val: boolean);
  99618. /**
  99619. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  99620. */
  99621. set computeBoundingBox(val: boolean);
  99622. /**
  99623. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  99624. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  99625. * Default : `true`
  99626. */
  99627. set depthSortParticles(val: boolean);
  99628. /**
  99629. * Gets if `setParticles()` computes the particle rotations or not.
  99630. * Default value : true. The SPS is faster when it's set to false.
  99631. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  99632. */
  99633. get computeParticleRotation(): boolean;
  99634. /**
  99635. * Gets if `setParticles()` computes the particle colors or not.
  99636. * Default value : true. The SPS is faster when it's set to false.
  99637. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  99638. */
  99639. get computeParticleColor(): boolean;
  99640. /**
  99641. * Gets if `setParticles()` computes the particle textures or not.
  99642. * Default value : true. The SPS is faster when it's set to false.
  99643. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  99644. */
  99645. get computeParticleTexture(): boolean;
  99646. /**
  99647. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  99648. * Default value : false. The SPS is faster when it's set to false.
  99649. * Note : the particle custom vertex positions aren't stored values.
  99650. */
  99651. get computeParticleVertex(): boolean;
  99652. /**
  99653. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  99654. */
  99655. get computeBoundingBox(): boolean;
  99656. /**
  99657. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  99658. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  99659. * Default : `true`
  99660. */
  99661. get depthSortParticles(): boolean;
  99662. /**
  99663. * Gets if the SPS is created as expandable at construction time.
  99664. * Default : `false`
  99665. */
  99666. get expandable(): boolean;
  99667. /**
  99668. * Gets if the SPS supports the Multi Materials
  99669. */
  99670. get multimaterialEnabled(): boolean;
  99671. /**
  99672. * Gets if the SPS uses the model materials for its own multimaterial.
  99673. */
  99674. get useModelMaterial(): boolean;
  99675. /**
  99676. * The SPS used material array.
  99677. */
  99678. get materials(): Material[];
  99679. /**
  99680. * Sets the SPS MultiMaterial from the passed materials.
  99681. * Note : the passed array is internally copied and not used then by reference.
  99682. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  99683. */
  99684. setMultiMaterial(materials: Material[]): void;
  99685. /**
  99686. * The SPS computed multimaterial object
  99687. */
  99688. get multimaterial(): MultiMaterial;
  99689. set multimaterial(mm: MultiMaterial);
  99690. /**
  99691. * If the subMeshes must be updated on the next call to setParticles()
  99692. */
  99693. get autoUpdateSubMeshes(): boolean;
  99694. set autoUpdateSubMeshes(val: boolean);
  99695. /**
  99696. * This function does nothing. It may be overwritten to set all the particle first values.
  99697. * The SPS doesn't call this function, you may have to call it by your own.
  99698. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99699. */
  99700. initParticles(): void;
  99701. /**
  99702. * This function does nothing. It may be overwritten to recycle a particle.
  99703. * The SPS doesn't call this function, you may have to call it by your own.
  99704. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99705. * @param particle The particle to recycle
  99706. * @returns the recycled particle
  99707. */
  99708. recycleParticle(particle: SolidParticle): SolidParticle;
  99709. /**
  99710. * Updates a particle : this function should be overwritten by the user.
  99711. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  99712. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  99713. * @example : just set a particle position or velocity and recycle conditions
  99714. * @param particle The particle to update
  99715. * @returns the updated particle
  99716. */
  99717. updateParticle(particle: SolidParticle): SolidParticle;
  99718. /**
  99719. * Updates a vertex of a particle : it can be overwritten by the user.
  99720. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  99721. * @param particle the current particle
  99722. * @param vertex the current index of the current particle
  99723. * @param pt the index of the current vertex in the particle shape
  99724. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  99725. * @example : just set a vertex particle position
  99726. * @returns the updated vertex
  99727. */
  99728. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  99729. /**
  99730. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  99731. * This does nothing and may be overwritten by the user.
  99732. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99733. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99734. * @param update the boolean update value actually passed to setParticles()
  99735. */
  99736. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  99737. /**
  99738. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  99739. * This will be passed three parameters.
  99740. * This does nothing and may be overwritten by the user.
  99741. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99742. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  99743. * @param update the boolean update value actually passed to setParticles()
  99744. */
  99745. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  99746. }
  99747. }
  99748. declare module BABYLON {
  99749. /**
  99750. * Represents one particle of a solid particle system.
  99751. */
  99752. export class SolidParticle {
  99753. /**
  99754. * particle global index
  99755. */
  99756. idx: number;
  99757. /**
  99758. * particle identifier
  99759. */
  99760. id: number;
  99761. /**
  99762. * The color of the particle
  99763. */
  99764. color: Nullable<Color4>;
  99765. /**
  99766. * The world space position of the particle.
  99767. */
  99768. position: Vector3;
  99769. /**
  99770. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  99771. */
  99772. rotation: Vector3;
  99773. /**
  99774. * The world space rotation quaternion of the particle.
  99775. */
  99776. rotationQuaternion: Nullable<Quaternion>;
  99777. /**
  99778. * The scaling of the particle.
  99779. */
  99780. scaling: Vector3;
  99781. /**
  99782. * The uvs of the particle.
  99783. */
  99784. uvs: Vector4;
  99785. /**
  99786. * The current speed of the particle.
  99787. */
  99788. velocity: Vector3;
  99789. /**
  99790. * The pivot point in the particle local space.
  99791. */
  99792. pivot: Vector3;
  99793. /**
  99794. * Must the particle be translated from its pivot point in its local space ?
  99795. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  99796. * Default : false
  99797. */
  99798. translateFromPivot: boolean;
  99799. /**
  99800. * Is the particle active or not ?
  99801. */
  99802. alive: boolean;
  99803. /**
  99804. * Is the particle visible or not ?
  99805. */
  99806. isVisible: boolean;
  99807. /**
  99808. * Index of this particle in the global "positions" array (Internal use)
  99809. * @hidden
  99810. */
  99811. _pos: number;
  99812. /**
  99813. * @hidden Index of this particle in the global "indices" array (Internal use)
  99814. */
  99815. _ind: number;
  99816. /**
  99817. * @hidden ModelShape of this particle (Internal use)
  99818. */
  99819. _model: ModelShape;
  99820. /**
  99821. * ModelShape id of this particle
  99822. */
  99823. shapeId: number;
  99824. /**
  99825. * Index of the particle in its shape id
  99826. */
  99827. idxInShape: number;
  99828. /**
  99829. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  99830. */
  99831. _modelBoundingInfo: BoundingInfo;
  99832. /**
  99833. * @hidden Particle BoundingInfo object (Internal use)
  99834. */
  99835. _boundingInfo: BoundingInfo;
  99836. /**
  99837. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  99838. */
  99839. _sps: SolidParticleSystem;
  99840. /**
  99841. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  99842. */
  99843. _stillInvisible: boolean;
  99844. /**
  99845. * @hidden Last computed particle rotation matrix
  99846. */
  99847. _rotationMatrix: number[];
  99848. /**
  99849. * Parent particle Id, if any.
  99850. * Default null.
  99851. */
  99852. parentId: Nullable<number>;
  99853. /**
  99854. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  99855. */
  99856. materialIndex: Nullable<number>;
  99857. /**
  99858. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  99859. * The possible values are :
  99860. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  99861. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  99862. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  99863. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  99864. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  99865. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  99866. * */
  99867. cullingStrategy: number;
  99868. /**
  99869. * @hidden Internal global position in the SPS.
  99870. */
  99871. _globalPosition: Vector3;
  99872. /**
  99873. * Creates a Solid Particle object.
  99874. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  99875. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  99876. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  99877. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  99878. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  99879. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  99880. * @param shapeId (integer) is the model shape identifier in the SPS.
  99881. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  99882. * @param sps defines the sps it is associated to
  99883. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  99884. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  99885. */
  99886. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  99887. /**
  99888. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  99889. * @param target the particle target
  99890. * @returns the current particle
  99891. */
  99892. copyToRef(target: SolidParticle): SolidParticle;
  99893. /**
  99894. * Legacy support, changed scale to scaling
  99895. */
  99896. get scale(): Vector3;
  99897. /**
  99898. * Legacy support, changed scale to scaling
  99899. */
  99900. set scale(scale: Vector3);
  99901. /**
  99902. * Legacy support, changed quaternion to rotationQuaternion
  99903. */
  99904. get quaternion(): Nullable<Quaternion>;
  99905. /**
  99906. * Legacy support, changed quaternion to rotationQuaternion
  99907. */
  99908. set quaternion(q: Nullable<Quaternion>);
  99909. /**
  99910. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  99911. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  99912. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  99913. * @returns true if it intersects
  99914. */
  99915. intersectsMesh(target: Mesh | SolidParticle): boolean;
  99916. /**
  99917. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  99918. * A particle is in the frustum if its bounding box intersects the frustum
  99919. * @param frustumPlanes defines the frustum to test
  99920. * @returns true if the particle is in the frustum planes
  99921. */
  99922. isInFrustum(frustumPlanes: Plane[]): boolean;
  99923. /**
  99924. * get the rotation matrix of the particle
  99925. * @hidden
  99926. */
  99927. getRotationMatrix(m: Matrix): void;
  99928. }
  99929. /**
  99930. * Represents the shape of the model used by one particle of a solid particle system.
  99931. * SPS internal tool, don't use it manually.
  99932. */
  99933. export class ModelShape {
  99934. /**
  99935. * The shape id
  99936. * @hidden
  99937. */
  99938. shapeID: number;
  99939. /**
  99940. * flat array of model positions (internal use)
  99941. * @hidden
  99942. */
  99943. _shape: Vector3[];
  99944. /**
  99945. * flat array of model UVs (internal use)
  99946. * @hidden
  99947. */
  99948. _shapeUV: number[];
  99949. /**
  99950. * color array of the model
  99951. * @hidden
  99952. */
  99953. _shapeColors: number[];
  99954. /**
  99955. * indices array of the model
  99956. * @hidden
  99957. */
  99958. _indices: number[];
  99959. /**
  99960. * normals array of the model
  99961. * @hidden
  99962. */
  99963. _normals: number[];
  99964. /**
  99965. * length of the shape in the model indices array (internal use)
  99966. * @hidden
  99967. */
  99968. _indicesLength: number;
  99969. /**
  99970. * Custom position function (internal use)
  99971. * @hidden
  99972. */
  99973. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  99974. /**
  99975. * Custom vertex function (internal use)
  99976. * @hidden
  99977. */
  99978. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  99979. /**
  99980. * Model material (internal use)
  99981. * @hidden
  99982. */
  99983. _material: Nullable<Material>;
  99984. /**
  99985. * 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.
  99986. * SPS internal tool, don't use it manually.
  99987. * @hidden
  99988. */
  99989. 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>);
  99990. }
  99991. /**
  99992. * Represents a Depth Sorted Particle in the solid particle system.
  99993. * @hidden
  99994. */
  99995. export class DepthSortedParticle {
  99996. /**
  99997. * Index of the particle in the "indices" array
  99998. */
  99999. ind: number;
  100000. /**
  100001. * Length of the particle shape in the "indices" array
  100002. */
  100003. indicesLength: number;
  100004. /**
  100005. * Squared distance from the particle to the camera
  100006. */
  100007. sqDistance: number;
  100008. /**
  100009. * Material index when used with MultiMaterials
  100010. */
  100011. materialIndex: number;
  100012. /**
  100013. * Creates a new sorted particle
  100014. * @param materialIndex
  100015. */
  100016. constructor(ind: number, indLength: number, materialIndex: number);
  100017. }
  100018. }
  100019. declare module BABYLON {
  100020. /**
  100021. * @hidden
  100022. */
  100023. export class _MeshCollisionData {
  100024. _checkCollisions: boolean;
  100025. _collisionMask: number;
  100026. _collisionGroup: number;
  100027. _collider: Nullable<Collider>;
  100028. _oldPositionForCollisions: Vector3;
  100029. _diffPositionForCollisions: Vector3;
  100030. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100031. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100032. }
  100033. }
  100034. declare module BABYLON {
  100035. /** @hidden */
  100036. class _FacetDataStorage {
  100037. facetPositions: Vector3[];
  100038. facetNormals: Vector3[];
  100039. facetPartitioning: number[][];
  100040. facetNb: number;
  100041. partitioningSubdivisions: number;
  100042. partitioningBBoxRatio: number;
  100043. facetDataEnabled: boolean;
  100044. facetParameters: any;
  100045. bbSize: Vector3;
  100046. subDiv: {
  100047. max: number;
  100048. X: number;
  100049. Y: number;
  100050. Z: number;
  100051. };
  100052. facetDepthSort: boolean;
  100053. facetDepthSortEnabled: boolean;
  100054. depthSortedIndices: IndicesArray;
  100055. depthSortedFacets: {
  100056. ind: number;
  100057. sqDistance: number;
  100058. }[];
  100059. facetDepthSortFunction: (f1: {
  100060. ind: number;
  100061. sqDistance: number;
  100062. }, f2: {
  100063. ind: number;
  100064. sqDistance: number;
  100065. }) => number;
  100066. facetDepthSortFrom: Vector3;
  100067. facetDepthSortOrigin: Vector3;
  100068. invertedMatrix: Matrix;
  100069. }
  100070. /**
  100071. * @hidden
  100072. **/
  100073. class _InternalAbstractMeshDataInfo {
  100074. _hasVertexAlpha: boolean;
  100075. _useVertexColors: boolean;
  100076. _numBoneInfluencers: number;
  100077. _applyFog: boolean;
  100078. _receiveShadows: boolean;
  100079. _facetData: _FacetDataStorage;
  100080. _visibility: number;
  100081. _skeleton: Nullable<Skeleton>;
  100082. _layerMask: number;
  100083. _computeBonesUsingShaders: boolean;
  100084. _isActive: boolean;
  100085. _onlyForInstances: boolean;
  100086. _isActiveIntermediate: boolean;
  100087. _onlyForInstancesIntermediate: boolean;
  100088. _actAsRegularMesh: boolean;
  100089. }
  100090. /**
  100091. * Class used to store all common mesh properties
  100092. */
  100093. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100094. /** No occlusion */
  100095. static OCCLUSION_TYPE_NONE: number;
  100096. /** Occlusion set to optimisitic */
  100097. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100098. /** Occlusion set to strict */
  100099. static OCCLUSION_TYPE_STRICT: number;
  100100. /** Use an accurante occlusion algorithm */
  100101. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100102. /** Use a conservative occlusion algorithm */
  100103. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100104. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100105. * Test order :
  100106. * Is the bounding sphere outside the frustum ?
  100107. * If not, are the bounding box vertices outside the frustum ?
  100108. * It not, then the cullable object is in the frustum.
  100109. */
  100110. static readonly CULLINGSTRATEGY_STANDARD: number;
  100111. /** Culling strategy : Bounding Sphere Only.
  100112. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100113. * It's also less accurate than the standard because some not visible objects can still be selected.
  100114. * Test : is the bounding sphere outside the frustum ?
  100115. * If not, then the cullable object is in the frustum.
  100116. */
  100117. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  100118. /** Culling strategy : Optimistic Inclusion.
  100119. * This in an inclusion test first, then the standard exclusion test.
  100120. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  100121. * 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.
  100122. * Anyway, it's as accurate as the standard strategy.
  100123. * Test :
  100124. * Is the cullable object bounding sphere center in the frustum ?
  100125. * If not, apply the default culling strategy.
  100126. */
  100127. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  100128. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  100129. * This in an inclusion test first, then the bounding sphere only exclusion test.
  100130. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  100131. * 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.
  100132. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  100133. * Test :
  100134. * Is the cullable object bounding sphere center in the frustum ?
  100135. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  100136. */
  100137. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  100138. /**
  100139. * No billboard
  100140. */
  100141. static get BILLBOARDMODE_NONE(): number;
  100142. /** Billboard on X axis */
  100143. static get BILLBOARDMODE_X(): number;
  100144. /** Billboard on Y axis */
  100145. static get BILLBOARDMODE_Y(): number;
  100146. /** Billboard on Z axis */
  100147. static get BILLBOARDMODE_Z(): number;
  100148. /** Billboard on all axes */
  100149. static get BILLBOARDMODE_ALL(): number;
  100150. /** Billboard on using position instead of orientation */
  100151. static get BILLBOARDMODE_USE_POSITION(): number;
  100152. /** @hidden */
  100153. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  100154. /**
  100155. * The culling strategy to use to check whether the mesh must be rendered or not.
  100156. * This value can be changed at any time and will be used on the next render mesh selection.
  100157. * The possible values are :
  100158. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100159. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100160. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100161. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100162. * Please read each static variable documentation to get details about the culling process.
  100163. * */
  100164. cullingStrategy: number;
  100165. /**
  100166. * Gets the number of facets in the mesh
  100167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100168. */
  100169. get facetNb(): number;
  100170. /**
  100171. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  100172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100173. */
  100174. get partitioningSubdivisions(): number;
  100175. set partitioningSubdivisions(nb: number);
  100176. /**
  100177. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  100178. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  100179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100180. */
  100181. get partitioningBBoxRatio(): number;
  100182. set partitioningBBoxRatio(ratio: number);
  100183. /**
  100184. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  100185. * Works only for updatable meshes.
  100186. * Doesn't work with multi-materials
  100187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100188. */
  100189. get mustDepthSortFacets(): boolean;
  100190. set mustDepthSortFacets(sort: boolean);
  100191. /**
  100192. * The location (Vector3) where the facet depth sort must be computed from.
  100193. * By default, the active camera position.
  100194. * Used only when facet depth sort is enabled
  100195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100196. */
  100197. get facetDepthSortFrom(): Vector3;
  100198. set facetDepthSortFrom(location: Vector3);
  100199. /**
  100200. * gets a boolean indicating if facetData is enabled
  100201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100202. */
  100203. get isFacetDataEnabled(): boolean;
  100204. /** @hidden */
  100205. _updateNonUniformScalingState(value: boolean): boolean;
  100206. /**
  100207. * An event triggered when this mesh collides with another one
  100208. */
  100209. onCollideObservable: Observable<AbstractMesh>;
  100210. /** Set a function to call when this mesh collides with another one */
  100211. set onCollide(callback: () => void);
  100212. /**
  100213. * An event triggered when the collision's position changes
  100214. */
  100215. onCollisionPositionChangeObservable: Observable<Vector3>;
  100216. /** Set a function to call when the collision's position changes */
  100217. set onCollisionPositionChange(callback: () => void);
  100218. /**
  100219. * An event triggered when material is changed
  100220. */
  100221. onMaterialChangedObservable: Observable<AbstractMesh>;
  100222. /**
  100223. * Gets or sets the orientation for POV movement & rotation
  100224. */
  100225. definedFacingForward: boolean;
  100226. /** @hidden */
  100227. _occlusionQuery: Nullable<WebGLQuery>;
  100228. /** @hidden */
  100229. _renderingGroup: Nullable<RenderingGroup>;
  100230. /**
  100231. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100232. */
  100233. get visibility(): number;
  100234. /**
  100235. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100236. */
  100237. set visibility(value: number);
  100238. /** Gets or sets the alpha index used to sort transparent meshes
  100239. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  100240. */
  100241. alphaIndex: number;
  100242. /**
  100243. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  100244. */
  100245. isVisible: boolean;
  100246. /**
  100247. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  100248. */
  100249. isPickable: boolean;
  100250. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  100251. showSubMeshesBoundingBox: boolean;
  100252. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  100253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100254. */
  100255. isBlocker: boolean;
  100256. /**
  100257. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  100258. */
  100259. enablePointerMoveEvents: boolean;
  100260. /**
  100261. * Specifies the rendering group id for this mesh (0 by default)
  100262. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  100263. */
  100264. renderingGroupId: number;
  100265. private _material;
  100266. /** Gets or sets current material */
  100267. get material(): Nullable<Material>;
  100268. set material(value: Nullable<Material>);
  100269. /**
  100270. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  100271. * @see http://doc.babylonjs.com/babylon101/shadows
  100272. */
  100273. get receiveShadows(): boolean;
  100274. set receiveShadows(value: boolean);
  100275. /** Defines color to use when rendering outline */
  100276. outlineColor: Color3;
  100277. /** Define width to use when rendering outline */
  100278. outlineWidth: number;
  100279. /** Defines color to use when rendering overlay */
  100280. overlayColor: Color3;
  100281. /** Defines alpha to use when rendering overlay */
  100282. overlayAlpha: number;
  100283. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  100284. get hasVertexAlpha(): boolean;
  100285. set hasVertexAlpha(value: boolean);
  100286. /** 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) */
  100287. get useVertexColors(): boolean;
  100288. set useVertexColors(value: boolean);
  100289. /**
  100290. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  100291. */
  100292. get computeBonesUsingShaders(): boolean;
  100293. set computeBonesUsingShaders(value: boolean);
  100294. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  100295. get numBoneInfluencers(): number;
  100296. set numBoneInfluencers(value: number);
  100297. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  100298. get applyFog(): boolean;
  100299. set applyFog(value: boolean);
  100300. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  100301. useOctreeForRenderingSelection: boolean;
  100302. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  100303. useOctreeForPicking: boolean;
  100304. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  100305. useOctreeForCollisions: boolean;
  100306. /**
  100307. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  100308. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  100309. */
  100310. get layerMask(): number;
  100311. set layerMask(value: number);
  100312. /**
  100313. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  100314. */
  100315. alwaysSelectAsActiveMesh: boolean;
  100316. /**
  100317. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  100318. */
  100319. doNotSyncBoundingInfo: boolean;
  100320. /**
  100321. * Gets or sets the current action manager
  100322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100323. */
  100324. actionManager: Nullable<AbstractActionManager>;
  100325. private _meshCollisionData;
  100326. /**
  100327. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  100328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100329. */
  100330. ellipsoid: Vector3;
  100331. /**
  100332. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  100333. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100334. */
  100335. ellipsoidOffset: Vector3;
  100336. /**
  100337. * Gets or sets a collision mask used to mask collisions (default is -1).
  100338. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100339. */
  100340. get collisionMask(): number;
  100341. set collisionMask(mask: number);
  100342. /**
  100343. * Gets or sets the current collision group mask (-1 by default).
  100344. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100345. */
  100346. get collisionGroup(): number;
  100347. set collisionGroup(mask: number);
  100348. /**
  100349. * Defines edge width used when edgesRenderer is enabled
  100350. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100351. */
  100352. edgesWidth: number;
  100353. /**
  100354. * Defines edge color used when edgesRenderer is enabled
  100355. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100356. */
  100357. edgesColor: Color4;
  100358. /** @hidden */
  100359. _edgesRenderer: Nullable<IEdgesRenderer>;
  100360. /** @hidden */
  100361. _masterMesh: Nullable<AbstractMesh>;
  100362. /** @hidden */
  100363. _boundingInfo: Nullable<BoundingInfo>;
  100364. /** @hidden */
  100365. _renderId: number;
  100366. /**
  100367. * Gets or sets the list of subMeshes
  100368. * @see http://doc.babylonjs.com/how_to/multi_materials
  100369. */
  100370. subMeshes: SubMesh[];
  100371. /** @hidden */
  100372. _intersectionsInProgress: AbstractMesh[];
  100373. /** @hidden */
  100374. _unIndexed: boolean;
  100375. /** @hidden */
  100376. _lightSources: Light[];
  100377. /** Gets the list of lights affecting that mesh */
  100378. get lightSources(): Light[];
  100379. /** @hidden */
  100380. get _positions(): Nullable<Vector3[]>;
  100381. /** @hidden */
  100382. _waitingData: {
  100383. lods: Nullable<any>;
  100384. actions: Nullable<any>;
  100385. freezeWorldMatrix: Nullable<boolean>;
  100386. };
  100387. /** @hidden */
  100388. _bonesTransformMatrices: Nullable<Float32Array>;
  100389. /** @hidden */
  100390. _transformMatrixTexture: Nullable<RawTexture>;
  100391. /**
  100392. * Gets or sets a skeleton to apply skining transformations
  100393. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100394. */
  100395. set skeleton(value: Nullable<Skeleton>);
  100396. get skeleton(): Nullable<Skeleton>;
  100397. /**
  100398. * An event triggered when the mesh is rebuilt.
  100399. */
  100400. onRebuildObservable: Observable<AbstractMesh>;
  100401. /**
  100402. * Creates a new AbstractMesh
  100403. * @param name defines the name of the mesh
  100404. * @param scene defines the hosting scene
  100405. */
  100406. constructor(name: string, scene?: Nullable<Scene>);
  100407. /**
  100408. * Returns the string "AbstractMesh"
  100409. * @returns "AbstractMesh"
  100410. */
  100411. getClassName(): string;
  100412. /**
  100413. * Gets a string representation of the current mesh
  100414. * @param fullDetails defines a boolean indicating if full details must be included
  100415. * @returns a string representation of the current mesh
  100416. */
  100417. toString(fullDetails?: boolean): string;
  100418. /**
  100419. * @hidden
  100420. */
  100421. protected _getEffectiveParent(): Nullable<Node>;
  100422. /** @hidden */
  100423. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  100424. /** @hidden */
  100425. _rebuild(): void;
  100426. /** @hidden */
  100427. _resyncLightSources(): void;
  100428. /** @hidden */
  100429. _resyncLightSource(light: Light): void;
  100430. /** @hidden */
  100431. _unBindEffect(): void;
  100432. /** @hidden */
  100433. _removeLightSource(light: Light, dispose: boolean): void;
  100434. private _markSubMeshesAsDirty;
  100435. /** @hidden */
  100436. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  100437. /** @hidden */
  100438. _markSubMeshesAsAttributesDirty(): void;
  100439. /** @hidden */
  100440. _markSubMeshesAsMiscDirty(): void;
  100441. /**
  100442. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  100443. */
  100444. get scaling(): Vector3;
  100445. set scaling(newScaling: Vector3);
  100446. /**
  100447. * Returns true if the mesh is blocked. Implemented by child classes
  100448. */
  100449. get isBlocked(): boolean;
  100450. /**
  100451. * Returns the mesh itself by default. Implemented by child classes
  100452. * @param camera defines the camera to use to pick the right LOD level
  100453. * @returns the currentAbstractMesh
  100454. */
  100455. getLOD(camera: Camera): Nullable<AbstractMesh>;
  100456. /**
  100457. * Returns 0 by default. Implemented by child classes
  100458. * @returns an integer
  100459. */
  100460. getTotalVertices(): number;
  100461. /**
  100462. * Returns a positive integer : the total number of indices in this mesh geometry.
  100463. * @returns the numner of indices or zero if the mesh has no geometry.
  100464. */
  100465. getTotalIndices(): number;
  100466. /**
  100467. * Returns null by default. Implemented by child classes
  100468. * @returns null
  100469. */
  100470. getIndices(): Nullable<IndicesArray>;
  100471. /**
  100472. * Returns the array of the requested vertex data kind. Implemented by child classes
  100473. * @param kind defines the vertex data kind to use
  100474. * @returns null
  100475. */
  100476. getVerticesData(kind: string): Nullable<FloatArray>;
  100477. /**
  100478. * Sets the vertex data of the mesh geometry for the requested `kind`.
  100479. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  100480. * Note that a new underlying VertexBuffer object is created each call.
  100481. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  100482. * @param kind defines vertex data kind:
  100483. * * VertexBuffer.PositionKind
  100484. * * VertexBuffer.UVKind
  100485. * * VertexBuffer.UV2Kind
  100486. * * VertexBuffer.UV3Kind
  100487. * * VertexBuffer.UV4Kind
  100488. * * VertexBuffer.UV5Kind
  100489. * * VertexBuffer.UV6Kind
  100490. * * VertexBuffer.ColorKind
  100491. * * VertexBuffer.MatricesIndicesKind
  100492. * * VertexBuffer.MatricesIndicesExtraKind
  100493. * * VertexBuffer.MatricesWeightsKind
  100494. * * VertexBuffer.MatricesWeightsExtraKind
  100495. * @param data defines the data source
  100496. * @param updatable defines if the data must be flagged as updatable (or static)
  100497. * @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
  100498. * @returns the current mesh
  100499. */
  100500. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  100501. /**
  100502. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  100503. * If the mesh has no geometry, it is simply returned as it is.
  100504. * @param kind defines vertex data kind:
  100505. * * VertexBuffer.PositionKind
  100506. * * VertexBuffer.UVKind
  100507. * * VertexBuffer.UV2Kind
  100508. * * VertexBuffer.UV3Kind
  100509. * * VertexBuffer.UV4Kind
  100510. * * VertexBuffer.UV5Kind
  100511. * * VertexBuffer.UV6Kind
  100512. * * VertexBuffer.ColorKind
  100513. * * VertexBuffer.MatricesIndicesKind
  100514. * * VertexBuffer.MatricesIndicesExtraKind
  100515. * * VertexBuffer.MatricesWeightsKind
  100516. * * VertexBuffer.MatricesWeightsExtraKind
  100517. * @param data defines the data source
  100518. * @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
  100519. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  100520. * @returns the current mesh
  100521. */
  100522. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  100523. /**
  100524. * Sets the mesh indices,
  100525. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  100526. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  100527. * @param totalVertices Defines the total number of vertices
  100528. * @returns the current mesh
  100529. */
  100530. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  100531. /**
  100532. * Gets a boolean indicating if specific vertex data is present
  100533. * @param kind defines the vertex data kind to use
  100534. * @returns true is data kind is present
  100535. */
  100536. isVerticesDataPresent(kind: string): boolean;
  100537. /**
  100538. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  100539. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  100540. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  100541. * @returns a BoundingInfo
  100542. */
  100543. getBoundingInfo(): BoundingInfo;
  100544. /**
  100545. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  100546. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  100547. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  100548. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  100549. * @returns the current mesh
  100550. */
  100551. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  100552. /**
  100553. * Overwrite the current bounding info
  100554. * @param boundingInfo defines the new bounding info
  100555. * @returns the current mesh
  100556. */
  100557. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  100558. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  100559. get useBones(): boolean;
  100560. /** @hidden */
  100561. _preActivate(): void;
  100562. /** @hidden */
  100563. _preActivateForIntermediateRendering(renderId: number): void;
  100564. /** @hidden */
  100565. _activate(renderId: number, intermediateRendering: boolean): boolean;
  100566. /** @hidden */
  100567. _postActivate(): void;
  100568. /** @hidden */
  100569. _freeze(): void;
  100570. /** @hidden */
  100571. _unFreeze(): void;
  100572. /**
  100573. * Gets the current world matrix
  100574. * @returns a Matrix
  100575. */
  100576. getWorldMatrix(): Matrix;
  100577. /** @hidden */
  100578. _getWorldMatrixDeterminant(): number;
  100579. /**
  100580. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  100581. */
  100582. get isAnInstance(): boolean;
  100583. /**
  100584. * Gets a boolean indicating if this mesh has instances
  100585. */
  100586. get hasInstances(): boolean;
  100587. /**
  100588. * Perform relative position change from the point of view of behind the front of the mesh.
  100589. * This is performed taking into account the meshes current rotation, so you do not have to care.
  100590. * Supports definition of mesh facing forward or backward
  100591. * @param amountRight defines the distance on the right axis
  100592. * @param amountUp defines the distance on the up axis
  100593. * @param amountForward defines the distance on the forward axis
  100594. * @returns the current mesh
  100595. */
  100596. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  100597. /**
  100598. * Calculate relative position change from the point of view of behind the front of the mesh.
  100599. * This is performed taking into account the meshes current rotation, so you do not have to care.
  100600. * Supports definition of mesh facing forward or backward
  100601. * @param amountRight defines the distance on the right axis
  100602. * @param amountUp defines the distance on the up axis
  100603. * @param amountForward defines the distance on the forward axis
  100604. * @returns the new displacement vector
  100605. */
  100606. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  100607. /**
  100608. * Perform relative rotation change from the point of view of behind the front of the mesh.
  100609. * Supports definition of mesh facing forward or backward
  100610. * @param flipBack defines the flip
  100611. * @param twirlClockwise defines the twirl
  100612. * @param tiltRight defines the tilt
  100613. * @returns the current mesh
  100614. */
  100615. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  100616. /**
  100617. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  100618. * Supports definition of mesh facing forward or backward.
  100619. * @param flipBack defines the flip
  100620. * @param twirlClockwise defines the twirl
  100621. * @param tiltRight defines the tilt
  100622. * @returns the new rotation vector
  100623. */
  100624. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  100625. /**
  100626. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  100627. * This means the mesh underlying bounding box and sphere are recomputed.
  100628. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  100629. * @returns the current mesh
  100630. */
  100631. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  100632. /** @hidden */
  100633. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  100634. /** @hidden */
  100635. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  100636. /** @hidden */
  100637. _updateBoundingInfo(): AbstractMesh;
  100638. /** @hidden */
  100639. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  100640. /** @hidden */
  100641. protected _afterComputeWorldMatrix(): void;
  100642. /** @hidden */
  100643. get _effectiveMesh(): AbstractMesh;
  100644. /**
  100645. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  100646. * A mesh is in the frustum if its bounding box intersects the frustum
  100647. * @param frustumPlanes defines the frustum to test
  100648. * @returns true if the mesh is in the frustum planes
  100649. */
  100650. isInFrustum(frustumPlanes: Plane[]): boolean;
  100651. /**
  100652. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  100653. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  100654. * @param frustumPlanes defines the frustum to test
  100655. * @returns true if the mesh is completely in the frustum planes
  100656. */
  100657. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  100658. /**
  100659. * True if the mesh intersects another mesh or a SolidParticle object
  100660. * @param mesh defines a target mesh or SolidParticle to test
  100661. * @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)
  100662. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  100663. * @returns true if there is an intersection
  100664. */
  100665. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  100666. /**
  100667. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  100668. * @param point defines the point to test
  100669. * @returns true if there is an intersection
  100670. */
  100671. intersectsPoint(point: Vector3): boolean;
  100672. /**
  100673. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  100674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100675. */
  100676. get checkCollisions(): boolean;
  100677. set checkCollisions(collisionEnabled: boolean);
  100678. /**
  100679. * Gets Collider object used to compute collisions (not physics)
  100680. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100681. */
  100682. get collider(): Nullable<Collider>;
  100683. /**
  100684. * Move the mesh using collision engine
  100685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100686. * @param displacement defines the requested displacement vector
  100687. * @returns the current mesh
  100688. */
  100689. moveWithCollisions(displacement: Vector3): AbstractMesh;
  100690. private _onCollisionPositionChange;
  100691. /** @hidden */
  100692. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  100693. /** @hidden */
  100694. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  100695. /** @hidden */
  100696. _checkCollision(collider: Collider): AbstractMesh;
  100697. /** @hidden */
  100698. _generatePointsArray(): boolean;
  100699. /**
  100700. * Checks if the passed Ray intersects with the mesh
  100701. * @param ray defines the ray to use
  100702. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  100703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100704. * @returns the picking info
  100705. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  100706. */
  100707. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  100708. /**
  100709. * Clones the current mesh
  100710. * @param name defines the mesh name
  100711. * @param newParent defines the new mesh parent
  100712. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  100713. * @returns the new mesh
  100714. */
  100715. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  100716. /**
  100717. * Disposes all the submeshes of the current meshnp
  100718. * @returns the current mesh
  100719. */
  100720. releaseSubMeshes(): AbstractMesh;
  100721. /**
  100722. * Releases resources associated with this abstract mesh.
  100723. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100724. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100725. */
  100726. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100727. /**
  100728. * Adds the passed mesh as a child to the current mesh
  100729. * @param mesh defines the child mesh
  100730. * @returns the current mesh
  100731. */
  100732. addChild(mesh: AbstractMesh): AbstractMesh;
  100733. /**
  100734. * Removes the passed mesh from the current mesh children list
  100735. * @param mesh defines the child mesh
  100736. * @returns the current mesh
  100737. */
  100738. removeChild(mesh: AbstractMesh): AbstractMesh;
  100739. /** @hidden */
  100740. private _initFacetData;
  100741. /**
  100742. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  100743. * This method can be called within the render loop.
  100744. * 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
  100745. * @returns the current mesh
  100746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100747. */
  100748. updateFacetData(): AbstractMesh;
  100749. /**
  100750. * Returns the facetLocalNormals array.
  100751. * The normals are expressed in the mesh local spac
  100752. * @returns an array of Vector3
  100753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100754. */
  100755. getFacetLocalNormals(): Vector3[];
  100756. /**
  100757. * Returns the facetLocalPositions array.
  100758. * The facet positions are expressed in the mesh local space
  100759. * @returns an array of Vector3
  100760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100761. */
  100762. getFacetLocalPositions(): Vector3[];
  100763. /**
  100764. * Returns the facetLocalPartioning array
  100765. * @returns an array of array of numbers
  100766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100767. */
  100768. getFacetLocalPartitioning(): number[][];
  100769. /**
  100770. * Returns the i-th facet position in the world system.
  100771. * This method allocates a new Vector3 per call
  100772. * @param i defines the facet index
  100773. * @returns a new Vector3
  100774. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100775. */
  100776. getFacetPosition(i: number): Vector3;
  100777. /**
  100778. * Sets the reference Vector3 with the i-th facet position in the world system
  100779. * @param i defines the facet index
  100780. * @param ref defines the target vector
  100781. * @returns the current mesh
  100782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100783. */
  100784. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  100785. /**
  100786. * Returns the i-th facet normal in the world system.
  100787. * This method allocates a new Vector3 per call
  100788. * @param i defines the facet index
  100789. * @returns a new Vector3
  100790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100791. */
  100792. getFacetNormal(i: number): Vector3;
  100793. /**
  100794. * Sets the reference Vector3 with the i-th facet normal in the world system
  100795. * @param i defines the facet index
  100796. * @param ref defines the target vector
  100797. * @returns the current mesh
  100798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100799. */
  100800. getFacetNormalToRef(i: number, ref: Vector3): this;
  100801. /**
  100802. * 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)
  100803. * @param x defines x coordinate
  100804. * @param y defines y coordinate
  100805. * @param z defines z coordinate
  100806. * @returns the array of facet indexes
  100807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100808. */
  100809. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  100810. /**
  100811. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  100812. * @param projected sets as the (x,y,z) world projection on the facet
  100813. * @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
  100814. * @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
  100815. * @param x defines x coordinate
  100816. * @param y defines y coordinate
  100817. * @param z defines z coordinate
  100818. * @returns the face index if found (or null instead)
  100819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100820. */
  100821. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  100822. /**
  100823. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  100824. * @param projected sets as the (x,y,z) local projection on the facet
  100825. * @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
  100826. * @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
  100827. * @param x defines x coordinate
  100828. * @param y defines y coordinate
  100829. * @param z defines z coordinate
  100830. * @returns the face index if found (or null instead)
  100831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100832. */
  100833. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  100834. /**
  100835. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  100836. * @returns the parameters
  100837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100838. */
  100839. getFacetDataParameters(): any;
  100840. /**
  100841. * Disables the feature FacetData and frees the related memory
  100842. * @returns the current mesh
  100843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  100844. */
  100845. disableFacetData(): AbstractMesh;
  100846. /**
  100847. * Updates the AbstractMesh indices array
  100848. * @param indices defines the data source
  100849. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  100850. * @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)
  100851. * @returns the current mesh
  100852. */
  100853. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  100854. /**
  100855. * Creates new normals data for the mesh
  100856. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  100857. * @returns the current mesh
  100858. */
  100859. createNormals(updatable: boolean): AbstractMesh;
  100860. /**
  100861. * Align the mesh with a normal
  100862. * @param normal defines the normal to use
  100863. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  100864. * @returns the current mesh
  100865. */
  100866. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  100867. /** @hidden */
  100868. _checkOcclusionQuery(): boolean;
  100869. /**
  100870. * Disables the mesh edge rendering mode
  100871. * @returns the currentAbstractMesh
  100872. */
  100873. disableEdgesRendering(): AbstractMesh;
  100874. /**
  100875. * Enables the edge rendering mode on the mesh.
  100876. * This mode makes the mesh edges visible
  100877. * @param epsilon defines the maximal distance between two angles to detect a face
  100878. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  100879. * @returns the currentAbstractMesh
  100880. * @see https://www.babylonjs-playground.com/#19O9TU#0
  100881. */
  100882. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  100883. }
  100884. }
  100885. declare module BABYLON {
  100886. /**
  100887. * Interface used to define ActionEvent
  100888. */
  100889. export interface IActionEvent {
  100890. /** The mesh or sprite that triggered the action */
  100891. source: any;
  100892. /** The X mouse cursor position at the time of the event */
  100893. pointerX: number;
  100894. /** The Y mouse cursor position at the time of the event */
  100895. pointerY: number;
  100896. /** The mesh that is currently pointed at (can be null) */
  100897. meshUnderPointer: Nullable<AbstractMesh>;
  100898. /** the original (browser) event that triggered the ActionEvent */
  100899. sourceEvent?: any;
  100900. /** additional data for the event */
  100901. additionalData?: any;
  100902. }
  100903. /**
  100904. * ActionEvent is the event being sent when an action is triggered.
  100905. */
  100906. export class ActionEvent implements IActionEvent {
  100907. /** The mesh or sprite that triggered the action */
  100908. source: any;
  100909. /** The X mouse cursor position at the time of the event */
  100910. pointerX: number;
  100911. /** The Y mouse cursor position at the time of the event */
  100912. pointerY: number;
  100913. /** The mesh that is currently pointed at (can be null) */
  100914. meshUnderPointer: Nullable<AbstractMesh>;
  100915. /** the original (browser) event that triggered the ActionEvent */
  100916. sourceEvent?: any;
  100917. /** additional data for the event */
  100918. additionalData?: any;
  100919. /**
  100920. * Creates a new ActionEvent
  100921. * @param source The mesh or sprite that triggered the action
  100922. * @param pointerX The X mouse cursor position at the time of the event
  100923. * @param pointerY The Y mouse cursor position at the time of the event
  100924. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  100925. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  100926. * @param additionalData additional data for the event
  100927. */
  100928. constructor(
  100929. /** The mesh or sprite that triggered the action */
  100930. source: any,
  100931. /** The X mouse cursor position at the time of the event */
  100932. pointerX: number,
  100933. /** The Y mouse cursor position at the time of the event */
  100934. pointerY: number,
  100935. /** The mesh that is currently pointed at (can be null) */
  100936. meshUnderPointer: Nullable<AbstractMesh>,
  100937. /** the original (browser) event that triggered the ActionEvent */
  100938. sourceEvent?: any,
  100939. /** additional data for the event */
  100940. additionalData?: any);
  100941. /**
  100942. * Helper function to auto-create an ActionEvent from a source mesh.
  100943. * @param source The source mesh that triggered the event
  100944. * @param evt The original (browser) event
  100945. * @param additionalData additional data for the event
  100946. * @returns the new ActionEvent
  100947. */
  100948. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  100949. /**
  100950. * Helper function to auto-create an ActionEvent from a source sprite
  100951. * @param source The source sprite that triggered the event
  100952. * @param scene Scene associated with the sprite
  100953. * @param evt The original (browser) event
  100954. * @param additionalData additional data for the event
  100955. * @returns the new ActionEvent
  100956. */
  100957. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  100958. /**
  100959. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  100960. * @param scene the scene where the event occurred
  100961. * @param evt The original (browser) event
  100962. * @returns the new ActionEvent
  100963. */
  100964. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  100965. /**
  100966. * Helper function to auto-create an ActionEvent from a primitive
  100967. * @param prim defines the target primitive
  100968. * @param pointerPos defines the pointer position
  100969. * @param evt The original (browser) event
  100970. * @param additionalData additional data for the event
  100971. * @returns the new ActionEvent
  100972. */
  100973. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  100974. }
  100975. }
  100976. declare module BABYLON {
  100977. /**
  100978. * Abstract class used to decouple action Manager from scene and meshes.
  100979. * Do not instantiate.
  100980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100981. */
  100982. export abstract class AbstractActionManager implements IDisposable {
  100983. /** Gets the list of active triggers */
  100984. static Triggers: {
  100985. [key: string]: number;
  100986. };
  100987. /** Gets the cursor to use when hovering items */
  100988. hoverCursor: string;
  100989. /** Gets the list of actions */
  100990. actions: IAction[];
  100991. /**
  100992. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  100993. */
  100994. isRecursive: boolean;
  100995. /**
  100996. * Releases all associated resources
  100997. */
  100998. abstract dispose(): void;
  100999. /**
  101000. * Does this action manager has pointer triggers
  101001. */
  101002. abstract get hasPointerTriggers(): boolean;
  101003. /**
  101004. * Does this action manager has pick triggers
  101005. */
  101006. abstract get hasPickTriggers(): boolean;
  101007. /**
  101008. * Process a specific trigger
  101009. * @param trigger defines the trigger to process
  101010. * @param evt defines the event details to be processed
  101011. */
  101012. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101013. /**
  101014. * Does this action manager handles actions of any of the given triggers
  101015. * @param triggers defines the triggers to be tested
  101016. * @return a boolean indicating whether one (or more) of the triggers is handled
  101017. */
  101018. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101019. /**
  101020. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101021. * speed.
  101022. * @param triggerA defines the trigger to be tested
  101023. * @param triggerB defines the trigger to be tested
  101024. * @return a boolean indicating whether one (or more) of the triggers is handled
  101025. */
  101026. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101027. /**
  101028. * Does this action manager handles actions of a given trigger
  101029. * @param trigger defines the trigger to be tested
  101030. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101031. * @return whether the trigger is handled
  101032. */
  101033. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101034. /**
  101035. * Serialize this manager to a JSON object
  101036. * @param name defines the property name to store this manager
  101037. * @returns a JSON representation of this manager
  101038. */
  101039. abstract serialize(name: string): any;
  101040. /**
  101041. * Registers an action to this action manager
  101042. * @param action defines the action to be registered
  101043. * @return the action amended (prepared) after registration
  101044. */
  101045. abstract registerAction(action: IAction): Nullable<IAction>;
  101046. /**
  101047. * Unregisters an action to this action manager
  101048. * @param action defines the action to be unregistered
  101049. * @return a boolean indicating whether the action has been unregistered
  101050. */
  101051. abstract unregisterAction(action: IAction): Boolean;
  101052. /**
  101053. * Does exist one action manager with at least one trigger
  101054. **/
  101055. static get HasTriggers(): boolean;
  101056. /**
  101057. * Does exist one action manager with at least one pick trigger
  101058. **/
  101059. static get HasPickTriggers(): boolean;
  101060. /**
  101061. * Does exist one action manager that handles actions of a given trigger
  101062. * @param trigger defines the trigger to be tested
  101063. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101064. **/
  101065. static HasSpecificTrigger(trigger: number): boolean;
  101066. }
  101067. }
  101068. declare module BABYLON {
  101069. /**
  101070. * Defines how a node can be built from a string name.
  101071. */
  101072. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101073. /**
  101074. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101075. */
  101076. export class Node implements IBehaviorAware<Node> {
  101077. /** @hidden */
  101078. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101079. private static _NodeConstructors;
  101080. /**
  101081. * Add a new node constructor
  101082. * @param type defines the type name of the node to construct
  101083. * @param constructorFunc defines the constructor function
  101084. */
  101085. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101086. /**
  101087. * Returns a node constructor based on type name
  101088. * @param type defines the type name
  101089. * @param name defines the new node name
  101090. * @param scene defines the hosting scene
  101091. * @param options defines optional options to transmit to constructors
  101092. * @returns the new constructor or null
  101093. */
  101094. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101095. /**
  101096. * Gets or sets the name of the node
  101097. */
  101098. name: string;
  101099. /**
  101100. * Gets or sets the id of the node
  101101. */
  101102. id: string;
  101103. /**
  101104. * Gets or sets the unique id of the node
  101105. */
  101106. uniqueId: number;
  101107. /**
  101108. * Gets or sets a string used to store user defined state for the node
  101109. */
  101110. state: string;
  101111. /**
  101112. * Gets or sets an object used to store user defined information for the node
  101113. */
  101114. metadata: any;
  101115. /**
  101116. * For internal use only. Please do not use.
  101117. */
  101118. reservedDataStore: any;
  101119. /**
  101120. * List of inspectable custom properties (used by the Inspector)
  101121. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101122. */
  101123. inspectableCustomProperties: IInspectable[];
  101124. private _doNotSerialize;
  101125. /**
  101126. * Gets or sets a boolean used to define if the node must be serialized
  101127. */
  101128. get doNotSerialize(): boolean;
  101129. set doNotSerialize(value: boolean);
  101130. /** @hidden */
  101131. _isDisposed: boolean;
  101132. /**
  101133. * Gets a list of Animations associated with the node
  101134. */
  101135. animations: Animation[];
  101136. protected _ranges: {
  101137. [name: string]: Nullable<AnimationRange>;
  101138. };
  101139. /**
  101140. * Callback raised when the node is ready to be used
  101141. */
  101142. onReady: Nullable<(node: Node) => void>;
  101143. private _isEnabled;
  101144. private _isParentEnabled;
  101145. private _isReady;
  101146. /** @hidden */
  101147. _currentRenderId: number;
  101148. private _parentUpdateId;
  101149. /** @hidden */
  101150. _childUpdateId: number;
  101151. /** @hidden */
  101152. _waitingParentId: Nullable<string>;
  101153. /** @hidden */
  101154. _scene: Scene;
  101155. /** @hidden */
  101156. _cache: any;
  101157. private _parentNode;
  101158. private _children;
  101159. /** @hidden */
  101160. _worldMatrix: Matrix;
  101161. /** @hidden */
  101162. _worldMatrixDeterminant: number;
  101163. /** @hidden */
  101164. _worldMatrixDeterminantIsDirty: boolean;
  101165. /** @hidden */
  101166. private _sceneRootNodesIndex;
  101167. /**
  101168. * Gets a boolean indicating if the node has been disposed
  101169. * @returns true if the node was disposed
  101170. */
  101171. isDisposed(): boolean;
  101172. /**
  101173. * Gets or sets the parent of the node (without keeping the current position in the scene)
  101174. * @see https://doc.babylonjs.com/how_to/parenting
  101175. */
  101176. set parent(parent: Nullable<Node>);
  101177. get parent(): Nullable<Node>;
  101178. /** @hidden */
  101179. _addToSceneRootNodes(): void;
  101180. /** @hidden */
  101181. _removeFromSceneRootNodes(): void;
  101182. private _animationPropertiesOverride;
  101183. /**
  101184. * Gets or sets the animation properties override
  101185. */
  101186. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  101187. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  101188. /**
  101189. * Gets a string idenfifying the name of the class
  101190. * @returns "Node" string
  101191. */
  101192. getClassName(): string;
  101193. /** @hidden */
  101194. readonly _isNode: boolean;
  101195. /**
  101196. * An event triggered when the mesh is disposed
  101197. */
  101198. onDisposeObservable: Observable<Node>;
  101199. private _onDisposeObserver;
  101200. /**
  101201. * Sets a callback that will be raised when the node will be disposed
  101202. */
  101203. set onDispose(callback: () => void);
  101204. /**
  101205. * Creates a new Node
  101206. * @param name the name and id to be given to this node
  101207. * @param scene the scene this node will be added to
  101208. */
  101209. constructor(name: string, scene?: Nullable<Scene>);
  101210. /**
  101211. * Gets the scene of the node
  101212. * @returns a scene
  101213. */
  101214. getScene(): Scene;
  101215. /**
  101216. * Gets the engine of the node
  101217. * @returns a Engine
  101218. */
  101219. getEngine(): Engine;
  101220. private _behaviors;
  101221. /**
  101222. * Attach a behavior to the node
  101223. * @see http://doc.babylonjs.com/features/behaviour
  101224. * @param behavior defines the behavior to attach
  101225. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  101226. * @returns the current Node
  101227. */
  101228. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  101229. /**
  101230. * Remove an attached behavior
  101231. * @see http://doc.babylonjs.com/features/behaviour
  101232. * @param behavior defines the behavior to attach
  101233. * @returns the current Node
  101234. */
  101235. removeBehavior(behavior: Behavior<Node>): Node;
  101236. /**
  101237. * Gets the list of attached behaviors
  101238. * @see http://doc.babylonjs.com/features/behaviour
  101239. */
  101240. get behaviors(): Behavior<Node>[];
  101241. /**
  101242. * Gets an attached behavior by name
  101243. * @param name defines the name of the behavior to look for
  101244. * @see http://doc.babylonjs.com/features/behaviour
  101245. * @returns null if behavior was not found else the requested behavior
  101246. */
  101247. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  101248. /**
  101249. * Returns the latest update of the World matrix
  101250. * @returns a Matrix
  101251. */
  101252. getWorldMatrix(): Matrix;
  101253. /** @hidden */
  101254. _getWorldMatrixDeterminant(): number;
  101255. /**
  101256. * Returns directly the latest state of the mesh World matrix.
  101257. * A Matrix is returned.
  101258. */
  101259. get worldMatrixFromCache(): Matrix;
  101260. /** @hidden */
  101261. _initCache(): void;
  101262. /** @hidden */
  101263. updateCache(force?: boolean): void;
  101264. /** @hidden */
  101265. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101266. /** @hidden */
  101267. _updateCache(ignoreParentClass?: boolean): void;
  101268. /** @hidden */
  101269. _isSynchronized(): boolean;
  101270. /** @hidden */
  101271. _markSyncedWithParent(): void;
  101272. /** @hidden */
  101273. isSynchronizedWithParent(): boolean;
  101274. /** @hidden */
  101275. isSynchronized(): boolean;
  101276. /**
  101277. * Is this node ready to be used/rendered
  101278. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101279. * @return true if the node is ready
  101280. */
  101281. isReady(completeCheck?: boolean): boolean;
  101282. /**
  101283. * Is this node enabled?
  101284. * 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
  101285. * @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
  101286. * @return whether this node (and its parent) is enabled
  101287. */
  101288. isEnabled(checkAncestors?: boolean): boolean;
  101289. /** @hidden */
  101290. protected _syncParentEnabledState(): void;
  101291. /**
  101292. * Set the enabled state of this node
  101293. * @param value defines the new enabled state
  101294. */
  101295. setEnabled(value: boolean): void;
  101296. /**
  101297. * Is this node a descendant of the given node?
  101298. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  101299. * @param ancestor defines the parent node to inspect
  101300. * @returns a boolean indicating if this node is a descendant of the given node
  101301. */
  101302. isDescendantOf(ancestor: Node): boolean;
  101303. /** @hidden */
  101304. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  101305. /**
  101306. * Will return all nodes that have this node as ascendant
  101307. * @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
  101308. * @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
  101309. * @return all children nodes of all types
  101310. */
  101311. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  101312. /**
  101313. * Get all child-meshes of this node
  101314. * @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)
  101315. * @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
  101316. * @returns an array of AbstractMesh
  101317. */
  101318. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  101319. /**
  101320. * Get all direct children of this node
  101321. * @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
  101322. * @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)
  101323. * @returns an array of Node
  101324. */
  101325. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  101326. /** @hidden */
  101327. _setReady(state: boolean): void;
  101328. /**
  101329. * Get an animation by name
  101330. * @param name defines the name of the animation to look for
  101331. * @returns null if not found else the requested animation
  101332. */
  101333. getAnimationByName(name: string): Nullable<Animation>;
  101334. /**
  101335. * Creates an animation range for this node
  101336. * @param name defines the name of the range
  101337. * @param from defines the starting key
  101338. * @param to defines the end key
  101339. */
  101340. createAnimationRange(name: string, from: number, to: number): void;
  101341. /**
  101342. * Delete a specific animation range
  101343. * @param name defines the name of the range to delete
  101344. * @param deleteFrames defines if animation frames from the range must be deleted as well
  101345. */
  101346. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  101347. /**
  101348. * Get an animation range by name
  101349. * @param name defines the name of the animation range to look for
  101350. * @returns null if not found else the requested animation range
  101351. */
  101352. getAnimationRange(name: string): Nullable<AnimationRange>;
  101353. /**
  101354. * Gets the list of all animation ranges defined on this node
  101355. * @returns an array
  101356. */
  101357. getAnimationRanges(): Nullable<AnimationRange>[];
  101358. /**
  101359. * Will start the animation sequence
  101360. * @param name defines the range frames for animation sequence
  101361. * @param loop defines if the animation should loop (false by default)
  101362. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  101363. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  101364. * @returns the object created for this animation. If range does not exist, it will return null
  101365. */
  101366. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  101367. /**
  101368. * Serialize animation ranges into a JSON compatible object
  101369. * @returns serialization object
  101370. */
  101371. serializeAnimationRanges(): any;
  101372. /**
  101373. * Computes the world matrix of the node
  101374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101375. * @returns the world matrix
  101376. */
  101377. computeWorldMatrix(force?: boolean): Matrix;
  101378. /**
  101379. * Releases resources associated with this node.
  101380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101382. */
  101383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101384. /**
  101385. * Parse animation range data from a serialization object and store them into a given node
  101386. * @param node defines where to store the animation ranges
  101387. * @param parsedNode defines the serialization object to read data from
  101388. * @param scene defines the hosting scene
  101389. */
  101390. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  101391. /**
  101392. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  101393. * @param includeDescendants Include bounding info from descendants as well (true by default)
  101394. * @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
  101395. * @returns the new bounding vectors
  101396. */
  101397. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  101398. min: Vector3;
  101399. max: Vector3;
  101400. };
  101401. }
  101402. }
  101403. declare module BABYLON {
  101404. /**
  101405. * @hidden
  101406. */
  101407. export class _IAnimationState {
  101408. key: number;
  101409. repeatCount: number;
  101410. workValue?: any;
  101411. loopMode?: number;
  101412. offsetValue?: any;
  101413. highLimitValue?: any;
  101414. }
  101415. /**
  101416. * Class used to store any kind of animation
  101417. */
  101418. export class Animation {
  101419. /**Name of the animation */
  101420. name: string;
  101421. /**Property to animate */
  101422. targetProperty: string;
  101423. /**The frames per second of the animation */
  101424. framePerSecond: number;
  101425. /**The data type of the animation */
  101426. dataType: number;
  101427. /**The loop mode of the animation */
  101428. loopMode?: number | undefined;
  101429. /**Specifies if blending should be enabled */
  101430. enableBlending?: boolean | undefined;
  101431. /**
  101432. * Use matrix interpolation instead of using direct key value when animating matrices
  101433. */
  101434. static AllowMatricesInterpolation: boolean;
  101435. /**
  101436. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  101437. */
  101438. static AllowMatrixDecomposeForInterpolation: boolean;
  101439. /**
  101440. * Stores the key frames of the animation
  101441. */
  101442. private _keys;
  101443. /**
  101444. * Stores the easing function of the animation
  101445. */
  101446. private _easingFunction;
  101447. /**
  101448. * @hidden Internal use only
  101449. */
  101450. _runtimeAnimations: RuntimeAnimation[];
  101451. /**
  101452. * The set of event that will be linked to this animation
  101453. */
  101454. private _events;
  101455. /**
  101456. * Stores an array of target property paths
  101457. */
  101458. targetPropertyPath: string[];
  101459. /**
  101460. * Stores the blending speed of the animation
  101461. */
  101462. blendingSpeed: number;
  101463. /**
  101464. * Stores the animation ranges for the animation
  101465. */
  101466. private _ranges;
  101467. /**
  101468. * @hidden Internal use
  101469. */
  101470. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  101471. /**
  101472. * Sets up an animation
  101473. * @param property The property to animate
  101474. * @param animationType The animation type to apply
  101475. * @param framePerSecond The frames per second of the animation
  101476. * @param easingFunction The easing function used in the animation
  101477. * @returns The created animation
  101478. */
  101479. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  101480. /**
  101481. * Create and start an animation on a node
  101482. * @param name defines the name of the global animation that will be run on all nodes
  101483. * @param node defines the root node where the animation will take place
  101484. * @param targetProperty defines property to animate
  101485. * @param framePerSecond defines the number of frame per second yo use
  101486. * @param totalFrame defines the number of frames in total
  101487. * @param from defines the initial value
  101488. * @param to defines the final value
  101489. * @param loopMode defines which loop mode you want to use (off by default)
  101490. * @param easingFunction defines the easing function to use (linear by default)
  101491. * @param onAnimationEnd defines the callback to call when animation end
  101492. * @returns the animatable created for this animation
  101493. */
  101494. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101495. /**
  101496. * Create and start an animation on a node and its descendants
  101497. * @param name defines the name of the global animation that will be run on all nodes
  101498. * @param node defines the root node where the animation will take place
  101499. * @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
  101500. * @param targetProperty defines property to animate
  101501. * @param framePerSecond defines the number of frame per second to use
  101502. * @param totalFrame defines the number of frames in total
  101503. * @param from defines the initial value
  101504. * @param to defines the final value
  101505. * @param loopMode defines which loop mode you want to use (off by default)
  101506. * @param easingFunction defines the easing function to use (linear by default)
  101507. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  101508. * @returns the list of animatables created for all nodes
  101509. * @example https://www.babylonjs-playground.com/#MH0VLI
  101510. */
  101511. 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[]>;
  101512. /**
  101513. * Creates a new animation, merges it with the existing animations and starts it
  101514. * @param name Name of the animation
  101515. * @param node Node which contains the scene that begins the animations
  101516. * @param targetProperty Specifies which property to animate
  101517. * @param framePerSecond The frames per second of the animation
  101518. * @param totalFrame The total number of frames
  101519. * @param from The frame at the beginning of the animation
  101520. * @param to The frame at the end of the animation
  101521. * @param loopMode Specifies the loop mode of the animation
  101522. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  101523. * @param onAnimationEnd Callback to run once the animation is complete
  101524. * @returns Nullable animation
  101525. */
  101526. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101527. /**
  101528. * Transition property of an host to the target Value
  101529. * @param property The property to transition
  101530. * @param targetValue The target Value of the property
  101531. * @param host The object where the property to animate belongs
  101532. * @param scene Scene used to run the animation
  101533. * @param frameRate Framerate (in frame/s) to use
  101534. * @param transition The transition type we want to use
  101535. * @param duration The duration of the animation, in milliseconds
  101536. * @param onAnimationEnd Callback trigger at the end of the animation
  101537. * @returns Nullable animation
  101538. */
  101539. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  101540. /**
  101541. * Return the array of runtime animations currently using this animation
  101542. */
  101543. get runtimeAnimations(): RuntimeAnimation[];
  101544. /**
  101545. * Specifies if any of the runtime animations are currently running
  101546. */
  101547. get hasRunningRuntimeAnimations(): boolean;
  101548. /**
  101549. * Initializes the animation
  101550. * @param name Name of the animation
  101551. * @param targetProperty Property to animate
  101552. * @param framePerSecond The frames per second of the animation
  101553. * @param dataType The data type of the animation
  101554. * @param loopMode The loop mode of the animation
  101555. * @param enableBlending Specifies if blending should be enabled
  101556. */
  101557. constructor(
  101558. /**Name of the animation */
  101559. name: string,
  101560. /**Property to animate */
  101561. targetProperty: string,
  101562. /**The frames per second of the animation */
  101563. framePerSecond: number,
  101564. /**The data type of the animation */
  101565. dataType: number,
  101566. /**The loop mode of the animation */
  101567. loopMode?: number | undefined,
  101568. /**Specifies if blending should be enabled */
  101569. enableBlending?: boolean | undefined);
  101570. /**
  101571. * Converts the animation to a string
  101572. * @param fullDetails support for multiple levels of logging within scene loading
  101573. * @returns String form of the animation
  101574. */
  101575. toString(fullDetails?: boolean): string;
  101576. /**
  101577. * Add an event to this animation
  101578. * @param event Event to add
  101579. */
  101580. addEvent(event: AnimationEvent): void;
  101581. /**
  101582. * Remove all events found at the given frame
  101583. * @param frame The frame to remove events from
  101584. */
  101585. removeEvents(frame: number): void;
  101586. /**
  101587. * Retrieves all the events from the animation
  101588. * @returns Events from the animation
  101589. */
  101590. getEvents(): AnimationEvent[];
  101591. /**
  101592. * Creates an animation range
  101593. * @param name Name of the animation range
  101594. * @param from Starting frame of the animation range
  101595. * @param to Ending frame of the animation
  101596. */
  101597. createRange(name: string, from: number, to: number): void;
  101598. /**
  101599. * Deletes an animation range by name
  101600. * @param name Name of the animation range to delete
  101601. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  101602. */
  101603. deleteRange(name: string, deleteFrames?: boolean): void;
  101604. /**
  101605. * Gets the animation range by name, or null if not defined
  101606. * @param name Name of the animation range
  101607. * @returns Nullable animation range
  101608. */
  101609. getRange(name: string): Nullable<AnimationRange>;
  101610. /**
  101611. * Gets the key frames from the animation
  101612. * @returns The key frames of the animation
  101613. */
  101614. getKeys(): Array<IAnimationKey>;
  101615. /**
  101616. * Gets the highest frame rate of the animation
  101617. * @returns Highest frame rate of the animation
  101618. */
  101619. getHighestFrame(): number;
  101620. /**
  101621. * Gets the easing function of the animation
  101622. * @returns Easing function of the animation
  101623. */
  101624. getEasingFunction(): IEasingFunction;
  101625. /**
  101626. * Sets the easing function of the animation
  101627. * @param easingFunction A custom mathematical formula for animation
  101628. */
  101629. setEasingFunction(easingFunction: EasingFunction): void;
  101630. /**
  101631. * Interpolates a scalar linearly
  101632. * @param startValue Start value of the animation curve
  101633. * @param endValue End value of the animation curve
  101634. * @param gradient Scalar amount to interpolate
  101635. * @returns Interpolated scalar value
  101636. */
  101637. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  101638. /**
  101639. * Interpolates a scalar cubically
  101640. * @param startValue Start value of the animation curve
  101641. * @param outTangent End tangent of the animation
  101642. * @param endValue End value of the animation curve
  101643. * @param inTangent Start tangent of the animation curve
  101644. * @param gradient Scalar amount to interpolate
  101645. * @returns Interpolated scalar value
  101646. */
  101647. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  101648. /**
  101649. * Interpolates a quaternion using a spherical linear interpolation
  101650. * @param startValue Start value of the animation curve
  101651. * @param endValue End value of the animation curve
  101652. * @param gradient Scalar amount to interpolate
  101653. * @returns Interpolated quaternion value
  101654. */
  101655. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  101656. /**
  101657. * Interpolates a quaternion cubically
  101658. * @param startValue Start value of the animation curve
  101659. * @param outTangent End tangent of the animation curve
  101660. * @param endValue End value of the animation curve
  101661. * @param inTangent Start tangent of the animation curve
  101662. * @param gradient Scalar amount to interpolate
  101663. * @returns Interpolated quaternion value
  101664. */
  101665. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  101666. /**
  101667. * Interpolates a Vector3 linearl
  101668. * @param startValue Start value of the animation curve
  101669. * @param endValue End value of the animation curve
  101670. * @param gradient Scalar amount to interpolate
  101671. * @returns Interpolated scalar value
  101672. */
  101673. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  101674. /**
  101675. * Interpolates a Vector3 cubically
  101676. * @param startValue Start value of the animation curve
  101677. * @param outTangent End tangent of the animation
  101678. * @param endValue End value of the animation curve
  101679. * @param inTangent Start tangent of the animation curve
  101680. * @param gradient Scalar amount to interpolate
  101681. * @returns InterpolatedVector3 value
  101682. */
  101683. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  101684. /**
  101685. * Interpolates a Vector2 linearly
  101686. * @param startValue Start value of the animation curve
  101687. * @param endValue End value of the animation curve
  101688. * @param gradient Scalar amount to interpolate
  101689. * @returns Interpolated Vector2 value
  101690. */
  101691. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  101692. /**
  101693. * Interpolates a Vector2 cubically
  101694. * @param startValue Start value of the animation curve
  101695. * @param outTangent End tangent of the animation
  101696. * @param endValue End value of the animation curve
  101697. * @param inTangent Start tangent of the animation curve
  101698. * @param gradient Scalar amount to interpolate
  101699. * @returns Interpolated Vector2 value
  101700. */
  101701. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  101702. /**
  101703. * Interpolates a size linearly
  101704. * @param startValue Start value of the animation curve
  101705. * @param endValue End value of the animation curve
  101706. * @param gradient Scalar amount to interpolate
  101707. * @returns Interpolated Size value
  101708. */
  101709. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  101710. /**
  101711. * Interpolates a Color3 linearly
  101712. * @param startValue Start value of the animation curve
  101713. * @param endValue End value of the animation curve
  101714. * @param gradient Scalar amount to interpolate
  101715. * @returns Interpolated Color3 value
  101716. */
  101717. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  101718. /**
  101719. * Interpolates a Color4 linearly
  101720. * @param startValue Start value of the animation curve
  101721. * @param endValue End value of the animation curve
  101722. * @param gradient Scalar amount to interpolate
  101723. * @returns Interpolated Color3 value
  101724. */
  101725. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  101726. /**
  101727. * @hidden Internal use only
  101728. */
  101729. _getKeyValue(value: any): any;
  101730. /**
  101731. * @hidden Internal use only
  101732. */
  101733. _interpolate(currentFrame: number, state: _IAnimationState): any;
  101734. /**
  101735. * Defines the function to use to interpolate matrices
  101736. * @param startValue defines the start matrix
  101737. * @param endValue defines the end matrix
  101738. * @param gradient defines the gradient between both matrices
  101739. * @param result defines an optional target matrix where to store the interpolation
  101740. * @returns the interpolated matrix
  101741. */
  101742. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  101743. /**
  101744. * Makes a copy of the animation
  101745. * @returns Cloned animation
  101746. */
  101747. clone(): Animation;
  101748. /**
  101749. * Sets the key frames of the animation
  101750. * @param values The animation key frames to set
  101751. */
  101752. setKeys(values: Array<IAnimationKey>): void;
  101753. /**
  101754. * Serializes the animation to an object
  101755. * @returns Serialized object
  101756. */
  101757. serialize(): any;
  101758. /**
  101759. * Float animation type
  101760. */
  101761. static readonly ANIMATIONTYPE_FLOAT: number;
  101762. /**
  101763. * Vector3 animation type
  101764. */
  101765. static readonly ANIMATIONTYPE_VECTOR3: number;
  101766. /**
  101767. * Quaternion animation type
  101768. */
  101769. static readonly ANIMATIONTYPE_QUATERNION: number;
  101770. /**
  101771. * Matrix animation type
  101772. */
  101773. static readonly ANIMATIONTYPE_MATRIX: number;
  101774. /**
  101775. * Color3 animation type
  101776. */
  101777. static readonly ANIMATIONTYPE_COLOR3: number;
  101778. /**
  101779. * Color3 animation type
  101780. */
  101781. static readonly ANIMATIONTYPE_COLOR4: number;
  101782. /**
  101783. * Vector2 animation type
  101784. */
  101785. static readonly ANIMATIONTYPE_VECTOR2: number;
  101786. /**
  101787. * Size animation type
  101788. */
  101789. static readonly ANIMATIONTYPE_SIZE: number;
  101790. /**
  101791. * Relative Loop Mode
  101792. */
  101793. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  101794. /**
  101795. * Cycle Loop Mode
  101796. */
  101797. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  101798. /**
  101799. * Constant Loop Mode
  101800. */
  101801. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  101802. /** @hidden */
  101803. static _UniversalLerp(left: any, right: any, amount: number): any;
  101804. /**
  101805. * Parses an animation object and creates an animation
  101806. * @param parsedAnimation Parsed animation object
  101807. * @returns Animation object
  101808. */
  101809. static Parse(parsedAnimation: any): Animation;
  101810. /**
  101811. * Appends the serialized animations from the source animations
  101812. * @param source Source containing the animations
  101813. * @param destination Target to store the animations
  101814. */
  101815. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  101816. }
  101817. }
  101818. declare module BABYLON {
  101819. /**
  101820. * Interface containing an array of animations
  101821. */
  101822. export interface IAnimatable {
  101823. /**
  101824. * Array of animations
  101825. */
  101826. animations: Nullable<Array<Animation>>;
  101827. }
  101828. }
  101829. declare module BABYLON {
  101830. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  101831. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101832. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101833. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101834. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101835. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101836. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101837. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101838. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101839. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101840. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101841. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101842. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101843. /**
  101844. * Decorator used to define property that can be serialized as reference to a camera
  101845. * @param sourceName defines the name of the property to decorate
  101846. */
  101847. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  101848. /**
  101849. * Class used to help serialization objects
  101850. */
  101851. export class SerializationHelper {
  101852. /** @hidden */
  101853. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  101854. /** @hidden */
  101855. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  101856. /** @hidden */
  101857. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  101858. /** @hidden */
  101859. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  101860. /**
  101861. * Appends the serialized animations from the source animations
  101862. * @param source Source containing the animations
  101863. * @param destination Target to store the animations
  101864. */
  101865. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  101866. /**
  101867. * Static function used to serialized a specific entity
  101868. * @param entity defines the entity to serialize
  101869. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  101870. * @returns a JSON compatible object representing the serialization of the entity
  101871. */
  101872. static Serialize<T>(entity: T, serializationObject?: any): any;
  101873. /**
  101874. * Creates a new entity from a serialization data object
  101875. * @param creationFunction defines a function used to instanciated the new entity
  101876. * @param source defines the source serialization data
  101877. * @param scene defines the hosting scene
  101878. * @param rootUrl defines the root url for resources
  101879. * @returns a new entity
  101880. */
  101881. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  101882. /**
  101883. * Clones an object
  101884. * @param creationFunction defines the function used to instanciate the new object
  101885. * @param source defines the source object
  101886. * @returns the cloned object
  101887. */
  101888. static Clone<T>(creationFunction: () => T, source: T): T;
  101889. /**
  101890. * Instanciates a new object based on a source one (some data will be shared between both object)
  101891. * @param creationFunction defines the function used to instanciate the new object
  101892. * @param source defines the source object
  101893. * @returns the new object
  101894. */
  101895. static Instanciate<T>(creationFunction: () => T, source: T): T;
  101896. }
  101897. }
  101898. declare module BABYLON {
  101899. /**
  101900. * Class used to manipulate GUIDs
  101901. */
  101902. export class GUID {
  101903. /**
  101904. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101905. * Be aware Math.random() could cause collisions, but:
  101906. * "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"
  101907. * @returns a pseudo random id
  101908. */
  101909. static RandomId(): string;
  101910. }
  101911. }
  101912. declare module BABYLON {
  101913. /**
  101914. * Base class of all the textures in babylon.
  101915. * It groups all the common properties the materials, post process, lights... might need
  101916. * in order to make a correct use of the texture.
  101917. */
  101918. export class BaseTexture implements IAnimatable {
  101919. /**
  101920. * Default anisotropic filtering level for the application.
  101921. * It is set to 4 as a good tradeoff between perf and quality.
  101922. */
  101923. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  101924. /**
  101925. * Gets or sets the unique id of the texture
  101926. */
  101927. uniqueId: number;
  101928. /**
  101929. * Define the name of the texture.
  101930. */
  101931. name: string;
  101932. /**
  101933. * Gets or sets an object used to store user defined information.
  101934. */
  101935. metadata: any;
  101936. /**
  101937. * For internal use only. Please do not use.
  101938. */
  101939. reservedDataStore: any;
  101940. private _hasAlpha;
  101941. /**
  101942. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  101943. */
  101944. set hasAlpha(value: boolean);
  101945. get hasAlpha(): boolean;
  101946. /**
  101947. * Defines if the alpha value should be determined via the rgb values.
  101948. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  101949. */
  101950. getAlphaFromRGB: boolean;
  101951. /**
  101952. * Intensity or strength of the texture.
  101953. * It is commonly used by materials to fine tune the intensity of the texture
  101954. */
  101955. level: number;
  101956. /**
  101957. * Define the UV chanel to use starting from 0 and defaulting to 0.
  101958. * This is part of the texture as textures usually maps to one uv set.
  101959. */
  101960. coordinatesIndex: number;
  101961. private _coordinatesMode;
  101962. /**
  101963. * How a texture is mapped.
  101964. *
  101965. * | Value | Type | Description |
  101966. * | ----- | ----------------------------------- | ----------- |
  101967. * | 0 | EXPLICIT_MODE | |
  101968. * | 1 | SPHERICAL_MODE | |
  101969. * | 2 | PLANAR_MODE | |
  101970. * | 3 | CUBIC_MODE | |
  101971. * | 4 | PROJECTION_MODE | |
  101972. * | 5 | SKYBOX_MODE | |
  101973. * | 6 | INVCUBIC_MODE | |
  101974. * | 7 | EQUIRECTANGULAR_MODE | |
  101975. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  101976. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  101977. */
  101978. set coordinatesMode(value: number);
  101979. get coordinatesMode(): number;
  101980. /**
  101981. * | Value | Type | Description |
  101982. * | ----- | ------------------ | ----------- |
  101983. * | 0 | CLAMP_ADDRESSMODE | |
  101984. * | 1 | WRAP_ADDRESSMODE | |
  101985. * | 2 | MIRROR_ADDRESSMODE | |
  101986. */
  101987. wrapU: number;
  101988. /**
  101989. * | Value | Type | Description |
  101990. * | ----- | ------------------ | ----------- |
  101991. * | 0 | CLAMP_ADDRESSMODE | |
  101992. * | 1 | WRAP_ADDRESSMODE | |
  101993. * | 2 | MIRROR_ADDRESSMODE | |
  101994. */
  101995. wrapV: number;
  101996. /**
  101997. * | Value | Type | Description |
  101998. * | ----- | ------------------ | ----------- |
  101999. * | 0 | CLAMP_ADDRESSMODE | |
  102000. * | 1 | WRAP_ADDRESSMODE | |
  102001. * | 2 | MIRROR_ADDRESSMODE | |
  102002. */
  102003. wrapR: number;
  102004. /**
  102005. * With compliant hardware and browser (supporting anisotropic filtering)
  102006. * this defines the level of anisotropic filtering in the texture.
  102007. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102008. */
  102009. anisotropicFilteringLevel: number;
  102010. /**
  102011. * Define if the texture is a cube texture or if false a 2d texture.
  102012. */
  102013. get isCube(): boolean;
  102014. set isCube(value: boolean);
  102015. /**
  102016. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102017. */
  102018. get is3D(): boolean;
  102019. set is3D(value: boolean);
  102020. /**
  102021. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102022. */
  102023. get is2DArray(): boolean;
  102024. set is2DArray(value: boolean);
  102025. /**
  102026. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102027. * HDR texture are usually stored in linear space.
  102028. * This only impacts the PBR and Background materials
  102029. */
  102030. gammaSpace: boolean;
  102031. /**
  102032. * Gets or sets whether or not the texture contains RGBD data.
  102033. */
  102034. get isRGBD(): boolean;
  102035. set isRGBD(value: boolean);
  102036. /**
  102037. * Is Z inverted in the texture (useful in a cube texture).
  102038. */
  102039. invertZ: boolean;
  102040. /**
  102041. * Are mip maps generated for this texture or not.
  102042. */
  102043. get noMipmap(): boolean;
  102044. /**
  102045. * @hidden
  102046. */
  102047. lodLevelInAlpha: boolean;
  102048. /**
  102049. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102050. */
  102051. get lodGenerationOffset(): number;
  102052. set lodGenerationOffset(value: number);
  102053. /**
  102054. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102055. */
  102056. get lodGenerationScale(): number;
  102057. set lodGenerationScale(value: number);
  102058. /**
  102059. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102060. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102061. * average roughness values.
  102062. */
  102063. get linearSpecularLOD(): boolean;
  102064. set linearSpecularLOD(value: boolean);
  102065. /**
  102066. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102067. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102068. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102069. */
  102070. get irradianceTexture(): Nullable<BaseTexture>;
  102071. set irradianceTexture(value: Nullable<BaseTexture>);
  102072. /**
  102073. * Define if the texture is a render target.
  102074. */
  102075. isRenderTarget: boolean;
  102076. /**
  102077. * Define the unique id of the texture in the scene.
  102078. */
  102079. get uid(): string;
  102080. /**
  102081. * Return a string representation of the texture.
  102082. * @returns the texture as a string
  102083. */
  102084. toString(): string;
  102085. /**
  102086. * Get the class name of the texture.
  102087. * @returns "BaseTexture"
  102088. */
  102089. getClassName(): string;
  102090. /**
  102091. * Define the list of animation attached to the texture.
  102092. */
  102093. animations: Animation[];
  102094. /**
  102095. * An event triggered when the texture is disposed.
  102096. */
  102097. onDisposeObservable: Observable<BaseTexture>;
  102098. private _onDisposeObserver;
  102099. /**
  102100. * Callback triggered when the texture has been disposed.
  102101. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102102. */
  102103. set onDispose(callback: () => void);
  102104. /**
  102105. * Define the current state of the loading sequence when in delayed load mode.
  102106. */
  102107. delayLoadState: number;
  102108. private _scene;
  102109. /** @hidden */
  102110. _texture: Nullable<InternalTexture>;
  102111. private _uid;
  102112. /**
  102113. * Define if the texture is preventinga material to render or not.
  102114. * If not and the texture is not ready, the engine will use a default black texture instead.
  102115. */
  102116. get isBlocking(): boolean;
  102117. /**
  102118. * Instantiates a new BaseTexture.
  102119. * Base class of all the textures in babylon.
  102120. * It groups all the common properties the materials, post process, lights... might need
  102121. * in order to make a correct use of the texture.
  102122. * @param scene Define the scene the texture blongs to
  102123. */
  102124. constructor(scene: Nullable<Scene>);
  102125. /**
  102126. * Get the scene the texture belongs to.
  102127. * @returns the scene or null if undefined
  102128. */
  102129. getScene(): Nullable<Scene>;
  102130. /**
  102131. * Get the texture transform matrix used to offset tile the texture for istance.
  102132. * @returns the transformation matrix
  102133. */
  102134. getTextureMatrix(): Matrix;
  102135. /**
  102136. * Get the texture reflection matrix used to rotate/transform the reflection.
  102137. * @returns the reflection matrix
  102138. */
  102139. getReflectionTextureMatrix(): Matrix;
  102140. /**
  102141. * Get the underlying lower level texture from Babylon.
  102142. * @returns the insternal texture
  102143. */
  102144. getInternalTexture(): Nullable<InternalTexture>;
  102145. /**
  102146. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  102147. * @returns true if ready or not blocking
  102148. */
  102149. isReadyOrNotBlocking(): boolean;
  102150. /**
  102151. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  102152. * @returns true if fully ready
  102153. */
  102154. isReady(): boolean;
  102155. private _cachedSize;
  102156. /**
  102157. * Get the size of the texture.
  102158. * @returns the texture size.
  102159. */
  102160. getSize(): ISize;
  102161. /**
  102162. * Get the base size of the texture.
  102163. * It can be different from the size if the texture has been resized for POT for instance
  102164. * @returns the base size
  102165. */
  102166. getBaseSize(): ISize;
  102167. /**
  102168. * Update the sampling mode of the texture.
  102169. * Default is Trilinear mode.
  102170. *
  102171. * | Value | Type | Description |
  102172. * | ----- | ------------------ | ----------- |
  102173. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  102174. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  102175. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  102176. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  102177. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  102178. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  102179. * | 7 | NEAREST_LINEAR | |
  102180. * | 8 | NEAREST_NEAREST | |
  102181. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  102182. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  102183. * | 11 | LINEAR_LINEAR | |
  102184. * | 12 | LINEAR_NEAREST | |
  102185. *
  102186. * > _mag_: magnification filter (close to the viewer)
  102187. * > _min_: minification filter (far from the viewer)
  102188. * > _mip_: filter used between mip map levels
  102189. *@param samplingMode Define the new sampling mode of the texture
  102190. */
  102191. updateSamplingMode(samplingMode: number): void;
  102192. /**
  102193. * Scales the texture if is `canRescale()`
  102194. * @param ratio the resize factor we want to use to rescale
  102195. */
  102196. scale(ratio: number): void;
  102197. /**
  102198. * Get if the texture can rescale.
  102199. */
  102200. get canRescale(): boolean;
  102201. /** @hidden */
  102202. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  102203. /** @hidden */
  102204. _rebuild(): void;
  102205. /**
  102206. * Triggers the load sequence in delayed load mode.
  102207. */
  102208. delayLoad(): void;
  102209. /**
  102210. * Clones the texture.
  102211. * @returns the cloned texture
  102212. */
  102213. clone(): Nullable<BaseTexture>;
  102214. /**
  102215. * Get the texture underlying type (INT, FLOAT...)
  102216. */
  102217. get textureType(): number;
  102218. /**
  102219. * Get the texture underlying format (RGB, RGBA...)
  102220. */
  102221. get textureFormat(): number;
  102222. /**
  102223. * Indicates that textures need to be re-calculated for all materials
  102224. */
  102225. protected _markAllSubMeshesAsTexturesDirty(): void;
  102226. /**
  102227. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  102228. * This will returns an RGBA array buffer containing either in values (0-255) or
  102229. * float values (0-1) depending of the underlying buffer type.
  102230. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  102231. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  102232. * @param buffer defines a user defined buffer to fill with data (can be null)
  102233. * @returns The Array buffer containing the pixels data.
  102234. */
  102235. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  102236. /**
  102237. * Release and destroy the underlying lower level texture aka internalTexture.
  102238. */
  102239. releaseInternalTexture(): void;
  102240. /** @hidden */
  102241. get _lodTextureHigh(): Nullable<BaseTexture>;
  102242. /** @hidden */
  102243. get _lodTextureMid(): Nullable<BaseTexture>;
  102244. /** @hidden */
  102245. get _lodTextureLow(): Nullable<BaseTexture>;
  102246. /**
  102247. * Dispose the texture and release its associated resources.
  102248. */
  102249. dispose(): void;
  102250. /**
  102251. * Serialize the texture into a JSON representation that can be parsed later on.
  102252. * @returns the JSON representation of the texture
  102253. */
  102254. serialize(): any;
  102255. /**
  102256. * Helper function to be called back once a list of texture contains only ready textures.
  102257. * @param textures Define the list of textures to wait for
  102258. * @param callback Define the callback triggered once the entire list will be ready
  102259. */
  102260. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  102261. }
  102262. }
  102263. declare module BABYLON {
  102264. /**
  102265. * Options to be used when creating an effect.
  102266. */
  102267. export interface IEffectCreationOptions {
  102268. /**
  102269. * Atrributes that will be used in the shader.
  102270. */
  102271. attributes: string[];
  102272. /**
  102273. * Uniform varible names that will be set in the shader.
  102274. */
  102275. uniformsNames: string[];
  102276. /**
  102277. * Uniform buffer variable names that will be set in the shader.
  102278. */
  102279. uniformBuffersNames: string[];
  102280. /**
  102281. * Sampler texture variable names that will be set in the shader.
  102282. */
  102283. samplers: string[];
  102284. /**
  102285. * Define statements that will be set in the shader.
  102286. */
  102287. defines: any;
  102288. /**
  102289. * Possible fallbacks for this effect to improve performance when needed.
  102290. */
  102291. fallbacks: Nullable<IEffectFallbacks>;
  102292. /**
  102293. * Callback that will be called when the shader is compiled.
  102294. */
  102295. onCompiled: Nullable<(effect: Effect) => void>;
  102296. /**
  102297. * Callback that will be called if an error occurs during shader compilation.
  102298. */
  102299. onError: Nullable<(effect: Effect, errors: string) => void>;
  102300. /**
  102301. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102302. */
  102303. indexParameters?: any;
  102304. /**
  102305. * Max number of lights that can be used in the shader.
  102306. */
  102307. maxSimultaneousLights?: number;
  102308. /**
  102309. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  102310. */
  102311. transformFeedbackVaryings?: Nullable<string[]>;
  102312. }
  102313. /**
  102314. * Effect containing vertex and fragment shader that can be executed on an object.
  102315. */
  102316. export class Effect implements IDisposable {
  102317. /**
  102318. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  102319. */
  102320. static ShadersRepository: string;
  102321. /**
  102322. * Name of the effect.
  102323. */
  102324. name: any;
  102325. /**
  102326. * String container all the define statements that should be set on the shader.
  102327. */
  102328. defines: string;
  102329. /**
  102330. * Callback that will be called when the shader is compiled.
  102331. */
  102332. onCompiled: Nullable<(effect: Effect) => void>;
  102333. /**
  102334. * Callback that will be called if an error occurs during shader compilation.
  102335. */
  102336. onError: Nullable<(effect: Effect, errors: string) => void>;
  102337. /**
  102338. * Callback that will be called when effect is bound.
  102339. */
  102340. onBind: Nullable<(effect: Effect) => void>;
  102341. /**
  102342. * Unique ID of the effect.
  102343. */
  102344. uniqueId: number;
  102345. /**
  102346. * Observable that will be called when the shader is compiled.
  102347. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  102348. */
  102349. onCompileObservable: Observable<Effect>;
  102350. /**
  102351. * Observable that will be called if an error occurs during shader compilation.
  102352. */
  102353. onErrorObservable: Observable<Effect>;
  102354. /** @hidden */
  102355. _onBindObservable: Nullable<Observable<Effect>>;
  102356. /**
  102357. * @hidden
  102358. * Specifies if the effect was previously ready
  102359. */
  102360. _wasPreviouslyReady: boolean;
  102361. /**
  102362. * Observable that will be called when effect is bound.
  102363. */
  102364. get onBindObservable(): Observable<Effect>;
  102365. /** @hidden */
  102366. _bonesComputationForcedToCPU: boolean;
  102367. private static _uniqueIdSeed;
  102368. private _engine;
  102369. private _uniformBuffersNames;
  102370. private _uniformsNames;
  102371. private _samplerList;
  102372. private _samplers;
  102373. private _isReady;
  102374. private _compilationError;
  102375. private _allFallbacksProcessed;
  102376. private _attributesNames;
  102377. private _attributes;
  102378. private _attributeLocationByName;
  102379. private _uniforms;
  102380. /**
  102381. * Key for the effect.
  102382. * @hidden
  102383. */
  102384. _key: string;
  102385. private _indexParameters;
  102386. private _fallbacks;
  102387. private _vertexSourceCode;
  102388. private _fragmentSourceCode;
  102389. private _vertexSourceCodeOverride;
  102390. private _fragmentSourceCodeOverride;
  102391. private _transformFeedbackVaryings;
  102392. /**
  102393. * Compiled shader to webGL program.
  102394. * @hidden
  102395. */
  102396. _pipelineContext: Nullable<IPipelineContext>;
  102397. private _valueCache;
  102398. private static _baseCache;
  102399. /**
  102400. * Instantiates an effect.
  102401. * An effect can be used to create/manage/execute vertex and fragment shaders.
  102402. * @param baseName Name of the effect.
  102403. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  102404. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  102405. * @param samplers List of sampler variables that will be passed to the shader.
  102406. * @param engine Engine to be used to render the effect
  102407. * @param defines Define statements to be added to the shader.
  102408. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  102409. * @param onCompiled Callback that will be called when the shader is compiled.
  102410. * @param onError Callback that will be called if an error occurs during shader compilation.
  102411. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102412. */
  102413. 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);
  102414. private _useFinalCode;
  102415. /**
  102416. * Unique key for this effect
  102417. */
  102418. get key(): string;
  102419. /**
  102420. * If the effect has been compiled and prepared.
  102421. * @returns if the effect is compiled and prepared.
  102422. */
  102423. isReady(): boolean;
  102424. private _isReadyInternal;
  102425. /**
  102426. * The engine the effect was initialized with.
  102427. * @returns the engine.
  102428. */
  102429. getEngine(): Engine;
  102430. /**
  102431. * The pipeline context for this effect
  102432. * @returns the associated pipeline context
  102433. */
  102434. getPipelineContext(): Nullable<IPipelineContext>;
  102435. /**
  102436. * The set of names of attribute variables for the shader.
  102437. * @returns An array of attribute names.
  102438. */
  102439. getAttributesNames(): string[];
  102440. /**
  102441. * Returns the attribute at the given index.
  102442. * @param index The index of the attribute.
  102443. * @returns The location of the attribute.
  102444. */
  102445. getAttributeLocation(index: number): number;
  102446. /**
  102447. * Returns the attribute based on the name of the variable.
  102448. * @param name of the attribute to look up.
  102449. * @returns the attribute location.
  102450. */
  102451. getAttributeLocationByName(name: string): number;
  102452. /**
  102453. * The number of attributes.
  102454. * @returns the numnber of attributes.
  102455. */
  102456. getAttributesCount(): number;
  102457. /**
  102458. * Gets the index of a uniform variable.
  102459. * @param uniformName of the uniform to look up.
  102460. * @returns the index.
  102461. */
  102462. getUniformIndex(uniformName: string): number;
  102463. /**
  102464. * Returns the attribute based on the name of the variable.
  102465. * @param uniformName of the uniform to look up.
  102466. * @returns the location of the uniform.
  102467. */
  102468. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  102469. /**
  102470. * Returns an array of sampler variable names
  102471. * @returns The array of sampler variable neames.
  102472. */
  102473. getSamplers(): string[];
  102474. /**
  102475. * The error from the last compilation.
  102476. * @returns the error string.
  102477. */
  102478. getCompilationError(): string;
  102479. /**
  102480. * Gets a boolean indicating that all fallbacks were used during compilation
  102481. * @returns true if all fallbacks were used
  102482. */
  102483. allFallbacksProcessed(): boolean;
  102484. /**
  102485. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  102486. * @param func The callback to be used.
  102487. */
  102488. executeWhenCompiled(func: (effect: Effect) => void): void;
  102489. private _checkIsReady;
  102490. private _loadShader;
  102491. /**
  102492. * Recompiles the webGL program
  102493. * @param vertexSourceCode The source code for the vertex shader.
  102494. * @param fragmentSourceCode The source code for the fragment shader.
  102495. * @param onCompiled Callback called when completed.
  102496. * @param onError Callback called on error.
  102497. * @hidden
  102498. */
  102499. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  102500. /**
  102501. * Prepares the effect
  102502. * @hidden
  102503. */
  102504. _prepareEffect(): void;
  102505. private _processCompilationErrors;
  102506. /**
  102507. * Checks if the effect is supported. (Must be called after compilation)
  102508. */
  102509. get isSupported(): boolean;
  102510. /**
  102511. * Binds a texture to the engine to be used as output of the shader.
  102512. * @param channel Name of the output variable.
  102513. * @param texture Texture to bind.
  102514. * @hidden
  102515. */
  102516. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  102517. /**
  102518. * Sets a texture on the engine to be used in the shader.
  102519. * @param channel Name of the sampler variable.
  102520. * @param texture Texture to set.
  102521. */
  102522. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  102523. /**
  102524. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  102525. * @param channel Name of the sampler variable.
  102526. * @param texture Texture to set.
  102527. */
  102528. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  102529. /**
  102530. * Sets an array of textures on the engine to be used in the shader.
  102531. * @param channel Name of the variable.
  102532. * @param textures Textures to set.
  102533. */
  102534. setTextureArray(channel: string, textures: BaseTexture[]): void;
  102535. /**
  102536. * 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)
  102537. * @param channel Name of the sampler variable.
  102538. * @param postProcess Post process to get the input texture from.
  102539. */
  102540. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  102541. /**
  102542. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  102543. * 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)
  102544. * @param channel Name of the sampler variable.
  102545. * @param postProcess Post process to get the output texture from.
  102546. */
  102547. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  102548. /** @hidden */
  102549. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  102550. /** @hidden */
  102551. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  102552. /** @hidden */
  102553. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  102554. /** @hidden */
  102555. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  102556. /**
  102557. * Binds a buffer to a uniform.
  102558. * @param buffer Buffer to bind.
  102559. * @param name Name of the uniform variable to bind to.
  102560. */
  102561. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  102562. /**
  102563. * Binds block to a uniform.
  102564. * @param blockName Name of the block to bind.
  102565. * @param index Index to bind.
  102566. */
  102567. bindUniformBlock(blockName: string, index: number): void;
  102568. /**
  102569. * Sets an interger value on a uniform variable.
  102570. * @param uniformName Name of the variable.
  102571. * @param value Value to be set.
  102572. * @returns this effect.
  102573. */
  102574. setInt(uniformName: string, value: number): Effect;
  102575. /**
  102576. * Sets an int array on a uniform variable.
  102577. * @param uniformName Name of the variable.
  102578. * @param array array to be set.
  102579. * @returns this effect.
  102580. */
  102581. setIntArray(uniformName: string, array: Int32Array): Effect;
  102582. /**
  102583. * 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)
  102584. * @param uniformName Name of the variable.
  102585. * @param array array to be set.
  102586. * @returns this effect.
  102587. */
  102588. setIntArray2(uniformName: string, array: Int32Array): Effect;
  102589. /**
  102590. * 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)
  102591. * @param uniformName Name of the variable.
  102592. * @param array array to be set.
  102593. * @returns this effect.
  102594. */
  102595. setIntArray3(uniformName: string, array: Int32Array): Effect;
  102596. /**
  102597. * 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)
  102598. * @param uniformName Name of the variable.
  102599. * @param array array to be set.
  102600. * @returns this effect.
  102601. */
  102602. setIntArray4(uniformName: string, array: Int32Array): Effect;
  102603. /**
  102604. * Sets an float array on a uniform variable.
  102605. * @param uniformName Name of the variable.
  102606. * @param array array to be set.
  102607. * @returns this effect.
  102608. */
  102609. setFloatArray(uniformName: string, array: Float32Array): Effect;
  102610. /**
  102611. * 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)
  102612. * @param uniformName Name of the variable.
  102613. * @param array array to be set.
  102614. * @returns this effect.
  102615. */
  102616. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  102617. /**
  102618. * 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)
  102619. * @param uniformName Name of the variable.
  102620. * @param array array to be set.
  102621. * @returns this effect.
  102622. */
  102623. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  102624. /**
  102625. * 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)
  102626. * @param uniformName Name of the variable.
  102627. * @param array array to be set.
  102628. * @returns this effect.
  102629. */
  102630. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  102631. /**
  102632. * Sets an array on a uniform variable.
  102633. * @param uniformName Name of the variable.
  102634. * @param array array to be set.
  102635. * @returns this effect.
  102636. */
  102637. setArray(uniformName: string, array: number[]): Effect;
  102638. /**
  102639. * 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)
  102640. * @param uniformName Name of the variable.
  102641. * @param array array to be set.
  102642. * @returns this effect.
  102643. */
  102644. setArray2(uniformName: string, array: number[]): Effect;
  102645. /**
  102646. * 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)
  102647. * @param uniformName Name of the variable.
  102648. * @param array array to be set.
  102649. * @returns this effect.
  102650. */
  102651. setArray3(uniformName: string, array: number[]): Effect;
  102652. /**
  102653. * 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)
  102654. * @param uniformName Name of the variable.
  102655. * @param array array to be set.
  102656. * @returns this effect.
  102657. */
  102658. setArray4(uniformName: string, array: number[]): Effect;
  102659. /**
  102660. * Sets matrices on a uniform variable.
  102661. * @param uniformName Name of the variable.
  102662. * @param matrices matrices to be set.
  102663. * @returns this effect.
  102664. */
  102665. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  102666. /**
  102667. * Sets matrix on a uniform variable.
  102668. * @param uniformName Name of the variable.
  102669. * @param matrix matrix to be set.
  102670. * @returns this effect.
  102671. */
  102672. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  102673. /**
  102674. * 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)
  102675. * @param uniformName Name of the variable.
  102676. * @param matrix matrix to be set.
  102677. * @returns this effect.
  102678. */
  102679. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  102680. /**
  102681. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  102682. * @param uniformName Name of the variable.
  102683. * @param matrix matrix to be set.
  102684. * @returns this effect.
  102685. */
  102686. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  102687. /**
  102688. * Sets a float on a uniform variable.
  102689. * @param uniformName Name of the variable.
  102690. * @param value value to be set.
  102691. * @returns this effect.
  102692. */
  102693. setFloat(uniformName: string, value: number): Effect;
  102694. /**
  102695. * Sets a boolean on a uniform variable.
  102696. * @param uniformName Name of the variable.
  102697. * @param bool value to be set.
  102698. * @returns this effect.
  102699. */
  102700. setBool(uniformName: string, bool: boolean): Effect;
  102701. /**
  102702. * Sets a Vector2 on a uniform variable.
  102703. * @param uniformName Name of the variable.
  102704. * @param vector2 vector2 to be set.
  102705. * @returns this effect.
  102706. */
  102707. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  102708. /**
  102709. * Sets a float2 on a uniform variable.
  102710. * @param uniformName Name of the variable.
  102711. * @param x First float in float2.
  102712. * @param y Second float in float2.
  102713. * @returns this effect.
  102714. */
  102715. setFloat2(uniformName: string, x: number, y: number): Effect;
  102716. /**
  102717. * Sets a Vector3 on a uniform variable.
  102718. * @param uniformName Name of the variable.
  102719. * @param vector3 Value to be set.
  102720. * @returns this effect.
  102721. */
  102722. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  102723. /**
  102724. * Sets a float3 on a uniform variable.
  102725. * @param uniformName Name of the variable.
  102726. * @param x First float in float3.
  102727. * @param y Second float in float3.
  102728. * @param z Third float in float3.
  102729. * @returns this effect.
  102730. */
  102731. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  102732. /**
  102733. * Sets a Vector4 on a uniform variable.
  102734. * @param uniformName Name of the variable.
  102735. * @param vector4 Value to be set.
  102736. * @returns this effect.
  102737. */
  102738. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  102739. /**
  102740. * Sets a float4 on a uniform variable.
  102741. * @param uniformName Name of the variable.
  102742. * @param x First float in float4.
  102743. * @param y Second float in float4.
  102744. * @param z Third float in float4.
  102745. * @param w Fourth float in float4.
  102746. * @returns this effect.
  102747. */
  102748. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  102749. /**
  102750. * Sets a Color3 on a uniform variable.
  102751. * @param uniformName Name of the variable.
  102752. * @param color3 Value to be set.
  102753. * @returns this effect.
  102754. */
  102755. setColor3(uniformName: string, color3: IColor3Like): Effect;
  102756. /**
  102757. * Sets a Color4 on a uniform variable.
  102758. * @param uniformName Name of the variable.
  102759. * @param color3 Value to be set.
  102760. * @param alpha Alpha value to be set.
  102761. * @returns this effect.
  102762. */
  102763. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  102764. /**
  102765. * Sets a Color4 on a uniform variable
  102766. * @param uniformName defines the name of the variable
  102767. * @param color4 defines the value to be set
  102768. * @returns this effect.
  102769. */
  102770. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  102771. /** Release all associated resources */
  102772. dispose(): void;
  102773. /**
  102774. * This function will add a new shader to the shader store
  102775. * @param name the name of the shader
  102776. * @param pixelShader optional pixel shader content
  102777. * @param vertexShader optional vertex shader content
  102778. */
  102779. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  102780. /**
  102781. * Store of each shader (The can be looked up using effect.key)
  102782. */
  102783. static ShadersStore: {
  102784. [key: string]: string;
  102785. };
  102786. /**
  102787. * Store of each included file for a shader (The can be looked up using effect.key)
  102788. */
  102789. static IncludesShadersStore: {
  102790. [key: string]: string;
  102791. };
  102792. /**
  102793. * Resets the cache of effects.
  102794. */
  102795. static ResetCache(): void;
  102796. }
  102797. }
  102798. declare module BABYLON {
  102799. /**
  102800. * Interface used to describe the capabilities of the engine relatively to the current browser
  102801. */
  102802. export interface EngineCapabilities {
  102803. /** Maximum textures units per fragment shader */
  102804. maxTexturesImageUnits: number;
  102805. /** Maximum texture units per vertex shader */
  102806. maxVertexTextureImageUnits: number;
  102807. /** Maximum textures units in the entire pipeline */
  102808. maxCombinedTexturesImageUnits: number;
  102809. /** Maximum texture size */
  102810. maxTextureSize: number;
  102811. /** Maximum texture samples */
  102812. maxSamples?: number;
  102813. /** Maximum cube texture size */
  102814. maxCubemapTextureSize: number;
  102815. /** Maximum render texture size */
  102816. maxRenderTextureSize: number;
  102817. /** Maximum number of vertex attributes */
  102818. maxVertexAttribs: number;
  102819. /** Maximum number of varyings */
  102820. maxVaryingVectors: number;
  102821. /** Maximum number of uniforms per vertex shader */
  102822. maxVertexUniformVectors: number;
  102823. /** Maximum number of uniforms per fragment shader */
  102824. maxFragmentUniformVectors: number;
  102825. /** Defines if standard derivates (dx/dy) are supported */
  102826. standardDerivatives: boolean;
  102827. /** Defines if s3tc texture compression is supported */
  102828. s3tc?: WEBGL_compressed_texture_s3tc;
  102829. /** Defines if pvrtc texture compression is supported */
  102830. pvrtc: any;
  102831. /** Defines if etc1 texture compression is supported */
  102832. etc1: any;
  102833. /** Defines if etc2 texture compression is supported */
  102834. etc2: any;
  102835. /** Defines if astc texture compression is supported */
  102836. astc: any;
  102837. /** Defines if float textures are supported */
  102838. textureFloat: boolean;
  102839. /** Defines if vertex array objects are supported */
  102840. vertexArrayObject: boolean;
  102841. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  102842. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  102843. /** Gets the maximum level of anisotropy supported */
  102844. maxAnisotropy: number;
  102845. /** Defines if instancing is supported */
  102846. instancedArrays: boolean;
  102847. /** Defines if 32 bits indices are supported */
  102848. uintIndices: boolean;
  102849. /** Defines if high precision shaders are supported */
  102850. highPrecisionShaderSupported: boolean;
  102851. /** Defines if depth reading in the fragment shader is supported */
  102852. fragmentDepthSupported: boolean;
  102853. /** Defines if float texture linear filtering is supported*/
  102854. textureFloatLinearFiltering: boolean;
  102855. /** Defines if rendering to float textures is supported */
  102856. textureFloatRender: boolean;
  102857. /** Defines if half float textures are supported*/
  102858. textureHalfFloat: boolean;
  102859. /** Defines if half float texture linear filtering is supported*/
  102860. textureHalfFloatLinearFiltering: boolean;
  102861. /** Defines if rendering to half float textures is supported */
  102862. textureHalfFloatRender: boolean;
  102863. /** Defines if textureLOD shader command is supported */
  102864. textureLOD: boolean;
  102865. /** Defines if draw buffers extension is supported */
  102866. drawBuffersExtension: boolean;
  102867. /** Defines if depth textures are supported */
  102868. depthTextureExtension: boolean;
  102869. /** Defines if float color buffer are supported */
  102870. colorBufferFloat: boolean;
  102871. /** Gets disjoint timer query extension (null if not supported) */
  102872. timerQuery?: EXT_disjoint_timer_query;
  102873. /** Defines if timestamp can be used with timer query */
  102874. canUseTimestampForTimerQuery: boolean;
  102875. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  102876. multiview?: any;
  102877. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  102878. oculusMultiview?: any;
  102879. /** Function used to let the system compiles shaders in background */
  102880. parallelShaderCompile?: {
  102881. COMPLETION_STATUS_KHR: number;
  102882. };
  102883. /** Max number of texture samples for MSAA */
  102884. maxMSAASamples: number;
  102885. /** Defines if the blend min max extension is supported */
  102886. blendMinMax: boolean;
  102887. }
  102888. }
  102889. declare module BABYLON {
  102890. /**
  102891. * @hidden
  102892. **/
  102893. export class DepthCullingState {
  102894. private _isDepthTestDirty;
  102895. private _isDepthMaskDirty;
  102896. private _isDepthFuncDirty;
  102897. private _isCullFaceDirty;
  102898. private _isCullDirty;
  102899. private _isZOffsetDirty;
  102900. private _isFrontFaceDirty;
  102901. private _depthTest;
  102902. private _depthMask;
  102903. private _depthFunc;
  102904. private _cull;
  102905. private _cullFace;
  102906. private _zOffset;
  102907. private _frontFace;
  102908. /**
  102909. * Initializes the state.
  102910. */
  102911. constructor();
  102912. get isDirty(): boolean;
  102913. get zOffset(): number;
  102914. set zOffset(value: number);
  102915. get cullFace(): Nullable<number>;
  102916. set cullFace(value: Nullable<number>);
  102917. get cull(): Nullable<boolean>;
  102918. set cull(value: Nullable<boolean>);
  102919. get depthFunc(): Nullable<number>;
  102920. set depthFunc(value: Nullable<number>);
  102921. get depthMask(): boolean;
  102922. set depthMask(value: boolean);
  102923. get depthTest(): boolean;
  102924. set depthTest(value: boolean);
  102925. get frontFace(): Nullable<number>;
  102926. set frontFace(value: Nullable<number>);
  102927. reset(): void;
  102928. apply(gl: WebGLRenderingContext): void;
  102929. }
  102930. }
  102931. declare module BABYLON {
  102932. /**
  102933. * @hidden
  102934. **/
  102935. export class StencilState {
  102936. /** 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 */
  102937. static readonly ALWAYS: number;
  102938. /** Passed to stencilOperation to specify that stencil value must be kept */
  102939. static readonly KEEP: number;
  102940. /** Passed to stencilOperation to specify that stencil value must be replaced */
  102941. static readonly REPLACE: number;
  102942. private _isStencilTestDirty;
  102943. private _isStencilMaskDirty;
  102944. private _isStencilFuncDirty;
  102945. private _isStencilOpDirty;
  102946. private _stencilTest;
  102947. private _stencilMask;
  102948. private _stencilFunc;
  102949. private _stencilFuncRef;
  102950. private _stencilFuncMask;
  102951. private _stencilOpStencilFail;
  102952. private _stencilOpDepthFail;
  102953. private _stencilOpStencilDepthPass;
  102954. get isDirty(): boolean;
  102955. get stencilFunc(): number;
  102956. set stencilFunc(value: number);
  102957. get stencilFuncRef(): number;
  102958. set stencilFuncRef(value: number);
  102959. get stencilFuncMask(): number;
  102960. set stencilFuncMask(value: number);
  102961. get stencilOpStencilFail(): number;
  102962. set stencilOpStencilFail(value: number);
  102963. get stencilOpDepthFail(): number;
  102964. set stencilOpDepthFail(value: number);
  102965. get stencilOpStencilDepthPass(): number;
  102966. set stencilOpStencilDepthPass(value: number);
  102967. get stencilMask(): number;
  102968. set stencilMask(value: number);
  102969. get stencilTest(): boolean;
  102970. set stencilTest(value: boolean);
  102971. constructor();
  102972. reset(): void;
  102973. apply(gl: WebGLRenderingContext): void;
  102974. }
  102975. }
  102976. declare module BABYLON {
  102977. /**
  102978. * @hidden
  102979. **/
  102980. export class AlphaState {
  102981. private _isAlphaBlendDirty;
  102982. private _isBlendFunctionParametersDirty;
  102983. private _isBlendEquationParametersDirty;
  102984. private _isBlendConstantsDirty;
  102985. private _alphaBlend;
  102986. private _blendFunctionParameters;
  102987. private _blendEquationParameters;
  102988. private _blendConstants;
  102989. /**
  102990. * Initializes the state.
  102991. */
  102992. constructor();
  102993. get isDirty(): boolean;
  102994. get alphaBlend(): boolean;
  102995. set alphaBlend(value: boolean);
  102996. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  102997. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  102998. setAlphaEquationParameters(rgb: number, alpha: number): void;
  102999. reset(): void;
  103000. apply(gl: WebGLRenderingContext): void;
  103001. }
  103002. }
  103003. declare module BABYLON {
  103004. /** @hidden */
  103005. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103006. attributeProcessor(attribute: string): string;
  103007. varyingProcessor(varying: string, isFragment: boolean): string;
  103008. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103009. }
  103010. }
  103011. declare module BABYLON {
  103012. /**
  103013. * Interface for attribute information associated with buffer instanciation
  103014. */
  103015. export interface InstancingAttributeInfo {
  103016. /**
  103017. * Name of the GLSL attribute
  103018. * if attribute index is not specified, this is used to retrieve the index from the effect
  103019. */
  103020. attributeName: string;
  103021. /**
  103022. * Index/offset of the attribute in the vertex shader
  103023. * if not specified, this will be computes from the name.
  103024. */
  103025. index?: number;
  103026. /**
  103027. * size of the attribute, 1, 2, 3 or 4
  103028. */
  103029. attributeSize: number;
  103030. /**
  103031. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103032. */
  103033. offset: number;
  103034. /**
  103035. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103036. * default to 1
  103037. */
  103038. divisor?: number;
  103039. /**
  103040. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103041. * default is FLOAT
  103042. */
  103043. attributeType?: number;
  103044. /**
  103045. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103046. */
  103047. normalized?: boolean;
  103048. }
  103049. }
  103050. declare module BABYLON {
  103051. interface ThinEngine {
  103052. /**
  103053. * Update a video texture
  103054. * @param texture defines the texture to update
  103055. * @param video defines the video element to use
  103056. * @param invertY defines if data must be stored with Y axis inverted
  103057. */
  103058. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103059. }
  103060. }
  103061. declare module BABYLON {
  103062. /**
  103063. * Settings for finer control over video usage
  103064. */
  103065. export interface VideoTextureSettings {
  103066. /**
  103067. * Applies `autoplay` to video, if specified
  103068. */
  103069. autoPlay?: boolean;
  103070. /**
  103071. * Applies `loop` to video, if specified
  103072. */
  103073. loop?: boolean;
  103074. /**
  103075. * Automatically updates internal texture from video at every frame in the render loop
  103076. */
  103077. autoUpdateTexture: boolean;
  103078. /**
  103079. * Image src displayed during the video loading or until the user interacts with the video.
  103080. */
  103081. poster?: string;
  103082. }
  103083. /**
  103084. * If you want to display a video in your scene, this is the special texture for that.
  103085. * This special texture works similar to other textures, with the exception of a few parameters.
  103086. * @see https://doc.babylonjs.com/how_to/video_texture
  103087. */
  103088. export class VideoTexture extends Texture {
  103089. /**
  103090. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103091. */
  103092. readonly autoUpdateTexture: boolean;
  103093. /**
  103094. * The video instance used by the texture internally
  103095. */
  103096. readonly video: HTMLVideoElement;
  103097. private _onUserActionRequestedObservable;
  103098. /**
  103099. * Event triggerd when a dom action is required by the user to play the video.
  103100. * This happens due to recent changes in browser policies preventing video to auto start.
  103101. */
  103102. get onUserActionRequestedObservable(): Observable<Texture>;
  103103. private _generateMipMaps;
  103104. private _engine;
  103105. private _stillImageCaptured;
  103106. private _displayingPosterTexture;
  103107. private _settings;
  103108. private _createInternalTextureOnEvent;
  103109. private _frameId;
  103110. private _currentSrc;
  103111. /**
  103112. * Creates a video texture.
  103113. * If you want to display a video in your scene, this is the special texture for that.
  103114. * This special texture works similar to other textures, with the exception of a few parameters.
  103115. * @see https://doc.babylonjs.com/how_to/video_texture
  103116. * @param name optional name, will detect from video source, if not defined
  103117. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  103118. * @param scene is obviously the current scene.
  103119. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  103120. * @param invertY is false by default but can be used to invert video on Y axis
  103121. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  103122. * @param settings allows finer control over video usage
  103123. */
  103124. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  103125. private _getName;
  103126. private _getVideo;
  103127. private _createInternalTexture;
  103128. private reset;
  103129. /**
  103130. * @hidden Internal method to initiate `update`.
  103131. */
  103132. _rebuild(): void;
  103133. /**
  103134. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  103135. */
  103136. update(): void;
  103137. /**
  103138. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  103139. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  103140. */
  103141. updateTexture(isVisible: boolean): void;
  103142. protected _updateInternalTexture: () => void;
  103143. /**
  103144. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  103145. * @param url New url.
  103146. */
  103147. updateURL(url: string): void;
  103148. /**
  103149. * Clones the texture.
  103150. * @returns the cloned texture
  103151. */
  103152. clone(): VideoTexture;
  103153. /**
  103154. * Dispose the texture and release its associated resources.
  103155. */
  103156. dispose(): void;
  103157. /**
  103158. * Creates a video texture straight from a stream.
  103159. * @param scene Define the scene the texture should be created in
  103160. * @param stream Define the stream the texture should be created from
  103161. * @returns The created video texture as a promise
  103162. */
  103163. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  103164. /**
  103165. * Creates a video texture straight from your WebCam video feed.
  103166. * @param scene Define the scene the texture should be created in
  103167. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103168. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103169. * @returns The created video texture as a promise
  103170. */
  103171. static CreateFromWebCamAsync(scene: Scene, constraints: {
  103172. minWidth: number;
  103173. maxWidth: number;
  103174. minHeight: number;
  103175. maxHeight: number;
  103176. deviceId: string;
  103177. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  103178. /**
  103179. * Creates a video texture straight from your WebCam video feed.
  103180. * @param scene Define the scene the texture should be created in
  103181. * @param onReady Define a callback to triggered once the texture will be ready
  103182. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103183. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103184. */
  103185. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  103186. minWidth: number;
  103187. maxWidth: number;
  103188. minHeight: number;
  103189. maxHeight: number;
  103190. deviceId: string;
  103191. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  103192. }
  103193. }
  103194. declare module BABYLON {
  103195. /**
  103196. * Defines the interface used by objects working like Scene
  103197. * @hidden
  103198. */
  103199. interface ISceneLike {
  103200. _addPendingData(data: any): void;
  103201. _removePendingData(data: any): void;
  103202. offlineProvider: IOfflineProvider;
  103203. }
  103204. /** Interface defining initialization parameters for Engine class */
  103205. export interface EngineOptions extends WebGLContextAttributes {
  103206. /**
  103207. * Defines if the engine should no exceed a specified device ratio
  103208. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  103209. */
  103210. limitDeviceRatio?: number;
  103211. /**
  103212. * Defines if webvr should be enabled automatically
  103213. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103214. */
  103215. autoEnableWebVR?: boolean;
  103216. /**
  103217. * Defines if webgl2 should be turned off even if supported
  103218. * @see http://doc.babylonjs.com/features/webgl2
  103219. */
  103220. disableWebGL2Support?: boolean;
  103221. /**
  103222. * Defines if webaudio should be initialized as well
  103223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103224. */
  103225. audioEngine?: boolean;
  103226. /**
  103227. * Defines if animations should run using a deterministic lock step
  103228. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103229. */
  103230. deterministicLockstep?: boolean;
  103231. /** Defines the maximum steps to use with deterministic lock step mode */
  103232. lockstepMaxSteps?: number;
  103233. /** Defines the seconds between each deterministic lock step */
  103234. timeStep?: number;
  103235. /**
  103236. * Defines that engine should ignore context lost events
  103237. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  103238. */
  103239. doNotHandleContextLost?: boolean;
  103240. /**
  103241. * Defines that engine should ignore modifying touch action attribute and style
  103242. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  103243. */
  103244. doNotHandleTouchAction?: boolean;
  103245. /**
  103246. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  103247. */
  103248. useHighPrecisionFloats?: boolean;
  103249. }
  103250. /**
  103251. * The base engine class (root of all engines)
  103252. */
  103253. export class ThinEngine {
  103254. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  103255. static ExceptionList: ({
  103256. key: string;
  103257. capture: string;
  103258. captureConstraint: number;
  103259. targets: string[];
  103260. } | {
  103261. key: string;
  103262. capture: null;
  103263. captureConstraint: null;
  103264. targets: string[];
  103265. })[];
  103266. /** @hidden */
  103267. static _TextureLoaders: IInternalTextureLoader[];
  103268. /**
  103269. * Returns the current npm package of the sdk
  103270. */
  103271. static get NpmPackage(): string;
  103272. /**
  103273. * Returns the current version of the framework
  103274. */
  103275. static get Version(): string;
  103276. /**
  103277. * Returns a string describing the current engine
  103278. */
  103279. get description(): string;
  103280. /**
  103281. * Gets or sets the epsilon value used by collision engine
  103282. */
  103283. static CollisionsEpsilon: number;
  103284. /**
  103285. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103286. */
  103287. static get ShadersRepository(): string;
  103288. static set ShadersRepository(value: string);
  103289. /**
  103290. * Gets or sets the textures that the engine should not attempt to load as compressed
  103291. */
  103292. protected _excludedCompressedTextures: string[];
  103293. /**
  103294. * Filters the compressed texture formats to only include
  103295. * files that are not included in the skippable list
  103296. *
  103297. * @param url the current extension
  103298. * @param textureFormatInUse the current compressed texture format
  103299. * @returns "format" string
  103300. */
  103301. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  103302. /** @hidden */
  103303. _shaderProcessor: IShaderProcessor;
  103304. /**
  103305. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  103306. */
  103307. forcePOTTextures: boolean;
  103308. /**
  103309. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  103310. */
  103311. isFullscreen: boolean;
  103312. /**
  103313. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  103314. */
  103315. cullBackFaces: boolean;
  103316. /**
  103317. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  103318. */
  103319. renderEvenInBackground: boolean;
  103320. /**
  103321. * Gets or sets a boolean indicating that cache can be kept between frames
  103322. */
  103323. preventCacheWipeBetweenFrames: boolean;
  103324. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  103325. validateShaderPrograms: boolean;
  103326. /**
  103327. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  103328. * This can provide greater z depth for distant objects.
  103329. */
  103330. useReverseDepthBuffer: boolean;
  103331. /**
  103332. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  103333. */
  103334. disableUniformBuffers: boolean;
  103335. /** @hidden */
  103336. _uniformBuffers: UniformBuffer[];
  103337. /**
  103338. * Gets a boolean indicating that the engine supports uniform buffers
  103339. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  103340. */
  103341. get supportsUniformBuffers(): boolean;
  103342. /** @hidden */
  103343. _gl: WebGLRenderingContext;
  103344. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  103345. protected _windowIsBackground: boolean;
  103346. protected _webGLVersion: number;
  103347. protected _creationOptions: EngineOptions;
  103348. protected _highPrecisionShadersAllowed: boolean;
  103349. /** @hidden */
  103350. get _shouldUseHighPrecisionShader(): boolean;
  103351. /**
  103352. * Gets a boolean indicating that only power of 2 textures are supported
  103353. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  103354. */
  103355. get needPOTTextures(): boolean;
  103356. /** @hidden */
  103357. _badOS: boolean;
  103358. /** @hidden */
  103359. _badDesktopOS: boolean;
  103360. private _hardwareScalingLevel;
  103361. /** @hidden */
  103362. _caps: EngineCapabilities;
  103363. private _isStencilEnable;
  103364. private _glVersion;
  103365. private _glRenderer;
  103366. private _glVendor;
  103367. /** @hidden */
  103368. _videoTextureSupported: boolean;
  103369. protected _renderingQueueLaunched: boolean;
  103370. protected _activeRenderLoops: (() => void)[];
  103371. /**
  103372. * Observable signaled when a context lost event is raised
  103373. */
  103374. onContextLostObservable: Observable<ThinEngine>;
  103375. /**
  103376. * Observable signaled when a context restored event is raised
  103377. */
  103378. onContextRestoredObservable: Observable<ThinEngine>;
  103379. private _onContextLost;
  103380. private _onContextRestored;
  103381. protected _contextWasLost: boolean;
  103382. /** @hidden */
  103383. _doNotHandleContextLost: boolean;
  103384. /**
  103385. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  103386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  103387. */
  103388. get doNotHandleContextLost(): boolean;
  103389. set doNotHandleContextLost(value: boolean);
  103390. /**
  103391. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  103392. */
  103393. disableVertexArrayObjects: boolean;
  103394. /** @hidden */
  103395. protected _colorWrite: boolean;
  103396. /** @hidden */
  103397. protected _colorWriteChanged: boolean;
  103398. /** @hidden */
  103399. protected _depthCullingState: DepthCullingState;
  103400. /** @hidden */
  103401. protected _stencilState: StencilState;
  103402. /** @hidden */
  103403. _alphaState: AlphaState;
  103404. /** @hidden */
  103405. _alphaMode: number;
  103406. /** @hidden */
  103407. _alphaEquation: number;
  103408. /** @hidden */
  103409. _internalTexturesCache: InternalTexture[];
  103410. /** @hidden */
  103411. protected _activeChannel: number;
  103412. private _currentTextureChannel;
  103413. /** @hidden */
  103414. protected _boundTexturesCache: {
  103415. [key: string]: Nullable<InternalTexture>;
  103416. };
  103417. /** @hidden */
  103418. protected _currentEffect: Nullable<Effect>;
  103419. /** @hidden */
  103420. protected _currentProgram: Nullable<WebGLProgram>;
  103421. private _compiledEffects;
  103422. private _vertexAttribArraysEnabled;
  103423. /** @hidden */
  103424. protected _cachedViewport: Nullable<IViewportLike>;
  103425. private _cachedVertexArrayObject;
  103426. /** @hidden */
  103427. protected _cachedVertexBuffers: any;
  103428. /** @hidden */
  103429. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  103430. /** @hidden */
  103431. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  103432. /** @hidden */
  103433. _currentRenderTarget: Nullable<InternalTexture>;
  103434. private _uintIndicesCurrentlySet;
  103435. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  103436. /** @hidden */
  103437. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  103438. private _currentBufferPointers;
  103439. private _currentInstanceLocations;
  103440. private _currentInstanceBuffers;
  103441. private _textureUnits;
  103442. /** @hidden */
  103443. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  103444. /** @hidden */
  103445. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  103446. /** @hidden */
  103447. _boundRenderFunction: any;
  103448. private _vaoRecordInProgress;
  103449. private _mustWipeVertexAttributes;
  103450. private _emptyTexture;
  103451. private _emptyCubeTexture;
  103452. private _emptyTexture3D;
  103453. private _emptyTexture2DArray;
  103454. /** @hidden */
  103455. _frameHandler: number;
  103456. private _nextFreeTextureSlots;
  103457. private _maxSimultaneousTextures;
  103458. private _activeRequests;
  103459. protected _texturesSupported: string[];
  103460. /** @hidden */
  103461. _textureFormatInUse: Nullable<string>;
  103462. protected get _supportsHardwareTextureRescaling(): boolean;
  103463. /**
  103464. * Gets the list of texture formats supported
  103465. */
  103466. get texturesSupported(): Array<string>;
  103467. /**
  103468. * Gets the list of texture formats in use
  103469. */
  103470. get textureFormatInUse(): Nullable<string>;
  103471. /**
  103472. * Gets the current viewport
  103473. */
  103474. get currentViewport(): Nullable<IViewportLike>;
  103475. /**
  103476. * Gets the default empty texture
  103477. */
  103478. get emptyTexture(): InternalTexture;
  103479. /**
  103480. * Gets the default empty 3D texture
  103481. */
  103482. get emptyTexture3D(): InternalTexture;
  103483. /**
  103484. * Gets the default empty 2D array texture
  103485. */
  103486. get emptyTexture2DArray(): InternalTexture;
  103487. /**
  103488. * Gets the default empty cube texture
  103489. */
  103490. get emptyCubeTexture(): InternalTexture;
  103491. /**
  103492. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  103493. */
  103494. readonly premultipliedAlpha: boolean;
  103495. /**
  103496. * Observable event triggered before each texture is initialized
  103497. */
  103498. onBeforeTextureInitObservable: Observable<Texture>;
  103499. /**
  103500. * Creates a new engine
  103501. * @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
  103502. * @param antialias defines enable antialiasing (default: false)
  103503. * @param options defines further options to be sent to the getContext() function
  103504. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103505. */
  103506. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103507. private _rebuildInternalTextures;
  103508. private _rebuildEffects;
  103509. /**
  103510. * Gets a boolean indicating if all created effects are ready
  103511. * @returns true if all effects are ready
  103512. */
  103513. areAllEffectsReady(): boolean;
  103514. protected _rebuildBuffers(): void;
  103515. private _initGLContext;
  103516. /**
  103517. * Gets version of the current webGL context
  103518. */
  103519. get webGLVersion(): number;
  103520. /**
  103521. * Gets a string idenfifying the name of the class
  103522. * @returns "Engine" string
  103523. */
  103524. getClassName(): string;
  103525. /**
  103526. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  103527. */
  103528. get isStencilEnable(): boolean;
  103529. /** @hidden */
  103530. _prepareWorkingCanvas(): void;
  103531. /**
  103532. * Reset the texture cache to empty state
  103533. */
  103534. resetTextureCache(): void;
  103535. /**
  103536. * Gets an object containing information about the current webGL context
  103537. * @returns an object containing the vender, the renderer and the version of the current webGL context
  103538. */
  103539. getGlInfo(): {
  103540. vendor: string;
  103541. renderer: string;
  103542. version: string;
  103543. };
  103544. /**
  103545. * Defines the hardware scaling level.
  103546. * By default the hardware scaling level is computed from the window device ratio.
  103547. * 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.
  103548. * @param level defines the level to use
  103549. */
  103550. setHardwareScalingLevel(level: number): void;
  103551. /**
  103552. * Gets the current hardware scaling level.
  103553. * By default the hardware scaling level is computed from the window device ratio.
  103554. * 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.
  103555. * @returns a number indicating the current hardware scaling level
  103556. */
  103557. getHardwareScalingLevel(): number;
  103558. /**
  103559. * Gets the list of loaded textures
  103560. * @returns an array containing all loaded textures
  103561. */
  103562. getLoadedTexturesCache(): InternalTexture[];
  103563. /**
  103564. * Gets the object containing all engine capabilities
  103565. * @returns the EngineCapabilities object
  103566. */
  103567. getCaps(): EngineCapabilities;
  103568. /**
  103569. * stop executing a render loop function and remove it from the execution array
  103570. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  103571. */
  103572. stopRenderLoop(renderFunction?: () => void): void;
  103573. /** @hidden */
  103574. _renderLoop(): void;
  103575. /**
  103576. * Gets the HTML canvas attached with the current webGL context
  103577. * @returns a HTML canvas
  103578. */
  103579. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  103580. /**
  103581. * Gets host window
  103582. * @returns the host window object
  103583. */
  103584. getHostWindow(): Nullable<Window>;
  103585. /**
  103586. * Gets the current render width
  103587. * @param useScreen defines if screen size must be used (or the current render target if any)
  103588. * @returns a number defining the current render width
  103589. */
  103590. getRenderWidth(useScreen?: boolean): number;
  103591. /**
  103592. * Gets the current render height
  103593. * @param useScreen defines if screen size must be used (or the current render target if any)
  103594. * @returns a number defining the current render height
  103595. */
  103596. getRenderHeight(useScreen?: boolean): number;
  103597. /**
  103598. * Can be used to override the current requestAnimationFrame requester.
  103599. * @hidden
  103600. */
  103601. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  103602. /**
  103603. * Register and execute a render loop. The engine can have more than one render function
  103604. * @param renderFunction defines the function to continuously execute
  103605. */
  103606. runRenderLoop(renderFunction: () => void): void;
  103607. /**
  103608. * Clear the current render buffer or the current render target (if any is set up)
  103609. * @param color defines the color to use
  103610. * @param backBuffer defines if the back buffer must be cleared
  103611. * @param depth defines if the depth buffer must be cleared
  103612. * @param stencil defines if the stencil buffer must be cleared
  103613. */
  103614. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  103615. private _viewportCached;
  103616. /** @hidden */
  103617. _viewport(x: number, y: number, width: number, height: number): void;
  103618. /**
  103619. * Set the WebGL's viewport
  103620. * @param viewport defines the viewport element to be used
  103621. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  103622. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  103623. */
  103624. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  103625. /**
  103626. * Begin a new frame
  103627. */
  103628. beginFrame(): void;
  103629. /**
  103630. * Enf the current frame
  103631. */
  103632. endFrame(): void;
  103633. /**
  103634. * Resize the view according to the canvas' size
  103635. */
  103636. resize(): void;
  103637. /**
  103638. * Force a specific size of the canvas
  103639. * @param width defines the new canvas' width
  103640. * @param height defines the new canvas' height
  103641. */
  103642. setSize(width: number, height: number): void;
  103643. /**
  103644. * Binds the frame buffer to the specified texture.
  103645. * @param texture The texture to render to or null for the default canvas
  103646. * @param faceIndex The face of the texture to render to in case of cube texture
  103647. * @param requiredWidth The width of the target to render to
  103648. * @param requiredHeight The height of the target to render to
  103649. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  103650. * @param lodLevel defines the lod level to bind to the frame buffer
  103651. * @param layer defines the 2d array index to bind to frame buffer to
  103652. */
  103653. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  103654. /** @hidden */
  103655. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  103656. /**
  103657. * Unbind the current render target texture from the webGL context
  103658. * @param texture defines the render target texture to unbind
  103659. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103660. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103661. */
  103662. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  103663. /**
  103664. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  103665. */
  103666. flushFramebuffer(): void;
  103667. /**
  103668. * Unbind the current render target and bind the default framebuffer
  103669. */
  103670. restoreDefaultFramebuffer(): void;
  103671. /** @hidden */
  103672. protected _resetVertexBufferBinding(): void;
  103673. /**
  103674. * Creates a vertex buffer
  103675. * @param data the data for the vertex buffer
  103676. * @returns the new WebGL static buffer
  103677. */
  103678. createVertexBuffer(data: DataArray): DataBuffer;
  103679. private _createVertexBuffer;
  103680. /**
  103681. * Creates a dynamic vertex buffer
  103682. * @param data the data for the dynamic vertex buffer
  103683. * @returns the new WebGL dynamic buffer
  103684. */
  103685. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  103686. protected _resetIndexBufferBinding(): void;
  103687. /**
  103688. * Creates a new index buffer
  103689. * @param indices defines the content of the index buffer
  103690. * @param updatable defines if the index buffer must be updatable
  103691. * @returns a new webGL buffer
  103692. */
  103693. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  103694. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  103695. /**
  103696. * Bind a webGL buffer to the webGL context
  103697. * @param buffer defines the buffer to bind
  103698. */
  103699. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  103700. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  103701. private bindBuffer;
  103702. /**
  103703. * update the bound buffer with the given data
  103704. * @param data defines the data to update
  103705. */
  103706. updateArrayBuffer(data: Float32Array): void;
  103707. private _vertexAttribPointer;
  103708. /** @hidden */
  103709. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  103710. private _bindVertexBuffersAttributes;
  103711. /**
  103712. * Records a vertex array object
  103713. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  103714. * @param vertexBuffers defines the list of vertex buffers to store
  103715. * @param indexBuffer defines the index buffer to store
  103716. * @param effect defines the effect to store
  103717. * @returns the new vertex array object
  103718. */
  103719. recordVertexArrayObject(vertexBuffers: {
  103720. [key: string]: VertexBuffer;
  103721. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  103722. /**
  103723. * Bind a specific vertex array object
  103724. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  103725. * @param vertexArrayObject defines the vertex array object to bind
  103726. * @param indexBuffer defines the index buffer to bind
  103727. */
  103728. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  103729. /**
  103730. * Bind webGl buffers directly to the webGL context
  103731. * @param vertexBuffer defines the vertex buffer to bind
  103732. * @param indexBuffer defines the index buffer to bind
  103733. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  103734. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  103735. * @param effect defines the effect associated with the vertex buffer
  103736. */
  103737. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  103738. private _unbindVertexArrayObject;
  103739. /**
  103740. * Bind a list of vertex buffers to the webGL context
  103741. * @param vertexBuffers defines the list of vertex buffers to bind
  103742. * @param indexBuffer defines the index buffer to bind
  103743. * @param effect defines the effect associated with the vertex buffers
  103744. */
  103745. bindBuffers(vertexBuffers: {
  103746. [key: string]: Nullable<VertexBuffer>;
  103747. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  103748. /**
  103749. * Unbind all instance attributes
  103750. */
  103751. unbindInstanceAttributes(): void;
  103752. /**
  103753. * Release and free the memory of a vertex array object
  103754. * @param vao defines the vertex array object to delete
  103755. */
  103756. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  103757. /** @hidden */
  103758. _releaseBuffer(buffer: DataBuffer): boolean;
  103759. protected _deleteBuffer(buffer: DataBuffer): void;
  103760. /**
  103761. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  103762. * @param instancesBuffer defines the webGL buffer to update and bind
  103763. * @param data defines the data to store in the buffer
  103764. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  103765. */
  103766. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  103767. /**
  103768. * Bind the content of a webGL buffer used with instanciation
  103769. * @param instancesBuffer defines the webGL buffer to bind
  103770. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  103771. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  103772. */
  103773. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  103774. /**
  103775. * Disable the instance attribute corresponding to the name in parameter
  103776. * @param name defines the name of the attribute to disable
  103777. */
  103778. disableInstanceAttributeByName(name: string): void;
  103779. /**
  103780. * Disable the instance attribute corresponding to the location in parameter
  103781. * @param attributeLocation defines the attribute location of the attribute to disable
  103782. */
  103783. disableInstanceAttribute(attributeLocation: number): void;
  103784. /**
  103785. * Disable the attribute corresponding to the location in parameter
  103786. * @param attributeLocation defines the attribute location of the attribute to disable
  103787. */
  103788. disableAttributeByIndex(attributeLocation: number): void;
  103789. /**
  103790. * Send a draw order
  103791. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  103792. * @param indexStart defines the starting index
  103793. * @param indexCount defines the number of index to draw
  103794. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103795. */
  103796. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  103797. /**
  103798. * Draw a list of points
  103799. * @param verticesStart defines the index of first vertex to draw
  103800. * @param verticesCount defines the count of vertices to draw
  103801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103802. */
  103803. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103804. /**
  103805. * Draw a list of unindexed primitives
  103806. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  103807. * @param verticesStart defines the index of first vertex to draw
  103808. * @param verticesCount defines the count of vertices to draw
  103809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103810. */
  103811. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103812. /**
  103813. * Draw a list of indexed primitives
  103814. * @param fillMode defines the primitive to use
  103815. * @param indexStart defines the starting index
  103816. * @param indexCount defines the number of index to draw
  103817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103818. */
  103819. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  103820. /**
  103821. * Draw a list of unindexed primitives
  103822. * @param fillMode defines the primitive to use
  103823. * @param verticesStart defines the index of first vertex to draw
  103824. * @param verticesCount defines the count of vertices to draw
  103825. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  103826. */
  103827. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103828. private _drawMode;
  103829. /** @hidden */
  103830. protected _reportDrawCall(): void;
  103831. /** @hidden */
  103832. _releaseEffect(effect: Effect): void;
  103833. /** @hidden */
  103834. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  103835. /**
  103836. * Create a new effect (used to store vertex/fragment shaders)
  103837. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  103838. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  103839. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  103840. * @param samplers defines an array of string used to represent textures
  103841. * @param defines defines the string containing the defines to use to compile the shaders
  103842. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  103843. * @param onCompiled defines a function to call when the effect creation is successful
  103844. * @param onError defines a function to call when the effect creation has failed
  103845. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  103846. * @returns the new Effect
  103847. */
  103848. 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;
  103849. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  103850. private _compileShader;
  103851. private _compileRawShader;
  103852. /**
  103853. * Directly creates a webGL program
  103854. * @param pipelineContext defines the pipeline context to attach to
  103855. * @param vertexCode defines the vertex shader code to use
  103856. * @param fragmentCode defines the fragment shader code to use
  103857. * @param context defines the webGL context to use (if not set, the current one will be used)
  103858. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  103859. * @returns the new webGL program
  103860. */
  103861. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103862. /**
  103863. * Creates a webGL program
  103864. * @param pipelineContext defines the pipeline context to attach to
  103865. * @param vertexCode defines the vertex shader code to use
  103866. * @param fragmentCode defines the fragment shader code to use
  103867. * @param defines defines the string containing the defines to use to compile the shaders
  103868. * @param context defines the webGL context to use (if not set, the current one will be used)
  103869. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  103870. * @returns the new webGL program
  103871. */
  103872. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103873. /**
  103874. * Creates a new pipeline context
  103875. * @returns the new pipeline
  103876. */
  103877. createPipelineContext(): IPipelineContext;
  103878. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  103879. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  103880. /** @hidden */
  103881. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  103882. /** @hidden */
  103883. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  103884. /** @hidden */
  103885. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  103886. /**
  103887. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  103888. * @param pipelineContext defines the pipeline context to use
  103889. * @param uniformsNames defines the list of uniform names
  103890. * @returns an array of webGL uniform locations
  103891. */
  103892. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  103893. /**
  103894. * Gets the lsit of active attributes for a given webGL program
  103895. * @param pipelineContext defines the pipeline context to use
  103896. * @param attributesNames defines the list of attribute names to get
  103897. * @returns an array of indices indicating the offset of each attribute
  103898. */
  103899. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  103900. /**
  103901. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  103902. * @param effect defines the effect to activate
  103903. */
  103904. enableEffect(effect: Nullable<Effect>): void;
  103905. /**
  103906. * Set the value of an uniform to a number (int)
  103907. * @param uniform defines the webGL uniform location where to store the value
  103908. * @param value defines the int number to store
  103909. */
  103910. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  103911. /**
  103912. * Set the value of an uniform to an array of int32
  103913. * @param uniform defines the webGL uniform location where to store the value
  103914. * @param array defines the array of int32 to store
  103915. */
  103916. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103917. /**
  103918. * Set the value of an uniform to an array of int32 (stored as vec2)
  103919. * @param uniform defines the webGL uniform location where to store the value
  103920. * @param array defines the array of int32 to store
  103921. */
  103922. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103923. /**
  103924. * Set the value of an uniform to an array of int32 (stored as vec3)
  103925. * @param uniform defines the webGL uniform location where to store the value
  103926. * @param array defines the array of int32 to store
  103927. */
  103928. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103929. /**
  103930. * Set the value of an uniform to an array of int32 (stored as vec4)
  103931. * @param uniform defines the webGL uniform location where to store the value
  103932. * @param array defines the array of int32 to store
  103933. */
  103934. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  103935. /**
  103936. * Set the value of an uniform to an array of number
  103937. * @param uniform defines the webGL uniform location where to store the value
  103938. * @param array defines the array of number to store
  103939. */
  103940. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103941. /**
  103942. * Set the value of an uniform to an array of number (stored as vec2)
  103943. * @param uniform defines the webGL uniform location where to store the value
  103944. * @param array defines the array of number to store
  103945. */
  103946. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103947. /**
  103948. * Set the value of an uniform to an array of number (stored as vec3)
  103949. * @param uniform defines the webGL uniform location where to store the value
  103950. * @param array defines the array of number to store
  103951. */
  103952. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103953. /**
  103954. * Set the value of an uniform to an array of number (stored as vec4)
  103955. * @param uniform defines the webGL uniform location where to store the value
  103956. * @param array defines the array of number to store
  103957. */
  103958. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  103959. /**
  103960. * Set the value of an uniform to an array of float32 (stored as matrices)
  103961. * @param uniform defines the webGL uniform location where to store the value
  103962. * @param matrices defines the array of float32 to store
  103963. */
  103964. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  103965. /**
  103966. * Set the value of an uniform to a matrix (3x3)
  103967. * @param uniform defines the webGL uniform location where to store the value
  103968. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  103969. */
  103970. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  103971. /**
  103972. * Set the value of an uniform to a matrix (2x2)
  103973. * @param uniform defines the webGL uniform location where to store the value
  103974. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  103975. */
  103976. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  103977. /**
  103978. * Set the value of an uniform to a number (float)
  103979. * @param uniform defines the webGL uniform location where to store the value
  103980. * @param value defines the float number to store
  103981. */
  103982. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  103983. /**
  103984. * Set the value of an uniform to a vec2
  103985. * @param uniform defines the webGL uniform location where to store the value
  103986. * @param x defines the 1st component of the value
  103987. * @param y defines the 2nd component of the value
  103988. */
  103989. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  103990. /**
  103991. * Set the value of an uniform to a vec3
  103992. * @param uniform defines the webGL uniform location where to store the value
  103993. * @param x defines the 1st component of the value
  103994. * @param y defines the 2nd component of the value
  103995. * @param z defines the 3rd component of the value
  103996. */
  103997. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  103998. /**
  103999. * Set the value of an uniform to a vec4
  104000. * @param uniform defines the webGL uniform location where to store the value
  104001. * @param x defines the 1st component of the value
  104002. * @param y defines the 2nd component of the value
  104003. * @param z defines the 3rd component of the value
  104004. * @param w defines the 4th component of the value
  104005. */
  104006. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104007. /**
  104008. * Apply all cached states (depth, culling, stencil and alpha)
  104009. */
  104010. applyStates(): void;
  104011. /**
  104012. * Enable or disable color writing
  104013. * @param enable defines the state to set
  104014. */
  104015. setColorWrite(enable: boolean): void;
  104016. /**
  104017. * Gets a boolean indicating if color writing is enabled
  104018. * @returns the current color writing state
  104019. */
  104020. getColorWrite(): boolean;
  104021. /**
  104022. * Gets the depth culling state manager
  104023. */
  104024. get depthCullingState(): DepthCullingState;
  104025. /**
  104026. * Gets the alpha state manager
  104027. */
  104028. get alphaState(): AlphaState;
  104029. /**
  104030. * Gets the stencil state manager
  104031. */
  104032. get stencilState(): StencilState;
  104033. /**
  104034. * Clears the list of texture accessible through engine.
  104035. * This can help preventing texture load conflict due to name collision.
  104036. */
  104037. clearInternalTexturesCache(): void;
  104038. /**
  104039. * Force the entire cache to be cleared
  104040. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104041. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104042. */
  104043. wipeCaches(bruteForce?: boolean): void;
  104044. /** @hidden */
  104045. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104046. min: number;
  104047. mag: number;
  104048. };
  104049. /** @hidden */
  104050. _createTexture(): WebGLTexture;
  104051. /**
  104052. * Usually called from Texture.ts.
  104053. * Passed information to create a WebGLTexture
  104054. * @param urlArg defines a value which contains one of the following:
  104055. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104056. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104057. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104058. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104059. * @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)
  104060. * @param scene needed for loading to the correct scene
  104061. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104062. * @param onLoad optional callback to be called upon successful completion
  104063. * @param onError optional callback to be called upon failure
  104064. * @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
  104065. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104066. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104067. * @param forcedExtension defines the extension to use to pick the right loader
  104068. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  104069. * @param mimeType defines an optional mime type
  104070. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104071. */
  104072. 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;
  104073. /**
  104074. * Loads an image as an HTMLImageElement.
  104075. * @param input url string, ArrayBuffer, or Blob to load
  104076. * @param onLoad callback called when the image successfully loads
  104077. * @param onError callback called when the image fails to load
  104078. * @param offlineProvider offline provider for caching
  104079. * @param mimeType optional mime type
  104080. * @returns the HTMLImageElement of the loaded image
  104081. * @hidden
  104082. */
  104083. 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>;
  104084. /**
  104085. * @hidden
  104086. */
  104087. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104088. /**
  104089. * Creates a raw texture
  104090. * @param data defines the data to store in the texture
  104091. * @param width defines the width of the texture
  104092. * @param height defines the height of the texture
  104093. * @param format defines the format of the data
  104094. * @param generateMipMaps defines if the engine should generate the mip levels
  104095. * @param invertY defines if data must be stored with Y axis inverted
  104096. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104097. * @param compression defines the compression used (null by default)
  104098. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104099. * @returns the raw texture inside an InternalTexture
  104100. */
  104101. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104102. /**
  104103. * Creates a new raw cube texture
  104104. * @param data defines the array of data to use to create each face
  104105. * @param size defines the size of the textures
  104106. * @param format defines the format of the data
  104107. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104108. * @param generateMipMaps defines if the engine should generate the mip levels
  104109. * @param invertY defines if data must be stored with Y axis inverted
  104110. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104111. * @param compression defines the compression used (null by default)
  104112. * @returns the cube texture as an InternalTexture
  104113. */
  104114. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104115. /**
  104116. * Creates a new raw 3D texture
  104117. * @param data defines the data used to create the texture
  104118. * @param width defines the width of the texture
  104119. * @param height defines the height of the texture
  104120. * @param depth defines the depth of the texture
  104121. * @param format defines the format of the texture
  104122. * @param generateMipMaps defines if the engine must generate mip levels
  104123. * @param invertY defines if data must be stored with Y axis inverted
  104124. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104125. * @param compression defines the compressed used (can be null)
  104126. * @param textureType defines the compressed used (can be null)
  104127. * @returns a new raw 3D texture (stored in an InternalTexture)
  104128. */
  104129. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104130. /**
  104131. * Creates a new raw 2D array texture
  104132. * @param data defines the data used to create the texture
  104133. * @param width defines the width of the texture
  104134. * @param height defines the height of the texture
  104135. * @param depth defines the number of layers of the texture
  104136. * @param format defines the format of the texture
  104137. * @param generateMipMaps defines if the engine must generate mip levels
  104138. * @param invertY defines if data must be stored with Y axis inverted
  104139. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104140. * @param compression defines the compressed used (can be null)
  104141. * @param textureType defines the compressed used (can be null)
  104142. * @returns a new raw 2D array texture (stored in an InternalTexture)
  104143. */
  104144. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104145. private _unpackFlipYCached;
  104146. /**
  104147. * In case you are sharing the context with other applications, it might
  104148. * be interested to not cache the unpack flip y state to ensure a consistent
  104149. * value would be set.
  104150. */
  104151. enableUnpackFlipYCached: boolean;
  104152. /** @hidden */
  104153. _unpackFlipY(value: boolean): void;
  104154. /** @hidden */
  104155. _getUnpackAlignement(): number;
  104156. private _getTextureTarget;
  104157. /**
  104158. * Update the sampling mode of a given texture
  104159. * @param samplingMode defines the required sampling mode
  104160. * @param texture defines the texture to update
  104161. * @param generateMipMaps defines whether to generate mipmaps for the texture
  104162. */
  104163. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  104164. /**
  104165. * Update the sampling mode of a given texture
  104166. * @param texture defines the texture to update
  104167. * @param wrapU defines the texture wrap mode of the u coordinates
  104168. * @param wrapV defines the texture wrap mode of the v coordinates
  104169. * @param wrapR defines the texture wrap mode of the r coordinates
  104170. */
  104171. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  104172. /** @hidden */
  104173. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  104174. width: number;
  104175. height: number;
  104176. layers?: number;
  104177. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  104178. /** @hidden */
  104179. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104180. /** @hidden */
  104181. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  104182. /**
  104183. * Update a portion of an internal texture
  104184. * @param texture defines the texture to update
  104185. * @param imageData defines the data to store into the texture
  104186. * @param xOffset defines the x coordinates of the update rectangle
  104187. * @param yOffset defines the y coordinates of the update rectangle
  104188. * @param width defines the width of the update rectangle
  104189. * @param height defines the height of the update rectangle
  104190. * @param faceIndex defines the face index if texture is a cube (0 by default)
  104191. * @param lod defines the lod level to update (0 by default)
  104192. */
  104193. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  104194. /** @hidden */
  104195. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104196. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  104197. private _prepareWebGLTexture;
  104198. /** @hidden */
  104199. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  104200. private _getDepthStencilBuffer;
  104201. /** @hidden */
  104202. _releaseFramebufferObjects(texture: InternalTexture): void;
  104203. /** @hidden */
  104204. _releaseTexture(texture: InternalTexture): void;
  104205. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  104206. protected _setProgram(program: WebGLProgram): void;
  104207. protected _boundUniforms: {
  104208. [key: number]: WebGLUniformLocation;
  104209. };
  104210. /**
  104211. * Binds an effect to the webGL context
  104212. * @param effect defines the effect to bind
  104213. */
  104214. bindSamplers(effect: Effect): void;
  104215. private _activateCurrentTexture;
  104216. /** @hidden */
  104217. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  104218. /** @hidden */
  104219. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  104220. /**
  104221. * Unbind all textures from the webGL context
  104222. */
  104223. unbindAllTextures(): void;
  104224. /**
  104225. * Sets a texture to the according uniform.
  104226. * @param channel The texture channel
  104227. * @param uniform The uniform to set
  104228. * @param texture The texture to apply
  104229. */
  104230. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  104231. private _bindSamplerUniformToChannel;
  104232. private _getTextureWrapMode;
  104233. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  104234. /**
  104235. * Sets an array of texture to the webGL context
  104236. * @param channel defines the channel where the texture array must be set
  104237. * @param uniform defines the associated uniform location
  104238. * @param textures defines the array of textures to bind
  104239. */
  104240. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  104241. /** @hidden */
  104242. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  104243. private _setTextureParameterFloat;
  104244. private _setTextureParameterInteger;
  104245. /**
  104246. * Unbind all vertex attributes from the webGL context
  104247. */
  104248. unbindAllAttributes(): void;
  104249. /**
  104250. * 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
  104251. */
  104252. releaseEffects(): void;
  104253. /**
  104254. * Dispose and release all associated resources
  104255. */
  104256. dispose(): void;
  104257. /**
  104258. * Attach a new callback raised when context lost event is fired
  104259. * @param callback defines the callback to call
  104260. */
  104261. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104262. /**
  104263. * Attach a new callback raised when context restored event is fired
  104264. * @param callback defines the callback to call
  104265. */
  104266. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104267. /**
  104268. * Get the current error code of the webGL context
  104269. * @returns the error code
  104270. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104271. */
  104272. getError(): number;
  104273. private _canRenderToFloatFramebuffer;
  104274. private _canRenderToHalfFloatFramebuffer;
  104275. private _canRenderToFramebuffer;
  104276. /** @hidden */
  104277. _getWebGLTextureType(type: number): number;
  104278. /** @hidden */
  104279. _getInternalFormat(format: number): number;
  104280. /** @hidden */
  104281. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  104282. /** @hidden */
  104283. _getRGBAMultiSampleBufferFormat(type: number): number;
  104284. /** @hidden */
  104285. _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;
  104286. /**
  104287. * Loads a file from a url
  104288. * @param url url to load
  104289. * @param onSuccess callback called when the file successfully loads
  104290. * @param onProgress callback called while file is loading (if the server supports this mode)
  104291. * @param offlineProvider defines the offline provider for caching
  104292. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104293. * @param onError callback called when the file fails to load
  104294. * @returns a file request object
  104295. * @hidden
  104296. */
  104297. 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;
  104298. /**
  104299. * Reads pixels from the current frame buffer. Please note that this function can be slow
  104300. * @param x defines the x coordinate of the rectangle where pixels must be read
  104301. * @param y defines the y coordinate of the rectangle where pixels must be read
  104302. * @param width defines the width of the rectangle where pixels must be read
  104303. * @param height defines the height of the rectangle where pixels must be read
  104304. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  104305. * @returns a Uint8Array containing RGBA colors
  104306. */
  104307. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  104308. private static _isSupported;
  104309. /**
  104310. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  104311. * @returns true if the engine can be created
  104312. * @ignorenaming
  104313. */
  104314. static isSupported(): boolean;
  104315. /**
  104316. * Find the next highest power of two.
  104317. * @param x Number to start search from.
  104318. * @return Next highest power of two.
  104319. */
  104320. static CeilingPOT(x: number): number;
  104321. /**
  104322. * Find the next lowest power of two.
  104323. * @param x Number to start search from.
  104324. * @return Next lowest power of two.
  104325. */
  104326. static FloorPOT(x: number): number;
  104327. /**
  104328. * Find the nearest power of two.
  104329. * @param x Number to start search from.
  104330. * @return Next nearest power of two.
  104331. */
  104332. static NearestPOT(x: number): number;
  104333. /**
  104334. * Get the closest exponent of two
  104335. * @param value defines the value to approximate
  104336. * @param max defines the maximum value to return
  104337. * @param mode defines how to define the closest value
  104338. * @returns closest exponent of two of the given value
  104339. */
  104340. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  104341. /**
  104342. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  104343. * @param func - the function to be called
  104344. * @param requester - the object that will request the next frame. Falls back to window.
  104345. * @returns frame number
  104346. */
  104347. static QueueNewFrame(func: () => void, requester?: any): number;
  104348. /**
  104349. * Gets host document
  104350. * @returns the host document object
  104351. */
  104352. getHostDocument(): Nullable<Document>;
  104353. }
  104354. }
  104355. declare module BABYLON {
  104356. /**
  104357. * Class representing spherical harmonics coefficients to the 3rd degree
  104358. */
  104359. export class SphericalHarmonics {
  104360. /**
  104361. * Defines whether or not the harmonics have been prescaled for rendering.
  104362. */
  104363. preScaled: boolean;
  104364. /**
  104365. * The l0,0 coefficients of the spherical harmonics
  104366. */
  104367. l00: Vector3;
  104368. /**
  104369. * The l1,-1 coefficients of the spherical harmonics
  104370. */
  104371. l1_1: Vector3;
  104372. /**
  104373. * The l1,0 coefficients of the spherical harmonics
  104374. */
  104375. l10: Vector3;
  104376. /**
  104377. * The l1,1 coefficients of the spherical harmonics
  104378. */
  104379. l11: Vector3;
  104380. /**
  104381. * The l2,-2 coefficients of the spherical harmonics
  104382. */
  104383. l2_2: Vector3;
  104384. /**
  104385. * The l2,-1 coefficients of the spherical harmonics
  104386. */
  104387. l2_1: Vector3;
  104388. /**
  104389. * The l2,0 coefficients of the spherical harmonics
  104390. */
  104391. l20: Vector3;
  104392. /**
  104393. * The l2,1 coefficients of the spherical harmonics
  104394. */
  104395. l21: Vector3;
  104396. /**
  104397. * The l2,2 coefficients of the spherical harmonics
  104398. */
  104399. l22: Vector3;
  104400. /**
  104401. * Adds a light to the spherical harmonics
  104402. * @param direction the direction of the light
  104403. * @param color the color of the light
  104404. * @param deltaSolidAngle the delta solid angle of the light
  104405. */
  104406. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  104407. /**
  104408. * Scales the spherical harmonics by the given amount
  104409. * @param scale the amount to scale
  104410. */
  104411. scaleInPlace(scale: number): void;
  104412. /**
  104413. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  104414. *
  104415. * ```
  104416. * E_lm = A_l * L_lm
  104417. * ```
  104418. *
  104419. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  104420. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  104421. * the scaling factors are given in equation 9.
  104422. */
  104423. convertIncidentRadianceToIrradiance(): void;
  104424. /**
  104425. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  104426. *
  104427. * ```
  104428. * L = (1/pi) * E * rho
  104429. * ```
  104430. *
  104431. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  104432. */
  104433. convertIrradianceToLambertianRadiance(): void;
  104434. /**
  104435. * Integrates the reconstruction coefficients directly in to the SH preventing further
  104436. * required operations at run time.
  104437. *
  104438. * This is simply done by scaling back the SH with Ylm constants parameter.
  104439. * The trigonometric part being applied by the shader at run time.
  104440. */
  104441. preScaleForRendering(): void;
  104442. /**
  104443. * Constructs a spherical harmonics from an array.
  104444. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  104445. * @returns the spherical harmonics
  104446. */
  104447. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  104448. /**
  104449. * Gets the spherical harmonics from polynomial
  104450. * @param polynomial the spherical polynomial
  104451. * @returns the spherical harmonics
  104452. */
  104453. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  104454. }
  104455. /**
  104456. * Class representing spherical polynomial coefficients to the 3rd degree
  104457. */
  104458. export class SphericalPolynomial {
  104459. private _harmonics;
  104460. /**
  104461. * The spherical harmonics used to create the polynomials.
  104462. */
  104463. get preScaledHarmonics(): SphericalHarmonics;
  104464. /**
  104465. * The x coefficients of the spherical polynomial
  104466. */
  104467. x: Vector3;
  104468. /**
  104469. * The y coefficients of the spherical polynomial
  104470. */
  104471. y: Vector3;
  104472. /**
  104473. * The z coefficients of the spherical polynomial
  104474. */
  104475. z: Vector3;
  104476. /**
  104477. * The xx coefficients of the spherical polynomial
  104478. */
  104479. xx: Vector3;
  104480. /**
  104481. * The yy coefficients of the spherical polynomial
  104482. */
  104483. yy: Vector3;
  104484. /**
  104485. * The zz coefficients of the spherical polynomial
  104486. */
  104487. zz: Vector3;
  104488. /**
  104489. * The xy coefficients of the spherical polynomial
  104490. */
  104491. xy: Vector3;
  104492. /**
  104493. * The yz coefficients of the spherical polynomial
  104494. */
  104495. yz: Vector3;
  104496. /**
  104497. * The zx coefficients of the spherical polynomial
  104498. */
  104499. zx: Vector3;
  104500. /**
  104501. * Adds an ambient color to the spherical polynomial
  104502. * @param color the color to add
  104503. */
  104504. addAmbient(color: Color3): void;
  104505. /**
  104506. * Scales the spherical polynomial by the given amount
  104507. * @param scale the amount to scale
  104508. */
  104509. scaleInPlace(scale: number): void;
  104510. /**
  104511. * Gets the spherical polynomial from harmonics
  104512. * @param harmonics the spherical harmonics
  104513. * @returns the spherical polynomial
  104514. */
  104515. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  104516. /**
  104517. * Constructs a spherical polynomial from an array.
  104518. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  104519. * @returns the spherical polynomial
  104520. */
  104521. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  104522. }
  104523. }
  104524. declare module BABYLON {
  104525. /**
  104526. * Defines the source of the internal texture
  104527. */
  104528. export enum InternalTextureSource {
  104529. /**
  104530. * The source of the texture data is unknown
  104531. */
  104532. Unknown = 0,
  104533. /**
  104534. * Texture data comes from an URL
  104535. */
  104536. Url = 1,
  104537. /**
  104538. * Texture data is only used for temporary storage
  104539. */
  104540. Temp = 2,
  104541. /**
  104542. * Texture data comes from raw data (ArrayBuffer)
  104543. */
  104544. Raw = 3,
  104545. /**
  104546. * Texture content is dynamic (video or dynamic texture)
  104547. */
  104548. Dynamic = 4,
  104549. /**
  104550. * Texture content is generated by rendering to it
  104551. */
  104552. RenderTarget = 5,
  104553. /**
  104554. * Texture content is part of a multi render target process
  104555. */
  104556. MultiRenderTarget = 6,
  104557. /**
  104558. * Texture data comes from a cube data file
  104559. */
  104560. Cube = 7,
  104561. /**
  104562. * Texture data comes from a raw cube data
  104563. */
  104564. CubeRaw = 8,
  104565. /**
  104566. * Texture data come from a prefiltered cube data file
  104567. */
  104568. CubePrefiltered = 9,
  104569. /**
  104570. * Texture content is raw 3D data
  104571. */
  104572. Raw3D = 10,
  104573. /**
  104574. * Texture content is raw 2D array data
  104575. */
  104576. Raw2DArray = 11,
  104577. /**
  104578. * Texture content is a depth texture
  104579. */
  104580. Depth = 12,
  104581. /**
  104582. * Texture data comes from a raw cube data encoded with RGBD
  104583. */
  104584. CubeRawRGBD = 13
  104585. }
  104586. /**
  104587. * Class used to store data associated with WebGL texture data for the engine
  104588. * This class should not be used directly
  104589. */
  104590. export class InternalTexture {
  104591. /** @hidden */
  104592. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  104593. /**
  104594. * Defines if the texture is ready
  104595. */
  104596. isReady: boolean;
  104597. /**
  104598. * Defines if the texture is a cube texture
  104599. */
  104600. isCube: boolean;
  104601. /**
  104602. * Defines if the texture contains 3D data
  104603. */
  104604. is3D: boolean;
  104605. /**
  104606. * Defines if the texture contains 2D array data
  104607. */
  104608. is2DArray: boolean;
  104609. /**
  104610. * Defines if the texture contains multiview data
  104611. */
  104612. isMultiview: boolean;
  104613. /**
  104614. * Gets the URL used to load this texture
  104615. */
  104616. url: string;
  104617. /**
  104618. * Gets the sampling mode of the texture
  104619. */
  104620. samplingMode: number;
  104621. /**
  104622. * Gets a boolean indicating if the texture needs mipmaps generation
  104623. */
  104624. generateMipMaps: boolean;
  104625. /**
  104626. * Gets the number of samples used by the texture (WebGL2+ only)
  104627. */
  104628. samples: number;
  104629. /**
  104630. * Gets the type of the texture (int, float...)
  104631. */
  104632. type: number;
  104633. /**
  104634. * Gets the format of the texture (RGB, RGBA...)
  104635. */
  104636. format: number;
  104637. /**
  104638. * Observable called when the texture is loaded
  104639. */
  104640. onLoadedObservable: Observable<InternalTexture>;
  104641. /**
  104642. * Gets the width of the texture
  104643. */
  104644. width: number;
  104645. /**
  104646. * Gets the height of the texture
  104647. */
  104648. height: number;
  104649. /**
  104650. * Gets the depth of the texture
  104651. */
  104652. depth: number;
  104653. /**
  104654. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  104655. */
  104656. baseWidth: number;
  104657. /**
  104658. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  104659. */
  104660. baseHeight: number;
  104661. /**
  104662. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  104663. */
  104664. baseDepth: number;
  104665. /**
  104666. * Gets a boolean indicating if the texture is inverted on Y axis
  104667. */
  104668. invertY: boolean;
  104669. /** @hidden */
  104670. _invertVScale: boolean;
  104671. /** @hidden */
  104672. _associatedChannel: number;
  104673. /** @hidden */
  104674. _source: InternalTextureSource;
  104675. /** @hidden */
  104676. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104677. /** @hidden */
  104678. _bufferView: Nullable<ArrayBufferView>;
  104679. /** @hidden */
  104680. _bufferViewArray: Nullable<ArrayBufferView[]>;
  104681. /** @hidden */
  104682. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  104683. /** @hidden */
  104684. _size: number;
  104685. /** @hidden */
  104686. _extension: string;
  104687. /** @hidden */
  104688. _files: Nullable<string[]>;
  104689. /** @hidden */
  104690. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104691. /** @hidden */
  104692. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104693. /** @hidden */
  104694. _framebuffer: Nullable<WebGLFramebuffer>;
  104695. /** @hidden */
  104696. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  104697. /** @hidden */
  104698. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  104699. /** @hidden */
  104700. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  104701. /** @hidden */
  104702. _attachments: Nullable<number[]>;
  104703. /** @hidden */
  104704. _cachedCoordinatesMode: Nullable<number>;
  104705. /** @hidden */
  104706. _cachedWrapU: Nullable<number>;
  104707. /** @hidden */
  104708. _cachedWrapV: Nullable<number>;
  104709. /** @hidden */
  104710. _cachedWrapR: Nullable<number>;
  104711. /** @hidden */
  104712. _cachedAnisotropicFilteringLevel: Nullable<number>;
  104713. /** @hidden */
  104714. _isDisabled: boolean;
  104715. /** @hidden */
  104716. _compression: Nullable<string>;
  104717. /** @hidden */
  104718. _generateStencilBuffer: boolean;
  104719. /** @hidden */
  104720. _generateDepthBuffer: boolean;
  104721. /** @hidden */
  104722. _comparisonFunction: number;
  104723. /** @hidden */
  104724. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  104725. /** @hidden */
  104726. _lodGenerationScale: number;
  104727. /** @hidden */
  104728. _lodGenerationOffset: number;
  104729. /** @hidden */
  104730. _depthStencilTexture: Nullable<InternalTexture>;
  104731. /** @hidden */
  104732. _colorTextureArray: Nullable<WebGLTexture>;
  104733. /** @hidden */
  104734. _depthStencilTextureArray: Nullable<WebGLTexture>;
  104735. /** @hidden */
  104736. _lodTextureHigh: Nullable<BaseTexture>;
  104737. /** @hidden */
  104738. _lodTextureMid: Nullable<BaseTexture>;
  104739. /** @hidden */
  104740. _lodTextureLow: Nullable<BaseTexture>;
  104741. /** @hidden */
  104742. _isRGBD: boolean;
  104743. /** @hidden */
  104744. _linearSpecularLOD: boolean;
  104745. /** @hidden */
  104746. _irradianceTexture: Nullable<BaseTexture>;
  104747. /** @hidden */
  104748. _webGLTexture: Nullable<WebGLTexture>;
  104749. /** @hidden */
  104750. _references: number;
  104751. private _engine;
  104752. /**
  104753. * Gets the Engine the texture belongs to.
  104754. * @returns The babylon engine
  104755. */
  104756. getEngine(): ThinEngine;
  104757. /**
  104758. * Gets the data source type of the texture
  104759. */
  104760. get source(): InternalTextureSource;
  104761. /**
  104762. * Creates a new InternalTexture
  104763. * @param engine defines the engine to use
  104764. * @param source defines the type of data that will be used
  104765. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104766. */
  104767. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  104768. /**
  104769. * Increments the number of references (ie. the number of Texture that point to it)
  104770. */
  104771. incrementReferences(): void;
  104772. /**
  104773. * Change the size of the texture (not the size of the content)
  104774. * @param width defines the new width
  104775. * @param height defines the new height
  104776. * @param depth defines the new depth (1 by default)
  104777. */
  104778. updateSize(width: int, height: int, depth?: int): void;
  104779. /** @hidden */
  104780. _rebuild(): void;
  104781. /** @hidden */
  104782. _swapAndDie(target: InternalTexture): void;
  104783. /**
  104784. * Dispose the current allocated resources
  104785. */
  104786. dispose(): void;
  104787. }
  104788. }
  104789. declare module BABYLON {
  104790. /**
  104791. * Class used to work with sound analyzer using fast fourier transform (FFT)
  104792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104793. */
  104794. export class Analyser {
  104795. /**
  104796. * Gets or sets the smoothing
  104797. * @ignorenaming
  104798. */
  104799. SMOOTHING: number;
  104800. /**
  104801. * Gets or sets the FFT table size
  104802. * @ignorenaming
  104803. */
  104804. FFT_SIZE: number;
  104805. /**
  104806. * Gets or sets the bar graph amplitude
  104807. * @ignorenaming
  104808. */
  104809. BARGRAPHAMPLITUDE: number;
  104810. /**
  104811. * Gets or sets the position of the debug canvas
  104812. * @ignorenaming
  104813. */
  104814. DEBUGCANVASPOS: {
  104815. x: number;
  104816. y: number;
  104817. };
  104818. /**
  104819. * Gets or sets the debug canvas size
  104820. * @ignorenaming
  104821. */
  104822. DEBUGCANVASSIZE: {
  104823. width: number;
  104824. height: number;
  104825. };
  104826. private _byteFreqs;
  104827. private _byteTime;
  104828. private _floatFreqs;
  104829. private _webAudioAnalyser;
  104830. private _debugCanvas;
  104831. private _debugCanvasContext;
  104832. private _scene;
  104833. private _registerFunc;
  104834. private _audioEngine;
  104835. /**
  104836. * Creates a new analyser
  104837. * @param scene defines hosting scene
  104838. */
  104839. constructor(scene: Scene);
  104840. /**
  104841. * Get the number of data values you will have to play with for the visualization
  104842. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  104843. * @returns a number
  104844. */
  104845. getFrequencyBinCount(): number;
  104846. /**
  104847. * Gets the current frequency data as a byte array
  104848. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  104849. * @returns a Uint8Array
  104850. */
  104851. getByteFrequencyData(): Uint8Array;
  104852. /**
  104853. * Gets the current waveform as a byte array
  104854. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  104855. * @returns a Uint8Array
  104856. */
  104857. getByteTimeDomainData(): Uint8Array;
  104858. /**
  104859. * Gets the current frequency data as a float array
  104860. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  104861. * @returns a Float32Array
  104862. */
  104863. getFloatFrequencyData(): Float32Array;
  104864. /**
  104865. * Renders the debug canvas
  104866. */
  104867. drawDebugCanvas(): void;
  104868. /**
  104869. * Stops rendering the debug canvas and removes it
  104870. */
  104871. stopDebugCanvas(): void;
  104872. /**
  104873. * Connects two audio nodes
  104874. * @param inputAudioNode defines first node to connect
  104875. * @param outputAudioNode defines second node to connect
  104876. */
  104877. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  104878. /**
  104879. * Releases all associated resources
  104880. */
  104881. dispose(): void;
  104882. }
  104883. }
  104884. declare module BABYLON {
  104885. /**
  104886. * This represents an audio engine and it is responsible
  104887. * to play, synchronize and analyse sounds throughout the application.
  104888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104889. */
  104890. export interface IAudioEngine extends IDisposable {
  104891. /**
  104892. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  104893. */
  104894. readonly canUseWebAudio: boolean;
  104895. /**
  104896. * Gets the current AudioContext if available.
  104897. */
  104898. readonly audioContext: Nullable<AudioContext>;
  104899. /**
  104900. * The master gain node defines the global audio volume of your audio engine.
  104901. */
  104902. readonly masterGain: GainNode;
  104903. /**
  104904. * Gets whether or not mp3 are supported by your browser.
  104905. */
  104906. readonly isMP3supported: boolean;
  104907. /**
  104908. * Gets whether or not ogg are supported by your browser.
  104909. */
  104910. readonly isOGGsupported: boolean;
  104911. /**
  104912. * Defines if Babylon should emit a warning if WebAudio is not supported.
  104913. * @ignoreNaming
  104914. */
  104915. WarnedWebAudioUnsupported: boolean;
  104916. /**
  104917. * Defines if the audio engine relies on a custom unlocked button.
  104918. * In this case, the embedded button will not be displayed.
  104919. */
  104920. useCustomUnlockedButton: boolean;
  104921. /**
  104922. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  104923. */
  104924. readonly unlocked: boolean;
  104925. /**
  104926. * Event raised when audio has been unlocked on the browser.
  104927. */
  104928. onAudioUnlockedObservable: Observable<AudioEngine>;
  104929. /**
  104930. * Event raised when audio has been locked on the browser.
  104931. */
  104932. onAudioLockedObservable: Observable<AudioEngine>;
  104933. /**
  104934. * Flags the audio engine in Locked state.
  104935. * This happens due to new browser policies preventing audio to autoplay.
  104936. */
  104937. lock(): void;
  104938. /**
  104939. * Unlocks the audio engine once a user action has been done on the dom.
  104940. * This is helpful to resume play once browser policies have been satisfied.
  104941. */
  104942. unlock(): void;
  104943. }
  104944. /**
  104945. * This represents the default audio engine used in babylon.
  104946. * It is responsible to play, synchronize and analyse sounds throughout the application.
  104947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104948. */
  104949. export class AudioEngine implements IAudioEngine {
  104950. private _audioContext;
  104951. private _audioContextInitialized;
  104952. private _muteButton;
  104953. private _hostElement;
  104954. /**
  104955. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  104956. */
  104957. canUseWebAudio: boolean;
  104958. /**
  104959. * The master gain node defines the global audio volume of your audio engine.
  104960. */
  104961. masterGain: GainNode;
  104962. /**
  104963. * Defines if Babylon should emit a warning if WebAudio is not supported.
  104964. * @ignoreNaming
  104965. */
  104966. WarnedWebAudioUnsupported: boolean;
  104967. /**
  104968. * Gets whether or not mp3 are supported by your browser.
  104969. */
  104970. isMP3supported: boolean;
  104971. /**
  104972. * Gets whether or not ogg are supported by your browser.
  104973. */
  104974. isOGGsupported: boolean;
  104975. /**
  104976. * Gets whether audio has been unlocked on the device.
  104977. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  104978. * a user interaction has happened.
  104979. */
  104980. unlocked: boolean;
  104981. /**
  104982. * Defines if the audio engine relies on a custom unlocked button.
  104983. * In this case, the embedded button will not be displayed.
  104984. */
  104985. useCustomUnlockedButton: boolean;
  104986. /**
  104987. * Event raised when audio has been unlocked on the browser.
  104988. */
  104989. onAudioUnlockedObservable: Observable<AudioEngine>;
  104990. /**
  104991. * Event raised when audio has been locked on the browser.
  104992. */
  104993. onAudioLockedObservable: Observable<AudioEngine>;
  104994. /**
  104995. * Gets the current AudioContext if available.
  104996. */
  104997. get audioContext(): Nullable<AudioContext>;
  104998. private _connectedAnalyser;
  104999. /**
  105000. * Instantiates a new audio engine.
  105001. *
  105002. * There should be only one per page as some browsers restrict the number
  105003. * of audio contexts you can create.
  105004. * @param hostElement defines the host element where to display the mute icon if necessary
  105005. */
  105006. constructor(hostElement?: Nullable<HTMLElement>);
  105007. /**
  105008. * Flags the audio engine in Locked state.
  105009. * This happens due to new browser policies preventing audio to autoplay.
  105010. */
  105011. lock(): void;
  105012. /**
  105013. * Unlocks the audio engine once a user action has been done on the dom.
  105014. * This is helpful to resume play once browser policies have been satisfied.
  105015. */
  105016. unlock(): void;
  105017. private _resumeAudioContext;
  105018. private _initializeAudioContext;
  105019. private _tryToRun;
  105020. private _triggerRunningState;
  105021. private _triggerSuspendedState;
  105022. private _displayMuteButton;
  105023. private _moveButtonToTopLeft;
  105024. private _onResize;
  105025. private _hideMuteButton;
  105026. /**
  105027. * Destroy and release the resources associated with the audio ccontext.
  105028. */
  105029. dispose(): void;
  105030. /**
  105031. * Gets the global volume sets on the master gain.
  105032. * @returns the global volume if set or -1 otherwise
  105033. */
  105034. getGlobalVolume(): number;
  105035. /**
  105036. * Sets the global volume of your experience (sets on the master gain).
  105037. * @param newVolume Defines the new global volume of the application
  105038. */
  105039. setGlobalVolume(newVolume: number): void;
  105040. /**
  105041. * Connect the audio engine to an audio analyser allowing some amazing
  105042. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105044. * @param analyser The analyser to connect to the engine
  105045. */
  105046. connectToAnalyser(analyser: Analyser): void;
  105047. }
  105048. }
  105049. declare module BABYLON {
  105050. /**
  105051. * Interface used to present a loading screen while loading a scene
  105052. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105053. */
  105054. export interface ILoadingScreen {
  105055. /**
  105056. * Function called to display the loading screen
  105057. */
  105058. displayLoadingUI: () => void;
  105059. /**
  105060. * Function called to hide the loading screen
  105061. */
  105062. hideLoadingUI: () => void;
  105063. /**
  105064. * Gets or sets the color to use for the background
  105065. */
  105066. loadingUIBackgroundColor: string;
  105067. /**
  105068. * Gets or sets the text to display while loading
  105069. */
  105070. loadingUIText: string;
  105071. }
  105072. /**
  105073. * Class used for the default loading screen
  105074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105075. */
  105076. export class DefaultLoadingScreen implements ILoadingScreen {
  105077. private _renderingCanvas;
  105078. private _loadingText;
  105079. private _loadingDivBackgroundColor;
  105080. private _loadingDiv;
  105081. private _loadingTextDiv;
  105082. /** Gets or sets the logo url to use for the default loading screen */
  105083. static DefaultLogoUrl: string;
  105084. /** Gets or sets the spinner url to use for the default loading screen */
  105085. static DefaultSpinnerUrl: string;
  105086. /**
  105087. * Creates a new default loading screen
  105088. * @param _renderingCanvas defines the canvas used to render the scene
  105089. * @param _loadingText defines the default text to display
  105090. * @param _loadingDivBackgroundColor defines the default background color
  105091. */
  105092. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105093. /**
  105094. * Function called to display the loading screen
  105095. */
  105096. displayLoadingUI(): void;
  105097. /**
  105098. * Function called to hide the loading screen
  105099. */
  105100. hideLoadingUI(): void;
  105101. /**
  105102. * Gets or sets the text to display while loading
  105103. */
  105104. set loadingUIText(text: string);
  105105. get loadingUIText(): string;
  105106. /**
  105107. * Gets or sets the color to use for the background
  105108. */
  105109. get loadingUIBackgroundColor(): string;
  105110. set loadingUIBackgroundColor(color: string);
  105111. private _resizeLoadingUI;
  105112. }
  105113. }
  105114. declare module BABYLON {
  105115. /**
  105116. * Interface for any object that can request an animation frame
  105117. */
  105118. export interface ICustomAnimationFrameRequester {
  105119. /**
  105120. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105121. */
  105122. renderFunction?: Function;
  105123. /**
  105124. * Called to request the next frame to render to
  105125. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  105126. */
  105127. requestAnimationFrame: Function;
  105128. /**
  105129. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  105130. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  105131. */
  105132. requestID?: number;
  105133. }
  105134. }
  105135. declare module BABYLON {
  105136. /**
  105137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  105138. */
  105139. export class PerformanceMonitor {
  105140. private _enabled;
  105141. private _rollingFrameTime;
  105142. private _lastFrameTimeMs;
  105143. /**
  105144. * constructor
  105145. * @param frameSampleSize The number of samples required to saturate the sliding window
  105146. */
  105147. constructor(frameSampleSize?: number);
  105148. /**
  105149. * Samples current frame
  105150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  105151. */
  105152. sampleFrame(timeMs?: number): void;
  105153. /**
  105154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105155. */
  105156. get averageFrameTime(): number;
  105157. /**
  105158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105159. */
  105160. get averageFrameTimeVariance(): number;
  105161. /**
  105162. * Returns the frame time of the most recent frame
  105163. */
  105164. get instantaneousFrameTime(): number;
  105165. /**
  105166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  105167. */
  105168. get averageFPS(): number;
  105169. /**
  105170. * Returns the average framerate in frames per second using the most recent frame time
  105171. */
  105172. get instantaneousFPS(): number;
  105173. /**
  105174. * Returns true if enough samples have been taken to completely fill the sliding window
  105175. */
  105176. get isSaturated(): boolean;
  105177. /**
  105178. * Enables contributions to the sliding window sample set
  105179. */
  105180. enable(): void;
  105181. /**
  105182. * Disables contributions to the sliding window sample set
  105183. * Samples will not be interpolated over the disabled period
  105184. */
  105185. disable(): void;
  105186. /**
  105187. * Returns true if sampling is enabled
  105188. */
  105189. get isEnabled(): boolean;
  105190. /**
  105191. * Resets performance monitor
  105192. */
  105193. reset(): void;
  105194. }
  105195. /**
  105196. * RollingAverage
  105197. *
  105198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  105199. */
  105200. export class RollingAverage {
  105201. /**
  105202. * Current average
  105203. */
  105204. average: number;
  105205. /**
  105206. * Current variance
  105207. */
  105208. variance: number;
  105209. protected _samples: Array<number>;
  105210. protected _sampleCount: number;
  105211. protected _pos: number;
  105212. protected _m2: number;
  105213. /**
  105214. * constructor
  105215. * @param length The number of samples required to saturate the sliding window
  105216. */
  105217. constructor(length: number);
  105218. /**
  105219. * Adds a sample to the sample set
  105220. * @param v The sample value
  105221. */
  105222. add(v: number): void;
  105223. /**
  105224. * Returns previously added values or null if outside of history or outside the sliding window domain
  105225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  105226. * @return Value previously recorded with add() or null if outside of range
  105227. */
  105228. history(i: number): number;
  105229. /**
  105230. * Returns true if enough samples have been taken to completely fill the sliding window
  105231. * @return true if sample-set saturated
  105232. */
  105233. isSaturated(): boolean;
  105234. /**
  105235. * Resets the rolling average (equivalent to 0 samples taken so far)
  105236. */
  105237. reset(): void;
  105238. /**
  105239. * Wraps a value around the sample range boundaries
  105240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  105241. * @return Wrapped position in sample range
  105242. */
  105243. protected _wrapPosition(i: number): number;
  105244. }
  105245. }
  105246. declare module BABYLON {
  105247. /**
  105248. * This class is used to track a performance counter which is number based.
  105249. * The user has access to many properties which give statistics of different nature.
  105250. *
  105251. * The implementer can track two kinds of Performance Counter: time and count.
  105252. * 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.
  105253. * 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.
  105254. */
  105255. export class PerfCounter {
  105256. /**
  105257. * Gets or sets a global boolean to turn on and off all the counters
  105258. */
  105259. static Enabled: boolean;
  105260. /**
  105261. * Returns the smallest value ever
  105262. */
  105263. get min(): number;
  105264. /**
  105265. * Returns the biggest value ever
  105266. */
  105267. get max(): number;
  105268. /**
  105269. * Returns the average value since the performance counter is running
  105270. */
  105271. get average(): number;
  105272. /**
  105273. * Returns the average value of the last second the counter was monitored
  105274. */
  105275. get lastSecAverage(): number;
  105276. /**
  105277. * Returns the current value
  105278. */
  105279. get current(): number;
  105280. /**
  105281. * Gets the accumulated total
  105282. */
  105283. get total(): number;
  105284. /**
  105285. * Gets the total value count
  105286. */
  105287. get count(): number;
  105288. /**
  105289. * Creates a new counter
  105290. */
  105291. constructor();
  105292. /**
  105293. * Call this method to start monitoring a new frame.
  105294. * 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.
  105295. */
  105296. fetchNewFrame(): void;
  105297. /**
  105298. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  105299. * @param newCount the count value to add to the monitored count
  105300. * @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.
  105301. */
  105302. addCount(newCount: number, fetchResult: boolean): void;
  105303. /**
  105304. * Start monitoring this performance counter
  105305. */
  105306. beginMonitoring(): void;
  105307. /**
  105308. * Compute the time lapsed since the previous beginMonitoring() call.
  105309. * @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
  105310. */
  105311. endMonitoring(newFrame?: boolean): void;
  105312. private _fetchResult;
  105313. private _startMonitoringTime;
  105314. private _min;
  105315. private _max;
  105316. private _average;
  105317. private _current;
  105318. private _totalValueCount;
  105319. private _totalAccumulated;
  105320. private _lastSecAverage;
  105321. private _lastSecAccumulated;
  105322. private _lastSecTime;
  105323. private _lastSecValueCount;
  105324. }
  105325. }
  105326. declare module BABYLON {
  105327. interface ThinEngine {
  105328. /**
  105329. * Sets alpha constants used by some alpha blending modes
  105330. * @param r defines the red component
  105331. * @param g defines the green component
  105332. * @param b defines the blue component
  105333. * @param a defines the alpha component
  105334. */
  105335. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  105336. /**
  105337. * Sets the current alpha mode
  105338. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  105339. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  105340. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105341. */
  105342. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  105343. /**
  105344. * Gets the current alpha mode
  105345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105346. * @returns the current alpha mode
  105347. */
  105348. getAlphaMode(): number;
  105349. /**
  105350. * Sets the current alpha equation
  105351. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  105352. */
  105353. setAlphaEquation(equation: number): void;
  105354. /**
  105355. * Gets the current alpha equation.
  105356. * @returns the current alpha equation
  105357. */
  105358. getAlphaEquation(): number;
  105359. }
  105360. }
  105361. declare module BABYLON {
  105362. /**
  105363. * Defines the interface used by display changed events
  105364. */
  105365. export interface IDisplayChangedEventArgs {
  105366. /** Gets the vrDisplay object (if any) */
  105367. vrDisplay: Nullable<any>;
  105368. /** Gets a boolean indicating if webVR is supported */
  105369. vrSupported: boolean;
  105370. }
  105371. /**
  105372. * Defines the interface used by objects containing a viewport (like a camera)
  105373. */
  105374. interface IViewportOwnerLike {
  105375. /**
  105376. * Gets or sets the viewport
  105377. */
  105378. viewport: IViewportLike;
  105379. }
  105380. /**
  105381. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  105382. */
  105383. export class Engine extends ThinEngine {
  105384. /** Defines that alpha blending is disabled */
  105385. static readonly ALPHA_DISABLE: number;
  105386. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  105387. static readonly ALPHA_ADD: number;
  105388. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  105389. static readonly ALPHA_COMBINE: number;
  105390. /** Defines that alpha blending to DEST - SRC * DEST */
  105391. static readonly ALPHA_SUBTRACT: number;
  105392. /** Defines that alpha blending to SRC * DEST */
  105393. static readonly ALPHA_MULTIPLY: number;
  105394. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  105395. static readonly ALPHA_MAXIMIZED: number;
  105396. /** Defines that alpha blending to SRC + DEST */
  105397. static readonly ALPHA_ONEONE: number;
  105398. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  105399. static readonly ALPHA_PREMULTIPLIED: number;
  105400. /**
  105401. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  105402. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  105403. */
  105404. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  105405. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  105406. static readonly ALPHA_INTERPOLATE: number;
  105407. /**
  105408. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  105409. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  105410. */
  105411. static readonly ALPHA_SCREENMODE: number;
  105412. /** Defines that the ressource is not delayed*/
  105413. static readonly DELAYLOADSTATE_NONE: number;
  105414. /** Defines that the ressource was successfully delay loaded */
  105415. static readonly DELAYLOADSTATE_LOADED: number;
  105416. /** Defines that the ressource is currently delay loading */
  105417. static readonly DELAYLOADSTATE_LOADING: number;
  105418. /** Defines that the ressource is delayed and has not started loading */
  105419. static readonly DELAYLOADSTATE_NOTLOADED: number;
  105420. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  105421. static readonly NEVER: number;
  105422. /** 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 */
  105423. static readonly ALWAYS: number;
  105424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  105425. static readonly LESS: number;
  105426. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  105427. static readonly EQUAL: number;
  105428. /** 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 */
  105429. static readonly LEQUAL: number;
  105430. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  105431. static readonly GREATER: number;
  105432. /** 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 */
  105433. static readonly GEQUAL: number;
  105434. /** 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 */
  105435. static readonly NOTEQUAL: number;
  105436. /** Passed to stencilOperation to specify that stencil value must be kept */
  105437. static readonly KEEP: number;
  105438. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105439. static readonly REPLACE: number;
  105440. /** Passed to stencilOperation to specify that stencil value must be incremented */
  105441. static readonly INCR: number;
  105442. /** Passed to stencilOperation to specify that stencil value must be decremented */
  105443. static readonly DECR: number;
  105444. /** Passed to stencilOperation to specify that stencil value must be inverted */
  105445. static readonly INVERT: number;
  105446. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  105447. static readonly INCR_WRAP: number;
  105448. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  105449. static readonly DECR_WRAP: number;
  105450. /** Texture is not repeating outside of 0..1 UVs */
  105451. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  105452. /** Texture is repeating outside of 0..1 UVs */
  105453. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  105454. /** Texture is repeating and mirrored */
  105455. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  105456. /** ALPHA */
  105457. static readonly TEXTUREFORMAT_ALPHA: number;
  105458. /** LUMINANCE */
  105459. static readonly TEXTUREFORMAT_LUMINANCE: number;
  105460. /** LUMINANCE_ALPHA */
  105461. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  105462. /** RGB */
  105463. static readonly TEXTUREFORMAT_RGB: number;
  105464. /** RGBA */
  105465. static readonly TEXTUREFORMAT_RGBA: number;
  105466. /** RED */
  105467. static readonly TEXTUREFORMAT_RED: number;
  105468. /** RED (2nd reference) */
  105469. static readonly TEXTUREFORMAT_R: number;
  105470. /** RG */
  105471. static readonly TEXTUREFORMAT_RG: number;
  105472. /** RED_INTEGER */
  105473. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  105474. /** RED_INTEGER (2nd reference) */
  105475. static readonly TEXTUREFORMAT_R_INTEGER: number;
  105476. /** RG_INTEGER */
  105477. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  105478. /** RGB_INTEGER */
  105479. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  105480. /** RGBA_INTEGER */
  105481. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  105482. /** UNSIGNED_BYTE */
  105483. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  105484. /** UNSIGNED_BYTE (2nd reference) */
  105485. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  105486. /** FLOAT */
  105487. static readonly TEXTURETYPE_FLOAT: number;
  105488. /** HALF_FLOAT */
  105489. static readonly TEXTURETYPE_HALF_FLOAT: number;
  105490. /** BYTE */
  105491. static readonly TEXTURETYPE_BYTE: number;
  105492. /** SHORT */
  105493. static readonly TEXTURETYPE_SHORT: number;
  105494. /** UNSIGNED_SHORT */
  105495. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  105496. /** INT */
  105497. static readonly TEXTURETYPE_INT: number;
  105498. /** UNSIGNED_INT */
  105499. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  105500. /** UNSIGNED_SHORT_4_4_4_4 */
  105501. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  105502. /** UNSIGNED_SHORT_5_5_5_1 */
  105503. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  105504. /** UNSIGNED_SHORT_5_6_5 */
  105505. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  105506. /** UNSIGNED_INT_2_10_10_10_REV */
  105507. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  105508. /** UNSIGNED_INT_24_8 */
  105509. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  105510. /** UNSIGNED_INT_10F_11F_11F_REV */
  105511. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  105512. /** UNSIGNED_INT_5_9_9_9_REV */
  105513. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  105514. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  105515. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  105516. /** nearest is mag = nearest and min = nearest and mip = linear */
  105517. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  105518. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105519. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  105520. /** Trilinear is mag = linear and min = linear and mip = linear */
  105521. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  105522. /** nearest is mag = nearest and min = nearest and mip = linear */
  105523. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  105524. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105525. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  105526. /** Trilinear is mag = linear and min = linear and mip = linear */
  105527. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  105528. /** mag = nearest and min = nearest and mip = nearest */
  105529. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  105530. /** mag = nearest and min = linear and mip = nearest */
  105531. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  105532. /** mag = nearest and min = linear and mip = linear */
  105533. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  105534. /** mag = nearest and min = linear and mip = none */
  105535. static readonly TEXTURE_NEAREST_LINEAR: number;
  105536. /** mag = nearest and min = nearest and mip = none */
  105537. static readonly TEXTURE_NEAREST_NEAREST: number;
  105538. /** mag = linear and min = nearest and mip = nearest */
  105539. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  105540. /** mag = linear and min = nearest and mip = linear */
  105541. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  105542. /** mag = linear and min = linear and mip = none */
  105543. static readonly TEXTURE_LINEAR_LINEAR: number;
  105544. /** mag = linear and min = nearest and mip = none */
  105545. static readonly TEXTURE_LINEAR_NEAREST: number;
  105546. /** Explicit coordinates mode */
  105547. static readonly TEXTURE_EXPLICIT_MODE: number;
  105548. /** Spherical coordinates mode */
  105549. static readonly TEXTURE_SPHERICAL_MODE: number;
  105550. /** Planar coordinates mode */
  105551. static readonly TEXTURE_PLANAR_MODE: number;
  105552. /** Cubic coordinates mode */
  105553. static readonly TEXTURE_CUBIC_MODE: number;
  105554. /** Projection coordinates mode */
  105555. static readonly TEXTURE_PROJECTION_MODE: number;
  105556. /** Skybox coordinates mode */
  105557. static readonly TEXTURE_SKYBOX_MODE: number;
  105558. /** Inverse Cubic coordinates mode */
  105559. static readonly TEXTURE_INVCUBIC_MODE: number;
  105560. /** Equirectangular coordinates mode */
  105561. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  105562. /** Equirectangular Fixed coordinates mode */
  105563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  105564. /** Equirectangular Fixed Mirrored coordinates mode */
  105565. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  105566. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  105567. static readonly SCALEMODE_FLOOR: number;
  105568. /** Defines that texture rescaling will look for the nearest power of 2 size */
  105569. static readonly SCALEMODE_NEAREST: number;
  105570. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  105571. static readonly SCALEMODE_CEILING: number;
  105572. /**
  105573. * Returns the current npm package of the sdk
  105574. */
  105575. static get NpmPackage(): string;
  105576. /**
  105577. * Returns the current version of the framework
  105578. */
  105579. static get Version(): string;
  105580. /** Gets the list of created engines */
  105581. static get Instances(): Engine[];
  105582. /**
  105583. * Gets the latest created engine
  105584. */
  105585. static get LastCreatedEngine(): Nullable<Engine>;
  105586. /**
  105587. * Gets the latest created scene
  105588. */
  105589. static get LastCreatedScene(): Nullable<Scene>;
  105590. /**
  105591. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  105592. * @param flag defines which part of the materials must be marked as dirty
  105593. * @param predicate defines a predicate used to filter which materials should be affected
  105594. */
  105595. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105596. /**
  105597. * Method called to create the default loading screen.
  105598. * This can be overriden in your own app.
  105599. * @param canvas The rendering canvas element
  105600. * @returns The loading screen
  105601. */
  105602. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  105603. /**
  105604. * Method called to create the default rescale post process on each engine.
  105605. */
  105606. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  105607. /**
  105608. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  105609. **/
  105610. enableOfflineSupport: boolean;
  105611. /**
  105612. * 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)
  105613. **/
  105614. disableManifestCheck: boolean;
  105615. /**
  105616. * Gets the list of created scenes
  105617. */
  105618. scenes: Scene[];
  105619. /**
  105620. * Event raised when a new scene is created
  105621. */
  105622. onNewSceneAddedObservable: Observable<Scene>;
  105623. /**
  105624. * Gets the list of created postprocesses
  105625. */
  105626. postProcesses: PostProcess[];
  105627. /**
  105628. * Gets a boolean indicating if the pointer is currently locked
  105629. */
  105630. isPointerLock: boolean;
  105631. /**
  105632. * Observable event triggered each time the rendering canvas is resized
  105633. */
  105634. onResizeObservable: Observable<Engine>;
  105635. /**
  105636. * Observable event triggered each time the canvas loses focus
  105637. */
  105638. onCanvasBlurObservable: Observable<Engine>;
  105639. /**
  105640. * Observable event triggered each time the canvas gains focus
  105641. */
  105642. onCanvasFocusObservable: Observable<Engine>;
  105643. /**
  105644. * Observable event triggered each time the canvas receives pointerout event
  105645. */
  105646. onCanvasPointerOutObservable: Observable<PointerEvent>;
  105647. /**
  105648. * Observable raised when the engine begins a new frame
  105649. */
  105650. onBeginFrameObservable: Observable<Engine>;
  105651. /**
  105652. * If set, will be used to request the next animation frame for the render loop
  105653. */
  105654. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  105655. /**
  105656. * Observable raised when the engine ends the current frame
  105657. */
  105658. onEndFrameObservable: Observable<Engine>;
  105659. /**
  105660. * Observable raised when the engine is about to compile a shader
  105661. */
  105662. onBeforeShaderCompilationObservable: Observable<Engine>;
  105663. /**
  105664. * Observable raised when the engine has jsut compiled a shader
  105665. */
  105666. onAfterShaderCompilationObservable: Observable<Engine>;
  105667. /**
  105668. * Gets the audio engine
  105669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105670. * @ignorenaming
  105671. */
  105672. static audioEngine: IAudioEngine;
  105673. /**
  105674. * Default AudioEngine factory responsible of creating the Audio Engine.
  105675. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  105676. */
  105677. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  105678. /**
  105679. * Default offline support factory responsible of creating a tool used to store data locally.
  105680. * By default, this will create a Database object if the workload has been embedded.
  105681. */
  105682. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  105683. private _loadingScreen;
  105684. private _pointerLockRequested;
  105685. private _dummyFramebuffer;
  105686. private _rescalePostProcess;
  105687. private _deterministicLockstep;
  105688. private _lockstepMaxSteps;
  105689. private _timeStep;
  105690. protected get _supportsHardwareTextureRescaling(): boolean;
  105691. private _fps;
  105692. private _deltaTime;
  105693. /** @hidden */
  105694. _drawCalls: PerfCounter;
  105695. /** 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 */
  105696. canvasTabIndex: number;
  105697. /**
  105698. * Turn this value on if you want to pause FPS computation when in background
  105699. */
  105700. disablePerformanceMonitorInBackground: boolean;
  105701. private _performanceMonitor;
  105702. /**
  105703. * Gets the performance monitor attached to this engine
  105704. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105705. */
  105706. get performanceMonitor(): PerformanceMonitor;
  105707. private _onFocus;
  105708. private _onBlur;
  105709. private _onCanvasPointerOut;
  105710. private _onCanvasBlur;
  105711. private _onCanvasFocus;
  105712. private _onFullscreenChange;
  105713. private _onPointerLockChange;
  105714. /**
  105715. * Gets the HTML element used to attach event listeners
  105716. * @returns a HTML element
  105717. */
  105718. getInputElement(): Nullable<HTMLElement>;
  105719. /**
  105720. * Creates a new engine
  105721. * @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
  105722. * @param antialias defines enable antialiasing (default: false)
  105723. * @param options defines further options to be sent to the getContext() function
  105724. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105725. */
  105726. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105727. /**
  105728. * Gets current aspect ratio
  105729. * @param viewportOwner defines the camera to use to get the aspect ratio
  105730. * @param useScreen defines if screen size must be used (or the current render target if any)
  105731. * @returns a number defining the aspect ratio
  105732. */
  105733. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  105734. /**
  105735. * Gets current screen aspect ratio
  105736. * @returns a number defining the aspect ratio
  105737. */
  105738. getScreenAspectRatio(): number;
  105739. /**
  105740. * Gets the client rect of the HTML canvas attached with the current webGL context
  105741. * @returns a client rectanglee
  105742. */
  105743. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  105744. /**
  105745. * Gets the client rect of the HTML element used for events
  105746. * @returns a client rectanglee
  105747. */
  105748. getInputElementClientRect(): Nullable<ClientRect>;
  105749. /**
  105750. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  105751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105752. * @returns true if engine is in deterministic lock step mode
  105753. */
  105754. isDeterministicLockStep(): boolean;
  105755. /**
  105756. * Gets the max steps when engine is running in deterministic lock step
  105757. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105758. * @returns the max steps
  105759. */
  105760. getLockstepMaxSteps(): number;
  105761. /**
  105762. * Returns the time in ms between steps when using deterministic lock step.
  105763. * @returns time step in (ms)
  105764. */
  105765. getTimeStep(): number;
  105766. /**
  105767. * Force the mipmap generation for the given render target texture
  105768. * @param texture defines the render target texture to use
  105769. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  105770. */
  105771. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  105772. /** States */
  105773. /**
  105774. * Set various states to the webGL context
  105775. * @param culling defines backface culling state
  105776. * @param zOffset defines the value to apply to zOffset (0 by default)
  105777. * @param force defines if states must be applied even if cache is up to date
  105778. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  105779. */
  105780. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  105781. /**
  105782. * Set the z offset to apply to current rendering
  105783. * @param value defines the offset to apply
  105784. */
  105785. setZOffset(value: number): void;
  105786. /**
  105787. * Gets the current value of the zOffset
  105788. * @returns the current zOffset state
  105789. */
  105790. getZOffset(): number;
  105791. /**
  105792. * Enable or disable depth buffering
  105793. * @param enable defines the state to set
  105794. */
  105795. setDepthBuffer(enable: boolean): void;
  105796. /**
  105797. * Gets a boolean indicating if depth writing is enabled
  105798. * @returns the current depth writing state
  105799. */
  105800. getDepthWrite(): boolean;
  105801. /**
  105802. * Enable or disable depth writing
  105803. * @param enable defines the state to set
  105804. */
  105805. setDepthWrite(enable: boolean): void;
  105806. /**
  105807. * Gets a boolean indicating if stencil buffer is enabled
  105808. * @returns the current stencil buffer state
  105809. */
  105810. getStencilBuffer(): boolean;
  105811. /**
  105812. * Enable or disable the stencil buffer
  105813. * @param enable defines if the stencil buffer must be enabled or disabled
  105814. */
  105815. setStencilBuffer(enable: boolean): void;
  105816. /**
  105817. * Gets the current stencil mask
  105818. * @returns a number defining the new stencil mask to use
  105819. */
  105820. getStencilMask(): number;
  105821. /**
  105822. * Sets the current stencil mask
  105823. * @param mask defines the new stencil mask to use
  105824. */
  105825. setStencilMask(mask: number): void;
  105826. /**
  105827. * Gets the current stencil function
  105828. * @returns a number defining the stencil function to use
  105829. */
  105830. getStencilFunction(): number;
  105831. /**
  105832. * Gets the current stencil reference value
  105833. * @returns a number defining the stencil reference value to use
  105834. */
  105835. getStencilFunctionReference(): number;
  105836. /**
  105837. * Gets the current stencil mask
  105838. * @returns a number defining the stencil mask to use
  105839. */
  105840. getStencilFunctionMask(): number;
  105841. /**
  105842. * Sets the current stencil function
  105843. * @param stencilFunc defines the new stencil function to use
  105844. */
  105845. setStencilFunction(stencilFunc: number): void;
  105846. /**
  105847. * Sets the current stencil reference
  105848. * @param reference defines the new stencil reference to use
  105849. */
  105850. setStencilFunctionReference(reference: number): void;
  105851. /**
  105852. * Sets the current stencil mask
  105853. * @param mask defines the new stencil mask to use
  105854. */
  105855. setStencilFunctionMask(mask: number): void;
  105856. /**
  105857. * Gets the current stencil operation when stencil fails
  105858. * @returns a number defining stencil operation to use when stencil fails
  105859. */
  105860. getStencilOperationFail(): number;
  105861. /**
  105862. * Gets the current stencil operation when depth fails
  105863. * @returns a number defining stencil operation to use when depth fails
  105864. */
  105865. getStencilOperationDepthFail(): number;
  105866. /**
  105867. * Gets the current stencil operation when stencil passes
  105868. * @returns a number defining stencil operation to use when stencil passes
  105869. */
  105870. getStencilOperationPass(): number;
  105871. /**
  105872. * Sets the stencil operation to use when stencil fails
  105873. * @param operation defines the stencil operation to use when stencil fails
  105874. */
  105875. setStencilOperationFail(operation: number): void;
  105876. /**
  105877. * Sets the stencil operation to use when depth fails
  105878. * @param operation defines the stencil operation to use when depth fails
  105879. */
  105880. setStencilOperationDepthFail(operation: number): void;
  105881. /**
  105882. * Sets the stencil operation to use when stencil passes
  105883. * @param operation defines the stencil operation to use when stencil passes
  105884. */
  105885. setStencilOperationPass(operation: number): void;
  105886. /**
  105887. * Sets a boolean indicating if the dithering state is enabled or disabled
  105888. * @param value defines the dithering state
  105889. */
  105890. setDitheringState(value: boolean): void;
  105891. /**
  105892. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  105893. * @param value defines the rasterizer state
  105894. */
  105895. setRasterizerState(value: boolean): void;
  105896. /**
  105897. * Gets the current depth function
  105898. * @returns a number defining the depth function
  105899. */
  105900. getDepthFunction(): Nullable<number>;
  105901. /**
  105902. * Sets the current depth function
  105903. * @param depthFunc defines the function to use
  105904. */
  105905. setDepthFunction(depthFunc: number): void;
  105906. /**
  105907. * Sets the current depth function to GREATER
  105908. */
  105909. setDepthFunctionToGreater(): void;
  105910. /**
  105911. * Sets the current depth function to GEQUAL
  105912. */
  105913. setDepthFunctionToGreaterOrEqual(): void;
  105914. /**
  105915. * Sets the current depth function to LESS
  105916. */
  105917. setDepthFunctionToLess(): void;
  105918. /**
  105919. * Sets the current depth function to LEQUAL
  105920. */
  105921. setDepthFunctionToLessOrEqual(): void;
  105922. private _cachedStencilBuffer;
  105923. private _cachedStencilFunction;
  105924. private _cachedStencilMask;
  105925. private _cachedStencilOperationPass;
  105926. private _cachedStencilOperationFail;
  105927. private _cachedStencilOperationDepthFail;
  105928. private _cachedStencilReference;
  105929. /**
  105930. * Caches the the state of the stencil buffer
  105931. */
  105932. cacheStencilState(): void;
  105933. /**
  105934. * Restores the state of the stencil buffer
  105935. */
  105936. restoreStencilState(): void;
  105937. /**
  105938. * Directly set the WebGL Viewport
  105939. * @param x defines the x coordinate of the viewport (in screen space)
  105940. * @param y defines the y coordinate of the viewport (in screen space)
  105941. * @param width defines the width of the viewport (in screen space)
  105942. * @param height defines the height of the viewport (in screen space)
  105943. * @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
  105944. */
  105945. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  105946. /**
  105947. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  105948. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  105949. * @param y defines the y-coordinate of the corner of the clear rectangle
  105950. * @param width defines the width of the clear rectangle
  105951. * @param height defines the height of the clear rectangle
  105952. * @param clearColor defines the clear color
  105953. */
  105954. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  105955. /**
  105956. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  105957. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  105958. * @param y defines the y-coordinate of the corner of the clear rectangle
  105959. * @param width defines the width of the clear rectangle
  105960. * @param height defines the height of the clear rectangle
  105961. */
  105962. enableScissor(x: number, y: number, width: number, height: number): void;
  105963. /**
  105964. * Disable previously set scissor test rectangle
  105965. */
  105966. disableScissor(): void;
  105967. protected _reportDrawCall(): void;
  105968. /**
  105969. * Initializes a webVR display and starts listening to display change events
  105970. * The onVRDisplayChangedObservable will be notified upon these changes
  105971. * @returns The onVRDisplayChangedObservable
  105972. */
  105973. initWebVR(): Observable<IDisplayChangedEventArgs>;
  105974. /** @hidden */
  105975. _prepareVRComponent(): void;
  105976. /** @hidden */
  105977. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  105978. /** @hidden */
  105979. _submitVRFrame(): void;
  105980. /**
  105981. * Call this function to leave webVR mode
  105982. * Will do nothing if webVR is not supported or if there is no webVR device
  105983. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105984. */
  105985. disableVR(): void;
  105986. /**
  105987. * Gets a boolean indicating that the system is in VR mode and is presenting
  105988. * @returns true if VR mode is engaged
  105989. */
  105990. isVRPresenting(): boolean;
  105991. /** @hidden */
  105992. _requestVRFrame(): void;
  105993. /** @hidden */
  105994. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105995. /**
  105996. * Gets the source code of the vertex shader associated with a specific webGL program
  105997. * @param program defines the program to use
  105998. * @returns a string containing the source code of the vertex shader associated with the program
  105999. */
  106000. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106001. /**
  106002. * Gets the source code of the fragment shader associated with a specific webGL program
  106003. * @param program defines the program to use
  106004. * @returns a string containing the source code of the fragment shader associated with the program
  106005. */
  106006. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106007. /**
  106008. * Sets a depth stencil texture from a render target to the according uniform.
  106009. * @param channel The texture channel
  106010. * @param uniform The uniform to set
  106011. * @param texture The render target texture containing the depth stencil texture to apply
  106012. */
  106013. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106014. /**
  106015. * Sets a texture to the webGL context from a postprocess
  106016. * @param channel defines the channel to use
  106017. * @param postProcess defines the source postprocess
  106018. */
  106019. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106020. /**
  106021. * Binds the output of the passed in post process to the texture channel specified
  106022. * @param channel The channel the texture should be bound to
  106023. * @param postProcess The post process which's output should be bound
  106024. */
  106025. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106026. /** @hidden */
  106027. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106028. protected _rebuildBuffers(): void;
  106029. /** @hidden */
  106030. _renderFrame(): void;
  106031. _renderLoop(): void;
  106032. /** @hidden */
  106033. _renderViews(): boolean;
  106034. /**
  106035. * Toggle full screen mode
  106036. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106037. */
  106038. switchFullscreen(requestPointerLock: boolean): void;
  106039. /**
  106040. * Enters full screen mode
  106041. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106042. */
  106043. enterFullscreen(requestPointerLock: boolean): void;
  106044. /**
  106045. * Exits full screen mode
  106046. */
  106047. exitFullscreen(): void;
  106048. /**
  106049. * Enters Pointerlock mode
  106050. */
  106051. enterPointerlock(): void;
  106052. /**
  106053. * Exits Pointerlock mode
  106054. */
  106055. exitPointerlock(): void;
  106056. /**
  106057. * Begin a new frame
  106058. */
  106059. beginFrame(): void;
  106060. /**
  106061. * Enf the current frame
  106062. */
  106063. endFrame(): void;
  106064. resize(): void;
  106065. /**
  106066. * Set the compressed texture format to use, based on the formats you have, and the formats
  106067. * supported by the hardware / browser.
  106068. *
  106069. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  106070. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  106071. * to API arguments needed to compressed textures. This puts the burden on the container
  106072. * generator to house the arcane code for determining these for current & future formats.
  106073. *
  106074. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106075. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106076. *
  106077. * Note: The result of this call is not taken into account when a texture is base64.
  106078. *
  106079. * @param formatsAvailable defines the list of those format families you have created
  106080. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  106081. *
  106082. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  106083. * @returns The extension selected.
  106084. */
  106085. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  106086. /**
  106087. * Set the compressed texture extensions or file names to skip.
  106088. *
  106089. * @param skippedFiles defines the list of those texture files you want to skip
  106090. * Example: [".dds", ".env", "myfile.png"]
  106091. */
  106092. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  106093. /**
  106094. * Force a specific size of the canvas
  106095. * @param width defines the new canvas' width
  106096. * @param height defines the new canvas' height
  106097. */
  106098. setSize(width: number, height: number): void;
  106099. /**
  106100. * Updates a dynamic vertex buffer.
  106101. * @param vertexBuffer the vertex buffer to update
  106102. * @param data the data used to update the vertex buffer
  106103. * @param byteOffset the byte offset of the data
  106104. * @param byteLength the byte length of the data
  106105. */
  106106. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106107. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106108. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106109. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106110. _releaseTexture(texture: InternalTexture): void;
  106111. /**
  106112. * @hidden
  106113. * Rescales a texture
  106114. * @param source input texutre
  106115. * @param destination destination texture
  106116. * @param scene scene to use to render the resize
  106117. * @param internalFormat format to use when resizing
  106118. * @param onComplete callback to be called when resize has completed
  106119. */
  106120. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106121. /**
  106122. * Gets the current framerate
  106123. * @returns a number representing the framerate
  106124. */
  106125. getFps(): number;
  106126. /**
  106127. * Gets the time spent between current and previous frame
  106128. * @returns a number representing the delta time in ms
  106129. */
  106130. getDeltaTime(): number;
  106131. private _measureFps;
  106132. /** @hidden */
  106133. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  106134. /**
  106135. * Update a dynamic index buffer
  106136. * @param indexBuffer defines the target index buffer
  106137. * @param indices defines the data to update
  106138. * @param offset defines the offset in the target index buffer where update should start
  106139. */
  106140. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  106141. /**
  106142. * Updates the sample count of a render target texture
  106143. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106144. * @param texture defines the texture to update
  106145. * @param samples defines the sample count to set
  106146. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106147. */
  106148. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  106149. /**
  106150. * Updates a depth texture Comparison Mode and Function.
  106151. * If the comparison Function is equal to 0, the mode will be set to none.
  106152. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  106153. * @param texture The texture to set the comparison function for
  106154. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  106155. */
  106156. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  106157. /**
  106158. * Creates a webGL buffer to use with instanciation
  106159. * @param capacity defines the size of the buffer
  106160. * @returns the webGL buffer
  106161. */
  106162. createInstancesBuffer(capacity: number): DataBuffer;
  106163. /**
  106164. * Delete a webGL buffer used with instanciation
  106165. * @param buffer defines the webGL buffer to delete
  106166. */
  106167. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  106168. /** @hidden */
  106169. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  106170. dispose(): void;
  106171. private _disableTouchAction;
  106172. /**
  106173. * Display the loading screen
  106174. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106175. */
  106176. displayLoadingUI(): void;
  106177. /**
  106178. * Hide the loading screen
  106179. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106180. */
  106181. hideLoadingUI(): void;
  106182. /**
  106183. * Gets the current loading screen object
  106184. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106185. */
  106186. get loadingScreen(): ILoadingScreen;
  106187. /**
  106188. * Sets the current loading screen object
  106189. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106190. */
  106191. set loadingScreen(loadingScreen: ILoadingScreen);
  106192. /**
  106193. * Sets the current loading screen text
  106194. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106195. */
  106196. set loadingUIText(text: string);
  106197. /**
  106198. * Sets the current loading screen background color
  106199. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106200. */
  106201. set loadingUIBackgroundColor(color: string);
  106202. /** Pointerlock and fullscreen */
  106203. /**
  106204. * Ask the browser to promote the current element to pointerlock mode
  106205. * @param element defines the DOM element to promote
  106206. */
  106207. static _RequestPointerlock(element: HTMLElement): void;
  106208. /**
  106209. * Asks the browser to exit pointerlock mode
  106210. */
  106211. static _ExitPointerlock(): void;
  106212. /**
  106213. * Ask the browser to promote the current element to fullscreen rendering mode
  106214. * @param element defines the DOM element to promote
  106215. */
  106216. static _RequestFullscreen(element: HTMLElement): void;
  106217. /**
  106218. * Asks the browser to exit fullscreen mode
  106219. */
  106220. static _ExitFullscreen(): void;
  106221. }
  106222. }
  106223. declare module BABYLON {
  106224. /**
  106225. * The engine store class is responsible to hold all the instances of Engine and Scene created
  106226. * during the life time of the application.
  106227. */
  106228. export class EngineStore {
  106229. /** Gets the list of created engines */
  106230. static Instances: Engine[];
  106231. /** @hidden */
  106232. static _LastCreatedScene: Nullable<Scene>;
  106233. /**
  106234. * Gets the latest created engine
  106235. */
  106236. static get LastCreatedEngine(): Nullable<Engine>;
  106237. /**
  106238. * Gets the latest created scene
  106239. */
  106240. static get LastCreatedScene(): Nullable<Scene>;
  106241. /**
  106242. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106243. * @ignorenaming
  106244. */
  106245. static UseFallbackTexture: boolean;
  106246. /**
  106247. * Texture content used if a texture cannot loaded
  106248. * @ignorenaming
  106249. */
  106250. static FallbackTexture: string;
  106251. }
  106252. }
  106253. declare module BABYLON {
  106254. /**
  106255. * Helper class that provides a small promise polyfill
  106256. */
  106257. export class PromisePolyfill {
  106258. /**
  106259. * Static function used to check if the polyfill is required
  106260. * If this is the case then the function will inject the polyfill to window.Promise
  106261. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  106262. */
  106263. static Apply(force?: boolean): void;
  106264. }
  106265. }
  106266. declare module BABYLON {
  106267. /**
  106268. * Interface for screenshot methods with describe argument called `size` as object with options
  106269. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  106270. */
  106271. export interface IScreenshotSize {
  106272. /**
  106273. * number in pixels for canvas height
  106274. */
  106275. height?: number;
  106276. /**
  106277. * multiplier allowing render at a higher or lower resolution
  106278. * If value is defined then height and width will be ignored and taken from camera
  106279. */
  106280. precision?: number;
  106281. /**
  106282. * number in pixels for canvas width
  106283. */
  106284. width?: number;
  106285. }
  106286. }
  106287. declare module BABYLON {
  106288. interface IColor4Like {
  106289. r: float;
  106290. g: float;
  106291. b: float;
  106292. a: float;
  106293. }
  106294. /**
  106295. * Class containing a set of static utilities functions
  106296. */
  106297. export class Tools {
  106298. /**
  106299. * Gets or sets the base URL to use to load assets
  106300. */
  106301. static get BaseUrl(): string;
  106302. static set BaseUrl(value: string);
  106303. /**
  106304. * Enable/Disable Custom HTTP Request Headers globally.
  106305. * default = false
  106306. * @see CustomRequestHeaders
  106307. */
  106308. static UseCustomRequestHeaders: boolean;
  106309. /**
  106310. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  106311. * i.e. when loading files, where the server/service expects an Authorization header
  106312. */
  106313. static CustomRequestHeaders: {
  106314. [key: string]: string;
  106315. };
  106316. /**
  106317. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  106318. */
  106319. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  106320. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  106321. /**
  106322. * Default behaviour for cors in the application.
  106323. * It can be a string if the expected behavior is identical in the entire app.
  106324. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  106325. */
  106326. static CorsBehavior: string | ((url: string | string[]) => string);
  106327. /**
  106328. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106329. * @ignorenaming
  106330. */
  106331. static get UseFallbackTexture(): boolean;
  106332. static set UseFallbackTexture(value: boolean);
  106333. /**
  106334. * Use this object to register external classes like custom textures or material
  106335. * to allow the laoders to instantiate them
  106336. */
  106337. static get RegisteredExternalClasses(): {
  106338. [key: string]: Object;
  106339. };
  106340. static set RegisteredExternalClasses(classes: {
  106341. [key: string]: Object;
  106342. });
  106343. /**
  106344. * Texture content used if a texture cannot loaded
  106345. * @ignorenaming
  106346. */
  106347. static get fallbackTexture(): string;
  106348. static set fallbackTexture(value: string);
  106349. /**
  106350. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  106351. * @param u defines the coordinate on X axis
  106352. * @param v defines the coordinate on Y axis
  106353. * @param width defines the width of the source data
  106354. * @param height defines the height of the source data
  106355. * @param pixels defines the source byte array
  106356. * @param color defines the output color
  106357. */
  106358. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  106359. /**
  106360. * Interpolates between a and b via alpha
  106361. * @param a The lower value (returned when alpha = 0)
  106362. * @param b The upper value (returned when alpha = 1)
  106363. * @param alpha The interpolation-factor
  106364. * @return The mixed value
  106365. */
  106366. static Mix(a: number, b: number, alpha: number): number;
  106367. /**
  106368. * Tries to instantiate a new object from a given class name
  106369. * @param className defines the class name to instantiate
  106370. * @returns the new object or null if the system was not able to do the instantiation
  106371. */
  106372. static Instantiate(className: string): any;
  106373. /**
  106374. * Provides a slice function that will work even on IE
  106375. * @param data defines the array to slice
  106376. * @param start defines the start of the data (optional)
  106377. * @param end defines the end of the data (optional)
  106378. * @returns the new sliced array
  106379. */
  106380. static Slice<T>(data: T, start?: number, end?: number): T;
  106381. /**
  106382. * Polyfill for setImmediate
  106383. * @param action defines the action to execute after the current execution block
  106384. */
  106385. static SetImmediate(action: () => void): void;
  106386. /**
  106387. * Function indicating if a number is an exponent of 2
  106388. * @param value defines the value to test
  106389. * @returns true if the value is an exponent of 2
  106390. */
  106391. static IsExponentOfTwo(value: number): boolean;
  106392. private static _tmpFloatArray;
  106393. /**
  106394. * Returns the nearest 32-bit single precision float representation of a Number
  106395. * @param value A Number. If the parameter is of a different type, it will get converted
  106396. * to a number or to NaN if it cannot be converted
  106397. * @returns number
  106398. */
  106399. static FloatRound(value: number): number;
  106400. /**
  106401. * Extracts the filename from a path
  106402. * @param path defines the path to use
  106403. * @returns the filename
  106404. */
  106405. static GetFilename(path: string): string;
  106406. /**
  106407. * Extracts the "folder" part of a path (everything before the filename).
  106408. * @param uri The URI to extract the info from
  106409. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  106410. * @returns The "folder" part of the path
  106411. */
  106412. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  106413. /**
  106414. * Extracts text content from a DOM element hierarchy
  106415. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  106416. */
  106417. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  106418. /**
  106419. * Convert an angle in radians to degrees
  106420. * @param angle defines the angle to convert
  106421. * @returns the angle in degrees
  106422. */
  106423. static ToDegrees(angle: number): number;
  106424. /**
  106425. * Convert an angle in degrees to radians
  106426. * @param angle defines the angle to convert
  106427. * @returns the angle in radians
  106428. */
  106429. static ToRadians(angle: number): number;
  106430. /**
  106431. * Returns an array if obj is not an array
  106432. * @param obj defines the object to evaluate as an array
  106433. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  106434. * @returns either obj directly if obj is an array or a new array containing obj
  106435. */
  106436. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  106437. /**
  106438. * Gets the pointer prefix to use
  106439. * @returns "pointer" if touch is enabled. Else returns "mouse"
  106440. */
  106441. static GetPointerPrefix(): string;
  106442. /**
  106443. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  106444. * @param url define the url we are trying
  106445. * @param element define the dom element where to configure the cors policy
  106446. */
  106447. static SetCorsBehavior(url: string | string[], element: {
  106448. crossOrigin: string | null;
  106449. }): void;
  106450. /**
  106451. * Removes unwanted characters from an url
  106452. * @param url defines the url to clean
  106453. * @returns the cleaned url
  106454. */
  106455. static CleanUrl(url: string): string;
  106456. /**
  106457. * Gets or sets a function used to pre-process url before using them to load assets
  106458. */
  106459. static get PreprocessUrl(): (url: string) => string;
  106460. static set PreprocessUrl(processor: (url: string) => string);
  106461. /**
  106462. * Loads an image as an HTMLImageElement.
  106463. * @param input url string, ArrayBuffer, or Blob to load
  106464. * @param onLoad callback called when the image successfully loads
  106465. * @param onError callback called when the image fails to load
  106466. * @param offlineProvider offline provider for caching
  106467. * @param mimeType optional mime type
  106468. * @returns the HTMLImageElement of the loaded image
  106469. */
  106470. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  106471. /**
  106472. * Loads a file from a url
  106473. * @param url url string, ArrayBuffer, or Blob to load
  106474. * @param onSuccess callback called when the file successfully loads
  106475. * @param onProgress callback called while file is loading (if the server supports this mode)
  106476. * @param offlineProvider defines the offline provider for caching
  106477. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106478. * @param onError callback called when the file fails to load
  106479. * @returns a file request object
  106480. */
  106481. 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;
  106482. /**
  106483. * Loads a file from a url
  106484. * @param url the file url to load
  106485. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  106486. */
  106487. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  106488. /**
  106489. * Load a script (identified by an url). When the url returns, the
  106490. * content of this file is added into a new script element, attached to the DOM (body element)
  106491. * @param scriptUrl defines the url of the script to laod
  106492. * @param onSuccess defines the callback called when the script is loaded
  106493. * @param onError defines the callback to call if an error occurs
  106494. * @param scriptId defines the id of the script element
  106495. */
  106496. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  106497. /**
  106498. * Load an asynchronous script (identified by an url). When the url returns, the
  106499. * content of this file is added into a new script element, attached to the DOM (body element)
  106500. * @param scriptUrl defines the url of the script to laod
  106501. * @param scriptId defines the id of the script element
  106502. * @returns a promise request object
  106503. */
  106504. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  106505. /**
  106506. * Loads a file from a blob
  106507. * @param fileToLoad defines the blob to use
  106508. * @param callback defines the callback to call when data is loaded
  106509. * @param progressCallback defines the callback to call during loading process
  106510. * @returns a file request object
  106511. */
  106512. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  106513. /**
  106514. * Reads a file from a File object
  106515. * @param file defines the file to load
  106516. * @param onSuccess defines the callback to call when data is loaded
  106517. * @param onProgress defines the callback to call during loading process
  106518. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  106519. * @param onError defines the callback to call when an error occurs
  106520. * @returns a file request object
  106521. */
  106522. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  106523. /**
  106524. * Creates a data url from a given string content
  106525. * @param content defines the content to convert
  106526. * @returns the new data url link
  106527. */
  106528. static FileAsURL(content: string): string;
  106529. /**
  106530. * Format the given number to a specific decimal format
  106531. * @param value defines the number to format
  106532. * @param decimals defines the number of decimals to use
  106533. * @returns the formatted string
  106534. */
  106535. static Format(value: number, decimals?: number): string;
  106536. /**
  106537. * Tries to copy an object by duplicating every property
  106538. * @param source defines the source object
  106539. * @param destination defines the target object
  106540. * @param doNotCopyList defines a list of properties to avoid
  106541. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  106542. */
  106543. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  106544. /**
  106545. * Gets a boolean indicating if the given object has no own property
  106546. * @param obj defines the object to test
  106547. * @returns true if object has no own property
  106548. */
  106549. static IsEmpty(obj: any): boolean;
  106550. /**
  106551. * Function used to register events at window level
  106552. * @param windowElement defines the Window object to use
  106553. * @param events defines the events to register
  106554. */
  106555. static RegisterTopRootEvents(windowElement: Window, events: {
  106556. name: string;
  106557. handler: Nullable<(e: FocusEvent) => any>;
  106558. }[]): void;
  106559. /**
  106560. * Function used to unregister events from window level
  106561. * @param windowElement defines the Window object to use
  106562. * @param events defines the events to unregister
  106563. */
  106564. static UnregisterTopRootEvents(windowElement: Window, events: {
  106565. name: string;
  106566. handler: Nullable<(e: FocusEvent) => any>;
  106567. }[]): void;
  106568. /**
  106569. * @ignore
  106570. */
  106571. static _ScreenshotCanvas: HTMLCanvasElement;
  106572. /**
  106573. * Dumps the current bound framebuffer
  106574. * @param width defines the rendering width
  106575. * @param height defines the rendering height
  106576. * @param engine defines the hosting engine
  106577. * @param successCallback defines the callback triggered once the data are available
  106578. * @param mimeType defines the mime type of the result
  106579. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  106580. */
  106581. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  106582. /**
  106583. * Converts the canvas data to blob.
  106584. * This acts as a polyfill for browsers not supporting the to blob function.
  106585. * @param canvas Defines the canvas to extract the data from
  106586. * @param successCallback Defines the callback triggered once the data are available
  106587. * @param mimeType Defines the mime type of the result
  106588. */
  106589. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  106590. /**
  106591. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  106592. * @param successCallback defines the callback triggered once the data are available
  106593. * @param mimeType defines the mime type of the result
  106594. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  106595. */
  106596. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  106597. /**
  106598. * Downloads a blob in the browser
  106599. * @param blob defines the blob to download
  106600. * @param fileName defines the name of the downloaded file
  106601. */
  106602. static Download(blob: Blob, fileName: string): void;
  106603. /**
  106604. * Captures a screenshot of the current rendering
  106605. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106606. * @param engine defines the rendering engine
  106607. * @param camera defines the source camera
  106608. * @param size This parameter can be set to a single number or to an object with the
  106609. * following (optional) properties: precision, width, height. If a single number is passed,
  106610. * it will be used for both width and height. If an object is passed, the screenshot size
  106611. * will be derived from the parameters. The precision property is a multiplier allowing
  106612. * rendering at a higher or lower resolution
  106613. * @param successCallback defines the callback receives a single parameter which contains the
  106614. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106615. * src parameter of an <img> to display it
  106616. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  106617. * Check your browser for supported MIME types
  106618. */
  106619. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  106620. /**
  106621. * Captures a screenshot of the current rendering
  106622. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106623. * @param engine defines the rendering engine
  106624. * @param camera defines the source camera
  106625. * @param size This parameter can be set to a single number or to an object with the
  106626. * following (optional) properties: precision, width, height. If a single number is passed,
  106627. * it will be used for both width and height. If an object is passed, the screenshot size
  106628. * will be derived from the parameters. The precision property is a multiplier allowing
  106629. * rendering at a higher or lower resolution
  106630. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  106631. * Check your browser for supported MIME types
  106632. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  106633. * to the src parameter of an <img> to display it
  106634. */
  106635. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  106636. /**
  106637. * Generates an image screenshot from the specified camera.
  106638. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106639. * @param engine The engine to use for rendering
  106640. * @param camera The camera to use for rendering
  106641. * @param size This parameter can be set to a single number or to an object with the
  106642. * following (optional) properties: precision, width, height. If a single number is passed,
  106643. * it will be used for both width and height. If an object is passed, the screenshot size
  106644. * will be derived from the parameters. The precision property is a multiplier allowing
  106645. * rendering at a higher or lower resolution
  106646. * @param successCallback The callback receives a single parameter which contains the
  106647. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  106648. * src parameter of an <img> to display it
  106649. * @param mimeType The MIME type of the screenshot image (default: image/png).
  106650. * Check your browser for supported MIME types
  106651. * @param samples Texture samples (default: 1)
  106652. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  106653. * @param fileName A name for for the downloaded file.
  106654. */
  106655. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  106656. /**
  106657. * Generates an image screenshot from the specified camera.
  106658. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  106659. * @param engine The engine to use for rendering
  106660. * @param camera The camera to use for rendering
  106661. * @param size This parameter can be set to a single number or to an object with the
  106662. * following (optional) properties: precision, width, height. If a single number is passed,
  106663. * it will be used for both width and height. If an object is passed, the screenshot size
  106664. * will be derived from the parameters. The precision property is a multiplier allowing
  106665. * rendering at a higher or lower resolution
  106666. * @param mimeType The MIME type of the screenshot image (default: image/png).
  106667. * Check your browser for supported MIME types
  106668. * @param samples Texture samples (default: 1)
  106669. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  106670. * @param fileName A name for for the downloaded file.
  106671. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  106672. * to the src parameter of an <img> to display it
  106673. */
  106674. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  106675. /**
  106676. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106677. * Be aware Math.random() could cause collisions, but:
  106678. * "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"
  106679. * @returns a pseudo random id
  106680. */
  106681. static RandomId(): string;
  106682. /**
  106683. * Test if the given uri is a base64 string
  106684. * @param uri The uri to test
  106685. * @return True if the uri is a base64 string or false otherwise
  106686. */
  106687. static IsBase64(uri: string): boolean;
  106688. /**
  106689. * Decode the given base64 uri.
  106690. * @param uri The uri to decode
  106691. * @return The decoded base64 data.
  106692. */
  106693. static DecodeBase64(uri: string): ArrayBuffer;
  106694. /**
  106695. * Gets the absolute url.
  106696. * @param url the input url
  106697. * @return the absolute url
  106698. */
  106699. static GetAbsoluteUrl(url: string): string;
  106700. /**
  106701. * No log
  106702. */
  106703. static readonly NoneLogLevel: number;
  106704. /**
  106705. * Only message logs
  106706. */
  106707. static readonly MessageLogLevel: number;
  106708. /**
  106709. * Only warning logs
  106710. */
  106711. static readonly WarningLogLevel: number;
  106712. /**
  106713. * Only error logs
  106714. */
  106715. static readonly ErrorLogLevel: number;
  106716. /**
  106717. * All logs
  106718. */
  106719. static readonly AllLogLevel: number;
  106720. /**
  106721. * Gets a value indicating the number of loading errors
  106722. * @ignorenaming
  106723. */
  106724. static get errorsCount(): number;
  106725. /**
  106726. * Callback called when a new log is added
  106727. */
  106728. static OnNewCacheEntry: (entry: string) => void;
  106729. /**
  106730. * Log a message to the console
  106731. * @param message defines the message to log
  106732. */
  106733. static Log(message: string): void;
  106734. /**
  106735. * Write a warning message to the console
  106736. * @param message defines the message to log
  106737. */
  106738. static Warn(message: string): void;
  106739. /**
  106740. * Write an error message to the console
  106741. * @param message defines the message to log
  106742. */
  106743. static Error(message: string): void;
  106744. /**
  106745. * Gets current log cache (list of logs)
  106746. */
  106747. static get LogCache(): string;
  106748. /**
  106749. * Clears the log cache
  106750. */
  106751. static ClearLogCache(): void;
  106752. /**
  106753. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  106754. */
  106755. static set LogLevels(level: number);
  106756. /**
  106757. * Checks if the window object exists
  106758. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  106759. */
  106760. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  106761. /**
  106762. * No performance log
  106763. */
  106764. static readonly PerformanceNoneLogLevel: number;
  106765. /**
  106766. * Use user marks to log performance
  106767. */
  106768. static readonly PerformanceUserMarkLogLevel: number;
  106769. /**
  106770. * Log performance to the console
  106771. */
  106772. static readonly PerformanceConsoleLogLevel: number;
  106773. private static _performance;
  106774. /**
  106775. * Sets the current performance log level
  106776. */
  106777. static set PerformanceLogLevel(level: number);
  106778. private static _StartPerformanceCounterDisabled;
  106779. private static _EndPerformanceCounterDisabled;
  106780. private static _StartUserMark;
  106781. private static _EndUserMark;
  106782. private static _StartPerformanceConsole;
  106783. private static _EndPerformanceConsole;
  106784. /**
  106785. * Starts a performance counter
  106786. */
  106787. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  106788. /**
  106789. * Ends a specific performance coutner
  106790. */
  106791. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  106792. /**
  106793. * Gets either window.performance.now() if supported or Date.now() else
  106794. */
  106795. static get Now(): number;
  106796. /**
  106797. * This method will return the name of the class used to create the instance of the given object.
  106798. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  106799. * @param object the object to get the class name from
  106800. * @param isType defines if the object is actually a type
  106801. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  106802. */
  106803. static GetClassName(object: any, isType?: boolean): string;
  106804. /**
  106805. * Gets the first element of an array satisfying a given predicate
  106806. * @param array defines the array to browse
  106807. * @param predicate defines the predicate to use
  106808. * @returns null if not found or the element
  106809. */
  106810. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  106811. /**
  106812. * This method will return the name of the full name of the class, including its owning module (if any).
  106813. * 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).
  106814. * @param object the object to get the class name from
  106815. * @param isType defines if the object is actually a type
  106816. * @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.
  106817. * @ignorenaming
  106818. */
  106819. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  106820. /**
  106821. * Returns a promise that resolves after the given amount of time.
  106822. * @param delay Number of milliseconds to delay
  106823. * @returns Promise that resolves after the given amount of time
  106824. */
  106825. static DelayAsync(delay: number): Promise<void>;
  106826. /**
  106827. * Utility function to detect if the current user agent is Safari
  106828. * @returns whether or not the current user agent is safari
  106829. */
  106830. static IsSafari(): boolean;
  106831. }
  106832. /**
  106833. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  106834. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  106835. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  106836. * @param name The name of the class, case should be preserved
  106837. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  106838. */
  106839. export function className(name: string, module?: string): (target: Object) => void;
  106840. /**
  106841. * An implementation of a loop for asynchronous functions.
  106842. */
  106843. export class AsyncLoop {
  106844. /**
  106845. * Defines the number of iterations for the loop
  106846. */
  106847. iterations: number;
  106848. /**
  106849. * Defines the current index of the loop.
  106850. */
  106851. index: number;
  106852. private _done;
  106853. private _fn;
  106854. private _successCallback;
  106855. /**
  106856. * Constructor.
  106857. * @param iterations the number of iterations.
  106858. * @param func the function to run each iteration
  106859. * @param successCallback the callback that will be called upon succesful execution
  106860. * @param offset starting offset.
  106861. */
  106862. constructor(
  106863. /**
  106864. * Defines the number of iterations for the loop
  106865. */
  106866. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  106867. /**
  106868. * Execute the next iteration. Must be called after the last iteration was finished.
  106869. */
  106870. executeNext(): void;
  106871. /**
  106872. * Break the loop and run the success callback.
  106873. */
  106874. breakLoop(): void;
  106875. /**
  106876. * Create and run an async loop.
  106877. * @param iterations the number of iterations.
  106878. * @param fn the function to run each iteration
  106879. * @param successCallback the callback that will be called upon succesful execution
  106880. * @param offset starting offset.
  106881. * @returns the created async loop object
  106882. */
  106883. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  106884. /**
  106885. * A for-loop that will run a given number of iterations synchronous and the rest async.
  106886. * @param iterations total number of iterations
  106887. * @param syncedIterations number of synchronous iterations in each async iteration.
  106888. * @param fn the function to call each iteration.
  106889. * @param callback a success call back that will be called when iterating stops.
  106890. * @param breakFunction a break condition (optional)
  106891. * @param timeout timeout settings for the setTimeout function. default - 0.
  106892. * @returns the created async loop object
  106893. */
  106894. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  106895. }
  106896. }
  106897. declare module BABYLON {
  106898. /**
  106899. * This class implement a typical dictionary using a string as key and the generic type T as value.
  106900. * The underlying implementation relies on an associative array to ensure the best performances.
  106901. * The value can be anything including 'null' but except 'undefined'
  106902. */
  106903. export class StringDictionary<T> {
  106904. /**
  106905. * This will clear this dictionary and copy the content from the 'source' one.
  106906. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  106907. * @param source the dictionary to take the content from and copy to this dictionary
  106908. */
  106909. copyFrom(source: StringDictionary<T>): void;
  106910. /**
  106911. * Get a value based from its key
  106912. * @param key the given key to get the matching value from
  106913. * @return the value if found, otherwise undefined is returned
  106914. */
  106915. get(key: string): T | undefined;
  106916. /**
  106917. * Get a value from its key or add it if it doesn't exist.
  106918. * This method will ensure you that a given key/data will be present in the dictionary.
  106919. * @param key the given key to get the matching value from
  106920. * @param factory the factory that will create the value if the key is not present in the dictionary.
  106921. * The factory will only be invoked if there's no data for the given key.
  106922. * @return the value corresponding to the key.
  106923. */
  106924. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  106925. /**
  106926. * Get a value from its key if present in the dictionary otherwise add it
  106927. * @param key the key to get the value from
  106928. * @param val if there's no such key/value pair in the dictionary add it with this value
  106929. * @return the value corresponding to the key
  106930. */
  106931. getOrAdd(key: string, val: T): T;
  106932. /**
  106933. * Check if there's a given key in the dictionary
  106934. * @param key the key to check for
  106935. * @return true if the key is present, false otherwise
  106936. */
  106937. contains(key: string): boolean;
  106938. /**
  106939. * Add a new key and its corresponding value
  106940. * @param key the key to add
  106941. * @param value the value corresponding to the key
  106942. * @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
  106943. */
  106944. add(key: string, value: T): boolean;
  106945. /**
  106946. * Update a specific value associated to a key
  106947. * @param key defines the key to use
  106948. * @param value defines the value to store
  106949. * @returns true if the value was updated (or false if the key was not found)
  106950. */
  106951. set(key: string, value: T): boolean;
  106952. /**
  106953. * Get the element of the given key and remove it from the dictionary
  106954. * @param key defines the key to search
  106955. * @returns the value associated with the key or null if not found
  106956. */
  106957. getAndRemove(key: string): Nullable<T>;
  106958. /**
  106959. * Remove a key/value from the dictionary.
  106960. * @param key the key to remove
  106961. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  106962. */
  106963. remove(key: string): boolean;
  106964. /**
  106965. * Clear the whole content of the dictionary
  106966. */
  106967. clear(): void;
  106968. /**
  106969. * Gets the current count
  106970. */
  106971. get count(): number;
  106972. /**
  106973. * Execute a callback on each key/val of the dictionary.
  106974. * Note that you can remove any element in this dictionary in the callback implementation
  106975. * @param callback the callback to execute on a given key/value pair
  106976. */
  106977. forEach(callback: (key: string, val: T) => void): void;
  106978. /**
  106979. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  106980. * If the callback returns null or undefined the method will iterate to the next key/value pair
  106981. * Note that you can remove any element in this dictionary in the callback implementation
  106982. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  106983. * @returns the first item
  106984. */
  106985. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  106986. private _count;
  106987. private _data;
  106988. }
  106989. }
  106990. declare module BABYLON {
  106991. /** @hidden */
  106992. export interface ICollisionCoordinator {
  106993. createCollider(): Collider;
  106994. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  106995. init(scene: Scene): void;
  106996. }
  106997. /** @hidden */
  106998. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  106999. private _scene;
  107000. private _scaledPosition;
  107001. private _scaledVelocity;
  107002. private _finalPosition;
  107003. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107004. createCollider(): Collider;
  107005. init(scene: Scene): void;
  107006. private _collideWithWorld;
  107007. }
  107008. }
  107009. declare module BABYLON {
  107010. /**
  107011. * Class used to manage all inputs for the scene.
  107012. */
  107013. export class InputManager {
  107014. /** The distance in pixel that you have to move to prevent some events */
  107015. static DragMovementThreshold: number;
  107016. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107017. static LongPressDelay: number;
  107018. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107019. static DoubleClickDelay: number;
  107020. /** If you need to check double click without raising a single click at first click, enable this flag */
  107021. static ExclusiveDoubleClickMode: boolean;
  107022. private _wheelEventName;
  107023. private _onPointerMove;
  107024. private _onPointerDown;
  107025. private _onPointerUp;
  107026. private _initClickEvent;
  107027. private _initActionManager;
  107028. private _delayedSimpleClick;
  107029. private _delayedSimpleClickTimeout;
  107030. private _previousDelayedSimpleClickTimeout;
  107031. private _meshPickProceed;
  107032. private _previousButtonPressed;
  107033. private _currentPickResult;
  107034. private _previousPickResult;
  107035. private _totalPointersPressed;
  107036. private _doubleClickOccured;
  107037. private _pointerOverMesh;
  107038. private _pickedDownMesh;
  107039. private _pickedUpMesh;
  107040. private _pointerX;
  107041. private _pointerY;
  107042. private _unTranslatedPointerX;
  107043. private _unTranslatedPointerY;
  107044. private _startingPointerPosition;
  107045. private _previousStartingPointerPosition;
  107046. private _startingPointerTime;
  107047. private _previousStartingPointerTime;
  107048. private _pointerCaptures;
  107049. private _onKeyDown;
  107050. private _onKeyUp;
  107051. private _onCanvasFocusObserver;
  107052. private _onCanvasBlurObserver;
  107053. private _scene;
  107054. /**
  107055. * Creates a new InputManager
  107056. * @param scene defines the hosting scene
  107057. */
  107058. constructor(scene: Scene);
  107059. /**
  107060. * Gets the mesh that is currently under the pointer
  107061. */
  107062. get meshUnderPointer(): Nullable<AbstractMesh>;
  107063. /**
  107064. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107065. */
  107066. get unTranslatedPointer(): Vector2;
  107067. /**
  107068. * Gets or sets the current on-screen X position of the pointer
  107069. */
  107070. get pointerX(): number;
  107071. set pointerX(value: number);
  107072. /**
  107073. * Gets or sets the current on-screen Y position of the pointer
  107074. */
  107075. get pointerY(): number;
  107076. set pointerY(value: number);
  107077. private _updatePointerPosition;
  107078. private _processPointerMove;
  107079. private _setRayOnPointerInfo;
  107080. private _checkPrePointerObservable;
  107081. /**
  107082. * Use this method to simulate a pointer move on a mesh
  107083. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107084. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107085. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107086. */
  107087. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107088. /**
  107089. * Use this method to simulate a pointer down on a mesh
  107090. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107091. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107092. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107093. */
  107094. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107095. private _processPointerDown;
  107096. /** @hidden */
  107097. _isPointerSwiping(): boolean;
  107098. /**
  107099. * Use this method to simulate a pointer up on a mesh
  107100. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107101. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107102. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107103. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107104. */
  107105. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107106. private _processPointerUp;
  107107. /**
  107108. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107109. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107110. * @returns true if the pointer was captured
  107111. */
  107112. isPointerCaptured(pointerId?: number): boolean;
  107113. /**
  107114. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107115. * @param attachUp defines if you want to attach events to pointerup
  107116. * @param attachDown defines if you want to attach events to pointerdown
  107117. * @param attachMove defines if you want to attach events to pointermove
  107118. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107119. */
  107120. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107121. /**
  107122. * Detaches all event handlers
  107123. */
  107124. detachControl(): void;
  107125. /**
  107126. * Force the value of meshUnderPointer
  107127. * @param mesh defines the mesh to use
  107128. */
  107129. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107130. /**
  107131. * Gets the mesh under the pointer
  107132. * @returns a Mesh or null if no mesh is under the pointer
  107133. */
  107134. getPointerOverMesh(): Nullable<AbstractMesh>;
  107135. }
  107136. }
  107137. declare module BABYLON {
  107138. /**
  107139. * Helper class used to generate session unique ID
  107140. */
  107141. export class UniqueIdGenerator {
  107142. private static _UniqueIdCounter;
  107143. /**
  107144. * Gets an unique (relatively to the current scene) Id
  107145. */
  107146. static get UniqueId(): number;
  107147. }
  107148. }
  107149. declare module BABYLON {
  107150. /**
  107151. * This class defines the direct association between an animation and a target
  107152. */
  107153. export class TargetedAnimation {
  107154. /**
  107155. * Animation to perform
  107156. */
  107157. animation: Animation;
  107158. /**
  107159. * Target to animate
  107160. */
  107161. target: any;
  107162. /**
  107163. * Serialize the object
  107164. * @returns the JSON object representing the current entity
  107165. */
  107166. serialize(): any;
  107167. }
  107168. /**
  107169. * Use this class to create coordinated animations on multiple targets
  107170. */
  107171. export class AnimationGroup implements IDisposable {
  107172. /** The name of the animation group */
  107173. name: string;
  107174. private _scene;
  107175. private _targetedAnimations;
  107176. private _animatables;
  107177. private _from;
  107178. private _to;
  107179. private _isStarted;
  107180. private _isPaused;
  107181. private _speedRatio;
  107182. private _loopAnimation;
  107183. /**
  107184. * Gets or sets the unique id of the node
  107185. */
  107186. uniqueId: number;
  107187. /**
  107188. * This observable will notify when one animation have ended
  107189. */
  107190. onAnimationEndObservable: Observable<TargetedAnimation>;
  107191. /**
  107192. * Observer raised when one animation loops
  107193. */
  107194. onAnimationLoopObservable: Observable<TargetedAnimation>;
  107195. /**
  107196. * Observer raised when all animations have looped
  107197. */
  107198. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  107199. /**
  107200. * This observable will notify when all animations have ended.
  107201. */
  107202. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  107203. /**
  107204. * This observable will notify when all animations have paused.
  107205. */
  107206. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  107207. /**
  107208. * This observable will notify when all animations are playing.
  107209. */
  107210. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  107211. /**
  107212. * Gets the first frame
  107213. */
  107214. get from(): number;
  107215. /**
  107216. * Gets the last frame
  107217. */
  107218. get to(): number;
  107219. /**
  107220. * Define if the animations are started
  107221. */
  107222. get isStarted(): boolean;
  107223. /**
  107224. * Gets a value indicating that the current group is playing
  107225. */
  107226. get isPlaying(): boolean;
  107227. /**
  107228. * Gets or sets the speed ratio to use for all animations
  107229. */
  107230. get speedRatio(): number;
  107231. /**
  107232. * Gets or sets the speed ratio to use for all animations
  107233. */
  107234. set speedRatio(value: number);
  107235. /**
  107236. * Gets or sets if all animations should loop or not
  107237. */
  107238. get loopAnimation(): boolean;
  107239. set loopAnimation(value: boolean);
  107240. /**
  107241. * Gets the targeted animations for this animation group
  107242. */
  107243. get targetedAnimations(): Array<TargetedAnimation>;
  107244. /**
  107245. * returning the list of animatables controlled by this animation group.
  107246. */
  107247. get animatables(): Array<Animatable>;
  107248. /**
  107249. * Instantiates a new Animation Group.
  107250. * This helps managing several animations at once.
  107251. * @see http://doc.babylonjs.com/how_to/group
  107252. * @param name Defines the name of the group
  107253. * @param scene Defines the scene the group belongs to
  107254. */
  107255. constructor(
  107256. /** The name of the animation group */
  107257. name: string, scene?: Nullable<Scene>);
  107258. /**
  107259. * Add an animation (with its target) in the group
  107260. * @param animation defines the animation we want to add
  107261. * @param target defines the target of the animation
  107262. * @returns the TargetedAnimation object
  107263. */
  107264. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  107265. /**
  107266. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  107267. * It can add constant keys at begin or end
  107268. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  107269. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  107270. * @returns the animation group
  107271. */
  107272. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  107273. private _animationLoopCount;
  107274. private _animationLoopFlags;
  107275. private _processLoop;
  107276. /**
  107277. * Start all animations on given targets
  107278. * @param loop defines if animations must loop
  107279. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  107280. * @param from defines the from key (optional)
  107281. * @param to defines the to key (optional)
  107282. * @returns the current animation group
  107283. */
  107284. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  107285. /**
  107286. * Pause all animations
  107287. * @returns the animation group
  107288. */
  107289. pause(): AnimationGroup;
  107290. /**
  107291. * Play all animations to initial state
  107292. * This function will start() the animations if they were not started or will restart() them if they were paused
  107293. * @param loop defines if animations must loop
  107294. * @returns the animation group
  107295. */
  107296. play(loop?: boolean): AnimationGroup;
  107297. /**
  107298. * Reset all animations to initial state
  107299. * @returns the animation group
  107300. */
  107301. reset(): AnimationGroup;
  107302. /**
  107303. * Restart animations from key 0
  107304. * @returns the animation group
  107305. */
  107306. restart(): AnimationGroup;
  107307. /**
  107308. * Stop all animations
  107309. * @returns the animation group
  107310. */
  107311. stop(): AnimationGroup;
  107312. /**
  107313. * Set animation weight for all animatables
  107314. * @param weight defines the weight to use
  107315. * @return the animationGroup
  107316. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107317. */
  107318. setWeightForAllAnimatables(weight: number): AnimationGroup;
  107319. /**
  107320. * Synchronize and normalize all animatables with a source animatable
  107321. * @param root defines the root animatable to synchronize with
  107322. * @return the animationGroup
  107323. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107324. */
  107325. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  107326. /**
  107327. * Goes to a specific frame in this animation group
  107328. * @param frame the frame number to go to
  107329. * @return the animationGroup
  107330. */
  107331. goToFrame(frame: number): AnimationGroup;
  107332. /**
  107333. * Dispose all associated resources
  107334. */
  107335. dispose(): void;
  107336. private _checkAnimationGroupEnded;
  107337. /**
  107338. * Clone the current animation group and returns a copy
  107339. * @param newName defines the name of the new group
  107340. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  107341. * @returns the new aniamtion group
  107342. */
  107343. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  107344. /**
  107345. * Serializes the animationGroup to an object
  107346. * @returns Serialized object
  107347. */
  107348. serialize(): any;
  107349. /**
  107350. * Returns a new AnimationGroup object parsed from the source provided.
  107351. * @param parsedAnimationGroup defines the source
  107352. * @param scene defines the scene that will receive the animationGroup
  107353. * @returns a new AnimationGroup
  107354. */
  107355. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  107356. /**
  107357. * Returns the string "AnimationGroup"
  107358. * @returns "AnimationGroup"
  107359. */
  107360. getClassName(): string;
  107361. /**
  107362. * Creates a detailled string about the object
  107363. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  107364. * @returns a string representing the object
  107365. */
  107366. toString(fullDetails?: boolean): string;
  107367. }
  107368. }
  107369. declare module BABYLON {
  107370. /**
  107371. * Define an interface for all classes that will hold resources
  107372. */
  107373. export interface IDisposable {
  107374. /**
  107375. * Releases all held resources
  107376. */
  107377. dispose(): void;
  107378. }
  107379. /** Interface defining initialization parameters for Scene class */
  107380. export interface SceneOptions {
  107381. /**
  107382. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  107383. * It will improve performance when the number of geometries becomes important.
  107384. */
  107385. useGeometryUniqueIdsMap?: boolean;
  107386. /**
  107387. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  107388. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107389. */
  107390. useMaterialMeshMap?: boolean;
  107391. /**
  107392. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  107393. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107394. */
  107395. useClonedMeshMap?: boolean;
  107396. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  107397. virtual?: boolean;
  107398. }
  107399. /**
  107400. * Represents a scene to be rendered by the engine.
  107401. * @see http://doc.babylonjs.com/features/scene
  107402. */
  107403. export class Scene extends AbstractScene implements IAnimatable {
  107404. /** The fog is deactivated */
  107405. static readonly FOGMODE_NONE: number;
  107406. /** The fog density is following an exponential function */
  107407. static readonly FOGMODE_EXP: number;
  107408. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  107409. static readonly FOGMODE_EXP2: number;
  107410. /** The fog density is following a linear function. */
  107411. static readonly FOGMODE_LINEAR: number;
  107412. /**
  107413. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  107414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107415. */
  107416. static MinDeltaTime: number;
  107417. /**
  107418. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  107419. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107420. */
  107421. static MaxDeltaTime: number;
  107422. /**
  107423. * Factory used to create the default material.
  107424. * @param name The name of the material to create
  107425. * @param scene The scene to create the material for
  107426. * @returns The default material
  107427. */
  107428. static DefaultMaterialFactory(scene: Scene): Material;
  107429. /**
  107430. * Factory used to create the a collision coordinator.
  107431. * @returns The collision coordinator
  107432. */
  107433. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  107434. /** @hidden */
  107435. _inputManager: InputManager;
  107436. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  107437. cameraToUseForPointers: Nullable<Camera>;
  107438. /** @hidden */
  107439. readonly _isScene: boolean;
  107440. /**
  107441. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  107442. */
  107443. autoClear: boolean;
  107444. /**
  107445. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  107446. */
  107447. autoClearDepthAndStencil: boolean;
  107448. /**
  107449. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  107450. */
  107451. clearColor: Color4;
  107452. /**
  107453. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  107454. */
  107455. ambientColor: Color3;
  107456. /**
  107457. * This is use to store the default BRDF lookup for PBR materials in your scene.
  107458. * It should only be one of the following (if not the default embedded one):
  107459. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107460. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  107461. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107462. * The material properties need to be setup according to the type of texture in use.
  107463. */
  107464. environmentBRDFTexture: BaseTexture;
  107465. /** @hidden */
  107466. protected _environmentTexture: Nullable<BaseTexture>;
  107467. /**
  107468. * Texture used in all pbr material as the reflection texture.
  107469. * As in the majority of the scene they are the same (exception for multi room and so on),
  107470. * this is easier to reference from here than from all the materials.
  107471. */
  107472. get environmentTexture(): Nullable<BaseTexture>;
  107473. /**
  107474. * Texture used in all pbr material as the reflection texture.
  107475. * As in the majority of the scene they are the same (exception for multi room and so on),
  107476. * this is easier to set here than in all the materials.
  107477. */
  107478. set environmentTexture(value: Nullable<BaseTexture>);
  107479. /** @hidden */
  107480. protected _environmentIntensity: number;
  107481. /**
  107482. * Intensity of the environment in all pbr material.
  107483. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107484. * As in the majority of the scene they are the same (exception for multi room and so on),
  107485. * this is easier to reference from here than from all the materials.
  107486. */
  107487. get environmentIntensity(): number;
  107488. /**
  107489. * Intensity of the environment in all pbr material.
  107490. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107491. * As in the majority of the scene they are the same (exception for multi room and so on),
  107492. * this is easier to set here than in all the materials.
  107493. */
  107494. set environmentIntensity(value: number);
  107495. /** @hidden */
  107496. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107497. /**
  107498. * Default image processing configuration used either in the rendering
  107499. * Forward main pass or through the imageProcessingPostProcess if present.
  107500. * As in the majority of the scene they are the same (exception for multi camera),
  107501. * this is easier to reference from here than from all the materials and post process.
  107502. *
  107503. * No setter as we it is a shared configuration, you can set the values instead.
  107504. */
  107505. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107506. private _forceWireframe;
  107507. /**
  107508. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  107509. */
  107510. set forceWireframe(value: boolean);
  107511. get forceWireframe(): boolean;
  107512. private _skipFrustumClipping;
  107513. /**
  107514. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  107515. */
  107516. set skipFrustumClipping(value: boolean);
  107517. get skipFrustumClipping(): boolean;
  107518. private _forcePointsCloud;
  107519. /**
  107520. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  107521. */
  107522. set forcePointsCloud(value: boolean);
  107523. get forcePointsCloud(): boolean;
  107524. /**
  107525. * Gets or sets the active clipplane 1
  107526. */
  107527. clipPlane: Nullable<Plane>;
  107528. /**
  107529. * Gets or sets the active clipplane 2
  107530. */
  107531. clipPlane2: Nullable<Plane>;
  107532. /**
  107533. * Gets or sets the active clipplane 3
  107534. */
  107535. clipPlane3: Nullable<Plane>;
  107536. /**
  107537. * Gets or sets the active clipplane 4
  107538. */
  107539. clipPlane4: Nullable<Plane>;
  107540. /**
  107541. * Gets or sets the active clipplane 5
  107542. */
  107543. clipPlane5: Nullable<Plane>;
  107544. /**
  107545. * Gets or sets the active clipplane 6
  107546. */
  107547. clipPlane6: Nullable<Plane>;
  107548. /**
  107549. * Gets or sets a boolean indicating if animations are enabled
  107550. */
  107551. animationsEnabled: boolean;
  107552. private _animationPropertiesOverride;
  107553. /**
  107554. * Gets or sets the animation properties override
  107555. */
  107556. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107557. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  107558. /**
  107559. * Gets or sets a boolean indicating if a constant deltatime has to be used
  107560. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  107561. */
  107562. useConstantAnimationDeltaTime: boolean;
  107563. /**
  107564. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  107565. * Please note that it requires to run a ray cast through the scene on every frame
  107566. */
  107567. constantlyUpdateMeshUnderPointer: boolean;
  107568. /**
  107569. * Defines the HTML cursor to use when hovering over interactive elements
  107570. */
  107571. hoverCursor: string;
  107572. /**
  107573. * Defines the HTML default cursor to use (empty by default)
  107574. */
  107575. defaultCursor: string;
  107576. /**
  107577. * Defines wether cursors are handled by the scene.
  107578. */
  107579. doNotHandleCursors: boolean;
  107580. /**
  107581. * This is used to call preventDefault() on pointer down
  107582. * in order to block unwanted artifacts like system double clicks
  107583. */
  107584. preventDefaultOnPointerDown: boolean;
  107585. /**
  107586. * This is used to call preventDefault() on pointer up
  107587. * in order to block unwanted artifacts like system double clicks
  107588. */
  107589. preventDefaultOnPointerUp: boolean;
  107590. /**
  107591. * Gets or sets user defined metadata
  107592. */
  107593. metadata: any;
  107594. /**
  107595. * For internal use only. Please do not use.
  107596. */
  107597. reservedDataStore: any;
  107598. /**
  107599. * Gets the name of the plugin used to load this scene (null by default)
  107600. */
  107601. loadingPluginName: string;
  107602. /**
  107603. * Use this array to add regular expressions used to disable offline support for specific urls
  107604. */
  107605. disableOfflineSupportExceptionRules: RegExp[];
  107606. /**
  107607. * An event triggered when the scene is disposed.
  107608. */
  107609. onDisposeObservable: Observable<Scene>;
  107610. private _onDisposeObserver;
  107611. /** Sets a function to be executed when this scene is disposed. */
  107612. set onDispose(callback: () => void);
  107613. /**
  107614. * An event triggered before rendering the scene (right after animations and physics)
  107615. */
  107616. onBeforeRenderObservable: Observable<Scene>;
  107617. private _onBeforeRenderObserver;
  107618. /** Sets a function to be executed before rendering this scene */
  107619. set beforeRender(callback: Nullable<() => void>);
  107620. /**
  107621. * An event triggered after rendering the scene
  107622. */
  107623. onAfterRenderObservable: Observable<Scene>;
  107624. /**
  107625. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  107626. */
  107627. onAfterRenderCameraObservable: Observable<Camera>;
  107628. private _onAfterRenderObserver;
  107629. /** Sets a function to be executed after rendering this scene */
  107630. set afterRender(callback: Nullable<() => void>);
  107631. /**
  107632. * An event triggered before animating the scene
  107633. */
  107634. onBeforeAnimationsObservable: Observable<Scene>;
  107635. /**
  107636. * An event triggered after animations processing
  107637. */
  107638. onAfterAnimationsObservable: Observable<Scene>;
  107639. /**
  107640. * An event triggered before draw calls are ready to be sent
  107641. */
  107642. onBeforeDrawPhaseObservable: Observable<Scene>;
  107643. /**
  107644. * An event triggered after draw calls have been sent
  107645. */
  107646. onAfterDrawPhaseObservable: Observable<Scene>;
  107647. /**
  107648. * An event triggered when the scene is ready
  107649. */
  107650. onReadyObservable: Observable<Scene>;
  107651. /**
  107652. * An event triggered before rendering a camera
  107653. */
  107654. onBeforeCameraRenderObservable: Observable<Camera>;
  107655. private _onBeforeCameraRenderObserver;
  107656. /** Sets a function to be executed before rendering a camera*/
  107657. set beforeCameraRender(callback: () => void);
  107658. /**
  107659. * An event triggered after rendering a camera
  107660. */
  107661. onAfterCameraRenderObservable: Observable<Camera>;
  107662. private _onAfterCameraRenderObserver;
  107663. /** Sets a function to be executed after rendering a camera*/
  107664. set afterCameraRender(callback: () => void);
  107665. /**
  107666. * An event triggered when active meshes evaluation is about to start
  107667. */
  107668. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  107669. /**
  107670. * An event triggered when active meshes evaluation is done
  107671. */
  107672. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  107673. /**
  107674. * An event triggered when particles rendering is about to start
  107675. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  107676. */
  107677. onBeforeParticlesRenderingObservable: Observable<Scene>;
  107678. /**
  107679. * An event triggered when particles rendering is done
  107680. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  107681. */
  107682. onAfterParticlesRenderingObservable: Observable<Scene>;
  107683. /**
  107684. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  107685. */
  107686. onDataLoadedObservable: Observable<Scene>;
  107687. /**
  107688. * An event triggered when a camera is created
  107689. */
  107690. onNewCameraAddedObservable: Observable<Camera>;
  107691. /**
  107692. * An event triggered when a camera is removed
  107693. */
  107694. onCameraRemovedObservable: Observable<Camera>;
  107695. /**
  107696. * An event triggered when a light is created
  107697. */
  107698. onNewLightAddedObservable: Observable<Light>;
  107699. /**
  107700. * An event triggered when a light is removed
  107701. */
  107702. onLightRemovedObservable: Observable<Light>;
  107703. /**
  107704. * An event triggered when a geometry is created
  107705. */
  107706. onNewGeometryAddedObservable: Observable<Geometry>;
  107707. /**
  107708. * An event triggered when a geometry is removed
  107709. */
  107710. onGeometryRemovedObservable: Observable<Geometry>;
  107711. /**
  107712. * An event triggered when a transform node is created
  107713. */
  107714. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  107715. /**
  107716. * An event triggered when a transform node is removed
  107717. */
  107718. onTransformNodeRemovedObservable: Observable<TransformNode>;
  107719. /**
  107720. * An event triggered when a mesh is created
  107721. */
  107722. onNewMeshAddedObservable: Observable<AbstractMesh>;
  107723. /**
  107724. * An event triggered when a mesh is removed
  107725. */
  107726. onMeshRemovedObservable: Observable<AbstractMesh>;
  107727. /**
  107728. * An event triggered when a skeleton is created
  107729. */
  107730. onNewSkeletonAddedObservable: Observable<Skeleton>;
  107731. /**
  107732. * An event triggered when a skeleton is removed
  107733. */
  107734. onSkeletonRemovedObservable: Observable<Skeleton>;
  107735. /**
  107736. * An event triggered when a material is created
  107737. */
  107738. onNewMaterialAddedObservable: Observable<Material>;
  107739. /**
  107740. * An event triggered when a material is removed
  107741. */
  107742. onMaterialRemovedObservable: Observable<Material>;
  107743. /**
  107744. * An event triggered when a texture is created
  107745. */
  107746. onNewTextureAddedObservable: Observable<BaseTexture>;
  107747. /**
  107748. * An event triggered when a texture is removed
  107749. */
  107750. onTextureRemovedObservable: Observable<BaseTexture>;
  107751. /**
  107752. * An event triggered when render targets are about to be rendered
  107753. * Can happen multiple times per frame.
  107754. */
  107755. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  107756. /**
  107757. * An event triggered when render targets were rendered.
  107758. * Can happen multiple times per frame.
  107759. */
  107760. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  107761. /**
  107762. * An event triggered before calculating deterministic simulation step
  107763. */
  107764. onBeforeStepObservable: Observable<Scene>;
  107765. /**
  107766. * An event triggered after calculating deterministic simulation step
  107767. */
  107768. onAfterStepObservable: Observable<Scene>;
  107769. /**
  107770. * An event triggered when the activeCamera property is updated
  107771. */
  107772. onActiveCameraChanged: Observable<Scene>;
  107773. /**
  107774. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  107775. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  107776. * 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)
  107777. */
  107778. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  107779. /**
  107780. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  107781. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  107782. * 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)
  107783. */
  107784. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  107785. /**
  107786. * This Observable will when a mesh has been imported into the scene.
  107787. */
  107788. onMeshImportedObservable: Observable<AbstractMesh>;
  107789. /**
  107790. * This Observable will when an animation file has been imported into the scene.
  107791. */
  107792. onAnimationFileImportedObservable: Observable<Scene>;
  107793. /**
  107794. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  107795. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  107796. */
  107797. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  107798. /** @hidden */
  107799. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  107800. /**
  107801. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  107802. */
  107803. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  107804. /**
  107805. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  107806. */
  107807. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  107808. /**
  107809. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  107810. */
  107811. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  107812. /** Callback called when a pointer move is detected */
  107813. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  107814. /** Callback called when a pointer down is detected */
  107815. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  107816. /** Callback called when a pointer up is detected */
  107817. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  107818. /** Callback called when a pointer pick is detected */
  107819. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  107820. /**
  107821. * 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).
  107822. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  107823. */
  107824. onPrePointerObservable: Observable<PointerInfoPre>;
  107825. /**
  107826. * Observable event triggered each time an input event is received from the rendering canvas
  107827. */
  107828. onPointerObservable: Observable<PointerInfo>;
  107829. /**
  107830. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  107831. */
  107832. get unTranslatedPointer(): Vector2;
  107833. /**
  107834. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  107835. */
  107836. static get DragMovementThreshold(): number;
  107837. static set DragMovementThreshold(value: number);
  107838. /**
  107839. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  107840. */
  107841. static get LongPressDelay(): number;
  107842. static set LongPressDelay(value: number);
  107843. /**
  107844. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  107845. */
  107846. static get DoubleClickDelay(): number;
  107847. static set DoubleClickDelay(value: number);
  107848. /** If you need to check double click without raising a single click at first click, enable this flag */
  107849. static get ExclusiveDoubleClickMode(): boolean;
  107850. static set ExclusiveDoubleClickMode(value: boolean);
  107851. /** @hidden */
  107852. _mirroredCameraPosition: Nullable<Vector3>;
  107853. /**
  107854. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  107855. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  107856. */
  107857. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  107858. /**
  107859. * Observable event triggered each time an keyboard event is received from the hosting window
  107860. */
  107861. onKeyboardObservable: Observable<KeyboardInfo>;
  107862. private _useRightHandedSystem;
  107863. /**
  107864. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  107865. */
  107866. set useRightHandedSystem(value: boolean);
  107867. get useRightHandedSystem(): boolean;
  107868. private _timeAccumulator;
  107869. private _currentStepId;
  107870. private _currentInternalStep;
  107871. /**
  107872. * Sets the step Id used by deterministic lock step
  107873. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107874. * @param newStepId defines the step Id
  107875. */
  107876. setStepId(newStepId: number): void;
  107877. /**
  107878. * Gets the step Id used by deterministic lock step
  107879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107880. * @returns the step Id
  107881. */
  107882. getStepId(): number;
  107883. /**
  107884. * Gets the internal step used by deterministic lock step
  107885. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107886. * @returns the internal step
  107887. */
  107888. getInternalStep(): number;
  107889. private _fogEnabled;
  107890. /**
  107891. * Gets or sets a boolean indicating if fog is enabled on this scene
  107892. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107893. * (Default is true)
  107894. */
  107895. set fogEnabled(value: boolean);
  107896. get fogEnabled(): boolean;
  107897. private _fogMode;
  107898. /**
  107899. * Gets or sets the fog mode to use
  107900. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107901. * | mode | value |
  107902. * | --- | --- |
  107903. * | FOGMODE_NONE | 0 |
  107904. * | FOGMODE_EXP | 1 |
  107905. * | FOGMODE_EXP2 | 2 |
  107906. * | FOGMODE_LINEAR | 3 |
  107907. */
  107908. set fogMode(value: number);
  107909. get fogMode(): number;
  107910. /**
  107911. * Gets or sets the fog color to use
  107912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107913. * (Default is Color3(0.2, 0.2, 0.3))
  107914. */
  107915. fogColor: Color3;
  107916. /**
  107917. * Gets or sets the fog density to use
  107918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107919. * (Default is 0.1)
  107920. */
  107921. fogDensity: number;
  107922. /**
  107923. * Gets or sets the fog start distance to use
  107924. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107925. * (Default is 0)
  107926. */
  107927. fogStart: number;
  107928. /**
  107929. * Gets or sets the fog end distance to use
  107930. * @see http://doc.babylonjs.com/babylon101/environment#fog
  107931. * (Default is 1000)
  107932. */
  107933. fogEnd: number;
  107934. private _shadowsEnabled;
  107935. /**
  107936. * Gets or sets a boolean indicating if shadows are enabled on this scene
  107937. */
  107938. set shadowsEnabled(value: boolean);
  107939. get shadowsEnabled(): boolean;
  107940. private _lightsEnabled;
  107941. /**
  107942. * Gets or sets a boolean indicating if lights are enabled on this scene
  107943. */
  107944. set lightsEnabled(value: boolean);
  107945. get lightsEnabled(): boolean;
  107946. /** All of the active cameras added to this scene. */
  107947. activeCameras: Camera[];
  107948. /** @hidden */
  107949. _activeCamera: Nullable<Camera>;
  107950. /** Gets or sets the current active camera */
  107951. get activeCamera(): Nullable<Camera>;
  107952. set activeCamera(value: Nullable<Camera>);
  107953. private _defaultMaterial;
  107954. /** The default material used on meshes when no material is affected */
  107955. get defaultMaterial(): Material;
  107956. /** The default material used on meshes when no material is affected */
  107957. set defaultMaterial(value: Material);
  107958. private _texturesEnabled;
  107959. /**
  107960. * Gets or sets a boolean indicating if textures are enabled on this scene
  107961. */
  107962. set texturesEnabled(value: boolean);
  107963. get texturesEnabled(): boolean;
  107964. /**
  107965. * Gets or sets a boolean indicating if particles are enabled on this scene
  107966. */
  107967. particlesEnabled: boolean;
  107968. /**
  107969. * Gets or sets a boolean indicating if sprites are enabled on this scene
  107970. */
  107971. spritesEnabled: boolean;
  107972. private _skeletonsEnabled;
  107973. /**
  107974. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  107975. */
  107976. set skeletonsEnabled(value: boolean);
  107977. get skeletonsEnabled(): boolean;
  107978. /**
  107979. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  107980. */
  107981. lensFlaresEnabled: boolean;
  107982. /**
  107983. * Gets or sets a boolean indicating if collisions are enabled on this scene
  107984. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  107985. */
  107986. collisionsEnabled: boolean;
  107987. private _collisionCoordinator;
  107988. /** @hidden */
  107989. get collisionCoordinator(): ICollisionCoordinator;
  107990. /**
  107991. * Defines the gravity applied to this scene (used only for collisions)
  107992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  107993. */
  107994. gravity: Vector3;
  107995. /**
  107996. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  107997. */
  107998. postProcessesEnabled: boolean;
  107999. /**
  108000. * The list of postprocesses added to the scene
  108001. */
  108002. postProcesses: PostProcess[];
  108003. /**
  108004. * Gets the current postprocess manager
  108005. */
  108006. postProcessManager: PostProcessManager;
  108007. /**
  108008. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108009. */
  108010. renderTargetsEnabled: boolean;
  108011. /**
  108012. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108013. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108014. */
  108015. dumpNextRenderTargets: boolean;
  108016. /**
  108017. * The list of user defined render targets added to the scene
  108018. */
  108019. customRenderTargets: RenderTargetTexture[];
  108020. /**
  108021. * Defines if texture loading must be delayed
  108022. * If true, textures will only be loaded when they need to be rendered
  108023. */
  108024. useDelayedTextureLoading: boolean;
  108025. /**
  108026. * Gets the list of meshes imported to the scene through SceneLoader
  108027. */
  108028. importedMeshesFiles: String[];
  108029. /**
  108030. * Gets or sets a boolean indicating if probes are enabled on this scene
  108031. */
  108032. probesEnabled: boolean;
  108033. /**
  108034. * Gets or sets the current offline provider to use to store scene data
  108035. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108036. */
  108037. offlineProvider: IOfflineProvider;
  108038. /**
  108039. * Gets or sets the action manager associated with the scene
  108040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108041. */
  108042. actionManager: AbstractActionManager;
  108043. private _meshesForIntersections;
  108044. /**
  108045. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108046. */
  108047. proceduralTexturesEnabled: boolean;
  108048. private _engine;
  108049. private _totalVertices;
  108050. /** @hidden */
  108051. _activeIndices: PerfCounter;
  108052. /** @hidden */
  108053. _activeParticles: PerfCounter;
  108054. /** @hidden */
  108055. _activeBones: PerfCounter;
  108056. private _animationRatio;
  108057. /** @hidden */
  108058. _animationTimeLast: number;
  108059. /** @hidden */
  108060. _animationTime: number;
  108061. /**
  108062. * Gets or sets a general scale for animation speed
  108063. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108064. */
  108065. animationTimeScale: number;
  108066. /** @hidden */
  108067. _cachedMaterial: Nullable<Material>;
  108068. /** @hidden */
  108069. _cachedEffect: Nullable<Effect>;
  108070. /** @hidden */
  108071. _cachedVisibility: Nullable<number>;
  108072. private _renderId;
  108073. private _frameId;
  108074. private _executeWhenReadyTimeoutId;
  108075. private _intermediateRendering;
  108076. private _viewUpdateFlag;
  108077. private _projectionUpdateFlag;
  108078. /** @hidden */
  108079. _toBeDisposed: Nullable<IDisposable>[];
  108080. private _activeRequests;
  108081. /** @hidden */
  108082. _pendingData: any[];
  108083. private _isDisposed;
  108084. /**
  108085. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108086. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108087. */
  108088. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108089. private _activeMeshes;
  108090. private _processedMaterials;
  108091. private _renderTargets;
  108092. /** @hidden */
  108093. _activeParticleSystems: SmartArray<IParticleSystem>;
  108094. private _activeSkeletons;
  108095. private _softwareSkinnedMeshes;
  108096. private _renderingManager;
  108097. /** @hidden */
  108098. _activeAnimatables: Animatable[];
  108099. private _transformMatrix;
  108100. private _sceneUbo;
  108101. /** @hidden */
  108102. _viewMatrix: Matrix;
  108103. private _projectionMatrix;
  108104. /** @hidden */
  108105. _forcedViewPosition: Nullable<Vector3>;
  108106. /** @hidden */
  108107. _frustumPlanes: Plane[];
  108108. /**
  108109. * Gets the list of frustum planes (built from the active camera)
  108110. */
  108111. get frustumPlanes(): Plane[];
  108112. /**
  108113. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108114. * This is useful if there are more lights that the maximum simulteanous authorized
  108115. */
  108116. requireLightSorting: boolean;
  108117. /** @hidden */
  108118. readonly useMaterialMeshMap: boolean;
  108119. /** @hidden */
  108120. readonly useClonedMeshMap: boolean;
  108121. private _externalData;
  108122. private _uid;
  108123. /**
  108124. * @hidden
  108125. * Backing store of defined scene components.
  108126. */
  108127. _components: ISceneComponent[];
  108128. /**
  108129. * @hidden
  108130. * Backing store of defined scene components.
  108131. */
  108132. _serializableComponents: ISceneSerializableComponent[];
  108133. /**
  108134. * List of components to register on the next registration step.
  108135. */
  108136. private _transientComponents;
  108137. /**
  108138. * Registers the transient components if needed.
  108139. */
  108140. private _registerTransientComponents;
  108141. /**
  108142. * @hidden
  108143. * Add a component to the scene.
  108144. * Note that the ccomponent could be registered on th next frame if this is called after
  108145. * the register component stage.
  108146. * @param component Defines the component to add to the scene
  108147. */
  108148. _addComponent(component: ISceneComponent): void;
  108149. /**
  108150. * @hidden
  108151. * Gets a component from the scene.
  108152. * @param name defines the name of the component to retrieve
  108153. * @returns the component or null if not present
  108154. */
  108155. _getComponent(name: string): Nullable<ISceneComponent>;
  108156. /**
  108157. * @hidden
  108158. * Defines the actions happening before camera updates.
  108159. */
  108160. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  108161. /**
  108162. * @hidden
  108163. * Defines the actions happening before clear the canvas.
  108164. */
  108165. _beforeClearStage: Stage<SimpleStageAction>;
  108166. /**
  108167. * @hidden
  108168. * Defines the actions when collecting render targets for the frame.
  108169. */
  108170. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108171. /**
  108172. * @hidden
  108173. * Defines the actions happening for one camera in the frame.
  108174. */
  108175. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108176. /**
  108177. * @hidden
  108178. * Defines the actions happening during the per mesh ready checks.
  108179. */
  108180. _isReadyForMeshStage: Stage<MeshStageAction>;
  108181. /**
  108182. * @hidden
  108183. * Defines the actions happening before evaluate active mesh checks.
  108184. */
  108185. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  108186. /**
  108187. * @hidden
  108188. * Defines the actions happening during the evaluate sub mesh checks.
  108189. */
  108190. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  108191. /**
  108192. * @hidden
  108193. * Defines the actions happening during the active mesh stage.
  108194. */
  108195. _activeMeshStage: Stage<ActiveMeshStageAction>;
  108196. /**
  108197. * @hidden
  108198. * Defines the actions happening during the per camera render target step.
  108199. */
  108200. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  108201. /**
  108202. * @hidden
  108203. * Defines the actions happening just before the active camera is drawing.
  108204. */
  108205. _beforeCameraDrawStage: Stage<CameraStageAction>;
  108206. /**
  108207. * @hidden
  108208. * Defines the actions happening just before a render target is drawing.
  108209. */
  108210. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108211. /**
  108212. * @hidden
  108213. * Defines the actions happening just before a rendering group is drawing.
  108214. */
  108215. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108216. /**
  108217. * @hidden
  108218. * Defines the actions happening just before a mesh is drawing.
  108219. */
  108220. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108221. /**
  108222. * @hidden
  108223. * Defines the actions happening just after a mesh has been drawn.
  108224. */
  108225. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108226. /**
  108227. * @hidden
  108228. * Defines the actions happening just after a rendering group has been drawn.
  108229. */
  108230. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108231. /**
  108232. * @hidden
  108233. * Defines the actions happening just after the active camera has been drawn.
  108234. */
  108235. _afterCameraDrawStage: Stage<CameraStageAction>;
  108236. /**
  108237. * @hidden
  108238. * Defines the actions happening just after a render target has been drawn.
  108239. */
  108240. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108241. /**
  108242. * @hidden
  108243. * Defines the actions happening just after rendering all cameras and computing intersections.
  108244. */
  108245. _afterRenderStage: Stage<SimpleStageAction>;
  108246. /**
  108247. * @hidden
  108248. * Defines the actions happening when a pointer move event happens.
  108249. */
  108250. _pointerMoveStage: Stage<PointerMoveStageAction>;
  108251. /**
  108252. * @hidden
  108253. * Defines the actions happening when a pointer down event happens.
  108254. */
  108255. _pointerDownStage: Stage<PointerUpDownStageAction>;
  108256. /**
  108257. * @hidden
  108258. * Defines the actions happening when a pointer up event happens.
  108259. */
  108260. _pointerUpStage: Stage<PointerUpDownStageAction>;
  108261. /**
  108262. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  108263. */
  108264. private geometriesByUniqueId;
  108265. /**
  108266. * Creates a new Scene
  108267. * @param engine defines the engine to use to render this scene
  108268. * @param options defines the scene options
  108269. */
  108270. constructor(engine: Engine, options?: SceneOptions);
  108271. /**
  108272. * Gets a string idenfifying the name of the class
  108273. * @returns "Scene" string
  108274. */
  108275. getClassName(): string;
  108276. private _defaultMeshCandidates;
  108277. /**
  108278. * @hidden
  108279. */
  108280. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108281. private _defaultSubMeshCandidates;
  108282. /**
  108283. * @hidden
  108284. */
  108285. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108286. /**
  108287. * Sets the default candidate providers for the scene.
  108288. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  108289. * and getCollidingSubMeshCandidates to their default function
  108290. */
  108291. setDefaultCandidateProviders(): void;
  108292. /**
  108293. * Gets the mesh that is currently under the pointer
  108294. */
  108295. get meshUnderPointer(): Nullable<AbstractMesh>;
  108296. /**
  108297. * Gets or sets the current on-screen X position of the pointer
  108298. */
  108299. get pointerX(): number;
  108300. set pointerX(value: number);
  108301. /**
  108302. * Gets or sets the current on-screen Y position of the pointer
  108303. */
  108304. get pointerY(): number;
  108305. set pointerY(value: number);
  108306. /**
  108307. * Gets the cached material (ie. the latest rendered one)
  108308. * @returns the cached material
  108309. */
  108310. getCachedMaterial(): Nullable<Material>;
  108311. /**
  108312. * Gets the cached effect (ie. the latest rendered one)
  108313. * @returns the cached effect
  108314. */
  108315. getCachedEffect(): Nullable<Effect>;
  108316. /**
  108317. * Gets the cached visibility state (ie. the latest rendered one)
  108318. * @returns the cached visibility state
  108319. */
  108320. getCachedVisibility(): Nullable<number>;
  108321. /**
  108322. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  108323. * @param material defines the current material
  108324. * @param effect defines the current effect
  108325. * @param visibility defines the current visibility state
  108326. * @returns true if one parameter is not cached
  108327. */
  108328. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  108329. /**
  108330. * Gets the engine associated with the scene
  108331. * @returns an Engine
  108332. */
  108333. getEngine(): Engine;
  108334. /**
  108335. * Gets the total number of vertices rendered per frame
  108336. * @returns the total number of vertices rendered per frame
  108337. */
  108338. getTotalVertices(): number;
  108339. /**
  108340. * Gets the performance counter for total vertices
  108341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108342. */
  108343. get totalVerticesPerfCounter(): PerfCounter;
  108344. /**
  108345. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  108346. * @returns the total number of active indices rendered per frame
  108347. */
  108348. getActiveIndices(): number;
  108349. /**
  108350. * Gets the performance counter for active indices
  108351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108352. */
  108353. get totalActiveIndicesPerfCounter(): PerfCounter;
  108354. /**
  108355. * Gets the total number of active particles rendered per frame
  108356. * @returns the total number of active particles rendered per frame
  108357. */
  108358. getActiveParticles(): number;
  108359. /**
  108360. * Gets the performance counter for active particles
  108361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108362. */
  108363. get activeParticlesPerfCounter(): PerfCounter;
  108364. /**
  108365. * Gets the total number of active bones rendered per frame
  108366. * @returns the total number of active bones rendered per frame
  108367. */
  108368. getActiveBones(): number;
  108369. /**
  108370. * Gets the performance counter for active bones
  108371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108372. */
  108373. get activeBonesPerfCounter(): PerfCounter;
  108374. /**
  108375. * Gets the array of active meshes
  108376. * @returns an array of AbstractMesh
  108377. */
  108378. getActiveMeshes(): SmartArray<AbstractMesh>;
  108379. /**
  108380. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  108381. * @returns a number
  108382. */
  108383. getAnimationRatio(): number;
  108384. /**
  108385. * Gets an unique Id for the current render phase
  108386. * @returns a number
  108387. */
  108388. getRenderId(): number;
  108389. /**
  108390. * Gets an unique Id for the current frame
  108391. * @returns a number
  108392. */
  108393. getFrameId(): number;
  108394. /** Call this function if you want to manually increment the render Id*/
  108395. incrementRenderId(): void;
  108396. private _createUbo;
  108397. /**
  108398. * Use this method to simulate a pointer move on a mesh
  108399. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108400. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108401. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108402. * @returns the current scene
  108403. */
  108404. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108405. /**
  108406. * Use this method to simulate a pointer down on a mesh
  108407. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108408. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108409. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108410. * @returns the current scene
  108411. */
  108412. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108413. /**
  108414. * Use this method to simulate a pointer up on a mesh
  108415. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108416. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108417. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108418. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108419. * @returns the current scene
  108420. */
  108421. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  108422. /**
  108423. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108424. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108425. * @returns true if the pointer was captured
  108426. */
  108427. isPointerCaptured(pointerId?: number): boolean;
  108428. /**
  108429. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108430. * @param attachUp defines if you want to attach events to pointerup
  108431. * @param attachDown defines if you want to attach events to pointerdown
  108432. * @param attachMove defines if you want to attach events to pointermove
  108433. */
  108434. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  108435. /** Detaches all event handlers*/
  108436. detachControl(): void;
  108437. /**
  108438. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  108439. * Delay loaded resources are not taking in account
  108440. * @return true if all required resources are ready
  108441. */
  108442. isReady(): boolean;
  108443. /** Resets all cached information relative to material (including effect and visibility) */
  108444. resetCachedMaterial(): void;
  108445. /**
  108446. * Registers a function to be called before every frame render
  108447. * @param func defines the function to register
  108448. */
  108449. registerBeforeRender(func: () => void): void;
  108450. /**
  108451. * Unregisters a function called before every frame render
  108452. * @param func defines the function to unregister
  108453. */
  108454. unregisterBeforeRender(func: () => void): void;
  108455. /**
  108456. * Registers a function to be called after every frame render
  108457. * @param func defines the function to register
  108458. */
  108459. registerAfterRender(func: () => void): void;
  108460. /**
  108461. * Unregisters a function called after every frame render
  108462. * @param func defines the function to unregister
  108463. */
  108464. unregisterAfterRender(func: () => void): void;
  108465. private _executeOnceBeforeRender;
  108466. /**
  108467. * The provided function will run before render once and will be disposed afterwards.
  108468. * A timeout delay can be provided so that the function will be executed in N ms.
  108469. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  108470. * @param func The function to be executed.
  108471. * @param timeout optional delay in ms
  108472. */
  108473. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  108474. /** @hidden */
  108475. _addPendingData(data: any): void;
  108476. /** @hidden */
  108477. _removePendingData(data: any): void;
  108478. /**
  108479. * Returns the number of items waiting to be loaded
  108480. * @returns the number of items waiting to be loaded
  108481. */
  108482. getWaitingItemsCount(): number;
  108483. /**
  108484. * Returns a boolean indicating if the scene is still loading data
  108485. */
  108486. get isLoading(): boolean;
  108487. /**
  108488. * Registers a function to be executed when the scene is ready
  108489. * @param {Function} func - the function to be executed
  108490. */
  108491. executeWhenReady(func: () => void): void;
  108492. /**
  108493. * Returns a promise that resolves when the scene is ready
  108494. * @returns A promise that resolves when the scene is ready
  108495. */
  108496. whenReadyAsync(): Promise<void>;
  108497. /** @hidden */
  108498. _checkIsReady(): void;
  108499. /**
  108500. * Gets all animatable attached to the scene
  108501. */
  108502. get animatables(): Animatable[];
  108503. /**
  108504. * Resets the last animation time frame.
  108505. * Useful to override when animations start running when loading a scene for the first time.
  108506. */
  108507. resetLastAnimationTimeFrame(): void;
  108508. /**
  108509. * Gets the current view matrix
  108510. * @returns a Matrix
  108511. */
  108512. getViewMatrix(): Matrix;
  108513. /**
  108514. * Gets the current projection matrix
  108515. * @returns a Matrix
  108516. */
  108517. getProjectionMatrix(): Matrix;
  108518. /**
  108519. * Gets the current transform matrix
  108520. * @returns a Matrix made of View * Projection
  108521. */
  108522. getTransformMatrix(): Matrix;
  108523. /**
  108524. * Sets the current transform matrix
  108525. * @param viewL defines the View matrix to use
  108526. * @param projectionL defines the Projection matrix to use
  108527. * @param viewR defines the right View matrix to use (if provided)
  108528. * @param projectionR defines the right Projection matrix to use (if provided)
  108529. */
  108530. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  108531. /**
  108532. * Gets the uniform buffer used to store scene data
  108533. * @returns a UniformBuffer
  108534. */
  108535. getSceneUniformBuffer(): UniformBuffer;
  108536. /**
  108537. * Gets an unique (relatively to the current scene) Id
  108538. * @returns an unique number for the scene
  108539. */
  108540. getUniqueId(): number;
  108541. /**
  108542. * Add a mesh to the list of scene's meshes
  108543. * @param newMesh defines the mesh to add
  108544. * @param recursive if all child meshes should also be added to the scene
  108545. */
  108546. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  108547. /**
  108548. * Remove a mesh for the list of scene's meshes
  108549. * @param toRemove defines the mesh to remove
  108550. * @param recursive if all child meshes should also be removed from the scene
  108551. * @returns the index where the mesh was in the mesh list
  108552. */
  108553. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  108554. /**
  108555. * Add a transform node to the list of scene's transform nodes
  108556. * @param newTransformNode defines the transform node to add
  108557. */
  108558. addTransformNode(newTransformNode: TransformNode): void;
  108559. /**
  108560. * Remove a transform node for the list of scene's transform nodes
  108561. * @param toRemove defines the transform node to remove
  108562. * @returns the index where the transform node was in the transform node list
  108563. */
  108564. removeTransformNode(toRemove: TransformNode): number;
  108565. /**
  108566. * Remove a skeleton for the list of scene's skeletons
  108567. * @param toRemove defines the skeleton to remove
  108568. * @returns the index where the skeleton was in the skeleton list
  108569. */
  108570. removeSkeleton(toRemove: Skeleton): number;
  108571. /**
  108572. * Remove a morph target for the list of scene's morph targets
  108573. * @param toRemove defines the morph target to remove
  108574. * @returns the index where the morph target was in the morph target list
  108575. */
  108576. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  108577. /**
  108578. * Remove a light for the list of scene's lights
  108579. * @param toRemove defines the light to remove
  108580. * @returns the index where the light was in the light list
  108581. */
  108582. removeLight(toRemove: Light): number;
  108583. /**
  108584. * Remove a camera for the list of scene's cameras
  108585. * @param toRemove defines the camera to remove
  108586. * @returns the index where the camera was in the camera list
  108587. */
  108588. removeCamera(toRemove: Camera): number;
  108589. /**
  108590. * Remove a particle system for the list of scene's particle systems
  108591. * @param toRemove defines the particle system to remove
  108592. * @returns the index where the particle system was in the particle system list
  108593. */
  108594. removeParticleSystem(toRemove: IParticleSystem): number;
  108595. /**
  108596. * Remove a animation for the list of scene's animations
  108597. * @param toRemove defines the animation to remove
  108598. * @returns the index where the animation was in the animation list
  108599. */
  108600. removeAnimation(toRemove: Animation): number;
  108601. /**
  108602. * Will stop the animation of the given target
  108603. * @param target - the target
  108604. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  108605. * @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)
  108606. */
  108607. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  108608. /**
  108609. * Removes the given animation group from this scene.
  108610. * @param toRemove The animation group to remove
  108611. * @returns The index of the removed animation group
  108612. */
  108613. removeAnimationGroup(toRemove: AnimationGroup): number;
  108614. /**
  108615. * Removes the given multi-material from this scene.
  108616. * @param toRemove The multi-material to remove
  108617. * @returns The index of the removed multi-material
  108618. */
  108619. removeMultiMaterial(toRemove: MultiMaterial): number;
  108620. /**
  108621. * Removes the given material from this scene.
  108622. * @param toRemove The material to remove
  108623. * @returns The index of the removed material
  108624. */
  108625. removeMaterial(toRemove: Material): number;
  108626. /**
  108627. * Removes the given action manager from this scene.
  108628. * @param toRemove The action manager to remove
  108629. * @returns The index of the removed action manager
  108630. */
  108631. removeActionManager(toRemove: AbstractActionManager): number;
  108632. /**
  108633. * Removes the given texture from this scene.
  108634. * @param toRemove The texture to remove
  108635. * @returns The index of the removed texture
  108636. */
  108637. removeTexture(toRemove: BaseTexture): number;
  108638. /**
  108639. * Adds the given light to this scene
  108640. * @param newLight The light to add
  108641. */
  108642. addLight(newLight: Light): void;
  108643. /**
  108644. * Sorts the list list based on light priorities
  108645. */
  108646. sortLightsByPriority(): void;
  108647. /**
  108648. * Adds the given camera to this scene
  108649. * @param newCamera The camera to add
  108650. */
  108651. addCamera(newCamera: Camera): void;
  108652. /**
  108653. * Adds the given skeleton to this scene
  108654. * @param newSkeleton The skeleton to add
  108655. */
  108656. addSkeleton(newSkeleton: Skeleton): void;
  108657. /**
  108658. * Adds the given particle system to this scene
  108659. * @param newParticleSystem The particle system to add
  108660. */
  108661. addParticleSystem(newParticleSystem: IParticleSystem): void;
  108662. /**
  108663. * Adds the given animation to this scene
  108664. * @param newAnimation The animation to add
  108665. */
  108666. addAnimation(newAnimation: Animation): void;
  108667. /**
  108668. * Adds the given animation group to this scene.
  108669. * @param newAnimationGroup The animation group to add
  108670. */
  108671. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  108672. /**
  108673. * Adds the given multi-material to this scene
  108674. * @param newMultiMaterial The multi-material to add
  108675. */
  108676. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  108677. /**
  108678. * Adds the given material to this scene
  108679. * @param newMaterial The material to add
  108680. */
  108681. addMaterial(newMaterial: Material): void;
  108682. /**
  108683. * Adds the given morph target to this scene
  108684. * @param newMorphTargetManager The morph target to add
  108685. */
  108686. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  108687. /**
  108688. * Adds the given geometry to this scene
  108689. * @param newGeometry The geometry to add
  108690. */
  108691. addGeometry(newGeometry: Geometry): void;
  108692. /**
  108693. * Adds the given action manager to this scene
  108694. * @param newActionManager The action manager to add
  108695. */
  108696. addActionManager(newActionManager: AbstractActionManager): void;
  108697. /**
  108698. * Adds the given texture to this scene.
  108699. * @param newTexture The texture to add
  108700. */
  108701. addTexture(newTexture: BaseTexture): void;
  108702. /**
  108703. * Switch active camera
  108704. * @param newCamera defines the new active camera
  108705. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  108706. */
  108707. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  108708. /**
  108709. * sets the active camera of the scene using its ID
  108710. * @param id defines the camera's ID
  108711. * @return the new active camera or null if none found.
  108712. */
  108713. setActiveCameraByID(id: string): Nullable<Camera>;
  108714. /**
  108715. * sets the active camera of the scene using its name
  108716. * @param name defines the camera's name
  108717. * @returns the new active camera or null if none found.
  108718. */
  108719. setActiveCameraByName(name: string): Nullable<Camera>;
  108720. /**
  108721. * get an animation group using its name
  108722. * @param name defines the material's name
  108723. * @return the animation group or null if none found.
  108724. */
  108725. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  108726. /**
  108727. * Get a material using its unique id
  108728. * @param uniqueId defines the material's unique id
  108729. * @return the material or null if none found.
  108730. */
  108731. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  108732. /**
  108733. * get a material using its id
  108734. * @param id defines the material's ID
  108735. * @return the material or null if none found.
  108736. */
  108737. getMaterialByID(id: string): Nullable<Material>;
  108738. /**
  108739. * Gets a the last added material using a given id
  108740. * @param id defines the material's ID
  108741. * @return the last material with the given id or null if none found.
  108742. */
  108743. getLastMaterialByID(id: string): Nullable<Material>;
  108744. /**
  108745. * Gets a material using its name
  108746. * @param name defines the material's name
  108747. * @return the material or null if none found.
  108748. */
  108749. getMaterialByName(name: string): Nullable<Material>;
  108750. /**
  108751. * Get a texture using its unique id
  108752. * @param uniqueId defines the texture's unique id
  108753. * @return the texture or null if none found.
  108754. */
  108755. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  108756. /**
  108757. * Gets a camera using its id
  108758. * @param id defines the id to look for
  108759. * @returns the camera or null if not found
  108760. */
  108761. getCameraByID(id: string): Nullable<Camera>;
  108762. /**
  108763. * Gets a camera using its unique id
  108764. * @param uniqueId defines the unique id to look for
  108765. * @returns the camera or null if not found
  108766. */
  108767. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  108768. /**
  108769. * Gets a camera using its name
  108770. * @param name defines the camera's name
  108771. * @return the camera or null if none found.
  108772. */
  108773. getCameraByName(name: string): Nullable<Camera>;
  108774. /**
  108775. * Gets a bone using its id
  108776. * @param id defines the bone's id
  108777. * @return the bone or null if not found
  108778. */
  108779. getBoneByID(id: string): Nullable<Bone>;
  108780. /**
  108781. * Gets a bone using its id
  108782. * @param name defines the bone's name
  108783. * @return the bone or null if not found
  108784. */
  108785. getBoneByName(name: string): Nullable<Bone>;
  108786. /**
  108787. * Gets a light node using its name
  108788. * @param name defines the the light's name
  108789. * @return the light or null if none found.
  108790. */
  108791. getLightByName(name: string): Nullable<Light>;
  108792. /**
  108793. * Gets a light node using its id
  108794. * @param id defines the light's id
  108795. * @return the light or null if none found.
  108796. */
  108797. getLightByID(id: string): Nullable<Light>;
  108798. /**
  108799. * Gets a light node using its scene-generated unique ID
  108800. * @param uniqueId defines the light's unique id
  108801. * @return the light or null if none found.
  108802. */
  108803. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  108804. /**
  108805. * Gets a particle system by id
  108806. * @param id defines the particle system id
  108807. * @return the corresponding system or null if none found
  108808. */
  108809. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  108810. /**
  108811. * Gets a geometry using its ID
  108812. * @param id defines the geometry's id
  108813. * @return the geometry or null if none found.
  108814. */
  108815. getGeometryByID(id: string): Nullable<Geometry>;
  108816. private _getGeometryByUniqueID;
  108817. /**
  108818. * Add a new geometry to this scene
  108819. * @param geometry defines the geometry to be added to the scene.
  108820. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  108821. * @return a boolean defining if the geometry was added or not
  108822. */
  108823. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  108824. /**
  108825. * Removes an existing geometry
  108826. * @param geometry defines the geometry to be removed from the scene
  108827. * @return a boolean defining if the geometry was removed or not
  108828. */
  108829. removeGeometry(geometry: Geometry): boolean;
  108830. /**
  108831. * Gets the list of geometries attached to the scene
  108832. * @returns an array of Geometry
  108833. */
  108834. getGeometries(): Geometry[];
  108835. /**
  108836. * Gets the first added mesh found of a given ID
  108837. * @param id defines the id to search for
  108838. * @return the mesh found or null if not found at all
  108839. */
  108840. getMeshByID(id: string): Nullable<AbstractMesh>;
  108841. /**
  108842. * Gets a list of meshes using their id
  108843. * @param id defines the id to search for
  108844. * @returns a list of meshes
  108845. */
  108846. getMeshesByID(id: string): Array<AbstractMesh>;
  108847. /**
  108848. * Gets the first added transform node found of a given ID
  108849. * @param id defines the id to search for
  108850. * @return the found transform node or null if not found at all.
  108851. */
  108852. getTransformNodeByID(id: string): Nullable<TransformNode>;
  108853. /**
  108854. * Gets a transform node with its auto-generated unique id
  108855. * @param uniqueId efines the unique id to search for
  108856. * @return the found transform node or null if not found at all.
  108857. */
  108858. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  108859. /**
  108860. * Gets a list of transform nodes using their id
  108861. * @param id defines the id to search for
  108862. * @returns a list of transform nodes
  108863. */
  108864. getTransformNodesByID(id: string): Array<TransformNode>;
  108865. /**
  108866. * Gets a mesh with its auto-generated unique id
  108867. * @param uniqueId defines the unique id to search for
  108868. * @return the found mesh or null if not found at all.
  108869. */
  108870. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  108871. /**
  108872. * Gets a the last added mesh using a given id
  108873. * @param id defines the id to search for
  108874. * @return the found mesh or null if not found at all.
  108875. */
  108876. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  108877. /**
  108878. * Gets a the last added node (Mesh, Camera, Light) using a given id
  108879. * @param id defines the id to search for
  108880. * @return the found node or null if not found at all
  108881. */
  108882. getLastEntryByID(id: string): Nullable<Node>;
  108883. /**
  108884. * Gets a node (Mesh, Camera, Light) using a given id
  108885. * @param id defines the id to search for
  108886. * @return the found node or null if not found at all
  108887. */
  108888. getNodeByID(id: string): Nullable<Node>;
  108889. /**
  108890. * Gets a node (Mesh, Camera, Light) using a given name
  108891. * @param name defines the name to search for
  108892. * @return the found node or null if not found at all.
  108893. */
  108894. getNodeByName(name: string): Nullable<Node>;
  108895. /**
  108896. * Gets a mesh using a given name
  108897. * @param name defines the name to search for
  108898. * @return the found mesh or null if not found at all.
  108899. */
  108900. getMeshByName(name: string): Nullable<AbstractMesh>;
  108901. /**
  108902. * Gets a transform node using a given name
  108903. * @param name defines the name to search for
  108904. * @return the found transform node or null if not found at all.
  108905. */
  108906. getTransformNodeByName(name: string): Nullable<TransformNode>;
  108907. /**
  108908. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  108909. * @param id defines the id to search for
  108910. * @return the found skeleton or null if not found at all.
  108911. */
  108912. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  108913. /**
  108914. * Gets a skeleton using a given auto generated unique id
  108915. * @param uniqueId defines the unique id to search for
  108916. * @return the found skeleton or null if not found at all.
  108917. */
  108918. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  108919. /**
  108920. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  108921. * @param id defines the id to search for
  108922. * @return the found skeleton or null if not found at all.
  108923. */
  108924. getSkeletonById(id: string): Nullable<Skeleton>;
  108925. /**
  108926. * Gets a skeleton using a given name
  108927. * @param name defines the name to search for
  108928. * @return the found skeleton or null if not found at all.
  108929. */
  108930. getSkeletonByName(name: string): Nullable<Skeleton>;
  108931. /**
  108932. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  108933. * @param id defines the id to search for
  108934. * @return the found morph target manager or null if not found at all.
  108935. */
  108936. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  108937. /**
  108938. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  108939. * @param id defines the id to search for
  108940. * @return the found morph target or null if not found at all.
  108941. */
  108942. getMorphTargetById(id: string): Nullable<MorphTarget>;
  108943. /**
  108944. * Gets a boolean indicating if the given mesh is active
  108945. * @param mesh defines the mesh to look for
  108946. * @returns true if the mesh is in the active list
  108947. */
  108948. isActiveMesh(mesh: AbstractMesh): boolean;
  108949. /**
  108950. * Return a unique id as a string which can serve as an identifier for the scene
  108951. */
  108952. get uid(): string;
  108953. /**
  108954. * Add an externaly attached data from its key.
  108955. * This method call will fail and return false, if such key already exists.
  108956. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  108957. * @param key the unique key that identifies the data
  108958. * @param data the data object to associate to the key for this Engine instance
  108959. * @return true if no such key were already present and the data was added successfully, false otherwise
  108960. */
  108961. addExternalData<T>(key: string, data: T): boolean;
  108962. /**
  108963. * Get an externaly attached data from its key
  108964. * @param key the unique key that identifies the data
  108965. * @return the associated data, if present (can be null), or undefined if not present
  108966. */
  108967. getExternalData<T>(key: string): Nullable<T>;
  108968. /**
  108969. * Get an externaly attached data from its key, create it using a factory if it's not already present
  108970. * @param key the unique key that identifies the data
  108971. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  108972. * @return the associated data, can be null if the factory returned null.
  108973. */
  108974. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  108975. /**
  108976. * Remove an externaly attached data from the Engine instance
  108977. * @param key the unique key that identifies the data
  108978. * @return true if the data was successfully removed, false if it doesn't exist
  108979. */
  108980. removeExternalData(key: string): boolean;
  108981. private _evaluateSubMesh;
  108982. /**
  108983. * Clear the processed materials smart array preventing retention point in material dispose.
  108984. */
  108985. freeProcessedMaterials(): void;
  108986. private _preventFreeActiveMeshesAndRenderingGroups;
  108987. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  108988. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  108989. * when disposing several meshes in a row or a hierarchy of meshes.
  108990. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  108991. */
  108992. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  108993. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  108994. /**
  108995. * Clear the active meshes smart array preventing retention point in mesh dispose.
  108996. */
  108997. freeActiveMeshes(): void;
  108998. /**
  108999. * Clear the info related to rendering groups preventing retention points during dispose.
  109000. */
  109001. freeRenderingGroups(): void;
  109002. /** @hidden */
  109003. _isInIntermediateRendering(): boolean;
  109004. /**
  109005. * Lambda returning the list of potentially active meshes.
  109006. */
  109007. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109008. /**
  109009. * Lambda returning the list of potentially active sub meshes.
  109010. */
  109011. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109012. /**
  109013. * Lambda returning the list of potentially intersecting sub meshes.
  109014. */
  109015. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109016. /**
  109017. * Lambda returning the list of potentially colliding sub meshes.
  109018. */
  109019. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109020. private _activeMeshesFrozen;
  109021. private _skipEvaluateActiveMeshesCompletely;
  109022. /**
  109023. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109024. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109025. * @returns the current scene
  109026. */
  109027. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109028. /**
  109029. * Use this function to restart evaluating active meshes on every frame
  109030. * @returns the current scene
  109031. */
  109032. unfreezeActiveMeshes(): Scene;
  109033. private _evaluateActiveMeshes;
  109034. private _activeMesh;
  109035. /**
  109036. * Update the transform matrix to update from the current active camera
  109037. * @param force defines a boolean used to force the update even if cache is up to date
  109038. */
  109039. updateTransformMatrix(force?: boolean): void;
  109040. private _bindFrameBuffer;
  109041. /** @hidden */
  109042. _allowPostProcessClearColor: boolean;
  109043. /** @hidden */
  109044. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109045. private _processSubCameras;
  109046. private _checkIntersections;
  109047. /** @hidden */
  109048. _advancePhysicsEngineStep(step: number): void;
  109049. /**
  109050. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109051. */
  109052. getDeterministicFrameTime: () => number;
  109053. /** @hidden */
  109054. _animate(): void;
  109055. /** Execute all animations (for a frame) */
  109056. animate(): void;
  109057. /**
  109058. * Render the scene
  109059. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109060. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109061. */
  109062. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109063. /**
  109064. * Freeze all materials
  109065. * A frozen material will not be updatable but should be faster to render
  109066. */
  109067. freezeMaterials(): void;
  109068. /**
  109069. * Unfreeze all materials
  109070. * A frozen material will not be updatable but should be faster to render
  109071. */
  109072. unfreezeMaterials(): void;
  109073. /**
  109074. * Releases all held ressources
  109075. */
  109076. dispose(): void;
  109077. /**
  109078. * Gets if the scene is already disposed
  109079. */
  109080. get isDisposed(): boolean;
  109081. /**
  109082. * Call this function to reduce memory footprint of the scene.
  109083. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109084. */
  109085. clearCachedVertexData(): void;
  109086. /**
  109087. * This function will remove the local cached buffer data from texture.
  109088. * It will save memory but will prevent the texture from being rebuilt
  109089. */
  109090. cleanCachedTextureBuffer(): void;
  109091. /**
  109092. * Get the world extend vectors with an optional filter
  109093. *
  109094. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109095. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109096. */
  109097. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109098. min: Vector3;
  109099. max: Vector3;
  109100. };
  109101. /**
  109102. * Creates a ray that can be used to pick in the scene
  109103. * @param x defines the x coordinate of the origin (on-screen)
  109104. * @param y defines the y coordinate of the origin (on-screen)
  109105. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109106. * @param camera defines the camera to use for the picking
  109107. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109108. * @returns a Ray
  109109. */
  109110. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109111. /**
  109112. * Creates a ray that can be used to pick in the scene
  109113. * @param x defines the x coordinate of the origin (on-screen)
  109114. * @param y defines the y coordinate of the origin (on-screen)
  109115. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109116. * @param result defines the ray where to store the picking ray
  109117. * @param camera defines the camera to use for the picking
  109118. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109119. * @returns the current scene
  109120. */
  109121. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  109122. /**
  109123. * Creates a ray that can be used to pick in the scene
  109124. * @param x defines the x coordinate of the origin (on-screen)
  109125. * @param y defines the y coordinate of the origin (on-screen)
  109126. * @param camera defines the camera to use for the picking
  109127. * @returns a Ray
  109128. */
  109129. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  109130. /**
  109131. * Creates a ray that can be used to pick in the scene
  109132. * @param x defines the x coordinate of the origin (on-screen)
  109133. * @param y defines the y coordinate of the origin (on-screen)
  109134. * @param result defines the ray where to store the picking ray
  109135. * @param camera defines the camera to use for the picking
  109136. * @returns the current scene
  109137. */
  109138. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  109139. /** Launch a ray to try to pick a mesh in the scene
  109140. * @param x position on screen
  109141. * @param y position on screen
  109142. * @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
  109143. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  109144. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109145. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109146. * @returns a PickingInfo
  109147. */
  109148. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109149. /** Use the given ray to pick a mesh in the scene
  109150. * @param ray The ray to use to pick meshes
  109151. * @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
  109152. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  109153. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109154. * @returns a PickingInfo
  109155. */
  109156. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109157. /**
  109158. * Launch a ray to try to pick a mesh in the scene
  109159. * @param x X position on screen
  109160. * @param y Y position on screen
  109161. * @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
  109162. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109163. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109164. * @returns an array of PickingInfo
  109165. */
  109166. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109167. /**
  109168. * Launch a ray to try to pick a mesh in the scene
  109169. * @param ray Ray to use
  109170. * @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
  109171. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109172. * @returns an array of PickingInfo
  109173. */
  109174. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109175. /**
  109176. * Force the value of meshUnderPointer
  109177. * @param mesh defines the mesh to use
  109178. */
  109179. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109180. /**
  109181. * Gets the mesh under the pointer
  109182. * @returns a Mesh or null if no mesh is under the pointer
  109183. */
  109184. getPointerOverMesh(): Nullable<AbstractMesh>;
  109185. /** @hidden */
  109186. _rebuildGeometries(): void;
  109187. /** @hidden */
  109188. _rebuildTextures(): void;
  109189. private _getByTags;
  109190. /**
  109191. * Get a list of meshes by tags
  109192. * @param tagsQuery defines the tags query to use
  109193. * @param forEach defines a predicate used to filter results
  109194. * @returns an array of Mesh
  109195. */
  109196. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  109197. /**
  109198. * Get a list of cameras by tags
  109199. * @param tagsQuery defines the tags query to use
  109200. * @param forEach defines a predicate used to filter results
  109201. * @returns an array of Camera
  109202. */
  109203. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  109204. /**
  109205. * Get a list of lights by tags
  109206. * @param tagsQuery defines the tags query to use
  109207. * @param forEach defines a predicate used to filter results
  109208. * @returns an array of Light
  109209. */
  109210. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  109211. /**
  109212. * Get a list of materials by tags
  109213. * @param tagsQuery defines the tags query to use
  109214. * @param forEach defines a predicate used to filter results
  109215. * @returns an array of Material
  109216. */
  109217. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  109218. /**
  109219. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109220. * This allowed control for front to back rendering or reversly depending of the special needs.
  109221. *
  109222. * @param renderingGroupId The rendering group id corresponding to its index
  109223. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109224. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109225. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109226. */
  109227. 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;
  109228. /**
  109229. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109230. *
  109231. * @param renderingGroupId The rendering group id corresponding to its index
  109232. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109233. * @param depth Automatically clears depth between groups if true and autoClear is true.
  109234. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  109235. */
  109236. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  109237. /**
  109238. * Gets the current auto clear configuration for one rendering group of the rendering
  109239. * manager.
  109240. * @param index the rendering group index to get the information for
  109241. * @returns The auto clear setup for the requested rendering group
  109242. */
  109243. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  109244. private _blockMaterialDirtyMechanism;
  109245. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  109246. get blockMaterialDirtyMechanism(): boolean;
  109247. set blockMaterialDirtyMechanism(value: boolean);
  109248. /**
  109249. * Will flag all materials as dirty to trigger new shader compilation
  109250. * @param flag defines the flag used to specify which material part must be marked as dirty
  109251. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  109252. */
  109253. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109254. /** @hidden */
  109255. _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;
  109256. /** @hidden */
  109257. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109258. /** @hidden */
  109259. _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;
  109260. /** @hidden */
  109261. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  109262. /** @hidden */
  109263. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  109264. /** @hidden */
  109265. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109266. }
  109267. }
  109268. declare module BABYLON {
  109269. /**
  109270. * Set of assets to keep when moving a scene into an asset container.
  109271. */
  109272. export class KeepAssets extends AbstractScene {
  109273. }
  109274. /**
  109275. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  109276. */
  109277. export class InstantiatedEntries {
  109278. /**
  109279. * List of new root nodes (eg. nodes with no parent)
  109280. */
  109281. rootNodes: TransformNode[];
  109282. /**
  109283. * List of new skeletons
  109284. */
  109285. skeletons: Skeleton[];
  109286. /**
  109287. * List of new animation groups
  109288. */
  109289. animationGroups: AnimationGroup[];
  109290. }
  109291. /**
  109292. * Container with a set of assets that can be added or removed from a scene.
  109293. */
  109294. export class AssetContainer extends AbstractScene {
  109295. /**
  109296. * The scene the AssetContainer belongs to.
  109297. */
  109298. scene: Scene;
  109299. /**
  109300. * Instantiates an AssetContainer.
  109301. * @param scene The scene the AssetContainer belongs to.
  109302. */
  109303. constructor(scene: Scene);
  109304. /**
  109305. * Instantiate or clone all meshes and add the new ones to the scene.
  109306. * Skeletons and animation groups will all be cloned
  109307. * @param nameFunction defines an optional function used to get new names for clones
  109308. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  109309. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  109310. */
  109311. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  109312. /**
  109313. * Adds all the assets from the container to the scene.
  109314. */
  109315. addAllToScene(): void;
  109316. /**
  109317. * Removes all the assets in the container from the scene
  109318. */
  109319. removeAllFromScene(): void;
  109320. /**
  109321. * Disposes all the assets in the container
  109322. */
  109323. dispose(): void;
  109324. private _moveAssets;
  109325. /**
  109326. * Removes all the assets contained in the scene and adds them to the container.
  109327. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  109328. */
  109329. moveAllFromScene(keepAssets?: KeepAssets): void;
  109330. /**
  109331. * 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.
  109332. * @returns the root mesh
  109333. */
  109334. createRootMesh(): Mesh;
  109335. /**
  109336. * Merge animations from this asset container into a scene
  109337. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109338. * @param animatables set of animatables to retarget to a node from the scene
  109339. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  109340. */
  109341. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  109342. }
  109343. }
  109344. declare module BABYLON {
  109345. /**
  109346. * Defines how the parser contract is defined.
  109347. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  109348. */
  109349. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  109350. /**
  109351. * Defines how the individual parser contract is defined.
  109352. * These parser can parse an individual asset
  109353. */
  109354. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  109355. /**
  109356. * Base class of the scene acting as a container for the different elements composing a scene.
  109357. * This class is dynamically extended by the different components of the scene increasing
  109358. * flexibility and reducing coupling
  109359. */
  109360. export abstract class AbstractScene {
  109361. /**
  109362. * Stores the list of available parsers in the application.
  109363. */
  109364. private static _BabylonFileParsers;
  109365. /**
  109366. * Stores the list of available individual parsers in the application.
  109367. */
  109368. private static _IndividualBabylonFileParsers;
  109369. /**
  109370. * Adds a parser in the list of available ones
  109371. * @param name Defines the name of the parser
  109372. * @param parser Defines the parser to add
  109373. */
  109374. static AddParser(name: string, parser: BabylonFileParser): void;
  109375. /**
  109376. * Gets a general parser from the list of avaialble ones
  109377. * @param name Defines the name of the parser
  109378. * @returns the requested parser or null
  109379. */
  109380. static GetParser(name: string): Nullable<BabylonFileParser>;
  109381. /**
  109382. * Adds n individual parser in the list of available ones
  109383. * @param name Defines the name of the parser
  109384. * @param parser Defines the parser to add
  109385. */
  109386. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  109387. /**
  109388. * Gets an individual parser from the list of avaialble ones
  109389. * @param name Defines the name of the parser
  109390. * @returns the requested parser or null
  109391. */
  109392. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  109393. /**
  109394. * Parser json data and populate both a scene and its associated container object
  109395. * @param jsonData Defines the data to parse
  109396. * @param scene Defines the scene to parse the data for
  109397. * @param container Defines the container attached to the parsing sequence
  109398. * @param rootUrl Defines the root url of the data
  109399. */
  109400. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  109401. /**
  109402. * Gets the list of root nodes (ie. nodes with no parent)
  109403. */
  109404. rootNodes: Node[];
  109405. /** All of the cameras added to this scene
  109406. * @see http://doc.babylonjs.com/babylon101/cameras
  109407. */
  109408. cameras: Camera[];
  109409. /**
  109410. * All of the lights added to this scene
  109411. * @see http://doc.babylonjs.com/babylon101/lights
  109412. */
  109413. lights: Light[];
  109414. /**
  109415. * All of the (abstract) meshes added to this scene
  109416. */
  109417. meshes: AbstractMesh[];
  109418. /**
  109419. * The list of skeletons added to the scene
  109420. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109421. */
  109422. skeletons: Skeleton[];
  109423. /**
  109424. * All of the particle systems added to this scene
  109425. * @see http://doc.babylonjs.com/babylon101/particles
  109426. */
  109427. particleSystems: IParticleSystem[];
  109428. /**
  109429. * Gets a list of Animations associated with the scene
  109430. */
  109431. animations: Animation[];
  109432. /**
  109433. * All of the animation groups added to this scene
  109434. * @see http://doc.babylonjs.com/how_to/group
  109435. */
  109436. animationGroups: AnimationGroup[];
  109437. /**
  109438. * All of the multi-materials added to this scene
  109439. * @see http://doc.babylonjs.com/how_to/multi_materials
  109440. */
  109441. multiMaterials: MultiMaterial[];
  109442. /**
  109443. * All of the materials added to this scene
  109444. * In the context of a Scene, it is not supposed to be modified manually.
  109445. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  109446. * Note also that the order of the Material within the array is not significant and might change.
  109447. * @see http://doc.babylonjs.com/babylon101/materials
  109448. */
  109449. materials: Material[];
  109450. /**
  109451. * The list of morph target managers added to the scene
  109452. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  109453. */
  109454. morphTargetManagers: MorphTargetManager[];
  109455. /**
  109456. * The list of geometries used in the scene.
  109457. */
  109458. geometries: Geometry[];
  109459. /**
  109460. * All of the tranform nodes added to this scene
  109461. * In the context of a Scene, it is not supposed to be modified manually.
  109462. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  109463. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  109464. * @see http://doc.babylonjs.com/how_to/transformnode
  109465. */
  109466. transformNodes: TransformNode[];
  109467. /**
  109468. * ActionManagers available on the scene.
  109469. */
  109470. actionManagers: AbstractActionManager[];
  109471. /**
  109472. * Textures to keep.
  109473. */
  109474. textures: BaseTexture[];
  109475. /**
  109476. * Environment texture for the scene
  109477. */
  109478. environmentTexture: Nullable<BaseTexture>;
  109479. /**
  109480. * @returns all meshes, lights, cameras, transformNodes and bones
  109481. */
  109482. getNodes(): Array<Node>;
  109483. }
  109484. }
  109485. declare module BABYLON {
  109486. /**
  109487. * Interface used to define options for Sound class
  109488. */
  109489. export interface ISoundOptions {
  109490. /**
  109491. * Does the sound autoplay once loaded.
  109492. */
  109493. autoplay?: boolean;
  109494. /**
  109495. * Does the sound loop after it finishes playing once.
  109496. */
  109497. loop?: boolean;
  109498. /**
  109499. * Sound's volume
  109500. */
  109501. volume?: number;
  109502. /**
  109503. * Is it a spatial sound?
  109504. */
  109505. spatialSound?: boolean;
  109506. /**
  109507. * Maximum distance to hear that sound
  109508. */
  109509. maxDistance?: number;
  109510. /**
  109511. * Uses user defined attenuation function
  109512. */
  109513. useCustomAttenuation?: boolean;
  109514. /**
  109515. * Define the roll off factor of spatial sounds.
  109516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109517. */
  109518. rolloffFactor?: number;
  109519. /**
  109520. * Define the reference distance the sound should be heard perfectly.
  109521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109522. */
  109523. refDistance?: number;
  109524. /**
  109525. * Define the distance attenuation model the sound will follow.
  109526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109527. */
  109528. distanceModel?: string;
  109529. /**
  109530. * Defines the playback speed (1 by default)
  109531. */
  109532. playbackRate?: number;
  109533. /**
  109534. * Defines if the sound is from a streaming source
  109535. */
  109536. streaming?: boolean;
  109537. /**
  109538. * Defines an optional length (in seconds) inside the sound file
  109539. */
  109540. length?: number;
  109541. /**
  109542. * Defines an optional offset (in seconds) inside the sound file
  109543. */
  109544. offset?: number;
  109545. /**
  109546. * If true, URLs will not be required to state the audio file codec to use.
  109547. */
  109548. skipCodecCheck?: boolean;
  109549. }
  109550. /**
  109551. * Defines a sound that can be played in the application.
  109552. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  109553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109554. */
  109555. export class Sound {
  109556. /**
  109557. * The name of the sound in the scene.
  109558. */
  109559. name: string;
  109560. /**
  109561. * Does the sound autoplay once loaded.
  109562. */
  109563. autoplay: boolean;
  109564. /**
  109565. * Does the sound loop after it finishes playing once.
  109566. */
  109567. loop: boolean;
  109568. /**
  109569. * Does the sound use a custom attenuation curve to simulate the falloff
  109570. * happening when the source gets further away from the camera.
  109571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  109572. */
  109573. useCustomAttenuation: boolean;
  109574. /**
  109575. * The sound track id this sound belongs to.
  109576. */
  109577. soundTrackId: number;
  109578. /**
  109579. * Is this sound currently played.
  109580. */
  109581. isPlaying: boolean;
  109582. /**
  109583. * Is this sound currently paused.
  109584. */
  109585. isPaused: boolean;
  109586. /**
  109587. * Does this sound enables spatial sound.
  109588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109589. */
  109590. spatialSound: boolean;
  109591. /**
  109592. * Define the reference distance the sound should be heard perfectly.
  109593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109594. */
  109595. refDistance: number;
  109596. /**
  109597. * Define the roll off factor of spatial sounds.
  109598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109599. */
  109600. rolloffFactor: number;
  109601. /**
  109602. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  109603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109604. */
  109605. maxDistance: number;
  109606. /**
  109607. * Define the distance attenuation model the sound will follow.
  109608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109609. */
  109610. distanceModel: string;
  109611. /**
  109612. * @hidden
  109613. * Back Compat
  109614. **/
  109615. onended: () => any;
  109616. /**
  109617. * Observable event when the current playing sound finishes.
  109618. */
  109619. onEndedObservable: Observable<Sound>;
  109620. private _panningModel;
  109621. private _playbackRate;
  109622. private _streaming;
  109623. private _startTime;
  109624. private _startOffset;
  109625. private _position;
  109626. /** @hidden */
  109627. _positionInEmitterSpace: boolean;
  109628. private _localDirection;
  109629. private _volume;
  109630. private _isReadyToPlay;
  109631. private _isDirectional;
  109632. private _readyToPlayCallback;
  109633. private _audioBuffer;
  109634. private _soundSource;
  109635. private _streamingSource;
  109636. private _soundPanner;
  109637. private _soundGain;
  109638. private _inputAudioNode;
  109639. private _outputAudioNode;
  109640. private _coneInnerAngle;
  109641. private _coneOuterAngle;
  109642. private _coneOuterGain;
  109643. private _scene;
  109644. private _connectedTransformNode;
  109645. private _customAttenuationFunction;
  109646. private _registerFunc;
  109647. private _isOutputConnected;
  109648. private _htmlAudioElement;
  109649. private _urlType;
  109650. private _length?;
  109651. private _offset?;
  109652. /** @hidden */
  109653. static _SceneComponentInitialization: (scene: Scene) => void;
  109654. /**
  109655. * Create a sound and attach it to a scene
  109656. * @param name Name of your sound
  109657. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  109658. * @param scene defines the scene the sound belongs to
  109659. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  109660. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  109661. */
  109662. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  109663. /**
  109664. * Release the sound and its associated resources
  109665. */
  109666. dispose(): void;
  109667. /**
  109668. * Gets if the sounds is ready to be played or not.
  109669. * @returns true if ready, otherwise false
  109670. */
  109671. isReady(): boolean;
  109672. private _soundLoaded;
  109673. /**
  109674. * Sets the data of the sound from an audiobuffer
  109675. * @param audioBuffer The audioBuffer containing the data
  109676. */
  109677. setAudioBuffer(audioBuffer: AudioBuffer): void;
  109678. /**
  109679. * Updates the current sounds options such as maxdistance, loop...
  109680. * @param options A JSON object containing values named as the object properties
  109681. */
  109682. updateOptions(options: ISoundOptions): void;
  109683. private _createSpatialParameters;
  109684. private _updateSpatialParameters;
  109685. /**
  109686. * Switch the panning model to HRTF:
  109687. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  109688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109689. */
  109690. switchPanningModelToHRTF(): void;
  109691. /**
  109692. * Switch the panning model to Equal Power:
  109693. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  109694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109695. */
  109696. switchPanningModelToEqualPower(): void;
  109697. private _switchPanningModel;
  109698. /**
  109699. * Connect this sound to a sound track audio node like gain...
  109700. * @param soundTrackAudioNode the sound track audio node to connect to
  109701. */
  109702. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  109703. /**
  109704. * Transform this sound into a directional source
  109705. * @param coneInnerAngle Size of the inner cone in degree
  109706. * @param coneOuterAngle Size of the outer cone in degree
  109707. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  109708. */
  109709. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  109710. /**
  109711. * Gets or sets the inner angle for the directional cone.
  109712. */
  109713. get directionalConeInnerAngle(): number;
  109714. /**
  109715. * Gets or sets the inner angle for the directional cone.
  109716. */
  109717. set directionalConeInnerAngle(value: number);
  109718. /**
  109719. * Gets or sets the outer angle for the directional cone.
  109720. */
  109721. get directionalConeOuterAngle(): number;
  109722. /**
  109723. * Gets or sets the outer angle for the directional cone.
  109724. */
  109725. set directionalConeOuterAngle(value: number);
  109726. /**
  109727. * Sets the position of the emitter if spatial sound is enabled
  109728. * @param newPosition Defines the new posisiton
  109729. */
  109730. setPosition(newPosition: Vector3): void;
  109731. /**
  109732. * Sets the local direction of the emitter if spatial sound is enabled
  109733. * @param newLocalDirection Defines the new local direction
  109734. */
  109735. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  109736. private _updateDirection;
  109737. /** @hidden */
  109738. updateDistanceFromListener(): void;
  109739. /**
  109740. * Sets a new custom attenuation function for the sound.
  109741. * @param callback Defines the function used for the attenuation
  109742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  109743. */
  109744. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  109745. /**
  109746. * Play the sound
  109747. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  109748. * @param offset (optional) Start the sound at a specific time in seconds
  109749. * @param length (optional) Sound duration (in seconds)
  109750. */
  109751. play(time?: number, offset?: number, length?: number): void;
  109752. private _onended;
  109753. /**
  109754. * Stop the sound
  109755. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  109756. */
  109757. stop(time?: number): void;
  109758. /**
  109759. * Put the sound in pause
  109760. */
  109761. pause(): void;
  109762. /**
  109763. * Sets a dedicated volume for this sounds
  109764. * @param newVolume Define the new volume of the sound
  109765. * @param time Define time for gradual change to new volume
  109766. */
  109767. setVolume(newVolume: number, time?: number): void;
  109768. /**
  109769. * Set the sound play back rate
  109770. * @param newPlaybackRate Define the playback rate the sound should be played at
  109771. */
  109772. setPlaybackRate(newPlaybackRate: number): void;
  109773. /**
  109774. * Gets the volume of the sound.
  109775. * @returns the volume of the sound
  109776. */
  109777. getVolume(): number;
  109778. /**
  109779. * Attach the sound to a dedicated mesh
  109780. * @param transformNode The transform node to connect the sound with
  109781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  109782. */
  109783. attachToMesh(transformNode: TransformNode): void;
  109784. /**
  109785. * Detach the sound from the previously attached mesh
  109786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  109787. */
  109788. detachFromMesh(): void;
  109789. private _onRegisterAfterWorldMatrixUpdate;
  109790. /**
  109791. * Clone the current sound in the scene.
  109792. * @returns the new sound clone
  109793. */
  109794. clone(): Nullable<Sound>;
  109795. /**
  109796. * Gets the current underlying audio buffer containing the data
  109797. * @returns the audio buffer
  109798. */
  109799. getAudioBuffer(): Nullable<AudioBuffer>;
  109800. /**
  109801. * Serializes the Sound in a JSON representation
  109802. * @returns the JSON representation of the sound
  109803. */
  109804. serialize(): any;
  109805. /**
  109806. * Parse a JSON representation of a sound to innstantiate in a given scene
  109807. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  109808. * @param scene Define the scene the new parsed sound should be created in
  109809. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  109810. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  109811. * @returns the newly parsed sound
  109812. */
  109813. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  109814. }
  109815. }
  109816. declare module BABYLON {
  109817. /**
  109818. * This defines an action helpful to play a defined sound on a triggered action.
  109819. */
  109820. export class PlaySoundAction extends Action {
  109821. private _sound;
  109822. /**
  109823. * Instantiate the action
  109824. * @param triggerOptions defines the trigger options
  109825. * @param sound defines the sound to play
  109826. * @param condition defines the trigger related conditions
  109827. */
  109828. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  109829. /** @hidden */
  109830. _prepare(): void;
  109831. /**
  109832. * Execute the action and play the sound.
  109833. */
  109834. execute(): void;
  109835. /**
  109836. * Serializes the actions and its related information.
  109837. * @param parent defines the object to serialize in
  109838. * @returns the serialized object
  109839. */
  109840. serialize(parent: any): any;
  109841. }
  109842. /**
  109843. * This defines an action helpful to stop a defined sound on a triggered action.
  109844. */
  109845. export class StopSoundAction extends Action {
  109846. private _sound;
  109847. /**
  109848. * Instantiate the action
  109849. * @param triggerOptions defines the trigger options
  109850. * @param sound defines the sound to stop
  109851. * @param condition defines the trigger related conditions
  109852. */
  109853. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  109854. /** @hidden */
  109855. _prepare(): void;
  109856. /**
  109857. * Execute the action and stop the sound.
  109858. */
  109859. execute(): void;
  109860. /**
  109861. * Serializes the actions and its related information.
  109862. * @param parent defines the object to serialize in
  109863. * @returns the serialized object
  109864. */
  109865. serialize(parent: any): any;
  109866. }
  109867. }
  109868. declare module BABYLON {
  109869. /**
  109870. * This defines an action responsible to change the value of a property
  109871. * by interpolating between its current value and the newly set one once triggered.
  109872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109873. */
  109874. export class InterpolateValueAction extends Action {
  109875. /**
  109876. * Defines the path of the property where the value should be interpolated
  109877. */
  109878. propertyPath: string;
  109879. /**
  109880. * Defines the target value at the end of the interpolation.
  109881. */
  109882. value: any;
  109883. /**
  109884. * Defines the time it will take for the property to interpolate to the value.
  109885. */
  109886. duration: number;
  109887. /**
  109888. * Defines if the other scene animations should be stopped when the action has been triggered
  109889. */
  109890. stopOtherAnimations?: boolean;
  109891. /**
  109892. * Defines a callback raised once the interpolation animation has been done.
  109893. */
  109894. onInterpolationDone?: () => void;
  109895. /**
  109896. * Observable triggered once the interpolation animation has been done.
  109897. */
  109898. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  109899. private _target;
  109900. private _effectiveTarget;
  109901. private _property;
  109902. /**
  109903. * Instantiate the action
  109904. * @param triggerOptions defines the trigger options
  109905. * @param target defines the object containing the value to interpolate
  109906. * @param propertyPath defines the path to the property in the target object
  109907. * @param value defines the target value at the end of the interpolation
  109908. * @param duration deines the time it will take for the property to interpolate to the value.
  109909. * @param condition defines the trigger related conditions
  109910. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  109911. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  109912. */
  109913. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  109914. /** @hidden */
  109915. _prepare(): void;
  109916. /**
  109917. * Execute the action starts the value interpolation.
  109918. */
  109919. execute(): void;
  109920. /**
  109921. * Serializes the actions and its related information.
  109922. * @param parent defines the object to serialize in
  109923. * @returns the serialized object
  109924. */
  109925. serialize(parent: any): any;
  109926. }
  109927. }
  109928. declare module BABYLON {
  109929. /**
  109930. * Options allowed during the creation of a sound track.
  109931. */
  109932. export interface ISoundTrackOptions {
  109933. /**
  109934. * The volume the sound track should take during creation
  109935. */
  109936. volume?: number;
  109937. /**
  109938. * Define if the sound track is the main sound track of the scene
  109939. */
  109940. mainTrack?: boolean;
  109941. }
  109942. /**
  109943. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  109944. * It will be also used in a future release to apply effects on a specific track.
  109945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  109946. */
  109947. export class SoundTrack {
  109948. /**
  109949. * The unique identifier of the sound track in the scene.
  109950. */
  109951. id: number;
  109952. /**
  109953. * The list of sounds included in the sound track.
  109954. */
  109955. soundCollection: Array<Sound>;
  109956. private _outputAudioNode;
  109957. private _scene;
  109958. private _connectedAnalyser;
  109959. private _options;
  109960. private _isInitialized;
  109961. /**
  109962. * Creates a new sound track.
  109963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  109964. * @param scene Define the scene the sound track belongs to
  109965. * @param options
  109966. */
  109967. constructor(scene: Scene, options?: ISoundTrackOptions);
  109968. private _initializeSoundTrackAudioGraph;
  109969. /**
  109970. * Release the sound track and its associated resources
  109971. */
  109972. dispose(): void;
  109973. /**
  109974. * Adds a sound to this sound track
  109975. * @param sound define the cound to add
  109976. * @ignoreNaming
  109977. */
  109978. AddSound(sound: Sound): void;
  109979. /**
  109980. * Removes a sound to this sound track
  109981. * @param sound define the cound to remove
  109982. * @ignoreNaming
  109983. */
  109984. RemoveSound(sound: Sound): void;
  109985. /**
  109986. * Set a global volume for the full sound track.
  109987. * @param newVolume Define the new volume of the sound track
  109988. */
  109989. setVolume(newVolume: number): void;
  109990. /**
  109991. * Switch the panning model to HRTF:
  109992. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  109993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109994. */
  109995. switchPanningModelToHRTF(): void;
  109996. /**
  109997. * Switch the panning model to Equal Power:
  109998. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  109999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110000. */
  110001. switchPanningModelToEqualPower(): void;
  110002. /**
  110003. * Connect the sound track to an audio analyser allowing some amazing
  110004. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110006. * @param analyser The analyser to connect to the engine
  110007. */
  110008. connectToAnalyser(analyser: Analyser): void;
  110009. }
  110010. }
  110011. declare module BABYLON {
  110012. interface AbstractScene {
  110013. /**
  110014. * The list of sounds used in the scene.
  110015. */
  110016. sounds: Nullable<Array<Sound>>;
  110017. }
  110018. interface Scene {
  110019. /**
  110020. * @hidden
  110021. * Backing field
  110022. */
  110023. _mainSoundTrack: SoundTrack;
  110024. /**
  110025. * The main sound track played by the scene.
  110026. * It cotains your primary collection of sounds.
  110027. */
  110028. mainSoundTrack: SoundTrack;
  110029. /**
  110030. * The list of sound tracks added to the scene
  110031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110032. */
  110033. soundTracks: Nullable<Array<SoundTrack>>;
  110034. /**
  110035. * Gets a sound using a given name
  110036. * @param name defines the name to search for
  110037. * @return the found sound or null if not found at all.
  110038. */
  110039. getSoundByName(name: string): Nullable<Sound>;
  110040. /**
  110041. * Gets or sets if audio support is enabled
  110042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110043. */
  110044. audioEnabled: boolean;
  110045. /**
  110046. * Gets or sets if audio will be output to headphones
  110047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110048. */
  110049. headphone: boolean;
  110050. /**
  110051. * Gets or sets custom audio listener position provider
  110052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110053. */
  110054. audioListenerPositionProvider: Nullable<() => Vector3>;
  110055. /**
  110056. * Gets or sets a refresh rate when using 3D audio positioning
  110057. */
  110058. audioPositioningRefreshRate: number;
  110059. }
  110060. /**
  110061. * Defines the sound scene component responsible to manage any sounds
  110062. * in a given scene.
  110063. */
  110064. export class AudioSceneComponent implements ISceneSerializableComponent {
  110065. /**
  110066. * The component name helpfull to identify the component in the list of scene components.
  110067. */
  110068. readonly name: string;
  110069. /**
  110070. * The scene the component belongs to.
  110071. */
  110072. scene: Scene;
  110073. private _audioEnabled;
  110074. /**
  110075. * Gets whether audio is enabled or not.
  110076. * Please use related enable/disable method to switch state.
  110077. */
  110078. get audioEnabled(): boolean;
  110079. private _headphone;
  110080. /**
  110081. * Gets whether audio is outputing to headphone or not.
  110082. * Please use the according Switch methods to change output.
  110083. */
  110084. get headphone(): boolean;
  110085. /**
  110086. * Gets or sets a refresh rate when using 3D audio positioning
  110087. */
  110088. audioPositioningRefreshRate: number;
  110089. private _audioListenerPositionProvider;
  110090. /**
  110091. * Gets the current audio listener position provider
  110092. */
  110093. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110094. /**
  110095. * Sets a custom listener position for all sounds in the scene
  110096. * By default, this is the position of the first active camera
  110097. */
  110098. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110099. /**
  110100. * Creates a new instance of the component for the given scene
  110101. * @param scene Defines the scene to register the component in
  110102. */
  110103. constructor(scene: Scene);
  110104. /**
  110105. * Registers the component in a given scene
  110106. */
  110107. register(): void;
  110108. /**
  110109. * Rebuilds the elements related to this component in case of
  110110. * context lost for instance.
  110111. */
  110112. rebuild(): void;
  110113. /**
  110114. * Serializes the component data to the specified json object
  110115. * @param serializationObject The object to serialize to
  110116. */
  110117. serialize(serializationObject: any): void;
  110118. /**
  110119. * Adds all the elements from the container to the scene
  110120. * @param container the container holding the elements
  110121. */
  110122. addFromContainer(container: AbstractScene): void;
  110123. /**
  110124. * Removes all the elements in the container from the scene
  110125. * @param container contains the elements to remove
  110126. * @param dispose if the removed element should be disposed (default: false)
  110127. */
  110128. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110129. /**
  110130. * Disposes the component and the associated ressources.
  110131. */
  110132. dispose(): void;
  110133. /**
  110134. * Disables audio in the associated scene.
  110135. */
  110136. disableAudio(): void;
  110137. /**
  110138. * Enables audio in the associated scene.
  110139. */
  110140. enableAudio(): void;
  110141. /**
  110142. * Switch audio to headphone output.
  110143. */
  110144. switchAudioModeForHeadphones(): void;
  110145. /**
  110146. * Switch audio to normal speakers.
  110147. */
  110148. switchAudioModeForNormalSpeakers(): void;
  110149. private _cachedCameraDirection;
  110150. private _cachedCameraPosition;
  110151. private _lastCheck;
  110152. private _afterRender;
  110153. }
  110154. }
  110155. declare module BABYLON {
  110156. /**
  110157. * Wraps one or more Sound objects and selects one with random weight for playback.
  110158. */
  110159. export class WeightedSound {
  110160. /** When true a Sound will be selected and played when the current playing Sound completes. */
  110161. loop: boolean;
  110162. private _coneInnerAngle;
  110163. private _coneOuterAngle;
  110164. private _volume;
  110165. /** A Sound is currently playing. */
  110166. isPlaying: boolean;
  110167. /** A Sound is currently paused. */
  110168. isPaused: boolean;
  110169. private _sounds;
  110170. private _weights;
  110171. private _currentIndex?;
  110172. /**
  110173. * Creates a new WeightedSound from the list of sounds given.
  110174. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  110175. * @param sounds Array of Sounds that will be selected from.
  110176. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  110177. */
  110178. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  110179. /**
  110180. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  110181. */
  110182. get directionalConeInnerAngle(): number;
  110183. /**
  110184. * The size of cone in degress for a directional sound in which there will be no attenuation.
  110185. */
  110186. set directionalConeInnerAngle(value: number);
  110187. /**
  110188. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110189. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110190. */
  110191. get directionalConeOuterAngle(): number;
  110192. /**
  110193. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110194. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110195. */
  110196. set directionalConeOuterAngle(value: number);
  110197. /**
  110198. * Playback volume.
  110199. */
  110200. get volume(): number;
  110201. /**
  110202. * Playback volume.
  110203. */
  110204. set volume(value: number);
  110205. private _onended;
  110206. /**
  110207. * Suspend playback
  110208. */
  110209. pause(): void;
  110210. /**
  110211. * Stop playback
  110212. */
  110213. stop(): void;
  110214. /**
  110215. * Start playback.
  110216. * @param startOffset Position the clip head at a specific time in seconds.
  110217. */
  110218. play(startOffset?: number): void;
  110219. }
  110220. }
  110221. declare module BABYLON {
  110222. /**
  110223. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  110224. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  110225. */
  110226. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  110227. /**
  110228. * Gets the name of the behavior.
  110229. */
  110230. get name(): string;
  110231. /**
  110232. * The easing function used by animations
  110233. */
  110234. static EasingFunction: BackEase;
  110235. /**
  110236. * The easing mode used by animations
  110237. */
  110238. static EasingMode: number;
  110239. /**
  110240. * The duration of the animation, in milliseconds
  110241. */
  110242. transitionDuration: number;
  110243. /**
  110244. * Length of the distance animated by the transition when lower radius is reached
  110245. */
  110246. lowerRadiusTransitionRange: number;
  110247. /**
  110248. * Length of the distance animated by the transition when upper radius is reached
  110249. */
  110250. upperRadiusTransitionRange: number;
  110251. private _autoTransitionRange;
  110252. /**
  110253. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110254. */
  110255. get autoTransitionRange(): boolean;
  110256. /**
  110257. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110258. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  110259. */
  110260. set autoTransitionRange(value: boolean);
  110261. private _attachedCamera;
  110262. private _onAfterCheckInputsObserver;
  110263. private _onMeshTargetChangedObserver;
  110264. /**
  110265. * Initializes the behavior.
  110266. */
  110267. init(): void;
  110268. /**
  110269. * Attaches the behavior to its arc rotate camera.
  110270. * @param camera Defines the camera to attach the behavior to
  110271. */
  110272. attach(camera: ArcRotateCamera): void;
  110273. /**
  110274. * Detaches the behavior from its current arc rotate camera.
  110275. */
  110276. detach(): void;
  110277. private _radiusIsAnimating;
  110278. private _radiusBounceTransition;
  110279. private _animatables;
  110280. private _cachedWheelPrecision;
  110281. /**
  110282. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  110283. * @param radiusLimit The limit to check against.
  110284. * @return Bool to indicate if at limit.
  110285. */
  110286. private _isRadiusAtLimit;
  110287. /**
  110288. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  110289. * @param radiusDelta The delta by which to animate to. Can be negative.
  110290. */
  110291. private _applyBoundRadiusAnimation;
  110292. /**
  110293. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  110294. */
  110295. protected _clearAnimationLocks(): void;
  110296. /**
  110297. * Stops and removes all animations that have been applied to the camera
  110298. */
  110299. stopAllAnimations(): void;
  110300. }
  110301. }
  110302. declare module BABYLON {
  110303. /**
  110304. * 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.
  110305. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  110306. */
  110307. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  110308. /**
  110309. * Gets the name of the behavior.
  110310. */
  110311. get name(): string;
  110312. private _mode;
  110313. private _radiusScale;
  110314. private _positionScale;
  110315. private _defaultElevation;
  110316. private _elevationReturnTime;
  110317. private _elevationReturnWaitTime;
  110318. private _zoomStopsAnimation;
  110319. private _framingTime;
  110320. /**
  110321. * The easing function used by animations
  110322. */
  110323. static EasingFunction: ExponentialEase;
  110324. /**
  110325. * The easing mode used by animations
  110326. */
  110327. static EasingMode: number;
  110328. /**
  110329. * Sets the current mode used by the behavior
  110330. */
  110331. set mode(mode: number);
  110332. /**
  110333. * Gets current mode used by the behavior.
  110334. */
  110335. get mode(): number;
  110336. /**
  110337. * Sets the scale applied to the radius (1 by default)
  110338. */
  110339. set radiusScale(radius: number);
  110340. /**
  110341. * Gets the scale applied to the radius
  110342. */
  110343. get radiusScale(): number;
  110344. /**
  110345. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110346. */
  110347. set positionScale(scale: number);
  110348. /**
  110349. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110350. */
  110351. get positionScale(): number;
  110352. /**
  110353. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110354. * behaviour is triggered, in radians.
  110355. */
  110356. set defaultElevation(elevation: number);
  110357. /**
  110358. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110359. * behaviour is triggered, in radians.
  110360. */
  110361. get defaultElevation(): number;
  110362. /**
  110363. * Sets the time (in milliseconds) taken to return to the default beta position.
  110364. * Negative value indicates camera should not return to default.
  110365. */
  110366. set elevationReturnTime(speed: number);
  110367. /**
  110368. * Gets the time (in milliseconds) taken to return to the default beta position.
  110369. * Negative value indicates camera should not return to default.
  110370. */
  110371. get elevationReturnTime(): number;
  110372. /**
  110373. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110374. */
  110375. set elevationReturnWaitTime(time: number);
  110376. /**
  110377. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110378. */
  110379. get elevationReturnWaitTime(): number;
  110380. /**
  110381. * Sets the flag that indicates if user zooming should stop animation.
  110382. */
  110383. set zoomStopsAnimation(flag: boolean);
  110384. /**
  110385. * Gets the flag that indicates if user zooming should stop animation.
  110386. */
  110387. get zoomStopsAnimation(): boolean;
  110388. /**
  110389. * Sets the transition time when framing the mesh, in milliseconds
  110390. */
  110391. set framingTime(time: number);
  110392. /**
  110393. * Gets the transition time when framing the mesh, in milliseconds
  110394. */
  110395. get framingTime(): number;
  110396. /**
  110397. * Define if the behavior should automatically change the configured
  110398. * camera limits and sensibilities.
  110399. */
  110400. autoCorrectCameraLimitsAndSensibility: boolean;
  110401. private _onPrePointerObservableObserver;
  110402. private _onAfterCheckInputsObserver;
  110403. private _onMeshTargetChangedObserver;
  110404. private _attachedCamera;
  110405. private _isPointerDown;
  110406. private _lastInteractionTime;
  110407. /**
  110408. * Initializes the behavior.
  110409. */
  110410. init(): void;
  110411. /**
  110412. * Attaches the behavior to its arc rotate camera.
  110413. * @param camera Defines the camera to attach the behavior to
  110414. */
  110415. attach(camera: ArcRotateCamera): void;
  110416. /**
  110417. * Detaches the behavior from its current arc rotate camera.
  110418. */
  110419. detach(): void;
  110420. private _animatables;
  110421. private _betaIsAnimating;
  110422. private _betaTransition;
  110423. private _radiusTransition;
  110424. private _vectorTransition;
  110425. /**
  110426. * Targets the given mesh and updates zoom level accordingly.
  110427. * @param mesh The mesh to target.
  110428. * @param radius Optional. If a cached radius position already exists, overrides default.
  110429. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110430. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110431. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110432. */
  110433. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110434. /**
  110435. * Targets the given mesh with its children and updates zoom level accordingly.
  110436. * @param mesh The mesh to target.
  110437. * @param radius Optional. If a cached radius position already exists, overrides default.
  110438. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110439. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110440. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110441. */
  110442. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110443. /**
  110444. * Targets the given meshes with their children and updates zoom level accordingly.
  110445. * @param meshes The mesh to target.
  110446. * @param radius Optional. If a cached radius position already exists, overrides default.
  110447. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110448. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110449. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110450. */
  110451. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110452. /**
  110453. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  110454. * @param minimumWorld Determines the smaller position of the bounding box extend
  110455. * @param maximumWorld Determines the bigger position of the bounding box extend
  110456. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110457. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110458. */
  110459. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110460. /**
  110461. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  110462. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  110463. * frustum width.
  110464. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  110465. * to fully enclose the mesh in the viewing frustum.
  110466. */
  110467. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  110468. /**
  110469. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  110470. * is automatically returned to its default position (expected to be above ground plane).
  110471. */
  110472. private _maintainCameraAboveGround;
  110473. /**
  110474. * Returns the frustum slope based on the canvas ratio and camera FOV
  110475. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  110476. */
  110477. private _getFrustumSlope;
  110478. /**
  110479. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  110480. */
  110481. private _clearAnimationLocks;
  110482. /**
  110483. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  110484. */
  110485. private _applyUserInteraction;
  110486. /**
  110487. * Stops and removes all animations that have been applied to the camera
  110488. */
  110489. stopAllAnimations(): void;
  110490. /**
  110491. * Gets a value indicating if the user is moving the camera
  110492. */
  110493. get isUserIsMoving(): boolean;
  110494. /**
  110495. * The camera can move all the way towards the mesh.
  110496. */
  110497. static IgnoreBoundsSizeMode: number;
  110498. /**
  110499. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  110500. */
  110501. static FitFrustumSidesMode: number;
  110502. }
  110503. }
  110504. declare module BABYLON {
  110505. /**
  110506. * Base class for Camera Pointer Inputs.
  110507. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  110508. * for example usage.
  110509. */
  110510. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  110511. /**
  110512. * Defines the camera the input is attached to.
  110513. */
  110514. abstract camera: Camera;
  110515. /**
  110516. * Whether keyboard modifier keys are pressed at time of last mouse event.
  110517. */
  110518. protected _altKey: boolean;
  110519. protected _ctrlKey: boolean;
  110520. protected _metaKey: boolean;
  110521. protected _shiftKey: boolean;
  110522. /**
  110523. * Which mouse buttons were pressed at time of last mouse event.
  110524. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  110525. */
  110526. protected _buttonsPressed: number;
  110527. /**
  110528. * Defines the buttons associated with the input to handle camera move.
  110529. */
  110530. buttons: number[];
  110531. /**
  110532. * Attach the input controls to a specific dom element to get the input from.
  110533. * @param element Defines the element the controls should be listened from
  110534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110535. */
  110536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110537. /**
  110538. * Detach the current controls from the specified dom element.
  110539. * @param element Defines the element to stop listening the inputs from
  110540. */
  110541. detachControl(element: Nullable<HTMLElement>): void;
  110542. /**
  110543. * Gets the class name of the current input.
  110544. * @returns the class name
  110545. */
  110546. getClassName(): string;
  110547. /**
  110548. * Get the friendly name associated with the input class.
  110549. * @returns the input friendly name
  110550. */
  110551. getSimpleName(): string;
  110552. /**
  110553. * Called on pointer POINTERDOUBLETAP event.
  110554. * Override this method to provide functionality on POINTERDOUBLETAP event.
  110555. */
  110556. protected onDoubleTap(type: string): void;
  110557. /**
  110558. * Called on pointer POINTERMOVE event if only a single touch is active.
  110559. * Override this method to provide functionality.
  110560. */
  110561. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110562. /**
  110563. * Called on pointer POINTERMOVE event if multiple touches are active.
  110564. * Override this method to provide functionality.
  110565. */
  110566. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110567. /**
  110568. * Called on JS contextmenu event.
  110569. * Override this method to provide functionality.
  110570. */
  110571. protected onContextMenu(evt: PointerEvent): void;
  110572. /**
  110573. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  110574. * press.
  110575. * Override this method to provide functionality.
  110576. */
  110577. protected onButtonDown(evt: PointerEvent): void;
  110578. /**
  110579. * Called each time a new POINTERUP event occurs. Ie, for each button
  110580. * release.
  110581. * Override this method to provide functionality.
  110582. */
  110583. protected onButtonUp(evt: PointerEvent): void;
  110584. /**
  110585. * Called when window becomes inactive.
  110586. * Override this method to provide functionality.
  110587. */
  110588. protected onLostFocus(): void;
  110589. private _pointerInput;
  110590. private _observer;
  110591. private _onLostFocus;
  110592. private pointA;
  110593. private pointB;
  110594. }
  110595. }
  110596. declare module BABYLON {
  110597. /**
  110598. * Manage the pointers inputs to control an arc rotate camera.
  110599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110600. */
  110601. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  110602. /**
  110603. * Defines the camera the input is attached to.
  110604. */
  110605. camera: ArcRotateCamera;
  110606. /**
  110607. * Gets the class name of the current input.
  110608. * @returns the class name
  110609. */
  110610. getClassName(): string;
  110611. /**
  110612. * Defines the buttons associated with the input to handle camera move.
  110613. */
  110614. buttons: number[];
  110615. /**
  110616. * Defines the pointer angular sensibility along the X axis or how fast is
  110617. * the camera rotating.
  110618. */
  110619. angularSensibilityX: number;
  110620. /**
  110621. * Defines the pointer angular sensibility along the Y axis or how fast is
  110622. * the camera rotating.
  110623. */
  110624. angularSensibilityY: number;
  110625. /**
  110626. * Defines the pointer pinch precision or how fast is the camera zooming.
  110627. */
  110628. pinchPrecision: number;
  110629. /**
  110630. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110631. * from 0.
  110632. * It defines the percentage of current camera.radius to use as delta when
  110633. * pinch zoom is used.
  110634. */
  110635. pinchDeltaPercentage: number;
  110636. /**
  110637. * Defines the pointer panning sensibility or how fast is the camera moving.
  110638. */
  110639. panningSensibility: number;
  110640. /**
  110641. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  110642. */
  110643. multiTouchPanning: boolean;
  110644. /**
  110645. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  110646. * zoom (pinch) through multitouch.
  110647. */
  110648. multiTouchPanAndZoom: boolean;
  110649. /**
  110650. * Revers pinch action direction.
  110651. */
  110652. pinchInwards: boolean;
  110653. private _isPanClick;
  110654. private _twoFingerActivityCount;
  110655. private _isPinching;
  110656. /**
  110657. * Called on pointer POINTERMOVE event if only a single touch is active.
  110658. */
  110659. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110660. /**
  110661. * Called on pointer POINTERDOUBLETAP event.
  110662. */
  110663. protected onDoubleTap(type: string): void;
  110664. /**
  110665. * Called on pointer POINTERMOVE event if multiple touches are active.
  110666. */
  110667. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110668. /**
  110669. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  110670. * press.
  110671. */
  110672. protected onButtonDown(evt: PointerEvent): void;
  110673. /**
  110674. * Called each time a new POINTERUP event occurs. Ie, for each button
  110675. * release.
  110676. */
  110677. protected onButtonUp(evt: PointerEvent): void;
  110678. /**
  110679. * Called when window becomes inactive.
  110680. */
  110681. protected onLostFocus(): void;
  110682. }
  110683. }
  110684. declare module BABYLON {
  110685. /**
  110686. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  110687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110688. */
  110689. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  110690. /**
  110691. * Defines the camera the input is attached to.
  110692. */
  110693. camera: ArcRotateCamera;
  110694. /**
  110695. * Defines the list of key codes associated with the up action (increase alpha)
  110696. */
  110697. keysUp: number[];
  110698. /**
  110699. * Defines the list of key codes associated with the down action (decrease alpha)
  110700. */
  110701. keysDown: number[];
  110702. /**
  110703. * Defines the list of key codes associated with the left action (increase beta)
  110704. */
  110705. keysLeft: number[];
  110706. /**
  110707. * Defines the list of key codes associated with the right action (decrease beta)
  110708. */
  110709. keysRight: number[];
  110710. /**
  110711. * Defines the list of key codes associated with the reset action.
  110712. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  110713. */
  110714. keysReset: number[];
  110715. /**
  110716. * Defines the panning sensibility of the inputs.
  110717. * (How fast is the camera paning)
  110718. */
  110719. panningSensibility: number;
  110720. /**
  110721. * Defines the zooming sensibility of the inputs.
  110722. * (How fast is the camera zooming)
  110723. */
  110724. zoomingSensibility: number;
  110725. /**
  110726. * Defines wether maintaining the alt key down switch the movement mode from
  110727. * orientation to zoom.
  110728. */
  110729. useAltToZoom: boolean;
  110730. /**
  110731. * Rotation speed of the camera
  110732. */
  110733. angularSpeed: number;
  110734. private _keys;
  110735. private _ctrlPressed;
  110736. private _altPressed;
  110737. private _onCanvasBlurObserver;
  110738. private _onKeyboardObserver;
  110739. private _engine;
  110740. private _scene;
  110741. /**
  110742. * Attach the input controls to a specific dom element to get the input from.
  110743. * @param element Defines the element the controls should be listened from
  110744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110745. */
  110746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110747. /**
  110748. * Detach the current controls from the specified dom element.
  110749. * @param element Defines the element to stop listening the inputs from
  110750. */
  110751. detachControl(element: Nullable<HTMLElement>): void;
  110752. /**
  110753. * Update the current camera state depending on the inputs that have been used this frame.
  110754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110755. */
  110756. checkInputs(): void;
  110757. /**
  110758. * Gets the class name of the current intput.
  110759. * @returns the class name
  110760. */
  110761. getClassName(): string;
  110762. /**
  110763. * Get the friendly name associated with the input class.
  110764. * @returns the input friendly name
  110765. */
  110766. getSimpleName(): string;
  110767. }
  110768. }
  110769. declare module BABYLON {
  110770. /**
  110771. * Manage the mouse wheel inputs to control an arc rotate camera.
  110772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110773. */
  110774. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  110775. /**
  110776. * Defines the camera the input is attached to.
  110777. */
  110778. camera: ArcRotateCamera;
  110779. /**
  110780. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  110781. */
  110782. wheelPrecision: number;
  110783. /**
  110784. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110785. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110786. */
  110787. wheelDeltaPercentage: number;
  110788. private _wheel;
  110789. private _observer;
  110790. private computeDeltaFromMouseWheelLegacyEvent;
  110791. /**
  110792. * Attach the input controls to a specific dom element to get the input from.
  110793. * @param element Defines the element the controls should be listened from
  110794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110795. */
  110796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110797. /**
  110798. * Detach the current controls from the specified dom element.
  110799. * @param element Defines the element to stop listening the inputs from
  110800. */
  110801. detachControl(element: Nullable<HTMLElement>): void;
  110802. /**
  110803. * Gets the class name of the current intput.
  110804. * @returns the class name
  110805. */
  110806. getClassName(): string;
  110807. /**
  110808. * Get the friendly name associated with the input class.
  110809. * @returns the input friendly name
  110810. */
  110811. getSimpleName(): string;
  110812. }
  110813. }
  110814. declare module BABYLON {
  110815. /**
  110816. * Default Inputs manager for the ArcRotateCamera.
  110817. * It groups all the default supported inputs for ease of use.
  110818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110819. */
  110820. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  110821. /**
  110822. * Instantiates a new ArcRotateCameraInputsManager.
  110823. * @param camera Defines the camera the inputs belong to
  110824. */
  110825. constructor(camera: ArcRotateCamera);
  110826. /**
  110827. * Add mouse wheel input support to the input manager.
  110828. * @returns the current input manager
  110829. */
  110830. addMouseWheel(): ArcRotateCameraInputsManager;
  110831. /**
  110832. * Add pointers input support to the input manager.
  110833. * @returns the current input manager
  110834. */
  110835. addPointers(): ArcRotateCameraInputsManager;
  110836. /**
  110837. * Add keyboard input support to the input manager.
  110838. * @returns the current input manager
  110839. */
  110840. addKeyboard(): ArcRotateCameraInputsManager;
  110841. }
  110842. }
  110843. declare module BABYLON {
  110844. /**
  110845. * This represents an orbital type of camera.
  110846. *
  110847. * 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.
  110848. * 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.
  110849. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  110850. */
  110851. export class ArcRotateCamera extends TargetCamera {
  110852. /**
  110853. * Defines the rotation angle of the camera along the longitudinal axis.
  110854. */
  110855. alpha: number;
  110856. /**
  110857. * Defines the rotation angle of the camera along the latitudinal axis.
  110858. */
  110859. beta: number;
  110860. /**
  110861. * Defines the radius of the camera from it s target point.
  110862. */
  110863. radius: number;
  110864. protected _target: Vector3;
  110865. protected _targetHost: Nullable<AbstractMesh>;
  110866. /**
  110867. * Defines the target point of the camera.
  110868. * The camera looks towards it form the radius distance.
  110869. */
  110870. get target(): Vector3;
  110871. set target(value: Vector3);
  110872. /**
  110873. * Define the current local position of the camera in the scene
  110874. */
  110875. get position(): Vector3;
  110876. set position(newPosition: Vector3);
  110877. protected _upVector: Vector3;
  110878. protected _upToYMatrix: Matrix;
  110879. protected _YToUpMatrix: Matrix;
  110880. /**
  110881. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  110882. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  110883. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  110884. */
  110885. set upVector(vec: Vector3);
  110886. get upVector(): Vector3;
  110887. /**
  110888. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  110889. */
  110890. setMatUp(): void;
  110891. /**
  110892. * Current inertia value on the longitudinal axis.
  110893. * The bigger this number the longer it will take for the camera to stop.
  110894. */
  110895. inertialAlphaOffset: number;
  110896. /**
  110897. * Current inertia value on the latitudinal axis.
  110898. * The bigger this number the longer it will take for the camera to stop.
  110899. */
  110900. inertialBetaOffset: number;
  110901. /**
  110902. * Current inertia value on the radius axis.
  110903. * The bigger this number the longer it will take for the camera to stop.
  110904. */
  110905. inertialRadiusOffset: number;
  110906. /**
  110907. * Minimum allowed angle on the longitudinal axis.
  110908. * This can help limiting how the Camera is able to move in the scene.
  110909. */
  110910. lowerAlphaLimit: Nullable<number>;
  110911. /**
  110912. * Maximum allowed angle on the longitudinal axis.
  110913. * This can help limiting how the Camera is able to move in the scene.
  110914. */
  110915. upperAlphaLimit: Nullable<number>;
  110916. /**
  110917. * Minimum allowed angle on the latitudinal axis.
  110918. * This can help limiting how the Camera is able to move in the scene.
  110919. */
  110920. lowerBetaLimit: number;
  110921. /**
  110922. * Maximum allowed angle on the latitudinal axis.
  110923. * This can help limiting how the Camera is able to move in the scene.
  110924. */
  110925. upperBetaLimit: number;
  110926. /**
  110927. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  110928. * This can help limiting how the Camera is able to move in the scene.
  110929. */
  110930. lowerRadiusLimit: Nullable<number>;
  110931. /**
  110932. * Maximum allowed distance of the camera to the target (The camera can not get further).
  110933. * This can help limiting how the Camera is able to move in the scene.
  110934. */
  110935. upperRadiusLimit: Nullable<number>;
  110936. /**
  110937. * Defines the current inertia value used during panning of the camera along the X axis.
  110938. */
  110939. inertialPanningX: number;
  110940. /**
  110941. * Defines the current inertia value used during panning of the camera along the Y axis.
  110942. */
  110943. inertialPanningY: number;
  110944. /**
  110945. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  110946. * Basically if your fingers moves away from more than this distance you will be considered
  110947. * in pinch mode.
  110948. */
  110949. pinchToPanMaxDistance: number;
  110950. /**
  110951. * Defines the maximum distance the camera can pan.
  110952. * This could help keeping the cammera always in your scene.
  110953. */
  110954. panningDistanceLimit: Nullable<number>;
  110955. /**
  110956. * Defines the target of the camera before paning.
  110957. */
  110958. panningOriginTarget: Vector3;
  110959. /**
  110960. * Defines the value of the inertia used during panning.
  110961. * 0 would mean stop inertia and one would mean no decelleration at all.
  110962. */
  110963. panningInertia: number;
  110964. /**
  110965. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  110966. */
  110967. get angularSensibilityX(): number;
  110968. set angularSensibilityX(value: number);
  110969. /**
  110970. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  110971. */
  110972. get angularSensibilityY(): number;
  110973. set angularSensibilityY(value: number);
  110974. /**
  110975. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  110976. */
  110977. get pinchPrecision(): number;
  110978. set pinchPrecision(value: number);
  110979. /**
  110980. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  110981. * It will be used instead of pinchDeltaPrecision if different from 0.
  110982. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  110983. */
  110984. get pinchDeltaPercentage(): number;
  110985. set pinchDeltaPercentage(value: number);
  110986. /**
  110987. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  110988. */
  110989. get panningSensibility(): number;
  110990. set panningSensibility(value: number);
  110991. /**
  110992. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  110993. */
  110994. get keysUp(): number[];
  110995. set keysUp(value: number[]);
  110996. /**
  110997. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  110998. */
  110999. get keysDown(): number[];
  111000. set keysDown(value: number[]);
  111001. /**
  111002. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111003. */
  111004. get keysLeft(): number[];
  111005. set keysLeft(value: number[]);
  111006. /**
  111007. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111008. */
  111009. get keysRight(): number[];
  111010. set keysRight(value: number[]);
  111011. /**
  111012. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111013. */
  111014. get wheelPrecision(): number;
  111015. set wheelPrecision(value: number);
  111016. /**
  111017. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111018. * It will be used instead of pinchDeltaPrecision if different from 0.
  111019. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111020. */
  111021. get wheelDeltaPercentage(): number;
  111022. set wheelDeltaPercentage(value: number);
  111023. /**
  111024. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111025. */
  111026. zoomOnFactor: number;
  111027. /**
  111028. * Defines a screen offset for the camera position.
  111029. */
  111030. targetScreenOffset: Vector2;
  111031. /**
  111032. * Allows the camera to be completely reversed.
  111033. * If false the camera can not arrive upside down.
  111034. */
  111035. allowUpsideDown: boolean;
  111036. /**
  111037. * Define if double tap/click is used to restore the previously saved state of the camera.
  111038. */
  111039. useInputToRestoreState: boolean;
  111040. /** @hidden */
  111041. _viewMatrix: Matrix;
  111042. /** @hidden */
  111043. _useCtrlForPanning: boolean;
  111044. /** @hidden */
  111045. _panningMouseButton: number;
  111046. /**
  111047. * Defines the input associated to the camera.
  111048. */
  111049. inputs: ArcRotateCameraInputsManager;
  111050. /** @hidden */
  111051. _reset: () => void;
  111052. /**
  111053. * Defines the allowed panning axis.
  111054. */
  111055. panningAxis: Vector3;
  111056. protected _localDirection: Vector3;
  111057. protected _transformedDirection: Vector3;
  111058. private _bouncingBehavior;
  111059. /**
  111060. * Gets the bouncing behavior of the camera if it has been enabled.
  111061. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111062. */
  111063. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111064. /**
  111065. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111066. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111067. */
  111068. get useBouncingBehavior(): boolean;
  111069. set useBouncingBehavior(value: boolean);
  111070. private _framingBehavior;
  111071. /**
  111072. * Gets the framing behavior of the camera if it has been enabled.
  111073. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111074. */
  111075. get framingBehavior(): Nullable<FramingBehavior>;
  111076. /**
  111077. * Defines if the framing behavior of the camera is enabled on the camera.
  111078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111079. */
  111080. get useFramingBehavior(): boolean;
  111081. set useFramingBehavior(value: boolean);
  111082. private _autoRotationBehavior;
  111083. /**
  111084. * Gets the auto rotation behavior of the camera if it has been enabled.
  111085. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111086. */
  111087. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111088. /**
  111089. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111091. */
  111092. get useAutoRotationBehavior(): boolean;
  111093. set useAutoRotationBehavior(value: boolean);
  111094. /**
  111095. * Observable triggered when the mesh target has been changed on the camera.
  111096. */
  111097. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111098. /**
  111099. * Event raised when the camera is colliding with a mesh.
  111100. */
  111101. onCollide: (collidedMesh: AbstractMesh) => void;
  111102. /**
  111103. * Defines whether the camera should check collision with the objects oh the scene.
  111104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111105. */
  111106. checkCollisions: boolean;
  111107. /**
  111108. * Defines the collision radius of the camera.
  111109. * This simulates a sphere around the camera.
  111110. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111111. */
  111112. collisionRadius: Vector3;
  111113. protected _collider: Collider;
  111114. protected _previousPosition: Vector3;
  111115. protected _collisionVelocity: Vector3;
  111116. protected _newPosition: Vector3;
  111117. protected _previousAlpha: number;
  111118. protected _previousBeta: number;
  111119. protected _previousRadius: number;
  111120. protected _collisionTriggered: boolean;
  111121. protected _targetBoundingCenter: Nullable<Vector3>;
  111122. private _computationVector;
  111123. /**
  111124. * Instantiates a new ArcRotateCamera in a given scene
  111125. * @param name Defines the name of the camera
  111126. * @param alpha Defines the camera rotation along the logitudinal axis
  111127. * @param beta Defines the camera rotation along the latitudinal axis
  111128. * @param radius Defines the camera distance from its target
  111129. * @param target Defines the camera target
  111130. * @param scene Defines the scene the camera belongs to
  111131. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  111132. */
  111133. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111134. /** @hidden */
  111135. _initCache(): void;
  111136. /** @hidden */
  111137. _updateCache(ignoreParentClass?: boolean): void;
  111138. protected _getTargetPosition(): Vector3;
  111139. private _storedAlpha;
  111140. private _storedBeta;
  111141. private _storedRadius;
  111142. private _storedTarget;
  111143. private _storedTargetScreenOffset;
  111144. /**
  111145. * Stores the current state of the camera (alpha, beta, radius and target)
  111146. * @returns the camera itself
  111147. */
  111148. storeState(): Camera;
  111149. /**
  111150. * @hidden
  111151. * Restored camera state. You must call storeState() first
  111152. */
  111153. _restoreStateValues(): boolean;
  111154. /** @hidden */
  111155. _isSynchronizedViewMatrix(): boolean;
  111156. /**
  111157. * Attached controls to the current camera.
  111158. * @param element Defines the element the controls should be listened from
  111159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111160. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  111161. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  111162. */
  111163. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  111164. /**
  111165. * Detach the current controls from the camera.
  111166. * The camera will stop reacting to inputs.
  111167. * @param element Defines the element to stop listening the inputs from
  111168. */
  111169. detachControl(element: HTMLElement): void;
  111170. /** @hidden */
  111171. _checkInputs(): void;
  111172. protected _checkLimits(): void;
  111173. /**
  111174. * Rebuilds angles (alpha, beta) and radius from the give position and target
  111175. */
  111176. rebuildAnglesAndRadius(): void;
  111177. /**
  111178. * Use a position to define the current camera related information like alpha, beta and radius
  111179. * @param position Defines the position to set the camera at
  111180. */
  111181. setPosition(position: Vector3): void;
  111182. /**
  111183. * Defines the target the camera should look at.
  111184. * This will automatically adapt alpha beta and radius to fit within the new target.
  111185. * @param target Defines the new target as a Vector or a mesh
  111186. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  111187. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  111188. */
  111189. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  111190. /** @hidden */
  111191. _getViewMatrix(): Matrix;
  111192. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  111193. /**
  111194. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  111195. * @param meshes Defines the mesh to zoom on
  111196. * @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)
  111197. */
  111198. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  111199. /**
  111200. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  111201. * The target will be changed but the radius
  111202. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  111203. * @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)
  111204. */
  111205. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  111206. min: Vector3;
  111207. max: Vector3;
  111208. distance: number;
  111209. }, doNotUpdateMaxZ?: boolean): void;
  111210. /**
  111211. * @override
  111212. * Override Camera.createRigCamera
  111213. */
  111214. createRigCamera(name: string, cameraIndex: number): Camera;
  111215. /**
  111216. * @hidden
  111217. * @override
  111218. * Override Camera._updateRigCameras
  111219. */
  111220. _updateRigCameras(): void;
  111221. /**
  111222. * Destroy the camera and release the current resources hold by it.
  111223. */
  111224. dispose(): void;
  111225. /**
  111226. * Gets the current object class name.
  111227. * @return the class name
  111228. */
  111229. getClassName(): string;
  111230. }
  111231. }
  111232. declare module BABYLON {
  111233. /**
  111234. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  111235. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111236. */
  111237. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  111238. /**
  111239. * Gets the name of the behavior.
  111240. */
  111241. get name(): string;
  111242. private _zoomStopsAnimation;
  111243. private _idleRotationSpeed;
  111244. private _idleRotationWaitTime;
  111245. private _idleRotationSpinupTime;
  111246. /**
  111247. * Sets the flag that indicates if user zooming should stop animation.
  111248. */
  111249. set zoomStopsAnimation(flag: boolean);
  111250. /**
  111251. * Gets the flag that indicates if user zooming should stop animation.
  111252. */
  111253. get zoomStopsAnimation(): boolean;
  111254. /**
  111255. * Sets the default speed at which the camera rotates around the model.
  111256. */
  111257. set idleRotationSpeed(speed: number);
  111258. /**
  111259. * Gets the default speed at which the camera rotates around the model.
  111260. */
  111261. get idleRotationSpeed(): number;
  111262. /**
  111263. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  111264. */
  111265. set idleRotationWaitTime(time: number);
  111266. /**
  111267. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  111268. */
  111269. get idleRotationWaitTime(): number;
  111270. /**
  111271. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111272. */
  111273. set idleRotationSpinupTime(time: number);
  111274. /**
  111275. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111276. */
  111277. get idleRotationSpinupTime(): number;
  111278. /**
  111279. * Gets a value indicating if the camera is currently rotating because of this behavior
  111280. */
  111281. get rotationInProgress(): boolean;
  111282. private _onPrePointerObservableObserver;
  111283. private _onAfterCheckInputsObserver;
  111284. private _attachedCamera;
  111285. private _isPointerDown;
  111286. private _lastFrameTime;
  111287. private _lastInteractionTime;
  111288. private _cameraRotationSpeed;
  111289. /**
  111290. * Initializes the behavior.
  111291. */
  111292. init(): void;
  111293. /**
  111294. * Attaches the behavior to its arc rotate camera.
  111295. * @param camera Defines the camera to attach the behavior to
  111296. */
  111297. attach(camera: ArcRotateCamera): void;
  111298. /**
  111299. * Detaches the behavior from its current arc rotate camera.
  111300. */
  111301. detach(): void;
  111302. /**
  111303. * Returns true if user is scrolling.
  111304. * @return true if user is scrolling.
  111305. */
  111306. private _userIsZooming;
  111307. private _lastFrameRadius;
  111308. private _shouldAnimationStopForInteraction;
  111309. /**
  111310. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111311. */
  111312. private _applyUserInteraction;
  111313. private _userIsMoving;
  111314. }
  111315. }
  111316. declare module BABYLON {
  111317. /**
  111318. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  111319. */
  111320. export class AttachToBoxBehavior implements Behavior<Mesh> {
  111321. private ui;
  111322. /**
  111323. * The name of the behavior
  111324. */
  111325. name: string;
  111326. /**
  111327. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  111328. */
  111329. distanceAwayFromFace: number;
  111330. /**
  111331. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  111332. */
  111333. distanceAwayFromBottomOfFace: number;
  111334. private _faceVectors;
  111335. private _target;
  111336. private _scene;
  111337. private _onRenderObserver;
  111338. private _tmpMatrix;
  111339. private _tmpVector;
  111340. /**
  111341. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  111342. * @param ui The transform node that should be attched to the mesh
  111343. */
  111344. constructor(ui: TransformNode);
  111345. /**
  111346. * Initializes the behavior
  111347. */
  111348. init(): void;
  111349. private _closestFace;
  111350. private _zeroVector;
  111351. private _lookAtTmpMatrix;
  111352. private _lookAtToRef;
  111353. /**
  111354. * Attaches the AttachToBoxBehavior to the passed in mesh
  111355. * @param target The mesh that the specified node will be attached to
  111356. */
  111357. attach(target: Mesh): void;
  111358. /**
  111359. * Detaches the behavior from the mesh
  111360. */
  111361. detach(): void;
  111362. }
  111363. }
  111364. declare module BABYLON {
  111365. /**
  111366. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  111367. */
  111368. export class FadeInOutBehavior implements Behavior<Mesh> {
  111369. /**
  111370. * Time in milliseconds to delay before fading in (Default: 0)
  111371. */
  111372. delay: number;
  111373. /**
  111374. * Time in milliseconds for the mesh to fade in (Default: 300)
  111375. */
  111376. fadeInTime: number;
  111377. private _millisecondsPerFrame;
  111378. private _hovered;
  111379. private _hoverValue;
  111380. private _ownerNode;
  111381. /**
  111382. * Instatiates the FadeInOutBehavior
  111383. */
  111384. constructor();
  111385. /**
  111386. * The name of the behavior
  111387. */
  111388. get name(): string;
  111389. /**
  111390. * Initializes the behavior
  111391. */
  111392. init(): void;
  111393. /**
  111394. * Attaches the fade behavior on the passed in mesh
  111395. * @param ownerNode The mesh that will be faded in/out once attached
  111396. */
  111397. attach(ownerNode: Mesh): void;
  111398. /**
  111399. * Detaches the behavior from the mesh
  111400. */
  111401. detach(): void;
  111402. /**
  111403. * Triggers the mesh to begin fading in or out
  111404. * @param value if the object should fade in or out (true to fade in)
  111405. */
  111406. fadeIn(value: boolean): void;
  111407. private _update;
  111408. private _setAllVisibility;
  111409. }
  111410. }
  111411. declare module BABYLON {
  111412. /**
  111413. * Class containing a set of static utilities functions for managing Pivots
  111414. * @hidden
  111415. */
  111416. export class PivotTools {
  111417. private static _PivotCached;
  111418. private static _OldPivotPoint;
  111419. private static _PivotTranslation;
  111420. private static _PivotTmpVector;
  111421. /** @hidden */
  111422. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  111423. /** @hidden */
  111424. static _RestorePivotPoint(mesh: AbstractMesh): void;
  111425. }
  111426. }
  111427. declare module BABYLON {
  111428. /**
  111429. * Class containing static functions to help procedurally build meshes
  111430. */
  111431. export class PlaneBuilder {
  111432. /**
  111433. * Creates a plane mesh
  111434. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  111435. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  111436. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  111437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111440. * @param name defines the name of the mesh
  111441. * @param options defines the options used to create the mesh
  111442. * @param scene defines the hosting scene
  111443. * @returns the plane mesh
  111444. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  111445. */
  111446. static CreatePlane(name: string, options: {
  111447. size?: number;
  111448. width?: number;
  111449. height?: number;
  111450. sideOrientation?: number;
  111451. frontUVs?: Vector4;
  111452. backUVs?: Vector4;
  111453. updatable?: boolean;
  111454. sourcePlane?: Plane;
  111455. }, scene?: Nullable<Scene>): Mesh;
  111456. }
  111457. }
  111458. declare module BABYLON {
  111459. /**
  111460. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  111461. */
  111462. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  111463. private static _AnyMouseID;
  111464. /**
  111465. * Abstract mesh the behavior is set on
  111466. */
  111467. attachedNode: AbstractMesh;
  111468. private _dragPlane;
  111469. private _scene;
  111470. private _pointerObserver;
  111471. private _beforeRenderObserver;
  111472. private static _planeScene;
  111473. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  111474. /**
  111475. * 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)
  111476. */
  111477. maxDragAngle: number;
  111478. /**
  111479. * @hidden
  111480. */
  111481. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  111482. /**
  111483. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111484. */
  111485. currentDraggingPointerID: number;
  111486. /**
  111487. * The last position where the pointer hit the drag plane in world space
  111488. */
  111489. lastDragPosition: Vector3;
  111490. /**
  111491. * If the behavior is currently in a dragging state
  111492. */
  111493. dragging: boolean;
  111494. /**
  111495. * 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)
  111496. */
  111497. dragDeltaRatio: number;
  111498. /**
  111499. * If the drag plane orientation should be updated during the dragging (Default: true)
  111500. */
  111501. updateDragPlane: boolean;
  111502. private _debugMode;
  111503. private _moving;
  111504. /**
  111505. * Fires each time the attached mesh is dragged with the pointer
  111506. * * delta between last drag position and current drag position in world space
  111507. * * dragDistance along the drag axis
  111508. * * dragPlaneNormal normal of the current drag plane used during the drag
  111509. * * dragPlanePoint in world space where the drag intersects the drag plane
  111510. */
  111511. onDragObservable: Observable<{
  111512. delta: Vector3;
  111513. dragPlanePoint: Vector3;
  111514. dragPlaneNormal: Vector3;
  111515. dragDistance: number;
  111516. pointerId: number;
  111517. }>;
  111518. /**
  111519. * Fires each time a drag begins (eg. mouse down on mesh)
  111520. */
  111521. onDragStartObservable: Observable<{
  111522. dragPlanePoint: Vector3;
  111523. pointerId: number;
  111524. }>;
  111525. /**
  111526. * Fires each time a drag ends (eg. mouse release after drag)
  111527. */
  111528. onDragEndObservable: Observable<{
  111529. dragPlanePoint: Vector3;
  111530. pointerId: number;
  111531. }>;
  111532. /**
  111533. * If the attached mesh should be moved when dragged
  111534. */
  111535. moveAttached: boolean;
  111536. /**
  111537. * If the drag behavior will react to drag events (Default: true)
  111538. */
  111539. enabled: boolean;
  111540. /**
  111541. * If pointer events should start and release the drag (Default: true)
  111542. */
  111543. startAndReleaseDragOnPointerEvents: boolean;
  111544. /**
  111545. * If camera controls should be detached during the drag
  111546. */
  111547. detachCameraControls: boolean;
  111548. /**
  111549. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  111550. */
  111551. useObjectOrientationForDragging: boolean;
  111552. private _options;
  111553. /**
  111554. * Gets the options used by the behavior
  111555. */
  111556. get options(): {
  111557. dragAxis?: Vector3;
  111558. dragPlaneNormal?: Vector3;
  111559. };
  111560. /**
  111561. * Sets the options used by the behavior
  111562. */
  111563. set options(options: {
  111564. dragAxis?: Vector3;
  111565. dragPlaneNormal?: Vector3;
  111566. });
  111567. /**
  111568. * Creates a pointer drag behavior that can be attached to a mesh
  111569. * @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)
  111570. */
  111571. constructor(options?: {
  111572. dragAxis?: Vector3;
  111573. dragPlaneNormal?: Vector3;
  111574. });
  111575. /**
  111576. * Predicate to determine if it is valid to move the object to a new position when it is moved
  111577. */
  111578. validateDrag: (targetPosition: Vector3) => boolean;
  111579. /**
  111580. * The name of the behavior
  111581. */
  111582. get name(): string;
  111583. /**
  111584. * Initializes the behavior
  111585. */
  111586. init(): void;
  111587. private _tmpVector;
  111588. private _alternatePickedPoint;
  111589. private _worldDragAxis;
  111590. private _targetPosition;
  111591. private _attachedElement;
  111592. /**
  111593. * Attaches the drag behavior the passed in mesh
  111594. * @param ownerNode The mesh that will be dragged around once attached
  111595. * @param predicate Predicate to use for pick filtering
  111596. */
  111597. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  111598. /**
  111599. * Force relase the drag action by code.
  111600. */
  111601. releaseDrag(): void;
  111602. private _startDragRay;
  111603. private _lastPointerRay;
  111604. /**
  111605. * Simulates the start of a pointer drag event on the behavior
  111606. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  111607. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  111608. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  111609. */
  111610. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  111611. private _startDrag;
  111612. private _dragDelta;
  111613. private _moveDrag;
  111614. private _pickWithRayOnDragPlane;
  111615. private _pointA;
  111616. private _pointB;
  111617. private _pointC;
  111618. private _lineA;
  111619. private _lineB;
  111620. private _localAxis;
  111621. private _lookAt;
  111622. private _updateDragPlanePosition;
  111623. /**
  111624. * Detaches the behavior from the mesh
  111625. */
  111626. detach(): void;
  111627. }
  111628. }
  111629. declare module BABYLON {
  111630. /**
  111631. * A behavior that when attached to a mesh will allow the mesh to be scaled
  111632. */
  111633. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  111634. private _dragBehaviorA;
  111635. private _dragBehaviorB;
  111636. private _startDistance;
  111637. private _initialScale;
  111638. private _targetScale;
  111639. private _ownerNode;
  111640. private _sceneRenderObserver;
  111641. /**
  111642. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  111643. */
  111644. constructor();
  111645. /**
  111646. * The name of the behavior
  111647. */
  111648. get name(): string;
  111649. /**
  111650. * Initializes the behavior
  111651. */
  111652. init(): void;
  111653. private _getCurrentDistance;
  111654. /**
  111655. * Attaches the scale behavior the passed in mesh
  111656. * @param ownerNode The mesh that will be scaled around once attached
  111657. */
  111658. attach(ownerNode: Mesh): void;
  111659. /**
  111660. * Detaches the behavior from the mesh
  111661. */
  111662. detach(): void;
  111663. }
  111664. }
  111665. declare module BABYLON {
  111666. /**
  111667. * 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
  111668. */
  111669. export class SixDofDragBehavior implements Behavior<Mesh> {
  111670. private static _virtualScene;
  111671. private _ownerNode;
  111672. private _sceneRenderObserver;
  111673. private _scene;
  111674. private _targetPosition;
  111675. private _virtualOriginMesh;
  111676. private _virtualDragMesh;
  111677. private _pointerObserver;
  111678. private _moving;
  111679. private _startingOrientation;
  111680. /**
  111681. * 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)
  111682. */
  111683. private zDragFactor;
  111684. /**
  111685. * If the object should rotate to face the drag origin
  111686. */
  111687. rotateDraggedObject: boolean;
  111688. /**
  111689. * If the behavior is currently in a dragging state
  111690. */
  111691. dragging: boolean;
  111692. /**
  111693. * 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)
  111694. */
  111695. dragDeltaRatio: number;
  111696. /**
  111697. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111698. */
  111699. currentDraggingPointerID: number;
  111700. /**
  111701. * If camera controls should be detached during the drag
  111702. */
  111703. detachCameraControls: boolean;
  111704. /**
  111705. * Fires each time a drag starts
  111706. */
  111707. onDragStartObservable: Observable<{}>;
  111708. /**
  111709. * Fires each time a drag ends (eg. mouse release after drag)
  111710. */
  111711. onDragEndObservable: Observable<{}>;
  111712. /**
  111713. * 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
  111714. */
  111715. constructor();
  111716. /**
  111717. * The name of the behavior
  111718. */
  111719. get name(): string;
  111720. /**
  111721. * Initializes the behavior
  111722. */
  111723. init(): void;
  111724. /**
  111725. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  111726. */
  111727. private get _pointerCamera();
  111728. /**
  111729. * Attaches the scale behavior the passed in mesh
  111730. * @param ownerNode The mesh that will be scaled around once attached
  111731. */
  111732. attach(ownerNode: Mesh): void;
  111733. /**
  111734. * Detaches the behavior from the mesh
  111735. */
  111736. detach(): void;
  111737. }
  111738. }
  111739. declare module BABYLON {
  111740. /**
  111741. * Class used to apply inverse kinematics to bones
  111742. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  111743. */
  111744. export class BoneIKController {
  111745. private static _tmpVecs;
  111746. private static _tmpQuat;
  111747. private static _tmpMats;
  111748. /**
  111749. * Gets or sets the target mesh
  111750. */
  111751. targetMesh: AbstractMesh;
  111752. /** Gets or sets the mesh used as pole */
  111753. poleTargetMesh: AbstractMesh;
  111754. /**
  111755. * Gets or sets the bone used as pole
  111756. */
  111757. poleTargetBone: Nullable<Bone>;
  111758. /**
  111759. * Gets or sets the target position
  111760. */
  111761. targetPosition: Vector3;
  111762. /**
  111763. * Gets or sets the pole target position
  111764. */
  111765. poleTargetPosition: Vector3;
  111766. /**
  111767. * Gets or sets the pole target local offset
  111768. */
  111769. poleTargetLocalOffset: Vector3;
  111770. /**
  111771. * Gets or sets the pole angle
  111772. */
  111773. poleAngle: number;
  111774. /**
  111775. * Gets or sets the mesh associated with the controller
  111776. */
  111777. mesh: AbstractMesh;
  111778. /**
  111779. * 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)
  111780. */
  111781. slerpAmount: number;
  111782. private _bone1Quat;
  111783. private _bone1Mat;
  111784. private _bone2Ang;
  111785. private _bone1;
  111786. private _bone2;
  111787. private _bone1Length;
  111788. private _bone2Length;
  111789. private _maxAngle;
  111790. private _maxReach;
  111791. private _rightHandedSystem;
  111792. private _bendAxis;
  111793. private _slerping;
  111794. private _adjustRoll;
  111795. /**
  111796. * Gets or sets maximum allowed angle
  111797. */
  111798. get maxAngle(): number;
  111799. set maxAngle(value: number);
  111800. /**
  111801. * Creates a new BoneIKController
  111802. * @param mesh defines the mesh to control
  111803. * @param bone defines the bone to control
  111804. * @param options defines options to set up the controller
  111805. */
  111806. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  111807. targetMesh?: AbstractMesh;
  111808. poleTargetMesh?: AbstractMesh;
  111809. poleTargetBone?: Bone;
  111810. poleTargetLocalOffset?: Vector3;
  111811. poleAngle?: number;
  111812. bendAxis?: Vector3;
  111813. maxAngle?: number;
  111814. slerpAmount?: number;
  111815. });
  111816. private _setMaxAngle;
  111817. /**
  111818. * Force the controller to update the bones
  111819. */
  111820. update(): void;
  111821. }
  111822. }
  111823. declare module BABYLON {
  111824. /**
  111825. * Class used to make a bone look toward a point in space
  111826. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  111827. */
  111828. export class BoneLookController {
  111829. private static _tmpVecs;
  111830. private static _tmpQuat;
  111831. private static _tmpMats;
  111832. /**
  111833. * The target Vector3 that the bone will look at
  111834. */
  111835. target: Vector3;
  111836. /**
  111837. * The mesh that the bone is attached to
  111838. */
  111839. mesh: AbstractMesh;
  111840. /**
  111841. * The bone that will be looking to the target
  111842. */
  111843. bone: Bone;
  111844. /**
  111845. * The up axis of the coordinate system that is used when the bone is rotated
  111846. */
  111847. upAxis: Vector3;
  111848. /**
  111849. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  111850. */
  111851. upAxisSpace: Space;
  111852. /**
  111853. * Used to make an adjustment to the yaw of the bone
  111854. */
  111855. adjustYaw: number;
  111856. /**
  111857. * Used to make an adjustment to the pitch of the bone
  111858. */
  111859. adjustPitch: number;
  111860. /**
  111861. * Used to make an adjustment to the roll of the bone
  111862. */
  111863. adjustRoll: number;
  111864. /**
  111865. * 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)
  111866. */
  111867. slerpAmount: number;
  111868. private _minYaw;
  111869. private _maxYaw;
  111870. private _minPitch;
  111871. private _maxPitch;
  111872. private _minYawSin;
  111873. private _minYawCos;
  111874. private _maxYawSin;
  111875. private _maxYawCos;
  111876. private _midYawConstraint;
  111877. private _minPitchTan;
  111878. private _maxPitchTan;
  111879. private _boneQuat;
  111880. private _slerping;
  111881. private _transformYawPitch;
  111882. private _transformYawPitchInv;
  111883. private _firstFrameSkipped;
  111884. private _yawRange;
  111885. private _fowardAxis;
  111886. /**
  111887. * Gets or sets the minimum yaw angle that the bone can look to
  111888. */
  111889. get minYaw(): number;
  111890. set minYaw(value: number);
  111891. /**
  111892. * Gets or sets the maximum yaw angle that the bone can look to
  111893. */
  111894. get maxYaw(): number;
  111895. set maxYaw(value: number);
  111896. /**
  111897. * Gets or sets the minimum pitch angle that the bone can look to
  111898. */
  111899. get minPitch(): number;
  111900. set minPitch(value: number);
  111901. /**
  111902. * Gets or sets the maximum pitch angle that the bone can look to
  111903. */
  111904. get maxPitch(): number;
  111905. set maxPitch(value: number);
  111906. /**
  111907. * Create a BoneLookController
  111908. * @param mesh the mesh that the bone belongs to
  111909. * @param bone the bone that will be looking to the target
  111910. * @param target the target Vector3 to look at
  111911. * @param options optional settings:
  111912. * * maxYaw: the maximum angle the bone will yaw to
  111913. * * minYaw: the minimum angle the bone will yaw to
  111914. * * maxPitch: the maximum angle the bone will pitch to
  111915. * * minPitch: the minimum angle the bone will yaw to
  111916. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  111917. * * upAxis: the up axis of the coordinate system
  111918. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  111919. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  111920. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  111921. * * adjustYaw: used to make an adjustment to the yaw of the bone
  111922. * * adjustPitch: used to make an adjustment to the pitch of the bone
  111923. * * adjustRoll: used to make an adjustment to the roll of the bone
  111924. **/
  111925. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  111926. maxYaw?: number;
  111927. minYaw?: number;
  111928. maxPitch?: number;
  111929. minPitch?: number;
  111930. slerpAmount?: number;
  111931. upAxis?: Vector3;
  111932. upAxisSpace?: Space;
  111933. yawAxis?: Vector3;
  111934. pitchAxis?: Vector3;
  111935. adjustYaw?: number;
  111936. adjustPitch?: number;
  111937. adjustRoll?: number;
  111938. });
  111939. /**
  111940. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  111941. */
  111942. update(): void;
  111943. private _getAngleDiff;
  111944. private _getAngleBetween;
  111945. private _isAngleBetween;
  111946. }
  111947. }
  111948. declare module BABYLON {
  111949. /**
  111950. * Manage the gamepad inputs to control an arc rotate camera.
  111951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111952. */
  111953. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  111954. /**
  111955. * Defines the camera the input is attached to.
  111956. */
  111957. camera: ArcRotateCamera;
  111958. /**
  111959. * Defines the gamepad the input is gathering event from.
  111960. */
  111961. gamepad: Nullable<Gamepad>;
  111962. /**
  111963. * Defines the gamepad rotation sensiblity.
  111964. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111965. */
  111966. gamepadRotationSensibility: number;
  111967. /**
  111968. * Defines the gamepad move sensiblity.
  111969. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111970. */
  111971. gamepadMoveSensibility: number;
  111972. private _yAxisScale;
  111973. /**
  111974. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  111975. */
  111976. get invertYAxis(): boolean;
  111977. set invertYAxis(value: boolean);
  111978. private _onGamepadConnectedObserver;
  111979. private _onGamepadDisconnectedObserver;
  111980. /**
  111981. * Attach the input controls to a specific dom element to get the input from.
  111982. * @param element Defines the element the controls should be listened from
  111983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111984. */
  111985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111986. /**
  111987. * Detach the current controls from the specified dom element.
  111988. * @param element Defines the element to stop listening the inputs from
  111989. */
  111990. detachControl(element: Nullable<HTMLElement>): void;
  111991. /**
  111992. * Update the current camera state depending on the inputs that have been used this frame.
  111993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111994. */
  111995. checkInputs(): void;
  111996. /**
  111997. * Gets the class name of the current intput.
  111998. * @returns the class name
  111999. */
  112000. getClassName(): string;
  112001. /**
  112002. * Get the friendly name associated with the input class.
  112003. * @returns the input friendly name
  112004. */
  112005. getSimpleName(): string;
  112006. }
  112007. }
  112008. declare module BABYLON {
  112009. interface ArcRotateCameraInputsManager {
  112010. /**
  112011. * Add orientation input support to the input manager.
  112012. * @returns the current input manager
  112013. */
  112014. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112015. }
  112016. /**
  112017. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112019. */
  112020. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112021. /**
  112022. * Defines the camera the input is attached to.
  112023. */
  112024. camera: ArcRotateCamera;
  112025. /**
  112026. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112027. */
  112028. alphaCorrection: number;
  112029. /**
  112030. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112031. */
  112032. gammaCorrection: number;
  112033. private _alpha;
  112034. private _gamma;
  112035. private _dirty;
  112036. private _deviceOrientationHandler;
  112037. /**
  112038. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112039. */
  112040. constructor();
  112041. /**
  112042. * Attach the input controls to a specific dom element to get the input from.
  112043. * @param element Defines the element the controls should be listened from
  112044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112045. */
  112046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112047. /** @hidden */
  112048. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112049. /**
  112050. * Update the current camera state depending on the inputs that have been used this frame.
  112051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112052. */
  112053. checkInputs(): void;
  112054. /**
  112055. * Detach the current controls from the specified dom element.
  112056. * @param element Defines the element to stop listening the inputs from
  112057. */
  112058. detachControl(element: Nullable<HTMLElement>): void;
  112059. /**
  112060. * Gets the class name of the current intput.
  112061. * @returns the class name
  112062. */
  112063. getClassName(): string;
  112064. /**
  112065. * Get the friendly name associated with the input class.
  112066. * @returns the input friendly name
  112067. */
  112068. getSimpleName(): string;
  112069. }
  112070. }
  112071. declare module BABYLON {
  112072. /**
  112073. * Listen to mouse events to control the camera.
  112074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112075. */
  112076. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112077. /**
  112078. * Defines the camera the input is attached to.
  112079. */
  112080. camera: FlyCamera;
  112081. /**
  112082. * Defines if touch is enabled. (Default is true.)
  112083. */
  112084. touchEnabled: boolean;
  112085. /**
  112086. * Defines the buttons associated with the input to handle camera rotation.
  112087. */
  112088. buttons: number[];
  112089. /**
  112090. * Assign buttons for Yaw control.
  112091. */
  112092. buttonsYaw: number[];
  112093. /**
  112094. * Assign buttons for Pitch control.
  112095. */
  112096. buttonsPitch: number[];
  112097. /**
  112098. * Assign buttons for Roll control.
  112099. */
  112100. buttonsRoll: number[];
  112101. /**
  112102. * Detect if any button is being pressed while mouse is moved.
  112103. * -1 = Mouse locked.
  112104. * 0 = Left button.
  112105. * 1 = Middle Button.
  112106. * 2 = Right Button.
  112107. */
  112108. activeButton: number;
  112109. /**
  112110. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  112111. * Higher values reduce its sensitivity.
  112112. */
  112113. angularSensibility: number;
  112114. private _mousemoveCallback;
  112115. private _observer;
  112116. private _rollObserver;
  112117. private previousPosition;
  112118. private noPreventDefault;
  112119. private element;
  112120. /**
  112121. * Listen to mouse events to control the camera.
  112122. * @param touchEnabled Define if touch is enabled. (Default is true.)
  112123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112124. */
  112125. constructor(touchEnabled?: boolean);
  112126. /**
  112127. * Attach the mouse control to the HTML DOM element.
  112128. * @param element Defines the element that listens to the input events.
  112129. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  112130. */
  112131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112132. /**
  112133. * Detach the current controls from the specified dom element.
  112134. * @param element Defines the element to stop listening the inputs from
  112135. */
  112136. detachControl(element: Nullable<HTMLElement>): void;
  112137. /**
  112138. * Gets the class name of the current input.
  112139. * @returns the class name.
  112140. */
  112141. getClassName(): string;
  112142. /**
  112143. * Get the friendly name associated with the input class.
  112144. * @returns the input's friendly name.
  112145. */
  112146. getSimpleName(): string;
  112147. private _pointerInput;
  112148. private _onMouseMove;
  112149. /**
  112150. * Rotate camera by mouse offset.
  112151. */
  112152. private rotateCamera;
  112153. }
  112154. }
  112155. declare module BABYLON {
  112156. /**
  112157. * Default Inputs manager for the FlyCamera.
  112158. * It groups all the default supported inputs for ease of use.
  112159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112160. */
  112161. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  112162. /**
  112163. * Instantiates a new FlyCameraInputsManager.
  112164. * @param camera Defines the camera the inputs belong to.
  112165. */
  112166. constructor(camera: FlyCamera);
  112167. /**
  112168. * Add keyboard input support to the input manager.
  112169. * @returns the new FlyCameraKeyboardMoveInput().
  112170. */
  112171. addKeyboard(): FlyCameraInputsManager;
  112172. /**
  112173. * Add mouse input support to the input manager.
  112174. * @param touchEnabled Enable touch screen support.
  112175. * @returns the new FlyCameraMouseInput().
  112176. */
  112177. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  112178. }
  112179. }
  112180. declare module BABYLON {
  112181. /**
  112182. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112183. * such as in a 3D Space Shooter or a Flight Simulator.
  112184. */
  112185. export class FlyCamera extends TargetCamera {
  112186. /**
  112187. * Define the collision ellipsoid of the camera.
  112188. * This is helpful for simulating a camera body, like a player's body.
  112189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112190. */
  112191. ellipsoid: Vector3;
  112192. /**
  112193. * Define an offset for the position of the ellipsoid around the camera.
  112194. * This can be helpful if the camera is attached away from the player's body center,
  112195. * such as at its head.
  112196. */
  112197. ellipsoidOffset: Vector3;
  112198. /**
  112199. * Enable or disable collisions of the camera with the rest of the scene objects.
  112200. */
  112201. checkCollisions: boolean;
  112202. /**
  112203. * Enable or disable gravity on the camera.
  112204. */
  112205. applyGravity: boolean;
  112206. /**
  112207. * Define the current direction the camera is moving to.
  112208. */
  112209. cameraDirection: Vector3;
  112210. /**
  112211. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  112212. * This overrides and empties cameraRotation.
  112213. */
  112214. rotationQuaternion: Quaternion;
  112215. /**
  112216. * Track Roll to maintain the wanted Rolling when looking around.
  112217. */
  112218. _trackRoll: number;
  112219. /**
  112220. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  112221. */
  112222. rollCorrect: number;
  112223. /**
  112224. * Mimic a banked turn, Rolling the camera when Yawing.
  112225. * It's recommended to use rollCorrect = 10 for faster banking correction.
  112226. */
  112227. bankedTurn: boolean;
  112228. /**
  112229. * Limit in radians for how much Roll banking will add. (Default: 90°)
  112230. */
  112231. bankedTurnLimit: number;
  112232. /**
  112233. * Value of 0 disables the banked Roll.
  112234. * Value of 1 is equal to the Yaw angle in radians.
  112235. */
  112236. bankedTurnMultiplier: number;
  112237. /**
  112238. * The inputs manager loads all the input sources, such as keyboard and mouse.
  112239. */
  112240. inputs: FlyCameraInputsManager;
  112241. /**
  112242. * Gets the input sensibility for mouse input.
  112243. * Higher values reduce sensitivity.
  112244. */
  112245. get angularSensibility(): number;
  112246. /**
  112247. * Sets the input sensibility for a mouse input.
  112248. * Higher values reduce sensitivity.
  112249. */
  112250. set angularSensibility(value: number);
  112251. /**
  112252. * Get the keys for camera movement forward.
  112253. */
  112254. get keysForward(): number[];
  112255. /**
  112256. * Set the keys for camera movement forward.
  112257. */
  112258. set keysForward(value: number[]);
  112259. /**
  112260. * Get the keys for camera movement backward.
  112261. */
  112262. get keysBackward(): number[];
  112263. set keysBackward(value: number[]);
  112264. /**
  112265. * Get the keys for camera movement up.
  112266. */
  112267. get keysUp(): number[];
  112268. /**
  112269. * Set the keys for camera movement up.
  112270. */
  112271. set keysUp(value: number[]);
  112272. /**
  112273. * Get the keys for camera movement down.
  112274. */
  112275. get keysDown(): number[];
  112276. /**
  112277. * Set the keys for camera movement down.
  112278. */
  112279. set keysDown(value: number[]);
  112280. /**
  112281. * Get the keys for camera movement left.
  112282. */
  112283. get keysLeft(): number[];
  112284. /**
  112285. * Set the keys for camera movement left.
  112286. */
  112287. set keysLeft(value: number[]);
  112288. /**
  112289. * Set the keys for camera movement right.
  112290. */
  112291. get keysRight(): number[];
  112292. /**
  112293. * Set the keys for camera movement right.
  112294. */
  112295. set keysRight(value: number[]);
  112296. /**
  112297. * Event raised when the camera collides with a mesh in the scene.
  112298. */
  112299. onCollide: (collidedMesh: AbstractMesh) => void;
  112300. private _collider;
  112301. private _needMoveForGravity;
  112302. private _oldPosition;
  112303. private _diffPosition;
  112304. private _newPosition;
  112305. /** @hidden */
  112306. _localDirection: Vector3;
  112307. /** @hidden */
  112308. _transformedDirection: Vector3;
  112309. /**
  112310. * Instantiates a FlyCamera.
  112311. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112312. * such as in a 3D Space Shooter or a Flight Simulator.
  112313. * @param name Define the name of the camera in the scene.
  112314. * @param position Define the starting position of the camera in the scene.
  112315. * @param scene Define the scene the camera belongs to.
  112316. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  112317. */
  112318. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112319. /**
  112320. * Attach a control to the HTML DOM element.
  112321. * @param element Defines the element that listens to the input events.
  112322. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  112323. */
  112324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112325. /**
  112326. * Detach a control from the HTML DOM element.
  112327. * The camera will stop reacting to that input.
  112328. * @param element Defines the element that listens to the input events.
  112329. */
  112330. detachControl(element: HTMLElement): void;
  112331. private _collisionMask;
  112332. /**
  112333. * Get the mask that the camera ignores in collision events.
  112334. */
  112335. get collisionMask(): number;
  112336. /**
  112337. * Set the mask that the camera ignores in collision events.
  112338. */
  112339. set collisionMask(mask: number);
  112340. /** @hidden */
  112341. _collideWithWorld(displacement: Vector3): void;
  112342. /** @hidden */
  112343. private _onCollisionPositionChange;
  112344. /** @hidden */
  112345. _checkInputs(): void;
  112346. /** @hidden */
  112347. _decideIfNeedsToMove(): boolean;
  112348. /** @hidden */
  112349. _updatePosition(): void;
  112350. /**
  112351. * Restore the Roll to its target value at the rate specified.
  112352. * @param rate - Higher means slower restoring.
  112353. * @hidden
  112354. */
  112355. restoreRoll(rate: number): void;
  112356. /**
  112357. * Destroy the camera and release the current resources held by it.
  112358. */
  112359. dispose(): void;
  112360. /**
  112361. * Get the current object class name.
  112362. * @returns the class name.
  112363. */
  112364. getClassName(): string;
  112365. }
  112366. }
  112367. declare module BABYLON {
  112368. /**
  112369. * Listen to keyboard events to control the camera.
  112370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112371. */
  112372. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  112373. /**
  112374. * Defines the camera the input is attached to.
  112375. */
  112376. camera: FlyCamera;
  112377. /**
  112378. * The list of keyboard keys used to control the forward move of the camera.
  112379. */
  112380. keysForward: number[];
  112381. /**
  112382. * The list of keyboard keys used to control the backward move of the camera.
  112383. */
  112384. keysBackward: number[];
  112385. /**
  112386. * The list of keyboard keys used to control the forward move of the camera.
  112387. */
  112388. keysUp: number[];
  112389. /**
  112390. * The list of keyboard keys used to control the backward move of the camera.
  112391. */
  112392. keysDown: number[];
  112393. /**
  112394. * The list of keyboard keys used to control the right strafe move of the camera.
  112395. */
  112396. keysRight: number[];
  112397. /**
  112398. * The list of keyboard keys used to control the left strafe move of the camera.
  112399. */
  112400. keysLeft: number[];
  112401. private _keys;
  112402. private _onCanvasBlurObserver;
  112403. private _onKeyboardObserver;
  112404. private _engine;
  112405. private _scene;
  112406. /**
  112407. * Attach the input controls to a specific dom element to get the input from.
  112408. * @param element Defines the element the controls should be listened from
  112409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112410. */
  112411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112412. /**
  112413. * Detach the current controls from the specified dom element.
  112414. * @param element Defines the element to stop listening the inputs from
  112415. */
  112416. detachControl(element: Nullable<HTMLElement>): void;
  112417. /**
  112418. * Gets the class name of the current intput.
  112419. * @returns the class name
  112420. */
  112421. getClassName(): string;
  112422. /** @hidden */
  112423. _onLostFocus(e: FocusEvent): void;
  112424. /**
  112425. * Get the friendly name associated with the input class.
  112426. * @returns the input friendly name
  112427. */
  112428. getSimpleName(): string;
  112429. /**
  112430. * Update the current camera state depending on the inputs that have been used this frame.
  112431. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112432. */
  112433. checkInputs(): void;
  112434. }
  112435. }
  112436. declare module BABYLON {
  112437. /**
  112438. * Manage the mouse wheel inputs to control a follow camera.
  112439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112440. */
  112441. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  112442. /**
  112443. * Defines the camera the input is attached to.
  112444. */
  112445. camera: FollowCamera;
  112446. /**
  112447. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  112448. */
  112449. axisControlRadius: boolean;
  112450. /**
  112451. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  112452. */
  112453. axisControlHeight: boolean;
  112454. /**
  112455. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  112456. */
  112457. axisControlRotation: boolean;
  112458. /**
  112459. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  112460. * relation to mouseWheel events.
  112461. */
  112462. wheelPrecision: number;
  112463. /**
  112464. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112465. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112466. */
  112467. wheelDeltaPercentage: number;
  112468. private _wheel;
  112469. private _observer;
  112470. /**
  112471. * Attach the input controls to a specific dom element to get the input from.
  112472. * @param element Defines the element the controls should be listened from
  112473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112474. */
  112475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112476. /**
  112477. * Detach the current controls from the specified dom element.
  112478. * @param element Defines the element to stop listening the inputs from
  112479. */
  112480. detachControl(element: Nullable<HTMLElement>): void;
  112481. /**
  112482. * Gets the class name of the current intput.
  112483. * @returns the class name
  112484. */
  112485. getClassName(): string;
  112486. /**
  112487. * Get the friendly name associated with the input class.
  112488. * @returns the input friendly name
  112489. */
  112490. getSimpleName(): string;
  112491. }
  112492. }
  112493. declare module BABYLON {
  112494. /**
  112495. * Manage the pointers inputs to control an follow camera.
  112496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112497. */
  112498. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  112499. /**
  112500. * Defines the camera the input is attached to.
  112501. */
  112502. camera: FollowCamera;
  112503. /**
  112504. * Gets the class name of the current input.
  112505. * @returns the class name
  112506. */
  112507. getClassName(): string;
  112508. /**
  112509. * Defines the pointer angular sensibility along the X axis or how fast is
  112510. * the camera rotating.
  112511. * A negative number will reverse the axis direction.
  112512. */
  112513. angularSensibilityX: number;
  112514. /**
  112515. * Defines the pointer angular sensibility along the Y axis or how fast is
  112516. * the camera rotating.
  112517. * A negative number will reverse the axis direction.
  112518. */
  112519. angularSensibilityY: number;
  112520. /**
  112521. * Defines the pointer pinch precision or how fast is the camera zooming.
  112522. * A negative number will reverse the axis direction.
  112523. */
  112524. pinchPrecision: number;
  112525. /**
  112526. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112527. * from 0.
  112528. * It defines the percentage of current camera.radius to use as delta when
  112529. * pinch zoom is used.
  112530. */
  112531. pinchDeltaPercentage: number;
  112532. /**
  112533. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  112534. */
  112535. axisXControlRadius: boolean;
  112536. /**
  112537. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  112538. */
  112539. axisXControlHeight: boolean;
  112540. /**
  112541. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  112542. */
  112543. axisXControlRotation: boolean;
  112544. /**
  112545. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  112546. */
  112547. axisYControlRadius: boolean;
  112548. /**
  112549. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  112550. */
  112551. axisYControlHeight: boolean;
  112552. /**
  112553. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  112554. */
  112555. axisYControlRotation: boolean;
  112556. /**
  112557. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  112558. */
  112559. axisPinchControlRadius: boolean;
  112560. /**
  112561. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  112562. */
  112563. axisPinchControlHeight: boolean;
  112564. /**
  112565. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  112566. */
  112567. axisPinchControlRotation: boolean;
  112568. /**
  112569. * Log error messages if basic misconfiguration has occurred.
  112570. */
  112571. warningEnable: boolean;
  112572. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112573. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112574. private _warningCounter;
  112575. private _warning;
  112576. }
  112577. }
  112578. declare module BABYLON {
  112579. /**
  112580. * Default Inputs manager for the FollowCamera.
  112581. * It groups all the default supported inputs for ease of use.
  112582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112583. */
  112584. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  112585. /**
  112586. * Instantiates a new FollowCameraInputsManager.
  112587. * @param camera Defines the camera the inputs belong to
  112588. */
  112589. constructor(camera: FollowCamera);
  112590. /**
  112591. * Add keyboard input support to the input manager.
  112592. * @returns the current input manager
  112593. */
  112594. addKeyboard(): FollowCameraInputsManager;
  112595. /**
  112596. * Add mouse wheel input support to the input manager.
  112597. * @returns the current input manager
  112598. */
  112599. addMouseWheel(): FollowCameraInputsManager;
  112600. /**
  112601. * Add pointers input support to the input manager.
  112602. * @returns the current input manager
  112603. */
  112604. addPointers(): FollowCameraInputsManager;
  112605. /**
  112606. * Add orientation input support to the input manager.
  112607. * @returns the current input manager
  112608. */
  112609. addVRDeviceOrientation(): FollowCameraInputsManager;
  112610. }
  112611. }
  112612. declare module BABYLON {
  112613. /**
  112614. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  112615. * an arc rotate version arcFollowCamera are available.
  112616. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112617. */
  112618. export class FollowCamera extends TargetCamera {
  112619. /**
  112620. * Distance the follow camera should follow an object at
  112621. */
  112622. radius: number;
  112623. /**
  112624. * Minimum allowed distance of the camera to the axis of rotation
  112625. * (The camera can not get closer).
  112626. * This can help limiting how the Camera is able to move in the scene.
  112627. */
  112628. lowerRadiusLimit: Nullable<number>;
  112629. /**
  112630. * Maximum allowed distance of the camera to the axis of rotation
  112631. * (The camera can not get further).
  112632. * This can help limiting how the Camera is able to move in the scene.
  112633. */
  112634. upperRadiusLimit: Nullable<number>;
  112635. /**
  112636. * Define a rotation offset between the camera and the object it follows
  112637. */
  112638. rotationOffset: number;
  112639. /**
  112640. * Minimum allowed angle to camera position relative to target object.
  112641. * This can help limiting how the Camera is able to move in the scene.
  112642. */
  112643. lowerRotationOffsetLimit: Nullable<number>;
  112644. /**
  112645. * Maximum allowed angle to camera position relative to target object.
  112646. * This can help limiting how the Camera is able to move in the scene.
  112647. */
  112648. upperRotationOffsetLimit: Nullable<number>;
  112649. /**
  112650. * Define a height offset between the camera and the object it follows.
  112651. * It can help following an object from the top (like a car chaing a plane)
  112652. */
  112653. heightOffset: number;
  112654. /**
  112655. * Minimum allowed height of camera position relative to target object.
  112656. * This can help limiting how the Camera is able to move in the scene.
  112657. */
  112658. lowerHeightOffsetLimit: Nullable<number>;
  112659. /**
  112660. * Maximum allowed height of camera position relative to target object.
  112661. * This can help limiting how the Camera is able to move in the scene.
  112662. */
  112663. upperHeightOffsetLimit: Nullable<number>;
  112664. /**
  112665. * Define how fast the camera can accelerate to follow it s target.
  112666. */
  112667. cameraAcceleration: number;
  112668. /**
  112669. * Define the speed limit of the camera following an object.
  112670. */
  112671. maxCameraSpeed: number;
  112672. /**
  112673. * Define the target of the camera.
  112674. */
  112675. lockedTarget: Nullable<AbstractMesh>;
  112676. /**
  112677. * Defines the input associated with the camera.
  112678. */
  112679. inputs: FollowCameraInputsManager;
  112680. /**
  112681. * Instantiates the follow camera.
  112682. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112683. * @param name Define the name of the camera in the scene
  112684. * @param position Define the position of the camera
  112685. * @param scene Define the scene the camera belong to
  112686. * @param lockedTarget Define the target of the camera
  112687. */
  112688. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  112689. private _follow;
  112690. /**
  112691. * Attached controls to the current camera.
  112692. * @param element Defines the element the controls should be listened from
  112693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112694. */
  112695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112696. /**
  112697. * Detach the current controls from the camera.
  112698. * The camera will stop reacting to inputs.
  112699. * @param element Defines the element to stop listening the inputs from
  112700. */
  112701. detachControl(element: HTMLElement): void;
  112702. /** @hidden */
  112703. _checkInputs(): void;
  112704. private _checkLimits;
  112705. /**
  112706. * Gets the camera class name.
  112707. * @returns the class name
  112708. */
  112709. getClassName(): string;
  112710. }
  112711. /**
  112712. * Arc Rotate version of the follow camera.
  112713. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  112714. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112715. */
  112716. export class ArcFollowCamera extends TargetCamera {
  112717. /** The longitudinal angle of the camera */
  112718. alpha: number;
  112719. /** The latitudinal angle of the camera */
  112720. beta: number;
  112721. /** The radius of the camera from its target */
  112722. radius: number;
  112723. /** Define the camera target (the messh it should follow) */
  112724. target: Nullable<AbstractMesh>;
  112725. private _cartesianCoordinates;
  112726. /**
  112727. * Instantiates a new ArcFollowCamera
  112728. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  112729. * @param name Define the name of the camera
  112730. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  112731. * @param beta Define the rotation angle of the camera around the elevation axis
  112732. * @param radius Define the radius of the camera from its target point
  112733. * @param target Define the target of the camera
  112734. * @param scene Define the scene the camera belongs to
  112735. */
  112736. constructor(name: string,
  112737. /** The longitudinal angle of the camera */
  112738. alpha: number,
  112739. /** The latitudinal angle of the camera */
  112740. beta: number,
  112741. /** The radius of the camera from its target */
  112742. radius: number,
  112743. /** Define the camera target (the messh it should follow) */
  112744. target: Nullable<AbstractMesh>, scene: Scene);
  112745. private _follow;
  112746. /** @hidden */
  112747. _checkInputs(): void;
  112748. /**
  112749. * Returns the class name of the object.
  112750. * It is mostly used internally for serialization purposes.
  112751. */
  112752. getClassName(): string;
  112753. }
  112754. }
  112755. declare module BABYLON {
  112756. /**
  112757. * Manage the keyboard inputs to control the movement of a follow camera.
  112758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112759. */
  112760. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  112761. /**
  112762. * Defines the camera the input is attached to.
  112763. */
  112764. camera: FollowCamera;
  112765. /**
  112766. * Defines the list of key codes associated with the up action (increase heightOffset)
  112767. */
  112768. keysHeightOffsetIncr: number[];
  112769. /**
  112770. * Defines the list of key codes associated with the down action (decrease heightOffset)
  112771. */
  112772. keysHeightOffsetDecr: number[];
  112773. /**
  112774. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  112775. */
  112776. keysHeightOffsetModifierAlt: boolean;
  112777. /**
  112778. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  112779. */
  112780. keysHeightOffsetModifierCtrl: boolean;
  112781. /**
  112782. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  112783. */
  112784. keysHeightOffsetModifierShift: boolean;
  112785. /**
  112786. * Defines the list of key codes associated with the left action (increase rotationOffset)
  112787. */
  112788. keysRotationOffsetIncr: number[];
  112789. /**
  112790. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  112791. */
  112792. keysRotationOffsetDecr: number[];
  112793. /**
  112794. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  112795. */
  112796. keysRotationOffsetModifierAlt: boolean;
  112797. /**
  112798. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  112799. */
  112800. keysRotationOffsetModifierCtrl: boolean;
  112801. /**
  112802. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  112803. */
  112804. keysRotationOffsetModifierShift: boolean;
  112805. /**
  112806. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  112807. */
  112808. keysRadiusIncr: number[];
  112809. /**
  112810. * Defines the list of key codes associated with the zoom-out action (increase radius)
  112811. */
  112812. keysRadiusDecr: number[];
  112813. /**
  112814. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  112815. */
  112816. keysRadiusModifierAlt: boolean;
  112817. /**
  112818. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  112819. */
  112820. keysRadiusModifierCtrl: boolean;
  112821. /**
  112822. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  112823. */
  112824. keysRadiusModifierShift: boolean;
  112825. /**
  112826. * Defines the rate of change of heightOffset.
  112827. */
  112828. heightSensibility: number;
  112829. /**
  112830. * Defines the rate of change of rotationOffset.
  112831. */
  112832. rotationSensibility: number;
  112833. /**
  112834. * Defines the rate of change of radius.
  112835. */
  112836. radiusSensibility: number;
  112837. private _keys;
  112838. private _ctrlPressed;
  112839. private _altPressed;
  112840. private _shiftPressed;
  112841. private _onCanvasBlurObserver;
  112842. private _onKeyboardObserver;
  112843. private _engine;
  112844. private _scene;
  112845. /**
  112846. * Attach the input controls to a specific dom element to get the input from.
  112847. * @param element Defines the element the controls should be listened from
  112848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112849. */
  112850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112851. /**
  112852. * Detach the current controls from the specified dom element.
  112853. * @param element Defines the element to stop listening the inputs from
  112854. */
  112855. detachControl(element: Nullable<HTMLElement>): void;
  112856. /**
  112857. * Update the current camera state depending on the inputs that have been used this frame.
  112858. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112859. */
  112860. checkInputs(): void;
  112861. /**
  112862. * Gets the class name of the current input.
  112863. * @returns the class name
  112864. */
  112865. getClassName(): string;
  112866. /**
  112867. * Get the friendly name associated with the input class.
  112868. * @returns the input friendly name
  112869. */
  112870. getSimpleName(): string;
  112871. /**
  112872. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  112873. * allow modification of the heightOffset value.
  112874. */
  112875. private _modifierHeightOffset;
  112876. /**
  112877. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  112878. * allow modification of the rotationOffset value.
  112879. */
  112880. private _modifierRotationOffset;
  112881. /**
  112882. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  112883. * allow modification of the radius value.
  112884. */
  112885. private _modifierRadius;
  112886. }
  112887. }
  112888. declare module BABYLON {
  112889. interface FreeCameraInputsManager {
  112890. /**
  112891. * @hidden
  112892. */
  112893. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  112894. /**
  112895. * Add orientation input support to the input manager.
  112896. * @returns the current input manager
  112897. */
  112898. addDeviceOrientation(): FreeCameraInputsManager;
  112899. }
  112900. /**
  112901. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  112902. * Screen rotation is taken into account.
  112903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112904. */
  112905. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  112906. private _camera;
  112907. private _screenOrientationAngle;
  112908. private _constantTranform;
  112909. private _screenQuaternion;
  112910. private _alpha;
  112911. private _beta;
  112912. private _gamma;
  112913. /**
  112914. * Can be used to detect if a device orientation sensor is available on a device
  112915. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  112916. * @returns a promise that will resolve on orientation change
  112917. */
  112918. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  112919. /**
  112920. * @hidden
  112921. */
  112922. _onDeviceOrientationChangedObservable: Observable<void>;
  112923. /**
  112924. * Instantiates a new input
  112925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112926. */
  112927. constructor();
  112928. /**
  112929. * Define the camera controlled by the input.
  112930. */
  112931. get camera(): FreeCamera;
  112932. set camera(camera: FreeCamera);
  112933. /**
  112934. * Attach the input controls to a specific dom element to get the input from.
  112935. * @param element Defines the element the controls should be listened from
  112936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112937. */
  112938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112939. private _orientationChanged;
  112940. private _deviceOrientation;
  112941. /**
  112942. * Detach the current controls from the specified dom element.
  112943. * @param element Defines the element to stop listening the inputs from
  112944. */
  112945. detachControl(element: Nullable<HTMLElement>): void;
  112946. /**
  112947. * Update the current camera state depending on the inputs that have been used this frame.
  112948. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112949. */
  112950. checkInputs(): void;
  112951. /**
  112952. * Gets the class name of the current intput.
  112953. * @returns the class name
  112954. */
  112955. getClassName(): string;
  112956. /**
  112957. * Get the friendly name associated with the input class.
  112958. * @returns the input friendly name
  112959. */
  112960. getSimpleName(): string;
  112961. }
  112962. }
  112963. declare module BABYLON {
  112964. /**
  112965. * Manage the gamepad inputs to control a free camera.
  112966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112967. */
  112968. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  112969. /**
  112970. * Define the camera the input is attached to.
  112971. */
  112972. camera: FreeCamera;
  112973. /**
  112974. * Define the Gamepad controlling the input
  112975. */
  112976. gamepad: Nullable<Gamepad>;
  112977. /**
  112978. * Defines the gamepad rotation sensiblity.
  112979. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112980. */
  112981. gamepadAngularSensibility: number;
  112982. /**
  112983. * Defines the gamepad move sensiblity.
  112984. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112985. */
  112986. gamepadMoveSensibility: number;
  112987. private _yAxisScale;
  112988. /**
  112989. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112990. */
  112991. get invertYAxis(): boolean;
  112992. set invertYAxis(value: boolean);
  112993. private _onGamepadConnectedObserver;
  112994. private _onGamepadDisconnectedObserver;
  112995. private _cameraTransform;
  112996. private _deltaTransform;
  112997. private _vector3;
  112998. private _vector2;
  112999. /**
  113000. * Attach the input controls to a specific dom element to get the input from.
  113001. * @param element Defines the element the controls should be listened from
  113002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113003. */
  113004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113005. /**
  113006. * Detach the current controls from the specified dom element.
  113007. * @param element Defines the element to stop listening the inputs from
  113008. */
  113009. detachControl(element: Nullable<HTMLElement>): void;
  113010. /**
  113011. * Update the current camera state depending on the inputs that have been used this frame.
  113012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113013. */
  113014. checkInputs(): void;
  113015. /**
  113016. * Gets the class name of the current intput.
  113017. * @returns the class name
  113018. */
  113019. getClassName(): string;
  113020. /**
  113021. * Get the friendly name associated with the input class.
  113022. * @returns the input friendly name
  113023. */
  113024. getSimpleName(): string;
  113025. }
  113026. }
  113027. declare module BABYLON {
  113028. /**
  113029. * Defines the potential axis of a Joystick
  113030. */
  113031. export enum JoystickAxis {
  113032. /** X axis */
  113033. X = 0,
  113034. /** Y axis */
  113035. Y = 1,
  113036. /** Z axis */
  113037. Z = 2
  113038. }
  113039. /**
  113040. * Class used to define virtual joystick (used in touch mode)
  113041. */
  113042. export class VirtualJoystick {
  113043. /**
  113044. * Gets or sets a boolean indicating that left and right values must be inverted
  113045. */
  113046. reverseLeftRight: boolean;
  113047. /**
  113048. * Gets or sets a boolean indicating that up and down values must be inverted
  113049. */
  113050. reverseUpDown: boolean;
  113051. /**
  113052. * Gets the offset value for the position (ie. the change of the position value)
  113053. */
  113054. deltaPosition: Vector3;
  113055. /**
  113056. * Gets a boolean indicating if the virtual joystick was pressed
  113057. */
  113058. pressed: boolean;
  113059. /**
  113060. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113061. */
  113062. static Canvas: Nullable<HTMLCanvasElement>;
  113063. private static _globalJoystickIndex;
  113064. private static vjCanvasContext;
  113065. private static vjCanvasWidth;
  113066. private static vjCanvasHeight;
  113067. private static halfWidth;
  113068. private _action;
  113069. private _axisTargetedByLeftAndRight;
  113070. private _axisTargetedByUpAndDown;
  113071. private _joystickSensibility;
  113072. private _inversedSensibility;
  113073. private _joystickPointerID;
  113074. private _joystickColor;
  113075. private _joystickPointerPos;
  113076. private _joystickPreviousPointerPos;
  113077. private _joystickPointerStartPos;
  113078. private _deltaJoystickVector;
  113079. private _leftJoystick;
  113080. private _touches;
  113081. private _onPointerDownHandlerRef;
  113082. private _onPointerMoveHandlerRef;
  113083. private _onPointerUpHandlerRef;
  113084. private _onResize;
  113085. /**
  113086. * Creates a new virtual joystick
  113087. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113088. */
  113089. constructor(leftJoystick?: boolean);
  113090. /**
  113091. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113092. * @param newJoystickSensibility defines the new sensibility
  113093. */
  113094. setJoystickSensibility(newJoystickSensibility: number): void;
  113095. private _onPointerDown;
  113096. private _onPointerMove;
  113097. private _onPointerUp;
  113098. /**
  113099. * Change the color of the virtual joystick
  113100. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113101. */
  113102. setJoystickColor(newColor: string): void;
  113103. /**
  113104. * Defines a callback to call when the joystick is touched
  113105. * @param action defines the callback
  113106. */
  113107. setActionOnTouch(action: () => any): void;
  113108. /**
  113109. * Defines which axis you'd like to control for left & right
  113110. * @param axis defines the axis to use
  113111. */
  113112. setAxisForLeftRight(axis: JoystickAxis): void;
  113113. /**
  113114. * Defines which axis you'd like to control for up & down
  113115. * @param axis defines the axis to use
  113116. */
  113117. setAxisForUpDown(axis: JoystickAxis): void;
  113118. private _drawVirtualJoystick;
  113119. /**
  113120. * Release internal HTML canvas
  113121. */
  113122. releaseCanvas(): void;
  113123. }
  113124. }
  113125. declare module BABYLON {
  113126. interface FreeCameraInputsManager {
  113127. /**
  113128. * Add virtual joystick input support to the input manager.
  113129. * @returns the current input manager
  113130. */
  113131. addVirtualJoystick(): FreeCameraInputsManager;
  113132. }
  113133. /**
  113134. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  113135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113136. */
  113137. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  113138. /**
  113139. * Defines the camera the input is attached to.
  113140. */
  113141. camera: FreeCamera;
  113142. private _leftjoystick;
  113143. private _rightjoystick;
  113144. /**
  113145. * Gets the left stick of the virtual joystick.
  113146. * @returns The virtual Joystick
  113147. */
  113148. getLeftJoystick(): VirtualJoystick;
  113149. /**
  113150. * Gets the right stick of the virtual joystick.
  113151. * @returns The virtual Joystick
  113152. */
  113153. getRightJoystick(): VirtualJoystick;
  113154. /**
  113155. * Update the current camera state depending on the inputs that have been used this frame.
  113156. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113157. */
  113158. checkInputs(): void;
  113159. /**
  113160. * Attach the input controls to a specific dom element to get the input from.
  113161. * @param element Defines the element the controls should be listened from
  113162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113163. */
  113164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113165. /**
  113166. * Detach the current controls from the specified dom element.
  113167. * @param element Defines the element to stop listening the inputs from
  113168. */
  113169. detachControl(element: Nullable<HTMLElement>): void;
  113170. /**
  113171. * Gets the class name of the current intput.
  113172. * @returns the class name
  113173. */
  113174. getClassName(): string;
  113175. /**
  113176. * Get the friendly name associated with the input class.
  113177. * @returns the input friendly name
  113178. */
  113179. getSimpleName(): string;
  113180. }
  113181. }
  113182. declare module BABYLON {
  113183. /**
  113184. * This represents a FPS type of camera controlled by touch.
  113185. * This is like a universal camera minus the Gamepad controls.
  113186. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113187. */
  113188. export class TouchCamera extends FreeCamera {
  113189. /**
  113190. * Defines the touch sensibility for rotation.
  113191. * The higher the faster.
  113192. */
  113193. get touchAngularSensibility(): number;
  113194. set touchAngularSensibility(value: number);
  113195. /**
  113196. * Defines the touch sensibility for move.
  113197. * The higher the faster.
  113198. */
  113199. get touchMoveSensibility(): number;
  113200. set touchMoveSensibility(value: number);
  113201. /**
  113202. * Instantiates a new touch camera.
  113203. * This represents a FPS type of camera controlled by touch.
  113204. * This is like a universal camera minus the Gamepad controls.
  113205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113206. * @param name Define the name of the camera in the scene
  113207. * @param position Define the start position of the camera in the scene
  113208. * @param scene Define the scene the camera belongs to
  113209. */
  113210. constructor(name: string, position: Vector3, scene: Scene);
  113211. /**
  113212. * Gets the current object class name.
  113213. * @return the class name
  113214. */
  113215. getClassName(): string;
  113216. /** @hidden */
  113217. _setupInputs(): void;
  113218. }
  113219. }
  113220. declare module BABYLON {
  113221. /**
  113222. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  113223. * being tilted forward or back and left or right.
  113224. */
  113225. export class DeviceOrientationCamera extends FreeCamera {
  113226. private _initialQuaternion;
  113227. private _quaternionCache;
  113228. private _tmpDragQuaternion;
  113229. private _disablePointerInputWhenUsingDeviceOrientation;
  113230. /**
  113231. * Creates a new device orientation camera
  113232. * @param name The name of the camera
  113233. * @param position The start position camera
  113234. * @param scene The scene the camera belongs to
  113235. */
  113236. constructor(name: string, position: Vector3, scene: Scene);
  113237. /**
  113238. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  113239. */
  113240. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  113241. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  113242. private _dragFactor;
  113243. /**
  113244. * Enabled turning on the y axis when the orientation sensor is active
  113245. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  113246. */
  113247. enableHorizontalDragging(dragFactor?: number): void;
  113248. /**
  113249. * Gets the current instance class name ("DeviceOrientationCamera").
  113250. * This helps avoiding instanceof at run time.
  113251. * @returns the class name
  113252. */
  113253. getClassName(): string;
  113254. /**
  113255. * @hidden
  113256. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  113257. */
  113258. _checkInputs(): void;
  113259. /**
  113260. * Reset the camera to its default orientation on the specified axis only.
  113261. * @param axis The axis to reset
  113262. */
  113263. resetToCurrentRotation(axis?: Axis): void;
  113264. }
  113265. }
  113266. declare module BABYLON {
  113267. /**
  113268. * Defines supported buttons for XBox360 compatible gamepads
  113269. */
  113270. export enum Xbox360Button {
  113271. /** A */
  113272. A = 0,
  113273. /** B */
  113274. B = 1,
  113275. /** X */
  113276. X = 2,
  113277. /** Y */
  113278. Y = 3,
  113279. /** Start */
  113280. Start = 4,
  113281. /** Back */
  113282. Back = 5,
  113283. /** Left button */
  113284. LB = 6,
  113285. /** Right button */
  113286. RB = 7,
  113287. /** Left stick */
  113288. LeftStick = 8,
  113289. /** Right stick */
  113290. RightStick = 9
  113291. }
  113292. /** Defines values for XBox360 DPad */
  113293. export enum Xbox360Dpad {
  113294. /** Up */
  113295. Up = 0,
  113296. /** Down */
  113297. Down = 1,
  113298. /** Left */
  113299. Left = 2,
  113300. /** Right */
  113301. Right = 3
  113302. }
  113303. /**
  113304. * Defines a XBox360 gamepad
  113305. */
  113306. export class Xbox360Pad extends Gamepad {
  113307. private _leftTrigger;
  113308. private _rightTrigger;
  113309. private _onlefttriggerchanged;
  113310. private _onrighttriggerchanged;
  113311. private _onbuttondown;
  113312. private _onbuttonup;
  113313. private _ondpaddown;
  113314. private _ondpadup;
  113315. /** Observable raised when a button is pressed */
  113316. onButtonDownObservable: Observable<Xbox360Button>;
  113317. /** Observable raised when a button is released */
  113318. onButtonUpObservable: Observable<Xbox360Button>;
  113319. /** Observable raised when a pad is pressed */
  113320. onPadDownObservable: Observable<Xbox360Dpad>;
  113321. /** Observable raised when a pad is released */
  113322. onPadUpObservable: Observable<Xbox360Dpad>;
  113323. private _buttonA;
  113324. private _buttonB;
  113325. private _buttonX;
  113326. private _buttonY;
  113327. private _buttonBack;
  113328. private _buttonStart;
  113329. private _buttonLB;
  113330. private _buttonRB;
  113331. private _buttonLeftStick;
  113332. private _buttonRightStick;
  113333. private _dPadUp;
  113334. private _dPadDown;
  113335. private _dPadLeft;
  113336. private _dPadRight;
  113337. private _isXboxOnePad;
  113338. /**
  113339. * Creates a new XBox360 gamepad object
  113340. * @param id defines the id of this gamepad
  113341. * @param index defines its index
  113342. * @param gamepad defines the internal HTML gamepad object
  113343. * @param xboxOne defines if it is a XBox One gamepad
  113344. */
  113345. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  113346. /**
  113347. * Defines the callback to call when left trigger is pressed
  113348. * @param callback defines the callback to use
  113349. */
  113350. onlefttriggerchanged(callback: (value: number) => void): void;
  113351. /**
  113352. * Defines the callback to call when right trigger is pressed
  113353. * @param callback defines the callback to use
  113354. */
  113355. onrighttriggerchanged(callback: (value: number) => void): void;
  113356. /**
  113357. * Gets the left trigger value
  113358. */
  113359. get leftTrigger(): number;
  113360. /**
  113361. * Sets the left trigger value
  113362. */
  113363. set leftTrigger(newValue: number);
  113364. /**
  113365. * Gets the right trigger value
  113366. */
  113367. get rightTrigger(): number;
  113368. /**
  113369. * Sets the right trigger value
  113370. */
  113371. set rightTrigger(newValue: number);
  113372. /**
  113373. * Defines the callback to call when a button is pressed
  113374. * @param callback defines the callback to use
  113375. */
  113376. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  113377. /**
  113378. * Defines the callback to call when a button is released
  113379. * @param callback defines the callback to use
  113380. */
  113381. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  113382. /**
  113383. * Defines the callback to call when a pad is pressed
  113384. * @param callback defines the callback to use
  113385. */
  113386. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  113387. /**
  113388. * Defines the callback to call when a pad is released
  113389. * @param callback defines the callback to use
  113390. */
  113391. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  113392. private _setButtonValue;
  113393. private _setDPadValue;
  113394. /**
  113395. * Gets the value of the `A` button
  113396. */
  113397. get buttonA(): number;
  113398. /**
  113399. * Sets the value of the `A` button
  113400. */
  113401. set buttonA(value: number);
  113402. /**
  113403. * Gets the value of the `B` button
  113404. */
  113405. get buttonB(): number;
  113406. /**
  113407. * Sets the value of the `B` button
  113408. */
  113409. set buttonB(value: number);
  113410. /**
  113411. * Gets the value of the `X` button
  113412. */
  113413. get buttonX(): number;
  113414. /**
  113415. * Sets the value of the `X` button
  113416. */
  113417. set buttonX(value: number);
  113418. /**
  113419. * Gets the value of the `Y` button
  113420. */
  113421. get buttonY(): number;
  113422. /**
  113423. * Sets the value of the `Y` button
  113424. */
  113425. set buttonY(value: number);
  113426. /**
  113427. * Gets the value of the `Start` button
  113428. */
  113429. get buttonStart(): number;
  113430. /**
  113431. * Sets the value of the `Start` button
  113432. */
  113433. set buttonStart(value: number);
  113434. /**
  113435. * Gets the value of the `Back` button
  113436. */
  113437. get buttonBack(): number;
  113438. /**
  113439. * Sets the value of the `Back` button
  113440. */
  113441. set buttonBack(value: number);
  113442. /**
  113443. * Gets the value of the `Left` button
  113444. */
  113445. get buttonLB(): number;
  113446. /**
  113447. * Sets the value of the `Left` button
  113448. */
  113449. set buttonLB(value: number);
  113450. /**
  113451. * Gets the value of the `Right` button
  113452. */
  113453. get buttonRB(): number;
  113454. /**
  113455. * Sets the value of the `Right` button
  113456. */
  113457. set buttonRB(value: number);
  113458. /**
  113459. * Gets the value of the Left joystick
  113460. */
  113461. get buttonLeftStick(): number;
  113462. /**
  113463. * Sets the value of the Left joystick
  113464. */
  113465. set buttonLeftStick(value: number);
  113466. /**
  113467. * Gets the value of the Right joystick
  113468. */
  113469. get buttonRightStick(): number;
  113470. /**
  113471. * Sets the value of the Right joystick
  113472. */
  113473. set buttonRightStick(value: number);
  113474. /**
  113475. * Gets the value of D-pad up
  113476. */
  113477. get dPadUp(): number;
  113478. /**
  113479. * Sets the value of D-pad up
  113480. */
  113481. set dPadUp(value: number);
  113482. /**
  113483. * Gets the value of D-pad down
  113484. */
  113485. get dPadDown(): number;
  113486. /**
  113487. * Sets the value of D-pad down
  113488. */
  113489. set dPadDown(value: number);
  113490. /**
  113491. * Gets the value of D-pad left
  113492. */
  113493. get dPadLeft(): number;
  113494. /**
  113495. * Sets the value of D-pad left
  113496. */
  113497. set dPadLeft(value: number);
  113498. /**
  113499. * Gets the value of D-pad right
  113500. */
  113501. get dPadRight(): number;
  113502. /**
  113503. * Sets the value of D-pad right
  113504. */
  113505. set dPadRight(value: number);
  113506. /**
  113507. * Force the gamepad to synchronize with device values
  113508. */
  113509. update(): void;
  113510. /**
  113511. * Disposes the gamepad
  113512. */
  113513. dispose(): void;
  113514. }
  113515. }
  113516. declare module BABYLON {
  113517. /**
  113518. * Defines supported buttons for DualShock compatible gamepads
  113519. */
  113520. export enum DualShockButton {
  113521. /** Cross */
  113522. Cross = 0,
  113523. /** Circle */
  113524. Circle = 1,
  113525. /** Square */
  113526. Square = 2,
  113527. /** Triangle */
  113528. Triangle = 3,
  113529. /** Options */
  113530. Options = 4,
  113531. /** Share */
  113532. Share = 5,
  113533. /** L1 */
  113534. L1 = 6,
  113535. /** R1 */
  113536. R1 = 7,
  113537. /** Left stick */
  113538. LeftStick = 8,
  113539. /** Right stick */
  113540. RightStick = 9
  113541. }
  113542. /** Defines values for DualShock DPad */
  113543. export enum DualShockDpad {
  113544. /** Up */
  113545. Up = 0,
  113546. /** Down */
  113547. Down = 1,
  113548. /** Left */
  113549. Left = 2,
  113550. /** Right */
  113551. Right = 3
  113552. }
  113553. /**
  113554. * Defines a DualShock gamepad
  113555. */
  113556. export class DualShockPad extends Gamepad {
  113557. private _leftTrigger;
  113558. private _rightTrigger;
  113559. private _onlefttriggerchanged;
  113560. private _onrighttriggerchanged;
  113561. private _onbuttondown;
  113562. private _onbuttonup;
  113563. private _ondpaddown;
  113564. private _ondpadup;
  113565. /** Observable raised when a button is pressed */
  113566. onButtonDownObservable: Observable<DualShockButton>;
  113567. /** Observable raised when a button is released */
  113568. onButtonUpObservable: Observable<DualShockButton>;
  113569. /** Observable raised when a pad is pressed */
  113570. onPadDownObservable: Observable<DualShockDpad>;
  113571. /** Observable raised when a pad is released */
  113572. onPadUpObservable: Observable<DualShockDpad>;
  113573. private _buttonCross;
  113574. private _buttonCircle;
  113575. private _buttonSquare;
  113576. private _buttonTriangle;
  113577. private _buttonShare;
  113578. private _buttonOptions;
  113579. private _buttonL1;
  113580. private _buttonR1;
  113581. private _buttonLeftStick;
  113582. private _buttonRightStick;
  113583. private _dPadUp;
  113584. private _dPadDown;
  113585. private _dPadLeft;
  113586. private _dPadRight;
  113587. /**
  113588. * Creates a new DualShock gamepad object
  113589. * @param id defines the id of this gamepad
  113590. * @param index defines its index
  113591. * @param gamepad defines the internal HTML gamepad object
  113592. */
  113593. constructor(id: string, index: number, gamepad: any);
  113594. /**
  113595. * Defines the callback to call when left trigger is pressed
  113596. * @param callback defines the callback to use
  113597. */
  113598. onlefttriggerchanged(callback: (value: number) => void): void;
  113599. /**
  113600. * Defines the callback to call when right trigger is pressed
  113601. * @param callback defines the callback to use
  113602. */
  113603. onrighttriggerchanged(callback: (value: number) => void): void;
  113604. /**
  113605. * Gets the left trigger value
  113606. */
  113607. get leftTrigger(): number;
  113608. /**
  113609. * Sets the left trigger value
  113610. */
  113611. set leftTrigger(newValue: number);
  113612. /**
  113613. * Gets the right trigger value
  113614. */
  113615. get rightTrigger(): number;
  113616. /**
  113617. * Sets the right trigger value
  113618. */
  113619. set rightTrigger(newValue: number);
  113620. /**
  113621. * Defines the callback to call when a button is pressed
  113622. * @param callback defines the callback to use
  113623. */
  113624. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  113625. /**
  113626. * Defines the callback to call when a button is released
  113627. * @param callback defines the callback to use
  113628. */
  113629. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  113630. /**
  113631. * Defines the callback to call when a pad is pressed
  113632. * @param callback defines the callback to use
  113633. */
  113634. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  113635. /**
  113636. * Defines the callback to call when a pad is released
  113637. * @param callback defines the callback to use
  113638. */
  113639. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  113640. private _setButtonValue;
  113641. private _setDPadValue;
  113642. /**
  113643. * Gets the value of the `Cross` button
  113644. */
  113645. get buttonCross(): number;
  113646. /**
  113647. * Sets the value of the `Cross` button
  113648. */
  113649. set buttonCross(value: number);
  113650. /**
  113651. * Gets the value of the `Circle` button
  113652. */
  113653. get buttonCircle(): number;
  113654. /**
  113655. * Sets the value of the `Circle` button
  113656. */
  113657. set buttonCircle(value: number);
  113658. /**
  113659. * Gets the value of the `Square` button
  113660. */
  113661. get buttonSquare(): number;
  113662. /**
  113663. * Sets the value of the `Square` button
  113664. */
  113665. set buttonSquare(value: number);
  113666. /**
  113667. * Gets the value of the `Triangle` button
  113668. */
  113669. get buttonTriangle(): number;
  113670. /**
  113671. * Sets the value of the `Triangle` button
  113672. */
  113673. set buttonTriangle(value: number);
  113674. /**
  113675. * Gets the value of the `Options` button
  113676. */
  113677. get buttonOptions(): number;
  113678. /**
  113679. * Sets the value of the `Options` button
  113680. */
  113681. set buttonOptions(value: number);
  113682. /**
  113683. * Gets the value of the `Share` button
  113684. */
  113685. get buttonShare(): number;
  113686. /**
  113687. * Sets the value of the `Share` button
  113688. */
  113689. set buttonShare(value: number);
  113690. /**
  113691. * Gets the value of the `L1` button
  113692. */
  113693. get buttonL1(): number;
  113694. /**
  113695. * Sets the value of the `L1` button
  113696. */
  113697. set buttonL1(value: number);
  113698. /**
  113699. * Gets the value of the `R1` button
  113700. */
  113701. get buttonR1(): number;
  113702. /**
  113703. * Sets the value of the `R1` button
  113704. */
  113705. set buttonR1(value: number);
  113706. /**
  113707. * Gets the value of the Left joystick
  113708. */
  113709. get buttonLeftStick(): number;
  113710. /**
  113711. * Sets the value of the Left joystick
  113712. */
  113713. set buttonLeftStick(value: number);
  113714. /**
  113715. * Gets the value of the Right joystick
  113716. */
  113717. get buttonRightStick(): number;
  113718. /**
  113719. * Sets the value of the Right joystick
  113720. */
  113721. set buttonRightStick(value: number);
  113722. /**
  113723. * Gets the value of D-pad up
  113724. */
  113725. get dPadUp(): number;
  113726. /**
  113727. * Sets the value of D-pad up
  113728. */
  113729. set dPadUp(value: number);
  113730. /**
  113731. * Gets the value of D-pad down
  113732. */
  113733. get dPadDown(): number;
  113734. /**
  113735. * Sets the value of D-pad down
  113736. */
  113737. set dPadDown(value: number);
  113738. /**
  113739. * Gets the value of D-pad left
  113740. */
  113741. get dPadLeft(): number;
  113742. /**
  113743. * Sets the value of D-pad left
  113744. */
  113745. set dPadLeft(value: number);
  113746. /**
  113747. * Gets the value of D-pad right
  113748. */
  113749. get dPadRight(): number;
  113750. /**
  113751. * Sets the value of D-pad right
  113752. */
  113753. set dPadRight(value: number);
  113754. /**
  113755. * Force the gamepad to synchronize with device values
  113756. */
  113757. update(): void;
  113758. /**
  113759. * Disposes the gamepad
  113760. */
  113761. dispose(): void;
  113762. }
  113763. }
  113764. declare module BABYLON {
  113765. /**
  113766. * Manager for handling gamepads
  113767. */
  113768. export class GamepadManager {
  113769. private _scene?;
  113770. private _babylonGamepads;
  113771. private _oneGamepadConnected;
  113772. /** @hidden */
  113773. _isMonitoring: boolean;
  113774. private _gamepadEventSupported;
  113775. private _gamepadSupport?;
  113776. /**
  113777. * observable to be triggered when the gamepad controller has been connected
  113778. */
  113779. onGamepadConnectedObservable: Observable<Gamepad>;
  113780. /**
  113781. * observable to be triggered when the gamepad controller has been disconnected
  113782. */
  113783. onGamepadDisconnectedObservable: Observable<Gamepad>;
  113784. private _onGamepadConnectedEvent;
  113785. private _onGamepadDisconnectedEvent;
  113786. /**
  113787. * Initializes the gamepad manager
  113788. * @param _scene BabylonJS scene
  113789. */
  113790. constructor(_scene?: Scene | undefined);
  113791. /**
  113792. * The gamepads in the game pad manager
  113793. */
  113794. get gamepads(): Gamepad[];
  113795. /**
  113796. * Get the gamepad controllers based on type
  113797. * @param type The type of gamepad controller
  113798. * @returns Nullable gamepad
  113799. */
  113800. getGamepadByType(type?: number): Nullable<Gamepad>;
  113801. /**
  113802. * Disposes the gamepad manager
  113803. */
  113804. dispose(): void;
  113805. private _addNewGamepad;
  113806. private _startMonitoringGamepads;
  113807. private _stopMonitoringGamepads;
  113808. /** @hidden */
  113809. _checkGamepadsStatus(): void;
  113810. private _updateGamepadObjects;
  113811. }
  113812. }
  113813. declare module BABYLON {
  113814. interface Scene {
  113815. /** @hidden */
  113816. _gamepadManager: Nullable<GamepadManager>;
  113817. /**
  113818. * Gets the gamepad manager associated with the scene
  113819. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  113820. */
  113821. gamepadManager: GamepadManager;
  113822. }
  113823. /**
  113824. * Interface representing a free camera inputs manager
  113825. */
  113826. interface FreeCameraInputsManager {
  113827. /**
  113828. * Adds gamepad input support to the FreeCameraInputsManager.
  113829. * @returns the FreeCameraInputsManager
  113830. */
  113831. addGamepad(): FreeCameraInputsManager;
  113832. }
  113833. /**
  113834. * Interface representing an arc rotate camera inputs manager
  113835. */
  113836. interface ArcRotateCameraInputsManager {
  113837. /**
  113838. * Adds gamepad input support to the ArcRotateCamera InputManager.
  113839. * @returns the camera inputs manager
  113840. */
  113841. addGamepad(): ArcRotateCameraInputsManager;
  113842. }
  113843. /**
  113844. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  113845. */
  113846. export class GamepadSystemSceneComponent implements ISceneComponent {
  113847. /**
  113848. * The component name helpfull to identify the component in the list of scene components.
  113849. */
  113850. readonly name: string;
  113851. /**
  113852. * The scene the component belongs to.
  113853. */
  113854. scene: Scene;
  113855. /**
  113856. * Creates a new instance of the component for the given scene
  113857. * @param scene Defines the scene to register the component in
  113858. */
  113859. constructor(scene: Scene);
  113860. /**
  113861. * Registers the component in a given scene
  113862. */
  113863. register(): void;
  113864. /**
  113865. * Rebuilds the elements related to this component in case of
  113866. * context lost for instance.
  113867. */
  113868. rebuild(): void;
  113869. /**
  113870. * Disposes the component and the associated ressources
  113871. */
  113872. dispose(): void;
  113873. private _beforeCameraUpdate;
  113874. }
  113875. }
  113876. declare module BABYLON {
  113877. /**
  113878. * 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,
  113879. * which still works and will still be found in many Playgrounds.
  113880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113881. */
  113882. export class UniversalCamera extends TouchCamera {
  113883. /**
  113884. * Defines the gamepad rotation sensiblity.
  113885. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113886. */
  113887. get gamepadAngularSensibility(): number;
  113888. set gamepadAngularSensibility(value: number);
  113889. /**
  113890. * Defines the gamepad move sensiblity.
  113891. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113892. */
  113893. get gamepadMoveSensibility(): number;
  113894. set gamepadMoveSensibility(value: number);
  113895. /**
  113896. * 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,
  113897. * which still works and will still be found in many Playgrounds.
  113898. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113899. * @param name Define the name of the camera in the scene
  113900. * @param position Define the start position of the camera in the scene
  113901. * @param scene Define the scene the camera belongs to
  113902. */
  113903. constructor(name: string, position: Vector3, scene: Scene);
  113904. /**
  113905. * Gets the current object class name.
  113906. * @return the class name
  113907. */
  113908. getClassName(): string;
  113909. }
  113910. }
  113911. declare module BABYLON {
  113912. /**
  113913. * This represents a FPS type of camera. This is only here for back compat purpose.
  113914. * Please use the UniversalCamera instead as both are identical.
  113915. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113916. */
  113917. export class GamepadCamera extends UniversalCamera {
  113918. /**
  113919. * Instantiates a new Gamepad Camera
  113920. * This represents a FPS type of camera. This is only here for back compat purpose.
  113921. * Please use the UniversalCamera instead as both are identical.
  113922. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113923. * @param name Define the name of the camera in the scene
  113924. * @param position Define the start position of the camera in the scene
  113925. * @param scene Define the scene the camera belongs to
  113926. */
  113927. constructor(name: string, position: Vector3, scene: Scene);
  113928. /**
  113929. * Gets the current object class name.
  113930. * @return the class name
  113931. */
  113932. getClassName(): string;
  113933. }
  113934. }
  113935. declare module BABYLON {
  113936. /** @hidden */
  113937. export var passPixelShader: {
  113938. name: string;
  113939. shader: string;
  113940. };
  113941. }
  113942. declare module BABYLON {
  113943. /** @hidden */
  113944. export var passCubePixelShader: {
  113945. name: string;
  113946. shader: string;
  113947. };
  113948. }
  113949. declare module BABYLON {
  113950. /**
  113951. * PassPostProcess which produces an output the same as it's input
  113952. */
  113953. export class PassPostProcess extends PostProcess {
  113954. /**
  113955. * Creates the PassPostProcess
  113956. * @param name The name of the effect.
  113957. * @param options The required width/height ratio to downsize to before computing the render pass.
  113958. * @param camera The camera to apply the render pass to.
  113959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113960. * @param engine The engine which the post process will be applied. (default: current engine)
  113961. * @param reusable If the post process can be reused on the same frame. (default: false)
  113962. * @param textureType The type of texture to be used when performing the post processing.
  113963. * @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)
  113964. */
  113965. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113966. }
  113967. /**
  113968. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  113969. */
  113970. export class PassCubePostProcess extends PostProcess {
  113971. private _face;
  113972. /**
  113973. * Gets or sets the cube face to display.
  113974. * * 0 is +X
  113975. * * 1 is -X
  113976. * * 2 is +Y
  113977. * * 3 is -Y
  113978. * * 4 is +Z
  113979. * * 5 is -Z
  113980. */
  113981. get face(): number;
  113982. set face(value: number);
  113983. /**
  113984. * Creates the PassCubePostProcess
  113985. * @param name The name of the effect.
  113986. * @param options The required width/height ratio to downsize to before computing the render pass.
  113987. * @param camera The camera to apply the render pass to.
  113988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113989. * @param engine The engine which the post process will be applied. (default: current engine)
  113990. * @param reusable If the post process can be reused on the same frame. (default: false)
  113991. * @param textureType The type of texture to be used when performing the post processing.
  113992. * @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)
  113993. */
  113994. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113995. }
  113996. }
  113997. declare module BABYLON {
  113998. /** @hidden */
  113999. export var anaglyphPixelShader: {
  114000. name: string;
  114001. shader: string;
  114002. };
  114003. }
  114004. declare module BABYLON {
  114005. /**
  114006. * Postprocess used to generate anaglyphic rendering
  114007. */
  114008. export class AnaglyphPostProcess extends PostProcess {
  114009. private _passedProcess;
  114010. /**
  114011. * Creates a new AnaglyphPostProcess
  114012. * @param name defines postprocess name
  114013. * @param options defines creation options or target ratio scale
  114014. * @param rigCameras defines cameras using this postprocess
  114015. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114016. * @param engine defines hosting engine
  114017. * @param reusable defines if the postprocess will be reused multiple times per frame
  114018. */
  114019. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114020. }
  114021. }
  114022. declare module BABYLON {
  114023. /**
  114024. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114025. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114026. */
  114027. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114028. /**
  114029. * Creates a new AnaglyphArcRotateCamera
  114030. * @param name defines camera name
  114031. * @param alpha defines alpha angle (in radians)
  114032. * @param beta defines beta angle (in radians)
  114033. * @param radius defines radius
  114034. * @param target defines camera target
  114035. * @param interaxialDistance defines distance between each color axis
  114036. * @param scene defines the hosting scene
  114037. */
  114038. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114039. /**
  114040. * Gets camera class name
  114041. * @returns AnaglyphArcRotateCamera
  114042. */
  114043. getClassName(): string;
  114044. }
  114045. }
  114046. declare module BABYLON {
  114047. /**
  114048. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114049. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114050. */
  114051. export class AnaglyphFreeCamera extends FreeCamera {
  114052. /**
  114053. * Creates a new AnaglyphFreeCamera
  114054. * @param name defines camera name
  114055. * @param position defines initial position
  114056. * @param interaxialDistance defines distance between each color axis
  114057. * @param scene defines the hosting scene
  114058. */
  114059. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114060. /**
  114061. * Gets camera class name
  114062. * @returns AnaglyphFreeCamera
  114063. */
  114064. getClassName(): string;
  114065. }
  114066. }
  114067. declare module BABYLON {
  114068. /**
  114069. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114070. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114071. */
  114072. export class AnaglyphGamepadCamera extends GamepadCamera {
  114073. /**
  114074. * Creates a new AnaglyphGamepadCamera
  114075. * @param name defines camera name
  114076. * @param position defines initial position
  114077. * @param interaxialDistance defines distance between each color axis
  114078. * @param scene defines the hosting scene
  114079. */
  114080. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114081. /**
  114082. * Gets camera class name
  114083. * @returns AnaglyphGamepadCamera
  114084. */
  114085. getClassName(): string;
  114086. }
  114087. }
  114088. declare module BABYLON {
  114089. /**
  114090. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114091. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114092. */
  114093. export class AnaglyphUniversalCamera extends UniversalCamera {
  114094. /**
  114095. * Creates a new AnaglyphUniversalCamera
  114096. * @param name defines camera name
  114097. * @param position defines initial position
  114098. * @param interaxialDistance defines distance between each color axis
  114099. * @param scene defines the hosting scene
  114100. */
  114101. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114102. /**
  114103. * Gets camera class name
  114104. * @returns AnaglyphUniversalCamera
  114105. */
  114106. getClassName(): string;
  114107. }
  114108. }
  114109. declare module BABYLON {
  114110. /** @hidden */
  114111. export var stereoscopicInterlacePixelShader: {
  114112. name: string;
  114113. shader: string;
  114114. };
  114115. }
  114116. declare module BABYLON {
  114117. /**
  114118. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  114119. */
  114120. export class StereoscopicInterlacePostProcessI extends PostProcess {
  114121. private _stepSize;
  114122. private _passedProcess;
  114123. /**
  114124. * Initializes a StereoscopicInterlacePostProcessI
  114125. * @param name The name of the effect.
  114126. * @param rigCameras The rig cameras to be appled to the post process
  114127. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  114128. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  114129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114130. * @param engine The engine which the post process will be applied. (default: current engine)
  114131. * @param reusable If the post process can be reused on the same frame. (default: false)
  114132. */
  114133. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114134. }
  114135. /**
  114136. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  114137. */
  114138. export class StereoscopicInterlacePostProcess extends PostProcess {
  114139. private _stepSize;
  114140. private _passedProcess;
  114141. /**
  114142. * Initializes a StereoscopicInterlacePostProcess
  114143. * @param name The name of the effect.
  114144. * @param rigCameras The rig cameras to be appled to the post process
  114145. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  114146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114147. * @param engine The engine which the post process will be applied. (default: current engine)
  114148. * @param reusable If the post process can be reused on the same frame. (default: false)
  114149. */
  114150. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114151. }
  114152. }
  114153. declare module BABYLON {
  114154. /**
  114155. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  114156. * @see http://doc.babylonjs.com/features/cameras
  114157. */
  114158. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  114159. /**
  114160. * Creates a new StereoscopicArcRotateCamera
  114161. * @param name defines camera name
  114162. * @param alpha defines alpha angle (in radians)
  114163. * @param beta defines beta angle (in radians)
  114164. * @param radius defines radius
  114165. * @param target defines camera target
  114166. * @param interaxialDistance defines distance between each color axis
  114167. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114168. * @param scene defines the hosting scene
  114169. */
  114170. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114171. /**
  114172. * Gets camera class name
  114173. * @returns StereoscopicArcRotateCamera
  114174. */
  114175. getClassName(): string;
  114176. }
  114177. }
  114178. declare module BABYLON {
  114179. /**
  114180. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  114181. * @see http://doc.babylonjs.com/features/cameras
  114182. */
  114183. export class StereoscopicFreeCamera extends FreeCamera {
  114184. /**
  114185. * Creates a new StereoscopicFreeCamera
  114186. * @param name defines camera name
  114187. * @param position defines initial position
  114188. * @param interaxialDistance defines distance between each color axis
  114189. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114190. * @param scene defines the hosting scene
  114191. */
  114192. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114193. /**
  114194. * Gets camera class name
  114195. * @returns StereoscopicFreeCamera
  114196. */
  114197. getClassName(): string;
  114198. }
  114199. }
  114200. declare module BABYLON {
  114201. /**
  114202. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  114203. * @see http://doc.babylonjs.com/features/cameras
  114204. */
  114205. export class StereoscopicGamepadCamera extends GamepadCamera {
  114206. /**
  114207. * Creates a new StereoscopicGamepadCamera
  114208. * @param name defines camera name
  114209. * @param position defines initial position
  114210. * @param interaxialDistance defines distance between each color axis
  114211. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114212. * @param scene defines the hosting scene
  114213. */
  114214. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114215. /**
  114216. * Gets camera class name
  114217. * @returns StereoscopicGamepadCamera
  114218. */
  114219. getClassName(): string;
  114220. }
  114221. }
  114222. declare module BABYLON {
  114223. /**
  114224. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  114225. * @see http://doc.babylonjs.com/features/cameras
  114226. */
  114227. export class StereoscopicUniversalCamera extends UniversalCamera {
  114228. /**
  114229. * Creates a new StereoscopicUniversalCamera
  114230. * @param name defines camera name
  114231. * @param position defines initial position
  114232. * @param interaxialDistance defines distance between each color axis
  114233. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114234. * @param scene defines the hosting scene
  114235. */
  114236. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114237. /**
  114238. * Gets camera class name
  114239. * @returns StereoscopicUniversalCamera
  114240. */
  114241. getClassName(): string;
  114242. }
  114243. }
  114244. declare module BABYLON {
  114245. /**
  114246. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  114247. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114248. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114249. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114250. */
  114251. export class VirtualJoysticksCamera extends FreeCamera {
  114252. /**
  114253. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  114254. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114255. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114256. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114257. * @param name Define the name of the camera in the scene
  114258. * @param position Define the start position of the camera in the scene
  114259. * @param scene Define the scene the camera belongs to
  114260. */
  114261. constructor(name: string, position: Vector3, scene: Scene);
  114262. /**
  114263. * Gets the current object class name.
  114264. * @return the class name
  114265. */
  114266. getClassName(): string;
  114267. }
  114268. }
  114269. declare module BABYLON {
  114270. /**
  114271. * This represents all the required metrics to create a VR camera.
  114272. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  114273. */
  114274. export class VRCameraMetrics {
  114275. /**
  114276. * Define the horizontal resolution off the screen.
  114277. */
  114278. hResolution: number;
  114279. /**
  114280. * Define the vertical resolution off the screen.
  114281. */
  114282. vResolution: number;
  114283. /**
  114284. * Define the horizontal screen size.
  114285. */
  114286. hScreenSize: number;
  114287. /**
  114288. * Define the vertical screen size.
  114289. */
  114290. vScreenSize: number;
  114291. /**
  114292. * Define the vertical screen center position.
  114293. */
  114294. vScreenCenter: number;
  114295. /**
  114296. * Define the distance of the eyes to the screen.
  114297. */
  114298. eyeToScreenDistance: number;
  114299. /**
  114300. * Define the distance between both lenses
  114301. */
  114302. lensSeparationDistance: number;
  114303. /**
  114304. * Define the distance between both viewer's eyes.
  114305. */
  114306. interpupillaryDistance: number;
  114307. /**
  114308. * Define the distortion factor of the VR postprocess.
  114309. * Please, touch with care.
  114310. */
  114311. distortionK: number[];
  114312. /**
  114313. * Define the chromatic aberration correction factors for the VR post process.
  114314. */
  114315. chromaAbCorrection: number[];
  114316. /**
  114317. * Define the scale factor of the post process.
  114318. * The smaller the better but the slower.
  114319. */
  114320. postProcessScaleFactor: number;
  114321. /**
  114322. * Define an offset for the lens center.
  114323. */
  114324. lensCenterOffset: number;
  114325. /**
  114326. * Define if the current vr camera should compensate the distortion of the lense or not.
  114327. */
  114328. compensateDistortion: boolean;
  114329. /**
  114330. * Defines if multiview should be enabled when rendering (Default: false)
  114331. */
  114332. multiviewEnabled: boolean;
  114333. /**
  114334. * Gets the rendering aspect ratio based on the provided resolutions.
  114335. */
  114336. get aspectRatio(): number;
  114337. /**
  114338. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  114339. */
  114340. get aspectRatioFov(): number;
  114341. /**
  114342. * @hidden
  114343. */
  114344. get leftHMatrix(): Matrix;
  114345. /**
  114346. * @hidden
  114347. */
  114348. get rightHMatrix(): Matrix;
  114349. /**
  114350. * @hidden
  114351. */
  114352. get leftPreViewMatrix(): Matrix;
  114353. /**
  114354. * @hidden
  114355. */
  114356. get rightPreViewMatrix(): Matrix;
  114357. /**
  114358. * Get the default VRMetrics based on the most generic setup.
  114359. * @returns the default vr metrics
  114360. */
  114361. static GetDefault(): VRCameraMetrics;
  114362. }
  114363. }
  114364. declare module BABYLON {
  114365. /** @hidden */
  114366. export var vrDistortionCorrectionPixelShader: {
  114367. name: string;
  114368. shader: string;
  114369. };
  114370. }
  114371. declare module BABYLON {
  114372. /**
  114373. * VRDistortionCorrectionPostProcess used for mobile VR
  114374. */
  114375. export class VRDistortionCorrectionPostProcess extends PostProcess {
  114376. private _isRightEye;
  114377. private _distortionFactors;
  114378. private _postProcessScaleFactor;
  114379. private _lensCenterOffset;
  114380. private _scaleIn;
  114381. private _scaleFactor;
  114382. private _lensCenter;
  114383. /**
  114384. * Initializes the VRDistortionCorrectionPostProcess
  114385. * @param name The name of the effect.
  114386. * @param camera The camera to apply the render pass to.
  114387. * @param isRightEye If this is for the right eye distortion
  114388. * @param vrMetrics All the required metrics for the VR camera
  114389. */
  114390. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  114391. }
  114392. }
  114393. declare module BABYLON {
  114394. /**
  114395. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  114396. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114397. */
  114398. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  114399. /**
  114400. * Creates a new VRDeviceOrientationArcRotateCamera
  114401. * @param name defines camera name
  114402. * @param alpha defines the camera rotation along the logitudinal axis
  114403. * @param beta defines the camera rotation along the latitudinal axis
  114404. * @param radius defines the camera distance from its target
  114405. * @param target defines the camera target
  114406. * @param scene defines the scene the camera belongs to
  114407. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114408. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114409. */
  114410. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114411. /**
  114412. * Gets camera class name
  114413. * @returns VRDeviceOrientationArcRotateCamera
  114414. */
  114415. getClassName(): string;
  114416. }
  114417. }
  114418. declare module BABYLON {
  114419. /**
  114420. * Camera used to simulate VR rendering (based on FreeCamera)
  114421. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114422. */
  114423. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  114424. /**
  114425. * Creates a new VRDeviceOrientationFreeCamera
  114426. * @param name defines camera name
  114427. * @param position defines the start position of the camera
  114428. * @param scene defines the scene the camera belongs to
  114429. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114430. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114431. */
  114432. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114433. /**
  114434. * Gets camera class name
  114435. * @returns VRDeviceOrientationFreeCamera
  114436. */
  114437. getClassName(): string;
  114438. }
  114439. }
  114440. declare module BABYLON {
  114441. /**
  114442. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  114443. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114444. */
  114445. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  114446. /**
  114447. * Creates a new VRDeviceOrientationGamepadCamera
  114448. * @param name defines camera name
  114449. * @param position defines the start position of the camera
  114450. * @param scene defines the scene the camera belongs to
  114451. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114452. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114453. */
  114454. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114455. /**
  114456. * Gets camera class name
  114457. * @returns VRDeviceOrientationGamepadCamera
  114458. */
  114459. getClassName(): string;
  114460. }
  114461. }
  114462. declare module BABYLON {
  114463. /** @hidden */
  114464. export var imageProcessingPixelShader: {
  114465. name: string;
  114466. shader: string;
  114467. };
  114468. }
  114469. declare module BABYLON {
  114470. /**
  114471. * ImageProcessingPostProcess
  114472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  114473. */
  114474. export class ImageProcessingPostProcess extends PostProcess {
  114475. /**
  114476. * Default configuration related to image processing available in the PBR Material.
  114477. */
  114478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114479. /**
  114480. * Gets the image processing configuration used either in this material.
  114481. */
  114482. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  114483. /**
  114484. * Sets the Default image processing configuration used either in the this material.
  114485. *
  114486. * If sets to null, the scene one is in use.
  114487. */
  114488. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  114489. /**
  114490. * Keep track of the image processing observer to allow dispose and replace.
  114491. */
  114492. private _imageProcessingObserver;
  114493. /**
  114494. * Attaches a new image processing configuration to the PBR Material.
  114495. * @param configuration
  114496. */
  114497. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  114498. /**
  114499. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114500. */
  114501. get colorCurves(): Nullable<ColorCurves>;
  114502. /**
  114503. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114504. */
  114505. set colorCurves(value: Nullable<ColorCurves>);
  114506. /**
  114507. * Gets wether the color curves effect is enabled.
  114508. */
  114509. get colorCurvesEnabled(): boolean;
  114510. /**
  114511. * Sets wether the color curves effect is enabled.
  114512. */
  114513. set colorCurvesEnabled(value: boolean);
  114514. /**
  114515. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114516. */
  114517. get colorGradingTexture(): Nullable<BaseTexture>;
  114518. /**
  114519. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114520. */
  114521. set colorGradingTexture(value: Nullable<BaseTexture>);
  114522. /**
  114523. * Gets wether the color grading effect is enabled.
  114524. */
  114525. get colorGradingEnabled(): boolean;
  114526. /**
  114527. * Gets wether the color grading effect is enabled.
  114528. */
  114529. set colorGradingEnabled(value: boolean);
  114530. /**
  114531. * Gets exposure used in the effect.
  114532. */
  114533. get exposure(): number;
  114534. /**
  114535. * Sets exposure used in the effect.
  114536. */
  114537. set exposure(value: number);
  114538. /**
  114539. * Gets wether tonemapping is enabled or not.
  114540. */
  114541. get toneMappingEnabled(): boolean;
  114542. /**
  114543. * Sets wether tonemapping is enabled or not
  114544. */
  114545. set toneMappingEnabled(value: boolean);
  114546. /**
  114547. * Gets the type of tone mapping effect.
  114548. */
  114549. get toneMappingType(): number;
  114550. /**
  114551. * Sets the type of tone mapping effect.
  114552. */
  114553. set toneMappingType(value: number);
  114554. /**
  114555. * Gets contrast used in the effect.
  114556. */
  114557. get contrast(): number;
  114558. /**
  114559. * Sets contrast used in the effect.
  114560. */
  114561. set contrast(value: number);
  114562. /**
  114563. * Gets Vignette stretch size.
  114564. */
  114565. get vignetteStretch(): number;
  114566. /**
  114567. * Sets Vignette stretch size.
  114568. */
  114569. set vignetteStretch(value: number);
  114570. /**
  114571. * Gets Vignette centre X Offset.
  114572. */
  114573. get vignetteCentreX(): number;
  114574. /**
  114575. * Sets Vignette centre X Offset.
  114576. */
  114577. set vignetteCentreX(value: number);
  114578. /**
  114579. * Gets Vignette centre Y Offset.
  114580. */
  114581. get vignetteCentreY(): number;
  114582. /**
  114583. * Sets Vignette centre Y Offset.
  114584. */
  114585. set vignetteCentreY(value: number);
  114586. /**
  114587. * Gets Vignette weight or intensity of the vignette effect.
  114588. */
  114589. get vignetteWeight(): number;
  114590. /**
  114591. * Sets Vignette weight or intensity of the vignette effect.
  114592. */
  114593. set vignetteWeight(value: number);
  114594. /**
  114595. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  114596. * if vignetteEnabled is set to true.
  114597. */
  114598. get vignetteColor(): Color4;
  114599. /**
  114600. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  114601. * if vignetteEnabled is set to true.
  114602. */
  114603. set vignetteColor(value: Color4);
  114604. /**
  114605. * Gets Camera field of view used by the Vignette effect.
  114606. */
  114607. get vignetteCameraFov(): number;
  114608. /**
  114609. * Sets Camera field of view used by the Vignette effect.
  114610. */
  114611. set vignetteCameraFov(value: number);
  114612. /**
  114613. * Gets the vignette blend mode allowing different kind of effect.
  114614. */
  114615. get vignetteBlendMode(): number;
  114616. /**
  114617. * Sets the vignette blend mode allowing different kind of effect.
  114618. */
  114619. set vignetteBlendMode(value: number);
  114620. /**
  114621. * Gets wether the vignette effect is enabled.
  114622. */
  114623. get vignetteEnabled(): boolean;
  114624. /**
  114625. * Sets wether the vignette effect is enabled.
  114626. */
  114627. set vignetteEnabled(value: boolean);
  114628. private _fromLinearSpace;
  114629. /**
  114630. * Gets wether the input of the processing is in Gamma or Linear Space.
  114631. */
  114632. get fromLinearSpace(): boolean;
  114633. /**
  114634. * Sets wether the input of the processing is in Gamma or Linear Space.
  114635. */
  114636. set fromLinearSpace(value: boolean);
  114637. /**
  114638. * Defines cache preventing GC.
  114639. */
  114640. private _defines;
  114641. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  114642. /**
  114643. * "ImageProcessingPostProcess"
  114644. * @returns "ImageProcessingPostProcess"
  114645. */
  114646. getClassName(): string;
  114647. protected _updateParameters(): void;
  114648. dispose(camera?: Camera): void;
  114649. }
  114650. }
  114651. declare module BABYLON {
  114652. /**
  114653. * Class containing static functions to help procedurally build meshes
  114654. */
  114655. export class GroundBuilder {
  114656. /**
  114657. * Creates a ground mesh
  114658. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  114659. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  114660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114661. * @param name defines the name of the mesh
  114662. * @param options defines the options used to create the mesh
  114663. * @param scene defines the hosting scene
  114664. * @returns the ground mesh
  114665. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  114666. */
  114667. static CreateGround(name: string, options: {
  114668. width?: number;
  114669. height?: number;
  114670. subdivisions?: number;
  114671. subdivisionsX?: number;
  114672. subdivisionsY?: number;
  114673. updatable?: boolean;
  114674. }, scene: any): Mesh;
  114675. /**
  114676. * Creates a tiled ground mesh
  114677. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  114678. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  114679. * * 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
  114680. * * 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
  114681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114682. * @param name defines the name of the mesh
  114683. * @param options defines the options used to create the mesh
  114684. * @param scene defines the hosting scene
  114685. * @returns the tiled ground mesh
  114686. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  114687. */
  114688. static CreateTiledGround(name: string, options: {
  114689. xmin: number;
  114690. zmin: number;
  114691. xmax: number;
  114692. zmax: number;
  114693. subdivisions?: {
  114694. w: number;
  114695. h: number;
  114696. };
  114697. precision?: {
  114698. w: number;
  114699. h: number;
  114700. };
  114701. updatable?: boolean;
  114702. }, scene?: Nullable<Scene>): Mesh;
  114703. /**
  114704. * Creates a ground mesh from a height map
  114705. * * The parameter `url` sets the URL of the height map image resource.
  114706. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  114707. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  114708. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  114709. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  114710. * * 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.
  114711. * * 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).
  114712. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114714. * @param name defines the name of the mesh
  114715. * @param url defines the url to the height map
  114716. * @param options defines the options used to create the mesh
  114717. * @param scene defines the hosting scene
  114718. * @returns the ground mesh
  114719. * @see https://doc.babylonjs.com/babylon101/height_map
  114720. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  114721. */
  114722. static CreateGroundFromHeightMap(name: string, url: string, options: {
  114723. width?: number;
  114724. height?: number;
  114725. subdivisions?: number;
  114726. minHeight?: number;
  114727. maxHeight?: number;
  114728. colorFilter?: Color3;
  114729. alphaFilter?: number;
  114730. updatable?: boolean;
  114731. onReady?: (mesh: GroundMesh) => void;
  114732. }, scene?: Nullable<Scene>): GroundMesh;
  114733. }
  114734. }
  114735. declare module BABYLON {
  114736. /**
  114737. * Class containing static functions to help procedurally build meshes
  114738. */
  114739. export class TorusBuilder {
  114740. /**
  114741. * Creates a torus mesh
  114742. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  114743. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  114744. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  114745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114748. * @param name defines the name of the mesh
  114749. * @param options defines the options used to create the mesh
  114750. * @param scene defines the hosting scene
  114751. * @returns the torus mesh
  114752. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  114753. */
  114754. static CreateTorus(name: string, options: {
  114755. diameter?: number;
  114756. thickness?: number;
  114757. tessellation?: number;
  114758. updatable?: boolean;
  114759. sideOrientation?: number;
  114760. frontUVs?: Vector4;
  114761. backUVs?: Vector4;
  114762. }, scene: any): Mesh;
  114763. }
  114764. }
  114765. declare module BABYLON {
  114766. /**
  114767. * Class containing static functions to help procedurally build meshes
  114768. */
  114769. export class CylinderBuilder {
  114770. /**
  114771. * Creates a cylinder or a cone mesh
  114772. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  114773. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  114774. * * 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.
  114775. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  114776. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  114777. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  114778. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  114779. * * 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).
  114780. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  114781. * * 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).
  114782. * * 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
  114783. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  114784. * * 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
  114785. * * 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.
  114786. * * If `enclose` is false, a ring surface is one element.
  114787. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  114788. * * 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
  114789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114792. * @param name defines the name of the mesh
  114793. * @param options defines the options used to create the mesh
  114794. * @param scene defines the hosting scene
  114795. * @returns the cylinder mesh
  114796. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  114797. */
  114798. static CreateCylinder(name: string, options: {
  114799. height?: number;
  114800. diameterTop?: number;
  114801. diameterBottom?: number;
  114802. diameter?: number;
  114803. tessellation?: number;
  114804. subdivisions?: number;
  114805. arc?: number;
  114806. faceColors?: Color4[];
  114807. faceUV?: Vector4[];
  114808. updatable?: boolean;
  114809. hasRings?: boolean;
  114810. enclose?: boolean;
  114811. cap?: number;
  114812. sideOrientation?: number;
  114813. frontUVs?: Vector4;
  114814. backUVs?: Vector4;
  114815. }, scene: any): Mesh;
  114816. }
  114817. }
  114818. declare module BABYLON {
  114819. /**
  114820. * States of the webXR experience
  114821. */
  114822. export enum WebXRState {
  114823. /**
  114824. * Transitioning to being in XR mode
  114825. */
  114826. ENTERING_XR = 0,
  114827. /**
  114828. * Transitioning to non XR mode
  114829. */
  114830. EXITING_XR = 1,
  114831. /**
  114832. * In XR mode and presenting
  114833. */
  114834. IN_XR = 2,
  114835. /**
  114836. * Not entered XR mode
  114837. */
  114838. NOT_IN_XR = 3
  114839. }
  114840. /**
  114841. * Abstraction of the XR render target
  114842. */
  114843. export interface WebXRRenderTarget extends IDisposable {
  114844. /**
  114845. * xrpresent context of the canvas which can be used to display/mirror xr content
  114846. */
  114847. canvasContext: WebGLRenderingContext;
  114848. /**
  114849. * xr layer for the canvas
  114850. */
  114851. xrLayer: Nullable<XRWebGLLayer>;
  114852. /**
  114853. * Initializes the xr layer for the session
  114854. * @param xrSession xr session
  114855. * @returns a promise that will resolve once the XR Layer has been created
  114856. */
  114857. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  114858. }
  114859. }
  114860. declare module BABYLON {
  114861. /**
  114862. * COnfiguration object for WebXR output canvas
  114863. */
  114864. export class WebXRManagedOutputCanvasOptions {
  114865. /**
  114866. * Options for this XR Layer output
  114867. */
  114868. canvasOptions?: XRWebGLLayerOptions;
  114869. /**
  114870. * CSS styling for a newly created canvas (if not provided)
  114871. */
  114872. newCanvasCssStyle?: string;
  114873. /**
  114874. * An optional canvas in case you wish to create it yourself and provide it here.
  114875. * If not provided, a new canvas will be created
  114876. */
  114877. canvasElement?: HTMLCanvasElement;
  114878. /**
  114879. * Get the default values of the configuration object
  114880. * @returns default values of this configuration object
  114881. */
  114882. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  114883. }
  114884. /**
  114885. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  114886. */
  114887. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  114888. private _options;
  114889. private _engine;
  114890. private _canvas;
  114891. /**
  114892. * Rendering context of the canvas which can be used to display/mirror xr content
  114893. */
  114894. canvasContext: WebGLRenderingContext;
  114895. /**
  114896. * xr layer for the canvas
  114897. */
  114898. xrLayer: Nullable<XRWebGLLayer>;
  114899. /**
  114900. * Initializes the xr layer for the session
  114901. * @param xrSession xr session
  114902. * @returns a promise that will resolve once the XR Layer has been created
  114903. */
  114904. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  114905. /**
  114906. * Initializes the canvas to be added/removed upon entering/exiting xr
  114907. * @param _xrSessionManager The XR Session manager
  114908. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  114909. */
  114910. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  114911. /**
  114912. * Disposes of the object
  114913. */
  114914. dispose(): void;
  114915. private _setManagedOutputCanvas;
  114916. private _addCanvas;
  114917. private _removeCanvas;
  114918. }
  114919. }
  114920. declare module BABYLON {
  114921. /**
  114922. * Manages an XRSession to work with Babylon's engine
  114923. * @see https://doc.babylonjs.com/how_to/webxr
  114924. */
  114925. export class WebXRSessionManager implements IDisposable {
  114926. /** The scene which the session should be created for */
  114927. scene: Scene;
  114928. /**
  114929. * Fires every time a new xrFrame arrives which can be used to update the camera
  114930. */
  114931. onXRFrameObservable: Observable<XRFrame>;
  114932. /**
  114933. * Fires when the xr session is ended either by the device or manually done
  114934. */
  114935. onXRSessionEnded: Observable<any>;
  114936. /**
  114937. * Fires when the xr session is ended either by the device or manually done
  114938. */
  114939. onXRSessionInit: Observable<XRSession>;
  114940. /**
  114941. * Fires when the reference space changed
  114942. */
  114943. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  114944. /**
  114945. * Underlying xr session
  114946. */
  114947. session: XRSession;
  114948. /**
  114949. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  114950. * or get the offset the player is currently at.
  114951. */
  114952. viewerReferenceSpace: XRReferenceSpace;
  114953. private _referenceSpace;
  114954. /**
  114955. * The current reference space used in this session. This reference space can constantly change!
  114956. * It is mainly used to offset the camera's position.
  114957. */
  114958. get referenceSpace(): XRReferenceSpace;
  114959. /**
  114960. * Set a new reference space and triggers the observable
  114961. */
  114962. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  114963. /**
  114964. * The base reference space from which the session started. good if you want to reset your
  114965. * reference space
  114966. */
  114967. baseReferenceSpace: XRReferenceSpace;
  114968. /**
  114969. * Used just in case of a failure to initialize an immersive session.
  114970. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  114971. */
  114972. defaultHeightCompensation: number;
  114973. /**
  114974. * Current XR frame
  114975. */
  114976. currentFrame: Nullable<XRFrame>;
  114977. /** WebXR timestamp updated every frame */
  114978. currentTimestamp: number;
  114979. private _xrNavigator;
  114980. private baseLayer;
  114981. private _rttProvider;
  114982. private _sessionEnded;
  114983. /**
  114984. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  114985. * @param scene The scene which the session should be created for
  114986. */
  114987. constructor(
  114988. /** The scene which the session should be created for */
  114989. scene: Scene);
  114990. /**
  114991. * Initializes the manager
  114992. * After initialization enterXR can be called to start an XR session
  114993. * @returns Promise which resolves after it is initialized
  114994. */
  114995. initializeAsync(): Promise<void>;
  114996. /**
  114997. * Initializes an xr session
  114998. * @param xrSessionMode mode to initialize
  114999. * @param xrSessionInit defines optional and required values to pass to the session builder
  115000. * @returns a promise which will resolve once the session has been initialized
  115001. */
  115002. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115003. /**
  115004. * Sets the reference space on the xr session
  115005. * @param referenceSpace space to set
  115006. * @returns a promise that will resolve once the reference space has been set
  115007. */
  115008. setReferenceSpaceAsync(referenceSpace?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115009. /**
  115010. * Resets the reference space to the one started the session
  115011. */
  115012. resetReferenceSpace(): void;
  115013. /**
  115014. * Updates the render state of the session
  115015. * @param state state to set
  115016. * @returns a promise that resolves once the render state has been updated
  115017. */
  115018. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115019. /**
  115020. * Starts rendering to the xr layer
  115021. */
  115022. runXRRenderLoop(): void;
  115023. /**
  115024. * Gets the correct render target texture to be rendered this frame for this eye
  115025. * @param eye the eye for which to get the render target
  115026. * @returns the render target for the specified eye
  115027. */
  115028. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115029. /**
  115030. * Stops the xrSession and restores the renderloop
  115031. * @returns Promise which resolves after it exits XR
  115032. */
  115033. exitXRAsync(): Promise<void>;
  115034. /**
  115035. * Checks if a session would be supported for the creation options specified
  115036. * @param sessionMode session mode to check if supported eg. immersive-vr
  115037. * @returns true if supported
  115038. */
  115039. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115040. /**
  115041. * Creates a WebXRRenderTarget object for the XR session
  115042. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115043. * @param options optional options to provide when creating a new render target
  115044. * @returns a WebXR render target to which the session can render
  115045. */
  115046. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115047. /**
  115048. * @hidden
  115049. * Converts the render layer of xrSession to a render target
  115050. * @param session session to create render target for
  115051. * @param scene scene the new render target should be created for
  115052. * @param baseLayer the webgl layer to create the render target for
  115053. */
  115054. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  115055. /**
  115056. * Disposes of the session manager
  115057. */
  115058. dispose(): void;
  115059. /**
  115060. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115061. * @param sessionMode defines the session to test
  115062. * @returns a promise with boolean as final value
  115063. */
  115064. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115065. }
  115066. }
  115067. declare module BABYLON {
  115068. /**
  115069. * WebXR Camera which holds the views for the xrSession
  115070. * @see https://doc.babylonjs.com/how_to/webxr
  115071. */
  115072. export class WebXRCamera extends FreeCamera {
  115073. private _xrSessionManager;
  115074. /**
  115075. * Is the camera in debug mode. Used when using an emulator
  115076. */
  115077. debugMode: boolean;
  115078. private _firstFrame;
  115079. private _referencedPosition;
  115080. private _referenceQuaternion;
  115081. private _xrInvPositionCache;
  115082. private _xrInvQuaternionCache;
  115083. /**
  115084. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115085. * @param name the name of the camera
  115086. * @param scene the scene to add the camera to
  115087. */
  115088. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115089. private _updateNumberOfRigCameras;
  115090. /**
  115091. * Sets this camera's transformation based on a non-vr camera
  115092. * @param otherCamera the non-vr camera to copy the transformation from
  115093. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  115094. */
  115095. setTransformationFromNonVRCamera(otherCamera: Camera, resetToBaseReferenceSpace?: boolean): void;
  115096. /** @hidden */
  115097. _updateForDualEyeDebugging(): void;
  115098. private _updateReferenceSpace;
  115099. private _updateReferenceSpaceOffset;
  115100. private _updateFromXRSession;
  115101. }
  115102. }
  115103. declare module BABYLON {
  115104. /**
  115105. * Defining the interface required for a (webxr) feature
  115106. */
  115107. export interface IWebXRFeature extends IDisposable {
  115108. /**
  115109. * Is this feature attached
  115110. */
  115111. attached: boolean;
  115112. /**
  115113. * Attach the feature to the session
  115114. * Will usually be called by the features manager
  115115. *
  115116. * @returns true if successful.
  115117. */
  115118. attach(): boolean;
  115119. /**
  115120. * Detach the feature from the session
  115121. * Will usually be called by the features manager
  115122. *
  115123. * @returns true if successful.
  115124. */
  115125. detach(): boolean;
  115126. }
  115127. /**
  115128. * Defining the constructor of a feature. Used to register the modules.
  115129. */
  115130. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  115131. /**
  115132. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  115133. * It is mainly used in AR sessions.
  115134. *
  115135. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  115136. */
  115137. export class WebXRFeaturesManager implements IDisposable {
  115138. private _xrSessionManager;
  115139. private static readonly _AvailableFeatures;
  115140. /**
  115141. * Used to register a module. After calling this function a developer can use this feature in the scene.
  115142. * Mainly used internally.
  115143. *
  115144. * @param featureName the name of the feature to register
  115145. * @param constructorFunction the function used to construct the module
  115146. * @param version the (babylon) version of the module
  115147. * @param stable is that a stable version of this module
  115148. */
  115149. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  115150. /**
  115151. * Returns a constructor of a specific feature.
  115152. *
  115153. * @param featureName the name of the feature to construct
  115154. * @param version the version of the feature to load
  115155. * @param xrSessionManager the xrSessionManager. Used to construct the module
  115156. * @param options optional options provided to the module.
  115157. * @returns a function that, when called, will return a new instance of this feature
  115158. */
  115159. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  115160. /**
  115161. * Return the latest unstable version of this feature
  115162. * @param featureName the name of the feature to search
  115163. * @returns the version number. if not found will return -1
  115164. */
  115165. static GetLatestVersionOfFeature(featureName: string): number;
  115166. /**
  115167. * Return the latest stable version of this feature
  115168. * @param featureName the name of the feature to search
  115169. * @returns the version number. if not found will return -1
  115170. */
  115171. static GetStableVersionOfFeature(featureName: string): number;
  115172. /**
  115173. * Can be used to return the list of features currently registered
  115174. *
  115175. * @returns an Array of available features
  115176. */
  115177. static GetAvailableFeatures(): string[];
  115178. /**
  115179. * Gets the versions available for a specific feature
  115180. * @param featureName the name of the feature
  115181. * @returns an array with the available versions
  115182. */
  115183. static GetAvailableVersions(featureName: string): string[];
  115184. private _features;
  115185. /**
  115186. * constructs a new features manages.
  115187. *
  115188. * @param _xrSessionManager an instance of WebXRSessionManager
  115189. */
  115190. constructor(_xrSessionManager: WebXRSessionManager);
  115191. /**
  115192. * 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.
  115193. * 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.
  115194. *
  115195. * @param featureName the name of the feature to load or the class of the feature
  115196. * @param version optional version to load. if not provided the latest version will be enabled
  115197. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  115198. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  115199. * @returns a new constructed feature or throws an error if feature not found.
  115200. */
  115201. enableFeature(featureName: string | {
  115202. Name: string;
  115203. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  115204. /**
  115205. * Used to disable an already-enabled feature
  115206. * The feature will be disposed and will be recreated once enabled.
  115207. * @param featureName the feature to disable
  115208. * @returns true if disable was successful
  115209. */
  115210. disableFeature(featureName: string | {
  115211. Name: string;
  115212. }): boolean;
  115213. /**
  115214. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  115215. * Can be used during a session to start a feature
  115216. * @param featureName the name of feature to attach
  115217. */
  115218. attachFeature(featureName: string): void;
  115219. /**
  115220. * Can be used inside a session or when the session ends to detach a specific feature
  115221. * @param featureName the name of the feature to detach
  115222. */
  115223. detachFeature(featureName: string): void;
  115224. /**
  115225. * Get the list of enabled features
  115226. * @returns an array of enabled features
  115227. */
  115228. getEnabledFeatures(): string[];
  115229. /**
  115230. * get the implementation of an enabled feature.
  115231. * @param featureName the name of the feature to load
  115232. * @returns the feature class, if found
  115233. */
  115234. getEnabledFeature(featureName: string): IWebXRFeature;
  115235. /**
  115236. * dispose this features manager
  115237. */
  115238. dispose(): void;
  115239. }
  115240. }
  115241. declare module BABYLON {
  115242. /**
  115243. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  115244. * @see https://doc.babylonjs.com/how_to/webxr
  115245. */
  115246. export class WebXRExperienceHelper implements IDisposable {
  115247. private scene;
  115248. /**
  115249. * Camera used to render xr content
  115250. */
  115251. camera: WebXRCamera;
  115252. /**
  115253. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  115254. */
  115255. state: WebXRState;
  115256. private _setState;
  115257. /**
  115258. * Fires when the state of the experience helper has changed
  115259. */
  115260. onStateChangedObservable: Observable<WebXRState>;
  115261. /**
  115262. * Observers registered here will be triggered after the camera's initial transformation is set
  115263. * This can be used to set a different ground level or an extra rotation.
  115264. *
  115265. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  115266. * to the position set after this observable is done executing.
  115267. */
  115268. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  115269. /** Session manager used to keep track of xr session */
  115270. sessionManager: WebXRSessionManager;
  115271. /** A features manager for this xr session */
  115272. featuresManager: WebXRFeaturesManager;
  115273. private _nonVRCamera;
  115274. private _originalSceneAutoClear;
  115275. private _supported;
  115276. /**
  115277. * Creates the experience helper
  115278. * @param scene the scene to attach the experience helper to
  115279. * @returns a promise for the experience helper
  115280. */
  115281. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  115282. /**
  115283. * Creates a WebXRExperienceHelper
  115284. * @param scene The scene the helper should be created in
  115285. */
  115286. private constructor();
  115287. /**
  115288. * Exits XR mode and returns the scene to its original state
  115289. * @returns promise that resolves after xr mode has exited
  115290. */
  115291. exitXRAsync(): Promise<void>;
  115292. /**
  115293. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  115294. * @param sessionMode options for the XR session
  115295. * @param referenceSpaceType frame of reference of the XR session
  115296. * @param renderTarget the output canvas that will be used to enter XR mode
  115297. * @returns promise that resolves after xr mode has entered
  115298. */
  115299. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  115300. /**
  115301. * Disposes of the experience helper
  115302. */
  115303. dispose(): void;
  115304. private _nonXRToXRCamera;
  115305. }
  115306. }
  115307. declare module BABYLON {
  115308. /**
  115309. * X-Y values for axes in WebXR
  115310. */
  115311. export interface IWebXRMotionControllerAxesValue {
  115312. /**
  115313. * The value of the x axis
  115314. */
  115315. x: number;
  115316. /**
  115317. * The value of the y-axis
  115318. */
  115319. y: number;
  115320. }
  115321. /**
  115322. * changed / previous values for the values of this component
  115323. */
  115324. export interface IWebXRMotionControllerComponentChangesValues<T> {
  115325. /**
  115326. * current (this frame) value
  115327. */
  115328. current: T;
  115329. /**
  115330. * previous (last change) value
  115331. */
  115332. previous: T;
  115333. }
  115334. /**
  115335. * Represents changes in the component between current frame and last values recorded
  115336. */
  115337. export interface IWebXRMotionControllerComponentChanges {
  115338. /**
  115339. * will be populated with previous and current values if touched changed
  115340. */
  115341. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115342. /**
  115343. * will be populated with previous and current values if pressed changed
  115344. */
  115345. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115346. /**
  115347. * will be populated with previous and current values if value changed
  115348. */
  115349. value?: IWebXRMotionControllerComponentChangesValues<number>;
  115350. /**
  115351. * will be populated with previous and current values if axes changed
  115352. */
  115353. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  115354. }
  115355. /**
  115356. * This class represents a single component (for example button or thumbstick) of a motion controller
  115357. */
  115358. export class WebXRControllerComponent implements IDisposable {
  115359. /**
  115360. * the id of this component
  115361. */
  115362. id: string;
  115363. /**
  115364. * the type of the component
  115365. */
  115366. type: MotionControllerComponentType;
  115367. private _buttonIndex;
  115368. private _axesIndices;
  115369. /**
  115370. * Thumbstick component type
  115371. */
  115372. static THUMBSTICK: string;
  115373. /**
  115374. * Touchpad component type
  115375. */
  115376. static TOUCHPAD: string;
  115377. /**
  115378. * trigger component type
  115379. */
  115380. static TRIGGER: string;
  115381. /**
  115382. * squeeze component type
  115383. */
  115384. static SQUEEZE: string;
  115385. /**
  115386. * Observers registered here will be triggered when the state of a button changes
  115387. * State change is either pressed / touched / value
  115388. */
  115389. onButtonStateChanged: Observable<WebXRControllerComponent>;
  115390. /**
  115391. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  115392. * the axes data changes
  115393. */
  115394. onAxisValueChanged: Observable<{
  115395. x: number;
  115396. y: number;
  115397. }>;
  115398. private _currentValue;
  115399. private _touched;
  115400. private _pressed;
  115401. private _axes;
  115402. private _changes;
  115403. /**
  115404. * Creates a new component for a motion controller.
  115405. * It is created by the motion controller itself
  115406. *
  115407. * @param id the id of this component
  115408. * @param type the type of the component
  115409. * @param _buttonIndex index in the buttons array of the gamepad
  115410. * @param _axesIndices indices of the values in the axes array of the gamepad
  115411. */
  115412. constructor(
  115413. /**
  115414. * the id of this component
  115415. */
  115416. id: string,
  115417. /**
  115418. * the type of the component
  115419. */
  115420. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  115421. /**
  115422. * Get the current value of this component
  115423. */
  115424. get value(): number;
  115425. /**
  115426. * is the button currently pressed
  115427. */
  115428. get pressed(): boolean;
  115429. /**
  115430. * is the button currently touched
  115431. */
  115432. get touched(): boolean;
  115433. /**
  115434. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  115435. */
  115436. get axes(): IWebXRMotionControllerAxesValue;
  115437. /**
  115438. * Get the changes. Elements will be populated only if they changed with their previous and current value
  115439. */
  115440. get changes(): IWebXRMotionControllerComponentChanges;
  115441. /**
  115442. * Is this component a button (hence - pressable)
  115443. * @returns true if can be pressed
  115444. */
  115445. isButton(): boolean;
  115446. /**
  115447. * Are there axes correlating to this component
  115448. * @return true is axes data is available
  115449. */
  115450. isAxes(): boolean;
  115451. /**
  115452. * update this component using the gamepad object it is in. Called on every frame
  115453. * @param nativeController the native gamepad controller object
  115454. */
  115455. update(nativeController: IMinimalMotionControllerObject): void;
  115456. /**
  115457. * Dispose this component
  115458. */
  115459. dispose(): void;
  115460. }
  115461. }
  115462. declare module BABYLON {
  115463. /**
  115464. * Class used to represent data loading progression
  115465. */
  115466. export class SceneLoaderProgressEvent {
  115467. /** defines if data length to load can be evaluated */
  115468. readonly lengthComputable: boolean;
  115469. /** defines the loaded data length */
  115470. readonly loaded: number;
  115471. /** defines the data length to load */
  115472. readonly total: number;
  115473. /**
  115474. * Create a new progress event
  115475. * @param lengthComputable defines if data length to load can be evaluated
  115476. * @param loaded defines the loaded data length
  115477. * @param total defines the data length to load
  115478. */
  115479. constructor(
  115480. /** defines if data length to load can be evaluated */
  115481. lengthComputable: boolean,
  115482. /** defines the loaded data length */
  115483. loaded: number,
  115484. /** defines the data length to load */
  115485. total: number);
  115486. /**
  115487. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  115488. * @param event defines the source event
  115489. * @returns a new SceneLoaderProgressEvent
  115490. */
  115491. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  115492. }
  115493. /**
  115494. * Interface used by SceneLoader plugins to define supported file extensions
  115495. */
  115496. export interface ISceneLoaderPluginExtensions {
  115497. /**
  115498. * Defines the list of supported extensions
  115499. */
  115500. [extension: string]: {
  115501. isBinary: boolean;
  115502. };
  115503. }
  115504. /**
  115505. * Interface used by SceneLoader plugin factory
  115506. */
  115507. export interface ISceneLoaderPluginFactory {
  115508. /**
  115509. * Defines the name of the factory
  115510. */
  115511. name: string;
  115512. /**
  115513. * Function called to create a new plugin
  115514. * @return the new plugin
  115515. */
  115516. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  115517. /**
  115518. * The callback that returns true if the data can be directly loaded.
  115519. * @param data string containing the file data
  115520. * @returns if the data can be loaded directly
  115521. */
  115522. canDirectLoad?(data: string): boolean;
  115523. }
  115524. /**
  115525. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  115526. */
  115527. export interface ISceneLoaderPluginBase {
  115528. /**
  115529. * The friendly name of this plugin.
  115530. */
  115531. name: string;
  115532. /**
  115533. * The file extensions supported by this plugin.
  115534. */
  115535. extensions: string | ISceneLoaderPluginExtensions;
  115536. /**
  115537. * The callback called when loading from a url.
  115538. * @param scene scene loading this url
  115539. * @param url url to load
  115540. * @param onSuccess callback called when the file successfully loads
  115541. * @param onProgress callback called while file is loading (if the server supports this mode)
  115542. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115543. * @param onError callback called when the file fails to load
  115544. * @returns a file request object
  115545. */
  115546. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  115547. /**
  115548. * The callback called when loading from a file object.
  115549. * @param scene scene loading this file
  115550. * @param file defines the file to load
  115551. * @param onSuccess defines the callback to call when data is loaded
  115552. * @param onProgress defines the callback to call during loading process
  115553. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115554. * @param onError defines the callback to call when an error occurs
  115555. * @returns a file request object
  115556. */
  115557. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  115558. /**
  115559. * The callback that returns true if the data can be directly loaded.
  115560. * @param data string containing the file data
  115561. * @returns if the data can be loaded directly
  115562. */
  115563. canDirectLoad?(data: string): boolean;
  115564. /**
  115565. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  115566. * @param scene scene loading this data
  115567. * @param data string containing the data
  115568. * @returns data to pass to the plugin
  115569. */
  115570. directLoad?(scene: Scene, data: string): any;
  115571. /**
  115572. * The callback that allows custom handling of the root url based on the response url.
  115573. * @param rootUrl the original root url
  115574. * @param responseURL the response url if available
  115575. * @returns the new root url
  115576. */
  115577. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  115578. }
  115579. /**
  115580. * Interface used to define a SceneLoader plugin
  115581. */
  115582. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  115583. /**
  115584. * Import meshes into a scene.
  115585. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115586. * @param scene The scene to import into
  115587. * @param data The data to import
  115588. * @param rootUrl The root url for scene and resources
  115589. * @param meshes The meshes array to import into
  115590. * @param particleSystems The particle systems array to import into
  115591. * @param skeletons The skeletons array to import into
  115592. * @param onError The callback when import fails
  115593. * @returns True if successful or false otherwise
  115594. */
  115595. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  115596. /**
  115597. * Load into a scene.
  115598. * @param scene The scene to load into
  115599. * @param data The data to import
  115600. * @param rootUrl The root url for scene and resources
  115601. * @param onError The callback when import fails
  115602. * @returns True if successful or false otherwise
  115603. */
  115604. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  115605. /**
  115606. * Load into an asset container.
  115607. * @param scene The scene to load into
  115608. * @param data The data to import
  115609. * @param rootUrl The root url for scene and resources
  115610. * @param onError The callback when import fails
  115611. * @returns The loaded asset container
  115612. */
  115613. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  115614. }
  115615. /**
  115616. * Interface used to define an async SceneLoader plugin
  115617. */
  115618. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  115619. /**
  115620. * Import meshes into a scene.
  115621. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115622. * @param scene The scene to import into
  115623. * @param data The data to import
  115624. * @param rootUrl The root url for scene and resources
  115625. * @param onProgress The callback when the load progresses
  115626. * @param fileName Defines the name of the file to load
  115627. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  115628. */
  115629. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  115630. meshes: AbstractMesh[];
  115631. particleSystems: IParticleSystem[];
  115632. skeletons: Skeleton[];
  115633. animationGroups: AnimationGroup[];
  115634. }>;
  115635. /**
  115636. * Load into a scene.
  115637. * @param scene The scene to load into
  115638. * @param data The data to import
  115639. * @param rootUrl The root url for scene and resources
  115640. * @param onProgress The callback when the load progresses
  115641. * @param fileName Defines the name of the file to load
  115642. * @returns Nothing
  115643. */
  115644. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  115645. /**
  115646. * Load into an asset container.
  115647. * @param scene The scene to load into
  115648. * @param data The data to import
  115649. * @param rootUrl The root url for scene and resources
  115650. * @param onProgress The callback when the load progresses
  115651. * @param fileName Defines the name of the file to load
  115652. * @returns The loaded asset container
  115653. */
  115654. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  115655. }
  115656. /**
  115657. * Mode that determines how to handle old animation groups before loading new ones.
  115658. */
  115659. export enum SceneLoaderAnimationGroupLoadingMode {
  115660. /**
  115661. * Reset all old animations to initial state then dispose them.
  115662. */
  115663. Clean = 0,
  115664. /**
  115665. * Stop all old animations.
  115666. */
  115667. Stop = 1,
  115668. /**
  115669. * Restart old animations from first frame.
  115670. */
  115671. Sync = 2,
  115672. /**
  115673. * Old animations remains untouched.
  115674. */
  115675. NoSync = 3
  115676. }
  115677. /**
  115678. * Class used to load scene from various file formats using registered plugins
  115679. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  115680. */
  115681. export class SceneLoader {
  115682. /**
  115683. * No logging while loading
  115684. */
  115685. static readonly NO_LOGGING: number;
  115686. /**
  115687. * Minimal logging while loading
  115688. */
  115689. static readonly MINIMAL_LOGGING: number;
  115690. /**
  115691. * Summary logging while loading
  115692. */
  115693. static readonly SUMMARY_LOGGING: number;
  115694. /**
  115695. * Detailled logging while loading
  115696. */
  115697. static readonly DETAILED_LOGGING: number;
  115698. /**
  115699. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  115700. */
  115701. static get ForceFullSceneLoadingForIncremental(): boolean;
  115702. static set ForceFullSceneLoadingForIncremental(value: boolean);
  115703. /**
  115704. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  115705. */
  115706. static get ShowLoadingScreen(): boolean;
  115707. static set ShowLoadingScreen(value: boolean);
  115708. /**
  115709. * Defines the current logging level (while loading the scene)
  115710. * @ignorenaming
  115711. */
  115712. static get loggingLevel(): number;
  115713. static set loggingLevel(value: number);
  115714. /**
  115715. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  115716. */
  115717. static get CleanBoneMatrixWeights(): boolean;
  115718. static set CleanBoneMatrixWeights(value: boolean);
  115719. /**
  115720. * Event raised when a plugin is used to load a scene
  115721. */
  115722. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  115723. private static _registeredPlugins;
  115724. private static _getDefaultPlugin;
  115725. private static _getPluginForExtension;
  115726. private static _getPluginForDirectLoad;
  115727. private static _getPluginForFilename;
  115728. private static _getDirectLoad;
  115729. private static _loadData;
  115730. private static _getFileInfo;
  115731. /**
  115732. * Gets a plugin that can load the given extension
  115733. * @param extension defines the extension to load
  115734. * @returns a plugin or null if none works
  115735. */
  115736. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  115737. /**
  115738. * Gets a boolean indicating that the given extension can be loaded
  115739. * @param extension defines the extension to load
  115740. * @returns true if the extension is supported
  115741. */
  115742. static IsPluginForExtensionAvailable(extension: string): boolean;
  115743. /**
  115744. * Adds a new plugin to the list of registered plugins
  115745. * @param plugin defines the plugin to add
  115746. */
  115747. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  115748. /**
  115749. * Import meshes into a scene
  115750. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115751. * @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)
  115752. * @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)
  115753. * @param scene the instance of BABYLON.Scene to append to
  115754. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  115755. * @param onProgress a callback with a progress event for each file being loaded
  115756. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115757. * @param pluginExtension the extension used to determine the plugin
  115758. * @returns The loaded plugin
  115759. */
  115760. 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>;
  115761. /**
  115762. * Import meshes into a scene
  115763. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  115764. * @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)
  115765. * @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)
  115766. * @param scene the instance of BABYLON.Scene to append to
  115767. * @param onProgress a callback with a progress event for each file being loaded
  115768. * @param pluginExtension the extension used to determine the plugin
  115769. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  115770. */
  115771. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  115772. meshes: AbstractMesh[];
  115773. particleSystems: IParticleSystem[];
  115774. skeletons: Skeleton[];
  115775. animationGroups: AnimationGroup[];
  115776. }>;
  115777. /**
  115778. * Load a scene
  115779. * @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)
  115780. * @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)
  115781. * @param engine is the instance of BABYLON.Engine to use to create the scene
  115782. * @param onSuccess a callback with the scene when import succeeds
  115783. * @param onProgress a callback with a progress event for each file being loaded
  115784. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115785. * @param pluginExtension the extension used to determine the plugin
  115786. * @returns The loaded plugin
  115787. */
  115788. 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>;
  115789. /**
  115790. * Load a scene
  115791. * @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)
  115792. * @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)
  115793. * @param engine is the instance of BABYLON.Engine to use to create the scene
  115794. * @param onProgress a callback with a progress event for each file being loaded
  115795. * @param pluginExtension the extension used to determine the plugin
  115796. * @returns The loaded scene
  115797. */
  115798. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  115799. /**
  115800. * Append a scene
  115801. * @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)
  115802. * @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)
  115803. * @param scene is the instance of BABYLON.Scene to append to
  115804. * @param onSuccess a callback with the scene when import succeeds
  115805. * @param onProgress a callback with a progress event for each file being loaded
  115806. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115807. * @param pluginExtension the extension used to determine the plugin
  115808. * @returns The loaded plugin
  115809. */
  115810. 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>;
  115811. /**
  115812. * Append a scene
  115813. * @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)
  115814. * @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)
  115815. * @param scene is the instance of BABYLON.Scene to append to
  115816. * @param onProgress a callback with a progress event for each file being loaded
  115817. * @param pluginExtension the extension used to determine the plugin
  115818. * @returns The given scene
  115819. */
  115820. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  115821. /**
  115822. * Load a scene into an asset container
  115823. * @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)
  115824. * @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)
  115825. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  115826. * @param onSuccess a callback with the scene when import succeeds
  115827. * @param onProgress a callback with a progress event for each file being loaded
  115828. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115829. * @param pluginExtension the extension used to determine the plugin
  115830. * @returns The loaded plugin
  115831. */
  115832. 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>;
  115833. /**
  115834. * Load a scene into an asset container
  115835. * @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)
  115836. * @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)
  115837. * @param scene is the instance of Scene to append to
  115838. * @param onProgress a callback with a progress event for each file being loaded
  115839. * @param pluginExtension the extension used to determine the plugin
  115840. * @returns The loaded asset container
  115841. */
  115842. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  115843. /**
  115844. * Import animations from a file into a scene
  115845. * @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)
  115846. * @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)
  115847. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  115848. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  115849. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  115850. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  115851. * @param onSuccess a callback with the scene when import succeeds
  115852. * @param onProgress a callback with a progress event for each file being loaded
  115853. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115854. */
  115855. 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;
  115856. /**
  115857. * Import animations from a file into a scene
  115858. * @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)
  115859. * @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)
  115860. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  115861. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  115862. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  115863. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  115864. * @param onSuccess a callback with the scene when import succeeds
  115865. * @param onProgress a callback with a progress event for each file being loaded
  115866. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  115867. * @returns the updated scene with imported animations
  115868. */
  115869. 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>;
  115870. }
  115871. }
  115872. declare module BABYLON {
  115873. /**
  115874. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  115875. */
  115876. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  115877. /**
  115878. * The type of components available in motion controllers.
  115879. * This is not the name of the component.
  115880. */
  115881. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  115882. /**
  115883. * The schema of motion controller layout.
  115884. * No object will be initialized using this interface
  115885. * This is used just to define the profile.
  115886. */
  115887. export interface IMotionControllerLayout {
  115888. /**
  115889. * Defines the main button component id
  115890. */
  115891. selectComponentId: string;
  115892. /**
  115893. * Available components (unsorted)
  115894. */
  115895. components: {
  115896. /**
  115897. * A map of component Ids
  115898. */
  115899. [componentId: string]: {
  115900. /**
  115901. * The type of input the component outputs
  115902. */
  115903. type: MotionControllerComponentType;
  115904. };
  115905. };
  115906. /**
  115907. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  115908. */
  115909. gamepad?: {
  115910. /**
  115911. * Is the mapping based on the xr-standard defined here:
  115912. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  115913. */
  115914. mapping: "" | "xr-standard";
  115915. /**
  115916. * The buttons available in this input in the right order
  115917. * index of this button will be the index in the gamepadObject.buttons array
  115918. * correlates to the componentId in components
  115919. */
  115920. buttons: Array<string | null>;
  115921. /**
  115922. * Definition of the axes of the gamepad input, sorted
  115923. * Correlates to componentIds in the components map
  115924. */
  115925. axes: Array<{
  115926. /**
  115927. * The component id that the axis correlates to
  115928. */
  115929. componentId: string;
  115930. /**
  115931. * X or Y Axis
  115932. */
  115933. axis: "x-axis" | "y-axis";
  115934. } | null>;
  115935. };
  115936. }
  115937. /**
  115938. * A definition for the layout map in the input profile
  115939. */
  115940. export interface IMotionControllerLayoutMap {
  115941. /**
  115942. * Layouts with handness type as a key
  115943. */
  115944. [handness: string]: IMotionControllerLayout;
  115945. }
  115946. /**
  115947. * The XR Input profile schema
  115948. * Profiles can be found here:
  115949. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  115950. */
  115951. export interface IMotionControllerProfile {
  115952. /**
  115953. * The id of this profile
  115954. * correlates to the profile(s) in the xrInput.profiles array
  115955. */
  115956. profileId: string;
  115957. /**
  115958. * fallback profiles for this profileId
  115959. */
  115960. fallbackProfileIds: string[];
  115961. /**
  115962. * The layout map, with handness as key
  115963. */
  115964. layouts: IMotionControllerLayoutMap;
  115965. }
  115966. /**
  115967. * A helper-interface for the 3 meshes needed for controller button animation
  115968. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  115969. */
  115970. export interface IMotionControllerButtonMeshMap {
  115971. /**
  115972. * The mesh that will be changed when value changes
  115973. */
  115974. valueMesh: AbstractMesh;
  115975. /**
  115976. * the mesh that defines the pressed value mesh position.
  115977. * This is used to find the max-position of this button
  115978. */
  115979. pressedMesh: AbstractMesh;
  115980. /**
  115981. * the mesh that defines the unpressed value mesh position.
  115982. * This is used to find the min (or initial) position of this button
  115983. */
  115984. unpressedMesh: AbstractMesh;
  115985. }
  115986. /**
  115987. * A helper-interface for the 3 meshes needed for controller axis animation.
  115988. * This will be expanded when touchpad animations are fully supported
  115989. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  115990. */
  115991. export interface IMotionControllerAxisMeshMap {
  115992. /**
  115993. * The mesh that will be changed when axis value changes
  115994. */
  115995. valueMesh: AbstractMesh;
  115996. /**
  115997. * the mesh that defines the minimum value mesh position.
  115998. */
  115999. minMesh: AbstractMesh;
  116000. /**
  116001. * the mesh that defines the maximum value mesh position.
  116002. */
  116003. maxMesh: AbstractMesh;
  116004. }
  116005. /**
  116006. * The elements needed for change-detection of the gamepad objects in motion controllers
  116007. */
  116008. export interface IMinimalMotionControllerObject {
  116009. /**
  116010. * An array of available buttons
  116011. */
  116012. buttons: Array<{
  116013. /**
  116014. * Value of the button/trigger
  116015. */
  116016. value: number;
  116017. /**
  116018. * If the button/trigger is currently touched
  116019. */
  116020. touched: boolean;
  116021. /**
  116022. * If the button/trigger is currently pressed
  116023. */
  116024. pressed: boolean;
  116025. }>;
  116026. /**
  116027. * Available axes of this controller
  116028. */
  116029. axes: number[];
  116030. }
  116031. /**
  116032. * An Abstract Motion controller
  116033. * This class receives an xrInput and a profile layout and uses those to initialize the components
  116034. * Each component has an observable to check for changes in value and state
  116035. */
  116036. export abstract class WebXRAbstractMotionController implements IDisposable {
  116037. protected scene: Scene;
  116038. protected layout: IMotionControllerLayout;
  116039. /**
  116040. * The gamepad object correlating to this controller
  116041. */
  116042. gamepadObject: IMinimalMotionControllerObject;
  116043. /**
  116044. * handness (left/right/none) of this controller
  116045. */
  116046. handness: MotionControllerHandness;
  116047. /**
  116048. * Component type map
  116049. */
  116050. static ComponentType: {
  116051. TRIGGER: string;
  116052. SQUEEZE: string;
  116053. TOUCHPAD: string;
  116054. THUMBSTICK: string;
  116055. BUTTON: string;
  116056. };
  116057. /**
  116058. * The profile id of this motion controller
  116059. */
  116060. abstract profileId: string;
  116061. /**
  116062. * A map of components (WebXRControllerComponent) in this motion controller
  116063. * Components have a ComponentType and can also have both button and axis definitions
  116064. */
  116065. readonly components: {
  116066. [id: string]: WebXRControllerComponent;
  116067. };
  116068. /**
  116069. * Observers registered here will be triggered when the model of this controller is done loading
  116070. */
  116071. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  116072. /**
  116073. * The root mesh of the model. It is null if the model was not yet initialized
  116074. */
  116075. rootMesh: Nullable<AbstractMesh>;
  116076. private _modelReady;
  116077. /**
  116078. * constructs a new abstract motion controller
  116079. * @param scene the scene to which the model of the controller will be added
  116080. * @param layout The profile layout to load
  116081. * @param gamepadObject The gamepad object correlating to this controller
  116082. * @param handness handness (left/right/none) of this controller
  116083. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  116084. */
  116085. constructor(scene: Scene, layout: IMotionControllerLayout,
  116086. /**
  116087. * The gamepad object correlating to this controller
  116088. */
  116089. gamepadObject: IMinimalMotionControllerObject,
  116090. /**
  116091. * handness (left/right/none) of this controller
  116092. */
  116093. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  116094. private _initComponent;
  116095. /**
  116096. * Update this model using the current XRFrame
  116097. * @param xrFrame the current xr frame to use and update the model
  116098. */
  116099. updateFromXRFrame(xrFrame: XRFrame): void;
  116100. /**
  116101. * Get the list of components available in this motion controller
  116102. * @returns an array of strings correlating to available components
  116103. */
  116104. getComponentTypes(): string[];
  116105. /**
  116106. * Get the main (Select) component of this controller as defined in the layout
  116107. * @returns the main component of this controller
  116108. */
  116109. getMainComponent(): WebXRControllerComponent;
  116110. /**
  116111. * get a component based an its component id as defined in layout.components
  116112. * @param id the id of the component
  116113. * @returns the component correlates to the id or undefined if not found
  116114. */
  116115. getComponent(id: string): WebXRControllerComponent;
  116116. /**
  116117. * Loads the model correlating to this controller
  116118. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  116119. * @returns A promise fulfilled with the result of the model loading
  116120. */
  116121. loadModel(): Promise<boolean>;
  116122. /**
  116123. * Update the model itself with the current frame data
  116124. * @param xrFrame the frame to use for updating the model mesh
  116125. */
  116126. protected updateModel(xrFrame: XRFrame): void;
  116127. /**
  116128. * Moves the axis on the controller mesh based on its current state
  116129. * @param axis the index of the axis
  116130. * @param axisValue the value of the axis which determines the meshes new position
  116131. * @hidden
  116132. */
  116133. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  116134. /**
  116135. * Moves the buttons on the controller mesh based on their current state
  116136. * @param buttonName the name of the button to move
  116137. * @param buttonValue the value of the button which determines the buttons new position
  116138. */
  116139. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  116140. private _getGenericFilenameAndPath;
  116141. private _getGenericParentMesh;
  116142. /**
  116143. * Get the filename and path for this controller's model
  116144. * @returns a map of filename and path
  116145. */
  116146. protected abstract _getFilenameAndPath(): {
  116147. filename: string;
  116148. path: string;
  116149. };
  116150. /**
  116151. * This function will be called after the model was successfully loaded and can be used
  116152. * for mesh transformations before it is available for the user
  116153. * @param meshes the loaded meshes
  116154. */
  116155. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  116156. /**
  116157. * Set the root mesh for this controller. Important for the WebXR controller class
  116158. * @param meshes the loaded meshes
  116159. */
  116160. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  116161. /**
  116162. * A function executed each frame that updates the mesh (if needed)
  116163. * @param xrFrame the current xrFrame
  116164. */
  116165. protected abstract _updateModel(xrFrame: XRFrame): void;
  116166. /**
  116167. * This function is called before the mesh is loaded. It checks for loading constraints.
  116168. * For example, this function can check if the GLB loader is available
  116169. * If this function returns false, the generic controller will be loaded instead
  116170. * @returns Is the client ready to load the mesh
  116171. */
  116172. protected abstract _getModelLoadingConstraints(): boolean;
  116173. /**
  116174. * Dispose this controller, the model mesh and all its components
  116175. */
  116176. dispose(): void;
  116177. }
  116178. }
  116179. declare module BABYLON {
  116180. /**
  116181. * A generic trigger-only motion controller for WebXR
  116182. */
  116183. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  116184. /**
  116185. * Static version of the profile id of this controller
  116186. */
  116187. static ProfileId: string;
  116188. profileId: string;
  116189. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  116190. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  116191. protected _updateModel(): void;
  116192. protected _getFilenameAndPath(): {
  116193. filename: string;
  116194. path: string;
  116195. };
  116196. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116197. protected _getModelLoadingConstraints(): boolean;
  116198. }
  116199. }
  116200. declare module BABYLON {
  116201. /**
  116202. * A construction function type to create a new controller based on an xrInput object
  116203. */
  116204. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  116205. /**
  116206. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  116207. *
  116208. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  116209. * it should be replaced with auto-loaded controllers.
  116210. *
  116211. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  116212. */
  116213. export class WebXRMotionControllerManager {
  116214. private static _AvailableControllers;
  116215. private static _Fallbacks;
  116216. /**
  116217. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  116218. *
  116219. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  116220. *
  116221. * @param type the profile type to register
  116222. * @param constructFunction the function to be called when loading this profile
  116223. */
  116224. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  116225. /**
  116226. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  116227. * The order of search:
  116228. *
  116229. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  116230. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  116231. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  116232. * 4) return the generic trigger controller if none were found
  116233. *
  116234. * @param xrInput the xrInput to which a new controller is initialized
  116235. * @param scene the scene to which the model will be added
  116236. * @param forceProfile force a certain profile for this controller
  116237. * @return the motion controller class for this profile id or the generic standard class if none was found
  116238. */
  116239. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  116240. /**
  116241. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  116242. * @param profileId the profile to which a fallback needs to be found
  116243. * @return an array with corresponding fallback profiles
  116244. */
  116245. static FindFallbackWithProfileId(profileId: string): string[];
  116246. /**
  116247. * Register a fallback to a specific profile.
  116248. * @param profileId the profileId that will receive the fallbacks
  116249. * @param fallbacks A list of fallback profiles
  116250. */
  116251. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  116252. /**
  116253. * Register the default fallbacks.
  116254. * This function is called automatically when this file is imported.
  116255. */
  116256. static DefaultFallbacks(): void;
  116257. }
  116258. }
  116259. declare module BABYLON {
  116260. /**
  116261. * Configuration options for the WebXR controller creation
  116262. */
  116263. export interface IWebXRControllerOptions {
  116264. /**
  116265. * Force a specific controller type for this controller.
  116266. * This can be used when creating your own profile or when testing different controllers
  116267. */
  116268. forceControllerProfile?: string;
  116269. }
  116270. /**
  116271. * Represents an XR controller
  116272. */
  116273. export class WebXRController {
  116274. private _scene;
  116275. /** The underlying input source for the controller */
  116276. inputSource: XRInputSource;
  116277. private _options;
  116278. /**
  116279. * 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
  116280. */
  116281. grip?: AbstractMesh;
  116282. /**
  116283. * Pointer which can be used to select objects or attach a visible laser to
  116284. */
  116285. pointer: AbstractMesh;
  116286. /**
  116287. * If available, this is the gamepad object related to this controller.
  116288. * Using this object it is possible to get click events and trackpad changes of the
  116289. * webxr controller that is currently being used.
  116290. */
  116291. motionController?: WebXRAbstractMotionController;
  116292. /**
  116293. * Event that fires when the controller is removed/disposed
  116294. */
  116295. onDisposeObservable: Observable<{}>;
  116296. private _tmpQuaternion;
  116297. private _tmpVector;
  116298. private _uniqueId;
  116299. /**
  116300. * Creates the controller
  116301. * @see https://doc.babylonjs.com/how_to/webxr
  116302. * @param _scene the scene which the controller should be associated to
  116303. * @param inputSource the underlying input source for the controller
  116304. * @param _options options for this controller creation
  116305. */
  116306. constructor(_scene: Scene,
  116307. /** The underlying input source for the controller */
  116308. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  116309. /**
  116310. * Get this controllers unique id
  116311. */
  116312. get uniqueId(): string;
  116313. /**
  116314. * Updates the controller pose based on the given XRFrame
  116315. * @param xrFrame xr frame to update the pose with
  116316. * @param referenceSpace reference space to use
  116317. */
  116318. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  116319. /**
  116320. * Gets a world space ray coming from the controller
  116321. * @param result the resulting ray
  116322. */
  116323. getWorldPointerRayToRef(result: Ray): void;
  116324. /**
  116325. * Disposes of the object
  116326. */
  116327. dispose(): void;
  116328. }
  116329. }
  116330. declare module BABYLON {
  116331. /**
  116332. * The schema for initialization options of the XR Input class
  116333. */
  116334. export interface IWebXRInputOptions {
  116335. /**
  116336. * If set to true no model will be automatically loaded
  116337. */
  116338. doNotLoadControllerMeshes?: boolean;
  116339. /**
  116340. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  116341. * If not found, the xr input profile data will be used.
  116342. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  116343. */
  116344. forceInputProfile?: string;
  116345. }
  116346. /**
  116347. * XR input used to track XR inputs such as controllers/rays
  116348. */
  116349. export class WebXRInput implements IDisposable {
  116350. /**
  116351. * the xr session manager for this session
  116352. */
  116353. xrSessionManager: WebXRSessionManager;
  116354. /**
  116355. * the WebXR camera for this session. Mainly used for teleportation
  116356. */
  116357. xrCamera: WebXRCamera;
  116358. private readonly options;
  116359. /**
  116360. * XR controllers being tracked
  116361. */
  116362. controllers: Array<WebXRController>;
  116363. private _frameObserver;
  116364. private _sessionEndedObserver;
  116365. private _sessionInitObserver;
  116366. /**
  116367. * Event when a controller has been connected/added
  116368. */
  116369. onControllerAddedObservable: Observable<WebXRController>;
  116370. /**
  116371. * Event when a controller has been removed/disconnected
  116372. */
  116373. onControllerRemovedObservable: Observable<WebXRController>;
  116374. /**
  116375. * Initializes the WebXRInput
  116376. * @param xrSessionManager the xr session manager for this session
  116377. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  116378. * @param options = initialization options for this xr input
  116379. */
  116380. constructor(
  116381. /**
  116382. * the xr session manager for this session
  116383. */
  116384. xrSessionManager: WebXRSessionManager,
  116385. /**
  116386. * the WebXR camera for this session. Mainly used for teleportation
  116387. */
  116388. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  116389. private _onInputSourcesChange;
  116390. private _addAndRemoveControllers;
  116391. /**
  116392. * Disposes of the object
  116393. */
  116394. dispose(): void;
  116395. }
  116396. }
  116397. declare module BABYLON {
  116398. /**
  116399. * This is the base class for all WebXR features.
  116400. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  116401. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  116402. */
  116403. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  116404. protected _xrSessionManager: WebXRSessionManager;
  116405. /**
  116406. * Construct a new (abstract) webxr feature
  116407. * @param _xrSessionManager the xr session manager for this feature
  116408. */
  116409. constructor(_xrSessionManager: WebXRSessionManager);
  116410. private _attached;
  116411. private _removeOnDetach;
  116412. /**
  116413. * Is this feature attached
  116414. */
  116415. get attached(): boolean;
  116416. /**
  116417. * attach this feature
  116418. *
  116419. * @returns true if successful, false is failed or already attached
  116420. */
  116421. attach(): boolean;
  116422. /**
  116423. * detach this feature.
  116424. *
  116425. * @returns true if successful, false if failed or already detached
  116426. */
  116427. detach(): boolean;
  116428. /**
  116429. * Dispose this feature and all of the resources attached
  116430. */
  116431. dispose(): void;
  116432. /**
  116433. * Code in this function will be executed on each xrFrame received from the browser.
  116434. * This function will not execute after the feature is detached.
  116435. * @param _xrFrame the current frame
  116436. */
  116437. protected _onXRFrame(_xrFrame: XRFrame): void;
  116438. /**
  116439. * This is used to register callbacks that will automatically be removed when detach is called.
  116440. * @param observable the observable to which the observer will be attached
  116441. * @param callback the callback to register
  116442. */
  116443. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  116444. }
  116445. }
  116446. declare module BABYLON {
  116447. /**
  116448. * Options interface for the pointer selection module
  116449. */
  116450. export interface IWebXRControllerPointerSelectionOptions {
  116451. /**
  116452. * the xr input to use with this pointer selection
  116453. */
  116454. xrInput: WebXRInput;
  116455. /**
  116456. * Different button type to use instead of the main component
  116457. */
  116458. overrideButtonId?: string;
  116459. /**
  116460. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  116461. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  116462. * 3000 means 3 seconds between pointing at something and selecting it
  116463. */
  116464. timeToSelect?: number;
  116465. /**
  116466. * 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)
  116467. * If not disabled, the last picked point will be used to execute a pointer up event
  116468. * If disabled, pointer up event will be triggered right after the pointer down event.
  116469. * Used in screen and gaze target ray mode only
  116470. */
  116471. disablePointerUpOnTouchOut: boolean;
  116472. /**
  116473. * For gaze mode (time to select instead of press)
  116474. */
  116475. forceGazeMode: boolean;
  116476. /**
  116477. * 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
  116478. * to start a new countdown to the pointer down event.
  116479. * Defaults to 1.
  116480. */
  116481. gazeModePointerMovedFactor?: number;
  116482. }
  116483. /**
  116484. * A module that will enable pointer selection for motion controllers of XR Input Sources
  116485. */
  116486. export class WebXRControllerPointerSelection extends WebXRAbstractFeature implements IWebXRFeature {
  116487. private readonly _options;
  116488. /**
  116489. * The module's name
  116490. */
  116491. static readonly Name: string;
  116492. /**
  116493. * The (Babylon) version of this module.
  116494. * This is an integer representing the implementation version.
  116495. * This number does not correspond to the webxr specs version
  116496. */
  116497. static readonly Version: number;
  116498. /**
  116499. * This color will be set to the laser pointer when selection is triggered
  116500. */
  116501. laserPointerPickedColor: Color3;
  116502. /**
  116503. * This color will be applied to the selection ring when selection is triggered
  116504. */
  116505. selectionMeshPickedColor: Color3;
  116506. /**
  116507. * default color of the selection ring
  116508. */
  116509. selectionMeshDefaultColor: Color3;
  116510. /**
  116511. * Default color of the laser pointer
  116512. */
  116513. lasterPointerDefaultColor: Color3;
  116514. /**
  116515. * Should the laser pointer be displayed
  116516. */
  116517. displayLaserPointer: boolean;
  116518. /**
  116519. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  116520. */
  116521. displaySelectionMesh: boolean;
  116522. /**
  116523. * Disable lighting on the laser pointer (so it will always be visible)
  116524. */
  116525. disablePointerLighting: boolean;
  116526. /**
  116527. * Disable lighting on the selection mesh (so it will always be visible)
  116528. */
  116529. disableSelectionMeshLighting: boolean;
  116530. private static _idCounter;
  116531. private _tmpRay;
  116532. private _controllers;
  116533. private _scene;
  116534. /**
  116535. * constructs a new background remover module
  116536. * @param _xrSessionManager the session manager for this module
  116537. * @param _options read-only options to be used in this module
  116538. */
  116539. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  116540. /**
  116541. * attach this feature
  116542. * Will usually be called by the features manager
  116543. *
  116544. * @returns true if successful.
  116545. */
  116546. attach(): boolean;
  116547. /**
  116548. * detach this feature.
  116549. * Will usually be called by the features manager
  116550. *
  116551. * @returns true if successful.
  116552. */
  116553. detach(): boolean;
  116554. /**
  116555. * Get the xr controller that correlates to the pointer id in the pointer event
  116556. *
  116557. * @param id the pointer id to search for
  116558. * @returns the controller that correlates to this id or null if not found
  116559. */
  116560. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  116561. protected _onXRFrame(_xrFrame: XRFrame): void;
  116562. private _attachController;
  116563. private _attachScreenRayMode;
  116564. private _attachGazeMode;
  116565. private _tmpVectorForPickCompare;
  116566. private _pickingMoved;
  116567. private _attachTrackedPointerRayMode;
  116568. private _detachController;
  116569. private _generateNewMeshPair;
  116570. private _convertNormalToDirectionOfRay;
  116571. private _updatePointerDistance;
  116572. }
  116573. }
  116574. declare module BABYLON {
  116575. /**
  116576. * Button which can be used to enter a different mode of XR
  116577. */
  116578. export class WebXREnterExitUIButton {
  116579. /** button element */
  116580. element: HTMLElement;
  116581. /** XR initialization options for the button */
  116582. sessionMode: XRSessionMode;
  116583. /** Reference space type */
  116584. referenceSpaceType: XRReferenceSpaceType;
  116585. /**
  116586. * Creates a WebXREnterExitUIButton
  116587. * @param element button element
  116588. * @param sessionMode XR initialization session mode
  116589. * @param referenceSpaceType the type of reference space to be used
  116590. */
  116591. constructor(
  116592. /** button element */
  116593. element: HTMLElement,
  116594. /** XR initialization options for the button */
  116595. sessionMode: XRSessionMode,
  116596. /** Reference space type */
  116597. referenceSpaceType: XRReferenceSpaceType);
  116598. /**
  116599. * Overwritable function which can be used to update the button's visuals when the state changes
  116600. * @param activeButton the current active button in the UI
  116601. */
  116602. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  116603. }
  116604. /**
  116605. * Options to create the webXR UI
  116606. */
  116607. export class WebXREnterExitUIOptions {
  116608. /**
  116609. * Context to enter xr with
  116610. */
  116611. renderTarget?: Nullable<WebXRRenderTarget>;
  116612. /**
  116613. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  116614. */
  116615. customButtons?: Array<WebXREnterExitUIButton>;
  116616. /**
  116617. * A session mode to use when creating the default button.
  116618. * Default is immersive-vr
  116619. */
  116620. sessionMode?: XRSessionMode;
  116621. /**
  116622. * A reference space type to use when creating the default button.
  116623. * Default is local-floor
  116624. */
  116625. referenceSpaceType?: XRReferenceSpaceType;
  116626. }
  116627. /**
  116628. * UI to allow the user to enter/exit XR mode
  116629. */
  116630. export class WebXREnterExitUI implements IDisposable {
  116631. private scene;
  116632. /** version of the options passed to this UI */
  116633. options: WebXREnterExitUIOptions;
  116634. private _overlay;
  116635. private _buttons;
  116636. private _activeButton;
  116637. /**
  116638. * Fired every time the active button is changed.
  116639. *
  116640. * When xr is entered via a button that launches xr that button will be the callback parameter
  116641. *
  116642. * When exiting xr the callback parameter will be null)
  116643. */
  116644. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  116645. /**
  116646. * Creates UI to allow the user to enter/exit XR mode
  116647. * @param scene the scene to add the ui to
  116648. * @param helper the xr experience helper to enter/exit xr with
  116649. * @param options options to configure the UI
  116650. * @returns the created ui
  116651. */
  116652. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  116653. /**
  116654. *
  116655. * @param scene babylon scene object to use
  116656. * @param options (read-only) version of the options passed to this UI
  116657. */
  116658. private constructor();
  116659. private _updateButtons;
  116660. /**
  116661. * Disposes of the object
  116662. */
  116663. dispose(): void;
  116664. }
  116665. }
  116666. declare module BABYLON {
  116667. /**
  116668. * Class containing static functions to help procedurally build meshes
  116669. */
  116670. export class LinesBuilder {
  116671. /**
  116672. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116673. * * 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
  116674. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116675. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116676. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116677. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116678. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116679. * * 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
  116680. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116683. * @param name defines the name of the new line system
  116684. * @param options defines the options used to create the line system
  116685. * @param scene defines the hosting scene
  116686. * @returns a new line system mesh
  116687. */
  116688. static CreateLineSystem(name: string, options: {
  116689. lines: Vector3[][];
  116690. updatable?: boolean;
  116691. instance?: Nullable<LinesMesh>;
  116692. colors?: Nullable<Color4[][]>;
  116693. useVertexAlpha?: boolean;
  116694. }, scene: Nullable<Scene>): LinesMesh;
  116695. /**
  116696. * Creates a line mesh
  116697. * 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
  116698. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116699. * * The parameter `points` is an array successive Vector3
  116700. * * 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
  116701. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116702. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116703. * * When updating an instance, remember that only point positions can change, not the number of points
  116704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116706. * @param name defines the name of the new line system
  116707. * @param options defines the options used to create the line system
  116708. * @param scene defines the hosting scene
  116709. * @returns a new line mesh
  116710. */
  116711. static CreateLines(name: string, options: {
  116712. points: Vector3[];
  116713. updatable?: boolean;
  116714. instance?: Nullable<LinesMesh>;
  116715. colors?: Color4[];
  116716. useVertexAlpha?: boolean;
  116717. }, scene?: Nullable<Scene>): LinesMesh;
  116718. /**
  116719. * Creates a dashed line mesh
  116720. * * 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
  116721. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116722. * * The parameter `points` is an array successive Vector3
  116723. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116724. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116725. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116726. * * 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
  116727. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116728. * * When updating an instance, remember that only point positions can change, not the number of points
  116729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116730. * @param name defines the name of the mesh
  116731. * @param options defines the options used to create the mesh
  116732. * @param scene defines the hosting scene
  116733. * @returns the dashed line mesh
  116734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116735. */
  116736. static CreateDashedLines(name: string, options: {
  116737. points: Vector3[];
  116738. dashSize?: number;
  116739. gapSize?: number;
  116740. dashNb?: number;
  116741. updatable?: boolean;
  116742. instance?: LinesMesh;
  116743. useVertexAlpha?: boolean;
  116744. }, scene?: Nullable<Scene>): LinesMesh;
  116745. }
  116746. }
  116747. declare module BABYLON {
  116748. /**
  116749. * The options container for the teleportation module
  116750. */
  116751. export interface IWebXRTeleportationOptions {
  116752. /**
  116753. * Babylon XR Input class for controller
  116754. */
  116755. xrInput: WebXRInput;
  116756. /**
  116757. * A list of meshes to use as floor meshes.
  116758. * Meshes can be added and removed after initializing the feature using the
  116759. * addFloorMesh and removeFloorMesh functions
  116760. * If empty, rotation will still work
  116761. */
  116762. floorMeshes?: AbstractMesh[];
  116763. /**
  116764. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  116765. * If you want to support rotation, make sure your mesh has a direction indicator.
  116766. *
  116767. * When left untouched, the default mesh will be initialized.
  116768. */
  116769. teleportationTargetMesh?: AbstractMesh;
  116770. /**
  116771. * Values to configure the default target mesh
  116772. */
  116773. defaultTargetMeshOptions?: {
  116774. /**
  116775. * Fill color of the teleportation area
  116776. */
  116777. teleportationFillColor?: string;
  116778. /**
  116779. * Border color for the teleportation area
  116780. */
  116781. teleportationBorderColor?: string;
  116782. /**
  116783. * Override the default material of the torus and arrow
  116784. */
  116785. torusArrowMaterial?: Material;
  116786. /**
  116787. * Disable the mesh's animation sequence
  116788. */
  116789. disableAnimation?: boolean;
  116790. };
  116791. /**
  116792. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  116793. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  116794. */
  116795. useMainComponentOnly?: boolean;
  116796. /**
  116797. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  116798. */
  116799. timeToTeleport?: number;
  116800. }
  116801. /**
  116802. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  116803. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  116804. * the input of the attached controllers.
  116805. */
  116806. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature implements IWebXRFeature {
  116807. private _options;
  116808. /**
  116809. * The module's name
  116810. */
  116811. static readonly Name: string;
  116812. /**
  116813. * The (Babylon) version of this module.
  116814. * This is an integer representing the implementation version.
  116815. * This number does not correspond to the webxr specs version
  116816. */
  116817. static readonly Version: number;
  116818. /**
  116819. * Is rotation enabled when moving forward?
  116820. * Disabling this feature will prevent the user from deciding the direction when teleporting
  116821. */
  116822. rotationEnabled: boolean;
  116823. /**
  116824. * Should the module support parabolic ray on top of direct ray
  116825. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  116826. * Very helpful when moving between floors / different heights
  116827. */
  116828. parabolicRayEnabled: boolean;
  116829. /**
  116830. * The distance from the user to the inspection point in the direction of the controller
  116831. * A higher number will allow the user to move further
  116832. * defaults to 5 (meters, in xr units)
  116833. */
  116834. parabolicCheckRadius: number;
  116835. /**
  116836. * How much rotation should be applied when rotating right and left
  116837. */
  116838. rotationAngle: number;
  116839. /**
  116840. * Distance to travel when moving backwards
  116841. */
  116842. backwardsTeleportationDistance: number;
  116843. /**
  116844. * Add a new mesh to the floor meshes array
  116845. * @param mesh the mesh to use as floor mesh
  116846. */
  116847. addFloorMesh(mesh: AbstractMesh): void;
  116848. /**
  116849. * Remove a mesh from the floor meshes array
  116850. * @param mesh the mesh to remove
  116851. */
  116852. removeFloorMesh(mesh: AbstractMesh): void;
  116853. /**
  116854. * Remove a mesh from the floor meshes array using its name
  116855. * @param name the mesh name to remove
  116856. */
  116857. removeFloorMeshByName(name: string): void;
  116858. private _tmpRay;
  116859. private _tmpVector;
  116860. private _floorMeshes;
  116861. private _controllers;
  116862. /**
  116863. * constructs a new anchor system
  116864. * @param _xrSessionManager an instance of WebXRSessionManager
  116865. * @param _options configuration object for this feature
  116866. */
  116867. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  116868. private _selectionFeature;
  116869. /**
  116870. * This function sets a selection feature that will be disabled when
  116871. * the forward ray is shown and will be reattached when hidden.
  116872. * This is used to remove the selection rays when moving.
  116873. * @param selectionFeature the feature to disable when forward movement is enabled
  116874. */
  116875. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  116876. attach(): boolean;
  116877. detach(): boolean;
  116878. dispose(): void;
  116879. protected _onXRFrame(_xrFrame: XRFrame): void;
  116880. private _currentTeleportationControllerId;
  116881. private _attachController;
  116882. private _teleportForward;
  116883. private _detachController;
  116884. private createDefaultTargetMesh;
  116885. private setTargetMeshVisibility;
  116886. private setTargetMeshPosition;
  116887. private _quadraticBezierCurve;
  116888. private showParabolicPath;
  116889. }
  116890. }
  116891. declare module BABYLON {
  116892. /**
  116893. * Options for the default xr helper
  116894. */
  116895. export class WebXRDefaultExperienceOptions {
  116896. /**
  116897. * Floor meshes that will be used for teleporting
  116898. */
  116899. floorMeshes?: Array<AbstractMesh>;
  116900. /**
  116901. * Enable or disable default UI to enter XR
  116902. */
  116903. disableDefaultUI?: boolean;
  116904. /**
  116905. * optional configuration for the output canvas
  116906. */
  116907. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  116908. /**
  116909. * optional UI options. This can be used among other to change session mode and reference space type
  116910. */
  116911. uiOptions?: WebXREnterExitUIOptions;
  116912. /**
  116913. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  116914. */
  116915. inputOptions?: IWebXRInputOptions;
  116916. /**
  116917. * Should teleportation not initialize. defaults to false.
  116918. */
  116919. disableTeleportation?: boolean;
  116920. }
  116921. /**
  116922. * Default experience which provides a similar setup to the previous webVRExperience
  116923. */
  116924. export class WebXRDefaultExperience {
  116925. /**
  116926. * Base experience
  116927. */
  116928. baseExperience: WebXRExperienceHelper;
  116929. /**
  116930. * Input experience extension
  116931. */
  116932. input: WebXRInput;
  116933. /**
  116934. * Enables laser pointer and selection
  116935. */
  116936. pointerSelection: WebXRControllerPointerSelection;
  116937. /**
  116938. * Enables teleportation
  116939. */
  116940. teleportation: WebXRMotionControllerTeleportation;
  116941. /**
  116942. * Enables ui for entering/exiting xr
  116943. */
  116944. enterExitUI: WebXREnterExitUI;
  116945. /**
  116946. * Default target xr should render to
  116947. */
  116948. renderTarget: WebXRRenderTarget;
  116949. /**
  116950. * Creates the default xr experience
  116951. * @param scene scene
  116952. * @param options options for basic configuration
  116953. * @returns resulting WebXRDefaultExperience
  116954. */
  116955. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116956. private constructor();
  116957. /**
  116958. * DIsposes of the experience helper
  116959. */
  116960. dispose(): void;
  116961. }
  116962. }
  116963. declare module BABYLON {
  116964. /**
  116965. * Options to modify the vr teleportation behavior.
  116966. */
  116967. export interface VRTeleportationOptions {
  116968. /**
  116969. * The name of the mesh which should be used as the teleportation floor. (default: null)
  116970. */
  116971. floorMeshName?: string;
  116972. /**
  116973. * A list of meshes to be used as the teleportation floor. (default: empty)
  116974. */
  116975. floorMeshes?: Mesh[];
  116976. /**
  116977. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  116978. */
  116979. teleportationMode?: number;
  116980. /**
  116981. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  116982. */
  116983. teleportationTime?: number;
  116984. /**
  116985. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  116986. */
  116987. teleportationSpeed?: number;
  116988. /**
  116989. * The easing function used in the animation or null for Linear. (default CircleEase)
  116990. */
  116991. easingFunction?: EasingFunction;
  116992. }
  116993. /**
  116994. * Options to modify the vr experience helper's behavior.
  116995. */
  116996. export interface VRExperienceHelperOptions extends WebVROptions {
  116997. /**
  116998. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  116999. */
  117000. createDeviceOrientationCamera?: boolean;
  117001. /**
  117002. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  117003. */
  117004. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  117005. /**
  117006. * Uses the main button on the controller to toggle the laser casted. (default: true)
  117007. */
  117008. laserToggle?: boolean;
  117009. /**
  117010. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  117011. */
  117012. floorMeshes?: Mesh[];
  117013. /**
  117014. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  117015. */
  117016. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  117017. /**
  117018. * Defines if WebXR should be used instead of WebVR (if available)
  117019. */
  117020. useXR?: boolean;
  117021. }
  117022. /**
  117023. * Event containing information after VR has been entered
  117024. */
  117025. export class OnAfterEnteringVRObservableEvent {
  117026. /**
  117027. * If entering vr was successful
  117028. */
  117029. success: boolean;
  117030. }
  117031. /**
  117032. * Helps to quickly add VR support to an existing scene.
  117033. * See http://doc.babylonjs.com/how_to/webvr_helper
  117034. */
  117035. export class VRExperienceHelper {
  117036. /** Options to modify the vr experience helper's behavior. */
  117037. webVROptions: VRExperienceHelperOptions;
  117038. private _scene;
  117039. private _position;
  117040. private _btnVR;
  117041. private _btnVRDisplayed;
  117042. private _webVRsupported;
  117043. private _webVRready;
  117044. private _webVRrequesting;
  117045. private _webVRpresenting;
  117046. private _hasEnteredVR;
  117047. private _fullscreenVRpresenting;
  117048. private _inputElement;
  117049. private _webVRCamera;
  117050. private _vrDeviceOrientationCamera;
  117051. private _deviceOrientationCamera;
  117052. private _existingCamera;
  117053. private _onKeyDown;
  117054. private _onVrDisplayPresentChange;
  117055. private _onVRDisplayChanged;
  117056. private _onVRRequestPresentStart;
  117057. private _onVRRequestPresentComplete;
  117058. /**
  117059. * 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)
  117060. */
  117061. enableGazeEvenWhenNoPointerLock: boolean;
  117062. /**
  117063. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  117064. */
  117065. exitVROnDoubleTap: boolean;
  117066. /**
  117067. * Observable raised right before entering VR.
  117068. */
  117069. onEnteringVRObservable: Observable<VRExperienceHelper>;
  117070. /**
  117071. * Observable raised when entering VR has completed.
  117072. */
  117073. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  117074. /**
  117075. * Observable raised when exiting VR.
  117076. */
  117077. onExitingVRObservable: Observable<VRExperienceHelper>;
  117078. /**
  117079. * Observable raised when controller mesh is loaded.
  117080. */
  117081. onControllerMeshLoadedObservable: Observable<WebVRController>;
  117082. /** Return this.onEnteringVRObservable
  117083. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  117084. */
  117085. get onEnteringVR(): Observable<VRExperienceHelper>;
  117086. /** Return this.onExitingVRObservable
  117087. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  117088. */
  117089. get onExitingVR(): Observable<VRExperienceHelper>;
  117090. /** Return this.onControllerMeshLoadedObservable
  117091. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  117092. */
  117093. get onControllerMeshLoaded(): Observable<WebVRController>;
  117094. private _rayLength;
  117095. private _useCustomVRButton;
  117096. private _teleportationRequested;
  117097. private _teleportActive;
  117098. private _floorMeshName;
  117099. private _floorMeshesCollection;
  117100. private _teleportationMode;
  117101. private _teleportationTime;
  117102. private _teleportationSpeed;
  117103. private _teleportationEasing;
  117104. private _rotationAllowed;
  117105. private _teleportBackwardsVector;
  117106. private _teleportationTarget;
  117107. private _isDefaultTeleportationTarget;
  117108. private _postProcessMove;
  117109. private _teleportationFillColor;
  117110. private _teleportationBorderColor;
  117111. private _rotationAngle;
  117112. private _haloCenter;
  117113. private _cameraGazer;
  117114. private _padSensibilityUp;
  117115. private _padSensibilityDown;
  117116. private _leftController;
  117117. private _rightController;
  117118. private _gazeColor;
  117119. private _laserColor;
  117120. private _pickedLaserColor;
  117121. private _pickedGazeColor;
  117122. /**
  117123. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  117124. */
  117125. onNewMeshSelected: Observable<AbstractMesh>;
  117126. /**
  117127. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  117128. * This observable will provide the mesh and the controller used to select the mesh
  117129. */
  117130. onMeshSelectedWithController: Observable<{
  117131. mesh: AbstractMesh;
  117132. controller: WebVRController;
  117133. }>;
  117134. /**
  117135. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  117136. */
  117137. onNewMeshPicked: Observable<PickingInfo>;
  117138. private _circleEase;
  117139. /**
  117140. * Observable raised before camera teleportation
  117141. */
  117142. onBeforeCameraTeleport: Observable<Vector3>;
  117143. /**
  117144. * Observable raised after camera teleportation
  117145. */
  117146. onAfterCameraTeleport: Observable<Vector3>;
  117147. /**
  117148. * Observable raised when current selected mesh gets unselected
  117149. */
  117150. onSelectedMeshUnselected: Observable<AbstractMesh>;
  117151. private _raySelectionPredicate;
  117152. /**
  117153. * To be optionaly changed by user to define custom ray selection
  117154. */
  117155. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  117156. /**
  117157. * To be optionaly changed by user to define custom selection logic (after ray selection)
  117158. */
  117159. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117160. /**
  117161. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  117162. */
  117163. teleportationEnabled: boolean;
  117164. private _defaultHeight;
  117165. private _teleportationInitialized;
  117166. private _interactionsEnabled;
  117167. private _interactionsRequested;
  117168. private _displayGaze;
  117169. private _displayLaserPointer;
  117170. /**
  117171. * The mesh used to display where the user is going to teleport.
  117172. */
  117173. get teleportationTarget(): Mesh;
  117174. /**
  117175. * Sets the mesh to be used to display where the user is going to teleport.
  117176. */
  117177. set teleportationTarget(value: Mesh);
  117178. /**
  117179. * 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
  117180. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  117181. * See http://doc.babylonjs.com/resources/baking_transformations
  117182. */
  117183. get gazeTrackerMesh(): Mesh;
  117184. set gazeTrackerMesh(value: Mesh);
  117185. /**
  117186. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  117187. */
  117188. updateGazeTrackerScale: boolean;
  117189. /**
  117190. * If the gaze trackers color should be updated when selecting meshes
  117191. */
  117192. updateGazeTrackerColor: boolean;
  117193. /**
  117194. * If the controller laser color should be updated when selecting meshes
  117195. */
  117196. updateControllerLaserColor: boolean;
  117197. /**
  117198. * The gaze tracking mesh corresponding to the left controller
  117199. */
  117200. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  117201. /**
  117202. * The gaze tracking mesh corresponding to the right controller
  117203. */
  117204. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  117205. /**
  117206. * If the ray of the gaze should be displayed.
  117207. */
  117208. get displayGaze(): boolean;
  117209. /**
  117210. * Sets if the ray of the gaze should be displayed.
  117211. */
  117212. set displayGaze(value: boolean);
  117213. /**
  117214. * If the ray of the LaserPointer should be displayed.
  117215. */
  117216. get displayLaserPointer(): boolean;
  117217. /**
  117218. * Sets if the ray of the LaserPointer should be displayed.
  117219. */
  117220. set displayLaserPointer(value: boolean);
  117221. /**
  117222. * The deviceOrientationCamera used as the camera when not in VR.
  117223. */
  117224. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  117225. /**
  117226. * Based on the current WebVR support, returns the current VR camera used.
  117227. */
  117228. get currentVRCamera(): Nullable<Camera>;
  117229. /**
  117230. * The webVRCamera which is used when in VR.
  117231. */
  117232. get webVRCamera(): WebVRFreeCamera;
  117233. /**
  117234. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  117235. */
  117236. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  117237. /**
  117238. * The html button that is used to trigger entering into VR.
  117239. */
  117240. get vrButton(): Nullable<HTMLButtonElement>;
  117241. private get _teleportationRequestInitiated();
  117242. /**
  117243. * Defines wether or not Pointer lock should be requested when switching to
  117244. * full screen.
  117245. */
  117246. requestPointerLockOnFullScreen: boolean;
  117247. /**
  117248. * If asking to force XR, this will be populated with the default xr experience
  117249. */
  117250. xr: WebXRDefaultExperience;
  117251. /**
  117252. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  117253. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  117254. */
  117255. xrTestDone: boolean;
  117256. /**
  117257. * Instantiates a VRExperienceHelper.
  117258. * Helps to quickly add VR support to an existing scene.
  117259. * @param scene The scene the VRExperienceHelper belongs to.
  117260. * @param webVROptions Options to modify the vr experience helper's behavior.
  117261. */
  117262. constructor(scene: Scene,
  117263. /** Options to modify the vr experience helper's behavior. */
  117264. webVROptions?: VRExperienceHelperOptions);
  117265. private completeVRInit;
  117266. private _onDefaultMeshLoaded;
  117267. private _onResize;
  117268. private _onFullscreenChange;
  117269. /**
  117270. * Gets a value indicating if we are currently in VR mode.
  117271. */
  117272. get isInVRMode(): boolean;
  117273. private onVrDisplayPresentChange;
  117274. private onVRDisplayChanged;
  117275. private moveButtonToBottomRight;
  117276. private displayVRButton;
  117277. private updateButtonVisibility;
  117278. private _cachedAngularSensibility;
  117279. /**
  117280. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  117281. * Otherwise, will use the fullscreen API.
  117282. */
  117283. enterVR(): void;
  117284. /**
  117285. * Attempt to exit VR, or fullscreen.
  117286. */
  117287. exitVR(): void;
  117288. /**
  117289. * The position of the vr experience helper.
  117290. */
  117291. get position(): Vector3;
  117292. /**
  117293. * Sets the position of the vr experience helper.
  117294. */
  117295. set position(value: Vector3);
  117296. /**
  117297. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  117298. */
  117299. enableInteractions(): void;
  117300. private get _noControllerIsActive();
  117301. private beforeRender;
  117302. private _isTeleportationFloor;
  117303. /**
  117304. * Adds a floor mesh to be used for teleportation.
  117305. * @param floorMesh the mesh to be used for teleportation.
  117306. */
  117307. addFloorMesh(floorMesh: Mesh): void;
  117308. /**
  117309. * Removes a floor mesh from being used for teleportation.
  117310. * @param floorMesh the mesh to be removed.
  117311. */
  117312. removeFloorMesh(floorMesh: Mesh): void;
  117313. /**
  117314. * Enables interactions and teleportation using the VR controllers and gaze.
  117315. * @param vrTeleportationOptions options to modify teleportation behavior.
  117316. */
  117317. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  117318. private _onNewGamepadConnected;
  117319. private _tryEnableInteractionOnController;
  117320. private _onNewGamepadDisconnected;
  117321. private _enableInteractionOnController;
  117322. private _checkTeleportWithRay;
  117323. private _checkRotate;
  117324. private _checkTeleportBackwards;
  117325. private _enableTeleportationOnController;
  117326. private _createTeleportationCircles;
  117327. private _displayTeleportationTarget;
  117328. private _hideTeleportationTarget;
  117329. private _rotateCamera;
  117330. private _moveTeleportationSelectorTo;
  117331. private _workingVector;
  117332. private _workingQuaternion;
  117333. private _workingMatrix;
  117334. /**
  117335. * Time Constant Teleportation Mode
  117336. */
  117337. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  117338. /**
  117339. * Speed Constant Teleportation Mode
  117340. */
  117341. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  117342. /**
  117343. * Teleports the users feet to the desired location
  117344. * @param location The location where the user's feet should be placed
  117345. */
  117346. teleportCamera(location: Vector3): void;
  117347. private _convertNormalToDirectionOfRay;
  117348. private _castRayAndSelectObject;
  117349. private _notifySelectedMeshUnselected;
  117350. /**
  117351. * Permanently set new colors for the laser pointer
  117352. * @param color the new laser color
  117353. * @param pickedColor the new laser color when picked mesh detected
  117354. */
  117355. setLaserColor(color: Color3, pickedColor?: Color3): void;
  117356. /**
  117357. * Set lighting enabled / disabled on the laser pointer of both controllers
  117358. * @param enabled should the lighting be enabled on the laser pointer
  117359. */
  117360. setLaserLightingState(enabled?: boolean): void;
  117361. /**
  117362. * Permanently set new colors for the gaze pointer
  117363. * @param color the new gaze color
  117364. * @param pickedColor the new gaze color when picked mesh detected
  117365. */
  117366. setGazeColor(color: Color3, pickedColor?: Color3): void;
  117367. /**
  117368. * Sets the color of the laser ray from the vr controllers.
  117369. * @param color new color for the ray.
  117370. */
  117371. changeLaserColor(color: Color3): void;
  117372. /**
  117373. * Sets the color of the ray from the vr headsets gaze.
  117374. * @param color new color for the ray.
  117375. */
  117376. changeGazeColor(color: Color3): void;
  117377. /**
  117378. * Exits VR and disposes of the vr experience helper
  117379. */
  117380. dispose(): void;
  117381. /**
  117382. * Gets the name of the VRExperienceHelper class
  117383. * @returns "VRExperienceHelper"
  117384. */
  117385. getClassName(): string;
  117386. }
  117387. }
  117388. declare module BABYLON {
  117389. /**
  117390. * Options used for hit testing
  117391. */
  117392. export interface IWebXRHitTestOptions {
  117393. /**
  117394. * Only test when user interacted with the scene. Default - hit test every frame
  117395. */
  117396. testOnPointerDownOnly?: boolean;
  117397. /**
  117398. * The node to use to transform the local results to world coordinates
  117399. */
  117400. worldParentNode?: TransformNode;
  117401. }
  117402. /**
  117403. * Interface defining the babylon result of raycasting/hit-test
  117404. */
  117405. export interface IWebXRHitResult {
  117406. /**
  117407. * The native hit test result
  117408. */
  117409. xrHitResult: XRHitResult;
  117410. /**
  117411. * Transformation matrix that can be applied to a node that will put it in the hit point location
  117412. */
  117413. transformationMatrix: Matrix;
  117414. }
  117415. /**
  117416. * The currently-working hit-test module.
  117417. * Hit test (or raycasting) is used to interact with the real world.
  117418. * For further information read here - https://github.com/immersive-web/hit-test
  117419. */
  117420. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRFeature {
  117421. /**
  117422. * options to use when constructing this feature
  117423. */
  117424. readonly options: IWebXRHitTestOptions;
  117425. /**
  117426. * The module's name
  117427. */
  117428. static readonly Name: string;
  117429. /**
  117430. * The (Babylon) version of this module.
  117431. * This is an integer representing the implementation version.
  117432. * This number does not correspond to the webxr specs version
  117433. */
  117434. static readonly Version: number;
  117435. /**
  117436. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  117437. * @param event the (select) event to use to select with
  117438. * @param referenceSpace the reference space to use for this hit test
  117439. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  117440. */
  117441. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  117442. /**
  117443. * execute a hit test with an XR Ray
  117444. *
  117445. * @param xrSession a native xrSession that will execute this hit test
  117446. * @param xrRay the ray (position and direction) to use for raycasting
  117447. * @param referenceSpace native XR reference space to use for the hit-test
  117448. * @param filter filter function that will filter the results
  117449. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  117450. */
  117451. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  117452. /**
  117453. * Triggered when new babylon (transformed) hit test results are available
  117454. */
  117455. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  117456. private _onSelectEnabled;
  117457. /**
  117458. * Creates a new instance of the (legacy version) hit test feature
  117459. * @param _xrSessionManager an instance of WebXRSessionManager
  117460. * @param options options to use when constructing this feature
  117461. */
  117462. constructor(_xrSessionManager: WebXRSessionManager,
  117463. /**
  117464. * options to use when constructing this feature
  117465. */
  117466. options?: IWebXRHitTestOptions);
  117467. /**
  117468. * Populated with the last native XR Hit Results
  117469. */
  117470. lastNativeXRHitResults: XRHitResult[];
  117471. /**
  117472. * attach this feature
  117473. * Will usually be called by the features manager
  117474. *
  117475. * @returns true if successful.
  117476. */
  117477. attach(): boolean;
  117478. /**
  117479. * detach this feature.
  117480. * Will usually be called by the features manager
  117481. *
  117482. * @returns true if successful.
  117483. */
  117484. detach(): boolean;
  117485. private _onHitTestResults;
  117486. private _origin;
  117487. private _direction;
  117488. private _mat;
  117489. protected _onXRFrame(frame: XRFrame): void;
  117490. private _onSelect;
  117491. /**
  117492. * Dispose this feature and all of the resources attached
  117493. */
  117494. dispose(): void;
  117495. }
  117496. }
  117497. declare module BABYLON {
  117498. /**
  117499. * Options used in the plane detector module
  117500. */
  117501. export interface IWebXRPlaneDetectorOptions {
  117502. /**
  117503. * The node to use to transform the local results to world coordinates
  117504. */
  117505. worldParentNode?: TransformNode;
  117506. }
  117507. /**
  117508. * A babylon interface for a webxr plane.
  117509. * A Plane is actually a polygon, built from N points in space
  117510. */
  117511. export interface IWebXRPlane {
  117512. /**
  117513. * a babylon-assigned ID for this polygon
  117514. */
  117515. id: number;
  117516. /**
  117517. * the native xr-plane object
  117518. */
  117519. xrPlane: XRPlane;
  117520. /**
  117521. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  117522. */
  117523. polygonDefinition: Array<Vector3>;
  117524. /**
  117525. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  117526. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  117527. */
  117528. transformationMatrix: Matrix;
  117529. }
  117530. /**
  117531. * The plane detector is used to detect planes in the real world when in AR
  117532. * For more information see https://github.com/immersive-web/real-world-geometry/
  117533. */
  117534. export class WebXRPlaneDetector extends WebXRAbstractFeature implements IWebXRFeature {
  117535. private _options;
  117536. /**
  117537. * The module's name
  117538. */
  117539. static readonly Name: string;
  117540. /**
  117541. * The (Babylon) version of this module.
  117542. * This is an integer representing the implementation version.
  117543. * This number does not correspond to the webxr specs version
  117544. */
  117545. static readonly Version: number;
  117546. /**
  117547. * Observers registered here will be executed when a new plane was added to the session
  117548. */
  117549. onPlaneAddedObservable: Observable<IWebXRPlane>;
  117550. /**
  117551. * Observers registered here will be executed when a plane is no longer detected in the session
  117552. */
  117553. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  117554. /**
  117555. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  117556. * This can execute N times every frame
  117557. */
  117558. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  117559. private _enabled;
  117560. private _detectedPlanes;
  117561. private _lastFrameDetected;
  117562. /**
  117563. * construct a new Plane Detector
  117564. * @param _xrSessionManager an instance of xr Session manager
  117565. * @param _options configuration to use when constructing this feature
  117566. */
  117567. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  117568. protected _onXRFrame(frame: XRFrame): void;
  117569. /**
  117570. * Dispose this feature and all of the resources attached
  117571. */
  117572. dispose(): void;
  117573. private _updatePlaneWithXRPlane;
  117574. /**
  117575. * avoiding using Array.find for global support.
  117576. * @param xrPlane the plane to find in the array
  117577. */
  117578. private findIndexInPlaneArray;
  117579. }
  117580. }
  117581. declare module BABYLON {
  117582. /**
  117583. * Configuration options of the anchor system
  117584. */
  117585. export interface IWebXRAnchorSystemOptions {
  117586. /**
  117587. * a node that will be used to convert local to world coordinates
  117588. */
  117589. worldParentNode?: TransformNode;
  117590. /**
  117591. * should the anchor system use plane detection.
  117592. * If set to true, the plane-detection feature should be set using setPlaneDetector
  117593. */
  117594. usePlaneDetection?: boolean;
  117595. /**
  117596. * Should a new anchor be added every time a select event is triggered
  117597. */
  117598. addAnchorOnSelect?: boolean;
  117599. }
  117600. /**
  117601. * A babylon container for an XR Anchor
  117602. */
  117603. export interface IWebXRAnchor {
  117604. /**
  117605. * A babylon-assigned ID for this anchor
  117606. */
  117607. id: number;
  117608. /**
  117609. * The native anchor object
  117610. */
  117611. xrAnchor: XRAnchor;
  117612. /**
  117613. * Transformation matrix to apply to an object attached to this anchor
  117614. */
  117615. transformationMatrix: Matrix;
  117616. }
  117617. /**
  117618. * An implementation of the anchor system of WebXR.
  117619. * Note that the current documented implementation is not available in any browser. Future implementations
  117620. * will use the frame to create an anchor and not the session or a detected plane
  117621. * For further information see https://github.com/immersive-web/anchors/
  117622. */
  117623. export class WebXRAnchorSystem extends WebXRAbstractFeature implements IWebXRFeature {
  117624. private _options;
  117625. /**
  117626. * The module's name
  117627. */
  117628. static readonly Name: string;
  117629. /**
  117630. * The (Babylon) version of this module.
  117631. * This is an integer representing the implementation version.
  117632. * This number does not correspond to the webxr specs version
  117633. */
  117634. static readonly Version: number;
  117635. /**
  117636. * Observers registered here will be executed when a new anchor was added to the session
  117637. */
  117638. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  117639. /**
  117640. * Observers registered here will be executed when an existing anchor updates
  117641. * This can execute N times every frame
  117642. */
  117643. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  117644. /**
  117645. * Observers registered here will be executed when an anchor was removed from the session
  117646. */
  117647. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  117648. private _planeDetector;
  117649. private _hitTestModule;
  117650. private _enabled;
  117651. private _trackedAnchors;
  117652. private _lastFrameDetected;
  117653. /**
  117654. * constructs a new anchor system
  117655. * @param _xrSessionManager an instance of WebXRSessionManager
  117656. * @param _options configuration object for this feature
  117657. */
  117658. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  117659. /**
  117660. * set the plane detector to use in order to create anchors from frames
  117661. * @param planeDetector the plane-detector module to use
  117662. * @param enable enable plane-anchors. default is true
  117663. */
  117664. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  117665. /**
  117666. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  117667. * @param hitTestModule the hit-test module to use.
  117668. */
  117669. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  117670. /**
  117671. * attach this feature
  117672. * Will usually be called by the features manager
  117673. *
  117674. * @returns true if successful.
  117675. */
  117676. attach(): boolean;
  117677. /**
  117678. * detach this feature.
  117679. * Will usually be called by the features manager
  117680. *
  117681. * @returns true if successful.
  117682. */
  117683. detach(): boolean;
  117684. /**
  117685. * Dispose this feature and all of the resources attached
  117686. */
  117687. dispose(): void;
  117688. protected _onXRFrame(frame: XRFrame): void;
  117689. private _onSelect;
  117690. /**
  117691. * Add anchor at a specific XR point.
  117692. *
  117693. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  117694. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  117695. * @returns a promise the fulfills when the anchor was created
  117696. */
  117697. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  117698. private _updateAnchorWithXRFrame;
  117699. /**
  117700. * avoiding using Array.find for global support.
  117701. * @param xrAnchor the plane to find in the array
  117702. */
  117703. private _findIndexInAnchorArray;
  117704. }
  117705. }
  117706. declare module BABYLON {
  117707. /**
  117708. * Options interface for the background remover plugin
  117709. */
  117710. export interface IWebXRBackgroundRemoverOptions {
  117711. /**
  117712. * don't disable the environment helper
  117713. */
  117714. ignoreEnvironmentHelper?: boolean;
  117715. /**
  117716. * flags to configure the removal of the environment helper.
  117717. * If not set, the entire background will be removed. If set, flags should be set as well.
  117718. */
  117719. environmentHelperRemovalFlags?: {
  117720. /**
  117721. * Should the skybox be removed (default false)
  117722. */
  117723. skyBox?: boolean;
  117724. /**
  117725. * Should the ground be removed (default false)
  117726. */
  117727. ground?: boolean;
  117728. };
  117729. /**
  117730. * Further background meshes to disable when entering AR
  117731. */
  117732. backgroundMeshes?: AbstractMesh[];
  117733. }
  117734. /**
  117735. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  117736. */
  117737. export class WebXRBackgroundRemover extends WebXRAbstractFeature implements IWebXRFeature {
  117738. /**
  117739. * read-only options to be used in this module
  117740. */
  117741. readonly options: IWebXRBackgroundRemoverOptions;
  117742. /**
  117743. * The module's name
  117744. */
  117745. static readonly Name: string;
  117746. /**
  117747. * The (Babylon) version of this module.
  117748. * This is an integer representing the implementation version.
  117749. * This number does not correspond to the webxr specs version
  117750. */
  117751. static readonly Version: number;
  117752. /**
  117753. * registered observers will be triggered when the background state changes
  117754. */
  117755. onBackgroundStateChangedObservable: Observable<boolean>;
  117756. /**
  117757. * constructs a new background remover module
  117758. * @param _xrSessionManager the session manager for this module
  117759. * @param options read-only options to be used in this module
  117760. */
  117761. constructor(_xrSessionManager: WebXRSessionManager,
  117762. /**
  117763. * read-only options to be used in this module
  117764. */
  117765. options?: IWebXRBackgroundRemoverOptions);
  117766. /**
  117767. * attach this feature
  117768. * Will usually be called by the features manager
  117769. *
  117770. * @returns true if successful.
  117771. */
  117772. attach(): boolean;
  117773. /**
  117774. * detach this feature.
  117775. * Will usually be called by the features manager
  117776. *
  117777. * @returns true if successful.
  117778. */
  117779. detach(): boolean;
  117780. private _setBackgroundState;
  117781. /**
  117782. * Dispose this feature and all of the resources attached
  117783. */
  117784. dispose(): void;
  117785. }
  117786. }
  117787. declare module BABYLON {
  117788. /**
  117789. * The motion controller class for all microsoft mixed reality controllers
  117790. */
  117791. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  117792. /**
  117793. * The base url used to load the left and right controller models
  117794. */
  117795. static MODEL_BASE_URL: string;
  117796. /**
  117797. * The name of the left controller model file
  117798. */
  117799. static MODEL_LEFT_FILENAME: string;
  117800. /**
  117801. * The name of the right controller model file
  117802. */
  117803. static MODEL_RIGHT_FILENAME: string;
  117804. profileId: string;
  117805. protected readonly _mapping: {
  117806. defaultButton: {
  117807. "valueNodeName": string;
  117808. "unpressedNodeName": string;
  117809. "pressedNodeName": string;
  117810. };
  117811. defaultAxis: {
  117812. "valueNodeName": string;
  117813. "minNodeName": string;
  117814. "maxNodeName": string;
  117815. };
  117816. buttons: {
  117817. "xr-standard-trigger": {
  117818. "rootNodeName": string;
  117819. "componentProperty": string;
  117820. "states": string[];
  117821. };
  117822. "xr-standard-squeeze": {
  117823. "rootNodeName": string;
  117824. "componentProperty": string;
  117825. "states": string[];
  117826. };
  117827. "xr-standard-touchpad": {
  117828. "rootNodeName": string;
  117829. "labelAnchorNodeName": string;
  117830. "touchPointNodeName": string;
  117831. };
  117832. "xr-standard-thumbstick": {
  117833. "rootNodeName": string;
  117834. "componentProperty": string;
  117835. "states": string[];
  117836. };
  117837. };
  117838. axes: {
  117839. "xr-standard-touchpad": {
  117840. "x-axis": {
  117841. "rootNodeName": string;
  117842. };
  117843. "y-axis": {
  117844. "rootNodeName": string;
  117845. };
  117846. };
  117847. "xr-standard-thumbstick": {
  117848. "x-axis": {
  117849. "rootNodeName": string;
  117850. };
  117851. "y-axis": {
  117852. "rootNodeName": string;
  117853. };
  117854. };
  117855. };
  117856. };
  117857. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117858. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117859. private _getChildByName;
  117860. private _getImmediateChildByName;
  117861. protected _getFilenameAndPath(): {
  117862. filename: string;
  117863. path: string;
  117864. };
  117865. protected _updateModel(): void;
  117866. protected _getModelLoadingConstraints(): boolean;
  117867. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117868. }
  117869. }
  117870. declare module BABYLON {
  117871. /**
  117872. * The motion controller class for oculus touch (quest, rift).
  117873. * This class supports legacy mapping as well the standard xr mapping
  117874. */
  117875. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  117876. private _forceLegacyControllers;
  117877. /**
  117878. * The base url used to load the left and right controller models
  117879. */
  117880. static MODEL_BASE_URL: string;
  117881. /**
  117882. * The name of the left controller model file
  117883. */
  117884. static MODEL_LEFT_FILENAME: string;
  117885. /**
  117886. * The name of the right controller model file
  117887. */
  117888. static MODEL_RIGHT_FILENAME: string;
  117889. /**
  117890. * Base Url for the Quest controller model.
  117891. */
  117892. static QUEST_MODEL_BASE_URL: string;
  117893. profileId: string;
  117894. private _modelRootNode;
  117895. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  117896. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117897. protected _getFilenameAndPath(): {
  117898. filename: string;
  117899. path: string;
  117900. };
  117901. /**
  117902. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  117903. * between the touch and touch 2.
  117904. */
  117905. private _isQuest;
  117906. protected _updateModel(): void;
  117907. protected _getModelLoadingConstraints(): boolean;
  117908. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117909. }
  117910. }
  117911. declare module BABYLON {
  117912. /**
  117913. * The motion controller class for the standard HTC-Vive controllers
  117914. */
  117915. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  117916. /**
  117917. * The base url used to load the left and right controller models
  117918. */
  117919. static MODEL_BASE_URL: string;
  117920. /**
  117921. * File name for the controller model.
  117922. */
  117923. static MODEL_FILENAME: string;
  117924. profileId: string;
  117925. private _modelRootNode;
  117926. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  117927. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117928. protected _getFilenameAndPath(): {
  117929. filename: string;
  117930. path: string;
  117931. };
  117932. protected _updateModel(): void;
  117933. protected _getModelLoadingConstraints(): boolean;
  117934. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117935. }
  117936. }
  117937. declare module BABYLON {
  117938. /**
  117939. * Contains an array of blocks representing the octree
  117940. */
  117941. export interface IOctreeContainer<T> {
  117942. /**
  117943. * Blocks within the octree
  117944. */
  117945. blocks: Array<OctreeBlock<T>>;
  117946. }
  117947. /**
  117948. * Class used to store a cell in an octree
  117949. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  117950. */
  117951. export class OctreeBlock<T> {
  117952. /**
  117953. * Gets the content of the current block
  117954. */
  117955. entries: T[];
  117956. /**
  117957. * Gets the list of block children
  117958. */
  117959. blocks: Array<OctreeBlock<T>>;
  117960. private _depth;
  117961. private _maxDepth;
  117962. private _capacity;
  117963. private _minPoint;
  117964. private _maxPoint;
  117965. private _boundingVectors;
  117966. private _creationFunc;
  117967. /**
  117968. * Creates a new block
  117969. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  117970. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  117971. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  117972. * @param depth defines the current depth of this block in the octree
  117973. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  117974. * @param creationFunc defines a callback to call when an element is added to the block
  117975. */
  117976. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  117977. /**
  117978. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  117979. */
  117980. get capacity(): number;
  117981. /**
  117982. * Gets the minimum vector (in world space) of the block's bounding box
  117983. */
  117984. get minPoint(): Vector3;
  117985. /**
  117986. * Gets the maximum vector (in world space) of the block's bounding box
  117987. */
  117988. get maxPoint(): Vector3;
  117989. /**
  117990. * Add a new element to this block
  117991. * @param entry defines the element to add
  117992. */
  117993. addEntry(entry: T): void;
  117994. /**
  117995. * Remove an element from this block
  117996. * @param entry defines the element to remove
  117997. */
  117998. removeEntry(entry: T): void;
  117999. /**
  118000. * Add an array of elements to this block
  118001. * @param entries defines the array of elements to add
  118002. */
  118003. addEntries(entries: T[]): void;
  118004. /**
  118005. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118006. * @param frustumPlanes defines the frustum planes to test
  118007. * @param selection defines the array to store current content if selection is positive
  118008. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118009. */
  118010. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118011. /**
  118012. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118013. * @param sphereCenter defines the bounding sphere center
  118014. * @param sphereRadius defines the bounding sphere radius
  118015. * @param selection defines the array to store current content if selection is positive
  118016. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118017. */
  118018. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118019. /**
  118020. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118021. * @param ray defines the ray to test with
  118022. * @param selection defines the array to store current content if selection is positive
  118023. */
  118024. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118025. /**
  118026. * Subdivide the content into child blocks (this block will then be empty)
  118027. */
  118028. createInnerBlocks(): void;
  118029. /**
  118030. * @hidden
  118031. */
  118032. 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;
  118033. }
  118034. }
  118035. declare module BABYLON {
  118036. /**
  118037. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118038. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118039. */
  118040. export class Octree<T> {
  118041. /** 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.) */
  118042. maxDepth: number;
  118043. /**
  118044. * Blocks within the octree containing objects
  118045. */
  118046. blocks: Array<OctreeBlock<T>>;
  118047. /**
  118048. * Content stored in the octree
  118049. */
  118050. dynamicContent: T[];
  118051. private _maxBlockCapacity;
  118052. private _selectionContent;
  118053. private _creationFunc;
  118054. /**
  118055. * Creates a octree
  118056. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118057. * @param creationFunc function to be used to instatiate the octree
  118058. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118059. * @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.)
  118060. */
  118061. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118062. /** 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.) */
  118063. maxDepth?: number);
  118064. /**
  118065. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118066. * @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);
  118067. * @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);
  118068. * @param entries meshes to be added to the octree blocks
  118069. */
  118070. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118071. /**
  118072. * Adds a mesh to the octree
  118073. * @param entry Mesh to add to the octree
  118074. */
  118075. addMesh(entry: T): void;
  118076. /**
  118077. * Remove an element from the octree
  118078. * @param entry defines the element to remove
  118079. */
  118080. removeMesh(entry: T): void;
  118081. /**
  118082. * Selects an array of meshes within the frustum
  118083. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118084. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118085. * @returns array of meshes within the frustum
  118086. */
  118087. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118088. /**
  118089. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118090. * @param sphereCenter defines the bounding sphere center
  118091. * @param sphereRadius defines the bounding sphere radius
  118092. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118093. * @returns an array of objects that intersect the sphere
  118094. */
  118095. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118096. /**
  118097. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118098. * @param ray defines the ray to test with
  118099. * @returns array of intersected objects
  118100. */
  118101. intersectsRay(ray: Ray): SmartArray<T>;
  118102. /**
  118103. * Adds a mesh into the octree block if it intersects the block
  118104. */
  118105. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118106. /**
  118107. * Adds a submesh into the octree block if it intersects the block
  118108. */
  118109. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118110. }
  118111. }
  118112. declare module BABYLON {
  118113. interface Scene {
  118114. /**
  118115. * @hidden
  118116. * Backing Filed
  118117. */
  118118. _selectionOctree: Octree<AbstractMesh>;
  118119. /**
  118120. * Gets the octree used to boost mesh selection (picking)
  118121. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118122. */
  118123. selectionOctree: Octree<AbstractMesh>;
  118124. /**
  118125. * Creates or updates the octree used to boost selection (picking)
  118126. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118127. * @param maxCapacity defines the maximum capacity per leaf
  118128. * @param maxDepth defines the maximum depth of the octree
  118129. * @returns an octree of AbstractMesh
  118130. */
  118131. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118132. }
  118133. interface AbstractMesh {
  118134. /**
  118135. * @hidden
  118136. * Backing Field
  118137. */
  118138. _submeshesOctree: Octree<SubMesh>;
  118139. /**
  118140. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118141. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118142. * @param maxCapacity defines the maximum size of each block (64 by default)
  118143. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118144. * @returns the new octree
  118145. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118146. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118147. */
  118148. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118149. }
  118150. /**
  118151. * Defines the octree scene component responsible to manage any octrees
  118152. * in a given scene.
  118153. */
  118154. export class OctreeSceneComponent {
  118155. /**
  118156. * The component name help to identify the component in the list of scene components.
  118157. */
  118158. readonly name: string;
  118159. /**
  118160. * The scene the component belongs to.
  118161. */
  118162. scene: Scene;
  118163. /**
  118164. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118165. */
  118166. readonly checksIsEnabled: boolean;
  118167. /**
  118168. * Creates a new instance of the component for the given scene
  118169. * @param scene Defines the scene to register the component in
  118170. */
  118171. constructor(scene: Scene);
  118172. /**
  118173. * Registers the component in a given scene
  118174. */
  118175. register(): void;
  118176. /**
  118177. * Return the list of active meshes
  118178. * @returns the list of active meshes
  118179. */
  118180. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118181. /**
  118182. * Return the list of active sub meshes
  118183. * @param mesh The mesh to get the candidates sub meshes from
  118184. * @returns the list of active sub meshes
  118185. */
  118186. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118187. private _tempRay;
  118188. /**
  118189. * Return the list of sub meshes intersecting with a given local ray
  118190. * @param mesh defines the mesh to find the submesh for
  118191. * @param localRay defines the ray in local space
  118192. * @returns the list of intersecting sub meshes
  118193. */
  118194. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118195. /**
  118196. * Return the list of sub meshes colliding with a collider
  118197. * @param mesh defines the mesh to find the submesh for
  118198. * @param collider defines the collider to evaluate the collision against
  118199. * @returns the list of colliding sub meshes
  118200. */
  118201. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118202. /**
  118203. * Rebuilds the elements related to this component in case of
  118204. * context lost for instance.
  118205. */
  118206. rebuild(): void;
  118207. /**
  118208. * Disposes the component and the associated ressources.
  118209. */
  118210. dispose(): void;
  118211. }
  118212. }
  118213. declare module BABYLON {
  118214. /**
  118215. * Renders a layer on top of an existing scene
  118216. */
  118217. export class UtilityLayerRenderer implements IDisposable {
  118218. /** the original scene that will be rendered on top of */
  118219. originalScene: Scene;
  118220. private _pointerCaptures;
  118221. private _lastPointerEvents;
  118222. private static _DefaultUtilityLayer;
  118223. private static _DefaultKeepDepthUtilityLayer;
  118224. private _sharedGizmoLight;
  118225. private _renderCamera;
  118226. /**
  118227. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118228. * @returns the camera that is used when rendering the utility layer
  118229. */
  118230. getRenderCamera(): Nullable<Camera>;
  118231. /**
  118232. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118233. * @param cam the camera that should be used when rendering the utility layer
  118234. */
  118235. setRenderCamera(cam: Nullable<Camera>): void;
  118236. /**
  118237. * @hidden
  118238. * Light which used by gizmos to get light shading
  118239. */
  118240. _getSharedGizmoLight(): HemisphericLight;
  118241. /**
  118242. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118243. */
  118244. pickUtilitySceneFirst: boolean;
  118245. /**
  118246. * 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)
  118247. */
  118248. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118249. /**
  118250. * 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)
  118251. */
  118252. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118253. /**
  118254. * The scene that is rendered on top of the original scene
  118255. */
  118256. utilityLayerScene: Scene;
  118257. /**
  118258. * If the utility layer should automatically be rendered on top of existing scene
  118259. */
  118260. shouldRender: boolean;
  118261. /**
  118262. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118263. */
  118264. onlyCheckPointerDownEvents: boolean;
  118265. /**
  118266. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118267. */
  118268. processAllEvents: boolean;
  118269. /**
  118270. * Observable raised when the pointer move from the utility layer scene to the main scene
  118271. */
  118272. onPointerOutObservable: Observable<number>;
  118273. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118274. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118275. private _afterRenderObserver;
  118276. private _sceneDisposeObserver;
  118277. private _originalPointerObserver;
  118278. /**
  118279. * Instantiates a UtilityLayerRenderer
  118280. * @param originalScene the original scene that will be rendered on top of
  118281. * @param handleEvents boolean indicating if the utility layer should handle events
  118282. */
  118283. constructor(
  118284. /** the original scene that will be rendered on top of */
  118285. originalScene: Scene, handleEvents?: boolean);
  118286. private _notifyObservers;
  118287. /**
  118288. * Renders the utility layers scene on top of the original scene
  118289. */
  118290. render(): void;
  118291. /**
  118292. * Disposes of the renderer
  118293. */
  118294. dispose(): void;
  118295. private _updateCamera;
  118296. }
  118297. }
  118298. declare module BABYLON {
  118299. /**
  118300. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118301. */
  118302. export class Gizmo implements IDisposable {
  118303. /** The utility layer the gizmo will be added to */
  118304. gizmoLayer: UtilityLayerRenderer;
  118305. /**
  118306. * The root mesh of the gizmo
  118307. */
  118308. _rootMesh: Mesh;
  118309. private _attachedMesh;
  118310. /**
  118311. * Ratio for the scale of the gizmo (Default: 1)
  118312. */
  118313. scaleRatio: number;
  118314. /**
  118315. * If a custom mesh has been set (Default: false)
  118316. */
  118317. protected _customMeshSet: boolean;
  118318. /**
  118319. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118320. * * When set, interactions will be enabled
  118321. */
  118322. get attachedMesh(): Nullable<AbstractMesh>;
  118323. set attachedMesh(value: Nullable<AbstractMesh>);
  118324. /**
  118325. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118326. * @param mesh The mesh to replace the default mesh of the gizmo
  118327. */
  118328. setCustomMesh(mesh: Mesh): void;
  118329. /**
  118330. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118331. */
  118332. updateGizmoRotationToMatchAttachedMesh: boolean;
  118333. /**
  118334. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118335. */
  118336. updateGizmoPositionToMatchAttachedMesh: boolean;
  118337. /**
  118338. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118339. */
  118340. updateScale: boolean;
  118341. protected _interactionsEnabled: boolean;
  118342. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118343. private _beforeRenderObserver;
  118344. private _tempVector;
  118345. /**
  118346. * Creates a gizmo
  118347. * @param gizmoLayer The utility layer the gizmo will be added to
  118348. */
  118349. constructor(
  118350. /** The utility layer the gizmo will be added to */
  118351. gizmoLayer?: UtilityLayerRenderer);
  118352. /**
  118353. * Updates the gizmo to match the attached mesh's position/rotation
  118354. */
  118355. protected _update(): void;
  118356. /**
  118357. * Disposes of the gizmo
  118358. */
  118359. dispose(): void;
  118360. }
  118361. }
  118362. declare module BABYLON {
  118363. /**
  118364. * Single plane drag gizmo
  118365. */
  118366. export class PlaneDragGizmo extends Gizmo {
  118367. /**
  118368. * Drag behavior responsible for the gizmos dragging interactions
  118369. */
  118370. dragBehavior: PointerDragBehavior;
  118371. private _pointerObserver;
  118372. /**
  118373. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118374. */
  118375. snapDistance: number;
  118376. /**
  118377. * Event that fires each time the gizmo snaps to a new location.
  118378. * * snapDistance is the the change in distance
  118379. */
  118380. onSnapObservable: Observable<{
  118381. snapDistance: number;
  118382. }>;
  118383. private _plane;
  118384. private _coloredMaterial;
  118385. private _hoverMaterial;
  118386. private _isEnabled;
  118387. private _parent;
  118388. /** @hidden */
  118389. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  118390. /** @hidden */
  118391. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118392. /**
  118393. * Creates a PlaneDragGizmo
  118394. * @param gizmoLayer The utility layer the gizmo will be added to
  118395. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  118396. * @param color The color of the gizmo
  118397. */
  118398. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118399. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118400. /**
  118401. * If the gizmo is enabled
  118402. */
  118403. set isEnabled(value: boolean);
  118404. get isEnabled(): boolean;
  118405. /**
  118406. * Disposes of the gizmo
  118407. */
  118408. dispose(): void;
  118409. }
  118410. }
  118411. declare module BABYLON {
  118412. /**
  118413. * Gizmo that enables dragging a mesh along 3 axis
  118414. */
  118415. export class PositionGizmo extends Gizmo {
  118416. /**
  118417. * Internal gizmo used for interactions on the x axis
  118418. */
  118419. xGizmo: AxisDragGizmo;
  118420. /**
  118421. * Internal gizmo used for interactions on the y axis
  118422. */
  118423. yGizmo: AxisDragGizmo;
  118424. /**
  118425. * Internal gizmo used for interactions on the z axis
  118426. */
  118427. zGizmo: AxisDragGizmo;
  118428. /**
  118429. * Internal gizmo used for interactions on the yz plane
  118430. */
  118431. xPlaneGizmo: PlaneDragGizmo;
  118432. /**
  118433. * Internal gizmo used for interactions on the xz plane
  118434. */
  118435. yPlaneGizmo: PlaneDragGizmo;
  118436. /**
  118437. * Internal gizmo used for interactions on the xy plane
  118438. */
  118439. zPlaneGizmo: PlaneDragGizmo;
  118440. /**
  118441. * private variables
  118442. */
  118443. private _meshAttached;
  118444. private _updateGizmoRotationToMatchAttachedMesh;
  118445. private _snapDistance;
  118446. private _scaleRatio;
  118447. /** Fires an event when any of it's sub gizmos are dragged */
  118448. onDragStartObservable: Observable<unknown>;
  118449. /** Fires an event when any of it's sub gizmos are released from dragging */
  118450. onDragEndObservable: Observable<unknown>;
  118451. /**
  118452. * If set to true, planar drag is enabled
  118453. */
  118454. private _planarGizmoEnabled;
  118455. get attachedMesh(): Nullable<AbstractMesh>;
  118456. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118457. /**
  118458. * Creates a PositionGizmo
  118459. * @param gizmoLayer The utility layer the gizmo will be added to
  118460. */
  118461. constructor(gizmoLayer?: UtilityLayerRenderer);
  118462. /**
  118463. * If the planar drag gizmo is enabled
  118464. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  118465. */
  118466. set planarGizmoEnabled(value: boolean);
  118467. get planarGizmoEnabled(): boolean;
  118468. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118469. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118470. /**
  118471. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118472. */
  118473. set snapDistance(value: number);
  118474. get snapDistance(): number;
  118475. /**
  118476. * Ratio for the scale of the gizmo (Default: 1)
  118477. */
  118478. set scaleRatio(value: number);
  118479. get scaleRatio(): number;
  118480. /**
  118481. * Disposes of the gizmo
  118482. */
  118483. dispose(): void;
  118484. /**
  118485. * CustomMeshes are not supported by this gizmo
  118486. * @param mesh The mesh to replace the default mesh of the gizmo
  118487. */
  118488. setCustomMesh(mesh: Mesh): void;
  118489. }
  118490. }
  118491. declare module BABYLON {
  118492. /**
  118493. * Single axis drag gizmo
  118494. */
  118495. export class AxisDragGizmo extends Gizmo {
  118496. /**
  118497. * Drag behavior responsible for the gizmos dragging interactions
  118498. */
  118499. dragBehavior: PointerDragBehavior;
  118500. private _pointerObserver;
  118501. /**
  118502. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118503. */
  118504. snapDistance: number;
  118505. /**
  118506. * Event that fires each time the gizmo snaps to a new location.
  118507. * * snapDistance is the the change in distance
  118508. */
  118509. onSnapObservable: Observable<{
  118510. snapDistance: number;
  118511. }>;
  118512. private _isEnabled;
  118513. private _parent;
  118514. private _arrow;
  118515. private _coloredMaterial;
  118516. private _hoverMaterial;
  118517. /** @hidden */
  118518. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  118519. /** @hidden */
  118520. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118521. /**
  118522. * Creates an AxisDragGizmo
  118523. * @param gizmoLayer The utility layer the gizmo will be added to
  118524. * @param dragAxis The axis which the gizmo will be able to drag on
  118525. * @param color The color of the gizmo
  118526. */
  118527. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118528. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118529. /**
  118530. * If the gizmo is enabled
  118531. */
  118532. set isEnabled(value: boolean);
  118533. get isEnabled(): boolean;
  118534. /**
  118535. * Disposes of the gizmo
  118536. */
  118537. dispose(): void;
  118538. }
  118539. }
  118540. declare module BABYLON.Debug {
  118541. /**
  118542. * The Axes viewer will show 3 axes in a specific point in space
  118543. */
  118544. export class AxesViewer {
  118545. private _xAxis;
  118546. private _yAxis;
  118547. private _zAxis;
  118548. private _scaleLinesFactor;
  118549. private _instanced;
  118550. /**
  118551. * Gets the hosting scene
  118552. */
  118553. scene: Scene;
  118554. /**
  118555. * Gets or sets a number used to scale line length
  118556. */
  118557. scaleLines: number;
  118558. /** Gets the node hierarchy used to render x-axis */
  118559. get xAxis(): TransformNode;
  118560. /** Gets the node hierarchy used to render y-axis */
  118561. get yAxis(): TransformNode;
  118562. /** Gets the node hierarchy used to render z-axis */
  118563. get zAxis(): TransformNode;
  118564. /**
  118565. * Creates a new AxesViewer
  118566. * @param scene defines the hosting scene
  118567. * @param scaleLines defines a number used to scale line length (1 by default)
  118568. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  118569. * @param xAxis defines the node hierarchy used to render the x-axis
  118570. * @param yAxis defines the node hierarchy used to render the y-axis
  118571. * @param zAxis defines the node hierarchy used to render the z-axis
  118572. */
  118573. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  118574. /**
  118575. * Force the viewer to update
  118576. * @param position defines the position of the viewer
  118577. * @param xaxis defines the x axis of the viewer
  118578. * @param yaxis defines the y axis of the viewer
  118579. * @param zaxis defines the z axis of the viewer
  118580. */
  118581. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  118582. /**
  118583. * Creates an instance of this axes viewer.
  118584. * @returns a new axes viewer with instanced meshes
  118585. */
  118586. createInstance(): AxesViewer;
  118587. /** Releases resources */
  118588. dispose(): void;
  118589. private static _SetRenderingGroupId;
  118590. }
  118591. }
  118592. declare module BABYLON.Debug {
  118593. /**
  118594. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  118595. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  118596. */
  118597. export class BoneAxesViewer extends AxesViewer {
  118598. /**
  118599. * Gets or sets the target mesh where to display the axes viewer
  118600. */
  118601. mesh: Nullable<Mesh>;
  118602. /**
  118603. * Gets or sets the target bone where to display the axes viewer
  118604. */
  118605. bone: Nullable<Bone>;
  118606. /** Gets current position */
  118607. pos: Vector3;
  118608. /** Gets direction of X axis */
  118609. xaxis: Vector3;
  118610. /** Gets direction of Y axis */
  118611. yaxis: Vector3;
  118612. /** Gets direction of Z axis */
  118613. zaxis: Vector3;
  118614. /**
  118615. * Creates a new BoneAxesViewer
  118616. * @param scene defines the hosting scene
  118617. * @param bone defines the target bone
  118618. * @param mesh defines the target mesh
  118619. * @param scaleLines defines a scaling factor for line length (1 by default)
  118620. */
  118621. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  118622. /**
  118623. * Force the viewer to update
  118624. */
  118625. update(): void;
  118626. /** Releases resources */
  118627. dispose(): void;
  118628. }
  118629. }
  118630. declare module BABYLON {
  118631. /**
  118632. * Interface used to define scene explorer extensibility option
  118633. */
  118634. export interface IExplorerExtensibilityOption {
  118635. /**
  118636. * Define the option label
  118637. */
  118638. label: string;
  118639. /**
  118640. * Defines the action to execute on click
  118641. */
  118642. action: (entity: any) => void;
  118643. }
  118644. /**
  118645. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  118646. */
  118647. export interface IExplorerExtensibilityGroup {
  118648. /**
  118649. * Defines a predicate to test if a given type mut be extended
  118650. */
  118651. predicate: (entity: any) => boolean;
  118652. /**
  118653. * Gets the list of options added to a type
  118654. */
  118655. entries: IExplorerExtensibilityOption[];
  118656. }
  118657. /**
  118658. * Interface used to define the options to use to create the Inspector
  118659. */
  118660. export interface IInspectorOptions {
  118661. /**
  118662. * Display in overlay mode (default: false)
  118663. */
  118664. overlay?: boolean;
  118665. /**
  118666. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  118667. */
  118668. globalRoot?: HTMLElement;
  118669. /**
  118670. * Display the Scene explorer
  118671. */
  118672. showExplorer?: boolean;
  118673. /**
  118674. * Display the property inspector
  118675. */
  118676. showInspector?: boolean;
  118677. /**
  118678. * Display in embed mode (both panes on the right)
  118679. */
  118680. embedMode?: boolean;
  118681. /**
  118682. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  118683. */
  118684. handleResize?: boolean;
  118685. /**
  118686. * Allow the panes to popup (default: true)
  118687. */
  118688. enablePopup?: boolean;
  118689. /**
  118690. * Allow the panes to be closed by users (default: true)
  118691. */
  118692. enableClose?: boolean;
  118693. /**
  118694. * Optional list of extensibility entries
  118695. */
  118696. explorerExtensibility?: IExplorerExtensibilityGroup[];
  118697. /**
  118698. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  118699. */
  118700. inspectorURL?: string;
  118701. /**
  118702. * Optional initial tab (default to DebugLayerTab.Properties)
  118703. */
  118704. initialTab?: DebugLayerTab;
  118705. }
  118706. interface Scene {
  118707. /**
  118708. * @hidden
  118709. * Backing field
  118710. */
  118711. _debugLayer: DebugLayer;
  118712. /**
  118713. * Gets the debug layer (aka Inspector) associated with the scene
  118714. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118715. */
  118716. debugLayer: DebugLayer;
  118717. }
  118718. /**
  118719. * Enum of inspector action tab
  118720. */
  118721. export enum DebugLayerTab {
  118722. /**
  118723. * Properties tag (default)
  118724. */
  118725. Properties = 0,
  118726. /**
  118727. * Debug tab
  118728. */
  118729. Debug = 1,
  118730. /**
  118731. * Statistics tab
  118732. */
  118733. Statistics = 2,
  118734. /**
  118735. * Tools tab
  118736. */
  118737. Tools = 3,
  118738. /**
  118739. * Settings tab
  118740. */
  118741. Settings = 4
  118742. }
  118743. /**
  118744. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118745. * what is happening in your scene
  118746. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118747. */
  118748. export class DebugLayer {
  118749. /**
  118750. * Define the url to get the inspector script from.
  118751. * By default it uses the babylonjs CDN.
  118752. * @ignoreNaming
  118753. */
  118754. static InspectorURL: string;
  118755. private _scene;
  118756. private BJSINSPECTOR;
  118757. private _onPropertyChangedObservable?;
  118758. /**
  118759. * Observable triggered when a property is changed through the inspector.
  118760. */
  118761. get onPropertyChangedObservable(): any;
  118762. /**
  118763. * Instantiates a new debug layer.
  118764. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118765. * what is happening in your scene
  118766. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118767. * @param scene Defines the scene to inspect
  118768. */
  118769. constructor(scene: Scene);
  118770. /** Creates the inspector window. */
  118771. private _createInspector;
  118772. /**
  118773. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  118774. * @param entity defines the entity to select
  118775. * @param lineContainerTitle defines the specific block to highlight
  118776. */
  118777. select(entity: any, lineContainerTitle?: string): void;
  118778. /** Get the inspector from bundle or global */
  118779. private _getGlobalInspector;
  118780. /**
  118781. * Get if the inspector is visible or not.
  118782. * @returns true if visible otherwise, false
  118783. */
  118784. isVisible(): boolean;
  118785. /**
  118786. * Hide the inspector and close its window.
  118787. */
  118788. hide(): void;
  118789. /**
  118790. * Launch the debugLayer.
  118791. * @param config Define the configuration of the inspector
  118792. * @return a promise fulfilled when the debug layer is visible
  118793. */
  118794. show(config?: IInspectorOptions): Promise<DebugLayer>;
  118795. }
  118796. }
  118797. declare module BABYLON {
  118798. /**
  118799. * Class containing static functions to help procedurally build meshes
  118800. */
  118801. export class BoxBuilder {
  118802. /**
  118803. * Creates a box mesh
  118804. * * The parameter `size` sets the size (float) of each box side (default 1)
  118805. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118806. * * 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)
  118807. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118811. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118812. * @param name defines the name of the mesh
  118813. * @param options defines the options used to create the mesh
  118814. * @param scene defines the hosting scene
  118815. * @returns the box mesh
  118816. */
  118817. static CreateBox(name: string, options: {
  118818. size?: number;
  118819. width?: number;
  118820. height?: number;
  118821. depth?: number;
  118822. faceUV?: Vector4[];
  118823. faceColors?: Color4[];
  118824. sideOrientation?: number;
  118825. frontUVs?: Vector4;
  118826. backUVs?: Vector4;
  118827. wrap?: boolean;
  118828. topBaseAt?: number;
  118829. bottomBaseAt?: number;
  118830. updatable?: boolean;
  118831. }, scene?: Nullable<Scene>): Mesh;
  118832. }
  118833. }
  118834. declare module BABYLON {
  118835. /**
  118836. * Class containing static functions to help procedurally build meshes
  118837. */
  118838. export class SphereBuilder {
  118839. /**
  118840. * Creates a sphere mesh
  118841. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118842. * * 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`)
  118843. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118844. * * 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
  118845. * * 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)
  118846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118849. * @param name defines the name of the mesh
  118850. * @param options defines the options used to create the mesh
  118851. * @param scene defines the hosting scene
  118852. * @returns the sphere mesh
  118853. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118854. */
  118855. static CreateSphere(name: string, options: {
  118856. segments?: number;
  118857. diameter?: number;
  118858. diameterX?: number;
  118859. diameterY?: number;
  118860. diameterZ?: number;
  118861. arc?: number;
  118862. slice?: number;
  118863. sideOrientation?: number;
  118864. frontUVs?: Vector4;
  118865. backUVs?: Vector4;
  118866. updatable?: boolean;
  118867. }, scene?: Nullable<Scene>): Mesh;
  118868. }
  118869. }
  118870. declare module BABYLON.Debug {
  118871. /**
  118872. * Used to show the physics impostor around the specific mesh
  118873. */
  118874. export class PhysicsViewer {
  118875. /** @hidden */
  118876. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  118877. /** @hidden */
  118878. protected _meshes: Array<Nullable<AbstractMesh>>;
  118879. /** @hidden */
  118880. protected _scene: Nullable<Scene>;
  118881. /** @hidden */
  118882. protected _numMeshes: number;
  118883. /** @hidden */
  118884. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  118885. private _renderFunction;
  118886. private _utilityLayer;
  118887. private _debugBoxMesh;
  118888. private _debugSphereMesh;
  118889. private _debugCylinderMesh;
  118890. private _debugMaterial;
  118891. private _debugMeshMeshes;
  118892. /**
  118893. * Creates a new PhysicsViewer
  118894. * @param scene defines the hosting scene
  118895. */
  118896. constructor(scene: Scene);
  118897. /** @hidden */
  118898. protected _updateDebugMeshes(): void;
  118899. /**
  118900. * Renders a specified physic impostor
  118901. * @param impostor defines the impostor to render
  118902. * @param targetMesh defines the mesh represented by the impostor
  118903. * @returns the new debug mesh used to render the impostor
  118904. */
  118905. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  118906. /**
  118907. * Hides a specified physic impostor
  118908. * @param impostor defines the impostor to hide
  118909. */
  118910. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  118911. private _getDebugMaterial;
  118912. private _getDebugBoxMesh;
  118913. private _getDebugSphereMesh;
  118914. private _getDebugCylinderMesh;
  118915. private _getDebugMeshMesh;
  118916. private _getDebugMesh;
  118917. /** Releases all resources */
  118918. dispose(): void;
  118919. }
  118920. }
  118921. declare module BABYLON {
  118922. /**
  118923. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  118924. * in order to better appreciate the issue one might have.
  118925. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  118926. */
  118927. export class RayHelper {
  118928. /**
  118929. * Defines the ray we are currently tryin to visualize.
  118930. */
  118931. ray: Nullable<Ray>;
  118932. private _renderPoints;
  118933. private _renderLine;
  118934. private _renderFunction;
  118935. private _scene;
  118936. private _updateToMeshFunction;
  118937. private _attachedToMesh;
  118938. private _meshSpaceDirection;
  118939. private _meshSpaceOrigin;
  118940. /**
  118941. * Helper function to create a colored helper in a scene in one line.
  118942. * @param ray Defines the ray we are currently tryin to visualize
  118943. * @param scene Defines the scene the ray is used in
  118944. * @param color Defines the color we want to see the ray in
  118945. * @returns The newly created ray helper.
  118946. */
  118947. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  118948. /**
  118949. * Instantiate a new ray helper.
  118950. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  118951. * in order to better appreciate the issue one might have.
  118952. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  118953. * @param ray Defines the ray we are currently tryin to visualize
  118954. */
  118955. constructor(ray: Ray);
  118956. /**
  118957. * Shows the ray we are willing to debug.
  118958. * @param scene Defines the scene the ray needs to be rendered in
  118959. * @param color Defines the color the ray needs to be rendered in
  118960. */
  118961. show(scene: Scene, color?: Color3): void;
  118962. /**
  118963. * Hides the ray we are debugging.
  118964. */
  118965. hide(): void;
  118966. private _render;
  118967. /**
  118968. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  118969. * @param mesh Defines the mesh we want the helper attached to
  118970. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  118971. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  118972. * @param length Defines the length of the ray
  118973. */
  118974. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  118975. /**
  118976. * Detach the ray helper from the mesh it has previously been attached to.
  118977. */
  118978. detachFromMesh(): void;
  118979. private _updateToMesh;
  118980. /**
  118981. * Dispose the helper and release its associated resources.
  118982. */
  118983. dispose(): void;
  118984. }
  118985. }
  118986. declare module BABYLON.Debug {
  118987. /**
  118988. * Class used to render a debug view of a given skeleton
  118989. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  118990. */
  118991. export class SkeletonViewer {
  118992. /** defines the skeleton to render */
  118993. skeleton: Skeleton;
  118994. /** defines the mesh attached to the skeleton */
  118995. mesh: AbstractMesh;
  118996. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  118997. autoUpdateBonesMatrices: boolean;
  118998. /** defines the rendering group id to use with the viewer */
  118999. renderingGroupId: number;
  119000. /** Gets or sets the color used to render the skeleton */
  119001. color: Color3;
  119002. private _scene;
  119003. private _debugLines;
  119004. private _debugMesh;
  119005. private _isEnabled;
  119006. private _renderFunction;
  119007. private _utilityLayer;
  119008. /**
  119009. * Returns the mesh used to render the bones
  119010. */
  119011. get debugMesh(): Nullable<LinesMesh>;
  119012. /**
  119013. * Creates a new SkeletonViewer
  119014. * @param skeleton defines the skeleton to render
  119015. * @param mesh defines the mesh attached to the skeleton
  119016. * @param scene defines the hosting scene
  119017. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119018. * @param renderingGroupId defines the rendering group id to use with the viewer
  119019. */
  119020. constructor(
  119021. /** defines the skeleton to render */
  119022. skeleton: Skeleton,
  119023. /** defines the mesh attached to the skeleton */
  119024. mesh: AbstractMesh, scene: Scene,
  119025. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119026. autoUpdateBonesMatrices?: boolean,
  119027. /** defines the rendering group id to use with the viewer */
  119028. renderingGroupId?: number);
  119029. /** Gets or sets a boolean indicating if the viewer is enabled */
  119030. set isEnabled(value: boolean);
  119031. get isEnabled(): boolean;
  119032. private _getBonePosition;
  119033. private _getLinesForBonesWithLength;
  119034. private _getLinesForBonesNoLength;
  119035. /** Update the viewer to sync with current skeleton state */
  119036. update(): void;
  119037. /** Release associated resources */
  119038. dispose(): void;
  119039. }
  119040. }
  119041. declare module BABYLON {
  119042. /**
  119043. * Options to create the null engine
  119044. */
  119045. export class NullEngineOptions {
  119046. /**
  119047. * Render width (Default: 512)
  119048. */
  119049. renderWidth: number;
  119050. /**
  119051. * Render height (Default: 256)
  119052. */
  119053. renderHeight: number;
  119054. /**
  119055. * Texture size (Default: 512)
  119056. */
  119057. textureSize: number;
  119058. /**
  119059. * If delta time between frames should be constant
  119060. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119061. */
  119062. deterministicLockstep: boolean;
  119063. /**
  119064. * Maximum about of steps between frames (Default: 4)
  119065. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119066. */
  119067. lockstepMaxSteps: number;
  119068. }
  119069. /**
  119070. * The null engine class provides support for headless version of babylon.js.
  119071. * This can be used in server side scenario or for testing purposes
  119072. */
  119073. export class NullEngine extends Engine {
  119074. private _options;
  119075. /**
  119076. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119077. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119078. * @returns true if engine is in deterministic lock step mode
  119079. */
  119080. isDeterministicLockStep(): boolean;
  119081. /**
  119082. * Gets the max steps when engine is running in deterministic lock step
  119083. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119084. * @returns the max steps
  119085. */
  119086. getLockstepMaxSteps(): number;
  119087. /**
  119088. * Gets the current hardware scaling level.
  119089. * By default the hardware scaling level is computed from the window device ratio.
  119090. * 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.
  119091. * @returns a number indicating the current hardware scaling level
  119092. */
  119093. getHardwareScalingLevel(): number;
  119094. constructor(options?: NullEngineOptions);
  119095. /**
  119096. * Creates a vertex buffer
  119097. * @param vertices the data for the vertex buffer
  119098. * @returns the new WebGL static buffer
  119099. */
  119100. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119101. /**
  119102. * Creates a new index buffer
  119103. * @param indices defines the content of the index buffer
  119104. * @param updatable defines if the index buffer must be updatable
  119105. * @returns a new webGL buffer
  119106. */
  119107. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119108. /**
  119109. * Clear the current render buffer or the current render target (if any is set up)
  119110. * @param color defines the color to use
  119111. * @param backBuffer defines if the back buffer must be cleared
  119112. * @param depth defines if the depth buffer must be cleared
  119113. * @param stencil defines if the stencil buffer must be cleared
  119114. */
  119115. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119116. /**
  119117. * Gets the current render width
  119118. * @param useScreen defines if screen size must be used (or the current render target if any)
  119119. * @returns a number defining the current render width
  119120. */
  119121. getRenderWidth(useScreen?: boolean): number;
  119122. /**
  119123. * Gets the current render height
  119124. * @param useScreen defines if screen size must be used (or the current render target if any)
  119125. * @returns a number defining the current render height
  119126. */
  119127. getRenderHeight(useScreen?: boolean): number;
  119128. /**
  119129. * Set the WebGL's viewport
  119130. * @param viewport defines the viewport element to be used
  119131. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119132. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119133. */
  119134. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119135. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119136. /**
  119137. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119138. * @param pipelineContext defines the pipeline context to use
  119139. * @param uniformsNames defines the list of uniform names
  119140. * @returns an array of webGL uniform locations
  119141. */
  119142. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119143. /**
  119144. * Gets the lsit of active attributes for a given webGL program
  119145. * @param pipelineContext defines the pipeline context to use
  119146. * @param attributesNames defines the list of attribute names to get
  119147. * @returns an array of indices indicating the offset of each attribute
  119148. */
  119149. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119150. /**
  119151. * Binds an effect to the webGL context
  119152. * @param effect defines the effect to bind
  119153. */
  119154. bindSamplers(effect: Effect): void;
  119155. /**
  119156. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119157. * @param effect defines the effect to activate
  119158. */
  119159. enableEffect(effect: Effect): void;
  119160. /**
  119161. * Set various states to the webGL context
  119162. * @param culling defines backface culling state
  119163. * @param zOffset defines the value to apply to zOffset (0 by default)
  119164. * @param force defines if states must be applied even if cache is up to date
  119165. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119166. */
  119167. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119168. /**
  119169. * Set the value of an uniform to an array of int32
  119170. * @param uniform defines the webGL uniform location where to store the value
  119171. * @param array defines the array of int32 to store
  119172. */
  119173. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119174. /**
  119175. * Set the value of an uniform to an array of int32 (stored as vec2)
  119176. * @param uniform defines the webGL uniform location where to store the value
  119177. * @param array defines the array of int32 to store
  119178. */
  119179. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119180. /**
  119181. * Set the value of an uniform to an array of int32 (stored as vec3)
  119182. * @param uniform defines the webGL uniform location where to store the value
  119183. * @param array defines the array of int32 to store
  119184. */
  119185. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119186. /**
  119187. * Set the value of an uniform to an array of int32 (stored as vec4)
  119188. * @param uniform defines the webGL uniform location where to store the value
  119189. * @param array defines the array of int32 to store
  119190. */
  119191. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119192. /**
  119193. * Set the value of an uniform to an array of float32
  119194. * @param uniform defines the webGL uniform location where to store the value
  119195. * @param array defines the array of float32 to store
  119196. */
  119197. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119198. /**
  119199. * Set the value of an uniform to an array of float32 (stored as vec2)
  119200. * @param uniform defines the webGL uniform location where to store the value
  119201. * @param array defines the array of float32 to store
  119202. */
  119203. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119204. /**
  119205. * Set the value of an uniform to an array of float32 (stored as vec3)
  119206. * @param uniform defines the webGL uniform location where to store the value
  119207. * @param array defines the array of float32 to store
  119208. */
  119209. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119210. /**
  119211. * Set the value of an uniform to an array of float32 (stored as vec4)
  119212. * @param uniform defines the webGL uniform location where to store the value
  119213. * @param array defines the array of float32 to store
  119214. */
  119215. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119216. /**
  119217. * Set the value of an uniform to an array of number
  119218. * @param uniform defines the webGL uniform location where to store the value
  119219. * @param array defines the array of number to store
  119220. */
  119221. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119222. /**
  119223. * Set the value of an uniform to an array of number (stored as vec2)
  119224. * @param uniform defines the webGL uniform location where to store the value
  119225. * @param array defines the array of number to store
  119226. */
  119227. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119228. /**
  119229. * Set the value of an uniform to an array of number (stored as vec3)
  119230. * @param uniform defines the webGL uniform location where to store the value
  119231. * @param array defines the array of number to store
  119232. */
  119233. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119234. /**
  119235. * Set the value of an uniform to an array of number (stored as vec4)
  119236. * @param uniform defines the webGL uniform location where to store the value
  119237. * @param array defines the array of number to store
  119238. */
  119239. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119240. /**
  119241. * Set the value of an uniform to an array of float32 (stored as matrices)
  119242. * @param uniform defines the webGL uniform location where to store the value
  119243. * @param matrices defines the array of float32 to store
  119244. */
  119245. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119246. /**
  119247. * Set the value of an uniform to a matrix (3x3)
  119248. * @param uniform defines the webGL uniform location where to store the value
  119249. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119250. */
  119251. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119252. /**
  119253. * Set the value of an uniform to a matrix (2x2)
  119254. * @param uniform defines the webGL uniform location where to store the value
  119255. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119256. */
  119257. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119258. /**
  119259. * Set the value of an uniform to a number (float)
  119260. * @param uniform defines the webGL uniform location where to store the value
  119261. * @param value defines the float number to store
  119262. */
  119263. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119264. /**
  119265. * Set the value of an uniform to a vec2
  119266. * @param uniform defines the webGL uniform location where to store the value
  119267. * @param x defines the 1st component of the value
  119268. * @param y defines the 2nd component of the value
  119269. */
  119270. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119271. /**
  119272. * Set the value of an uniform to a vec3
  119273. * @param uniform defines the webGL uniform location where to store the value
  119274. * @param x defines the 1st component of the value
  119275. * @param y defines the 2nd component of the value
  119276. * @param z defines the 3rd component of the value
  119277. */
  119278. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119279. /**
  119280. * Set the value of an uniform to a boolean
  119281. * @param uniform defines the webGL uniform location where to store the value
  119282. * @param bool defines the boolean to store
  119283. */
  119284. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119285. /**
  119286. * Set the value of an uniform to a vec4
  119287. * @param uniform defines the webGL uniform location where to store the value
  119288. * @param x defines the 1st component of the value
  119289. * @param y defines the 2nd component of the value
  119290. * @param z defines the 3rd component of the value
  119291. * @param w defines the 4th component of the value
  119292. */
  119293. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119294. /**
  119295. * Sets the current alpha mode
  119296. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119297. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119298. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119299. */
  119300. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119301. /**
  119302. * Bind webGl buffers directly to the webGL context
  119303. * @param vertexBuffers defines the vertex buffer to bind
  119304. * @param indexBuffer defines the index buffer to bind
  119305. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119306. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119307. * @param effect defines the effect associated with the vertex buffer
  119308. */
  119309. bindBuffers(vertexBuffers: {
  119310. [key: string]: VertexBuffer;
  119311. }, indexBuffer: DataBuffer, effect: Effect): void;
  119312. /**
  119313. * Force the entire cache to be cleared
  119314. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119315. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119316. */
  119317. wipeCaches(bruteForce?: boolean): void;
  119318. /**
  119319. * Send a draw order
  119320. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119321. * @param indexStart defines the starting index
  119322. * @param indexCount defines the number of index to draw
  119323. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119324. */
  119325. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119326. /**
  119327. * Draw a list of indexed primitives
  119328. * @param fillMode defines the primitive to use
  119329. * @param indexStart defines the starting index
  119330. * @param indexCount defines the number of index to draw
  119331. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119332. */
  119333. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119334. /**
  119335. * Draw a list of unindexed primitives
  119336. * @param fillMode defines the primitive to use
  119337. * @param verticesStart defines the index of first vertex to draw
  119338. * @param verticesCount defines the count of vertices to draw
  119339. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119340. */
  119341. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119342. /** @hidden */
  119343. _createTexture(): WebGLTexture;
  119344. /** @hidden */
  119345. _releaseTexture(texture: InternalTexture): void;
  119346. /**
  119347. * Usually called from Texture.ts.
  119348. * Passed information to create a WebGLTexture
  119349. * @param urlArg defines a value which contains one of the following:
  119350. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119351. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119352. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119353. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119354. * @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)
  119355. * @param scene needed for loading to the correct scene
  119356. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119357. * @param onLoad optional callback to be called upon successful completion
  119358. * @param onError optional callback to be called upon failure
  119359. * @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
  119360. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119361. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119362. * @param forcedExtension defines the extension to use to pick the right loader
  119363. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119364. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119365. */
  119366. 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;
  119367. /**
  119368. * Creates a new render target texture
  119369. * @param size defines the size of the texture
  119370. * @param options defines the options used to create the texture
  119371. * @returns a new render target texture stored in an InternalTexture
  119372. */
  119373. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119374. /**
  119375. * Update the sampling mode of a given texture
  119376. * @param samplingMode defines the required sampling mode
  119377. * @param texture defines the texture to update
  119378. */
  119379. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119380. /**
  119381. * Binds the frame buffer to the specified texture.
  119382. * @param texture The texture to render to or null for the default canvas
  119383. * @param faceIndex The face of the texture to render to in case of cube texture
  119384. * @param requiredWidth The width of the target to render to
  119385. * @param requiredHeight The height of the target to render to
  119386. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119387. * @param lodLevel defines le lod level to bind to the frame buffer
  119388. */
  119389. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119390. /**
  119391. * Unbind the current render target texture from the webGL context
  119392. * @param texture defines the render target texture to unbind
  119393. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119394. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119395. */
  119396. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119397. /**
  119398. * Creates a dynamic vertex buffer
  119399. * @param vertices the data for the dynamic vertex buffer
  119400. * @returns the new WebGL dynamic buffer
  119401. */
  119402. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119403. /**
  119404. * Update the content of a dynamic texture
  119405. * @param texture defines the texture to update
  119406. * @param canvas defines the canvas containing the source
  119407. * @param invertY defines if data must be stored with Y axis inverted
  119408. * @param premulAlpha defines if alpha is stored as premultiplied
  119409. * @param format defines the format of the data
  119410. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119411. */
  119412. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119413. /**
  119414. * Gets a boolean indicating if all created effects are ready
  119415. * @returns true if all effects are ready
  119416. */
  119417. areAllEffectsReady(): boolean;
  119418. /**
  119419. * @hidden
  119420. * Get the current error code of the webGL context
  119421. * @returns the error code
  119422. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  119423. */
  119424. getError(): number;
  119425. /** @hidden */
  119426. _getUnpackAlignement(): number;
  119427. /** @hidden */
  119428. _unpackFlipY(value: boolean): void;
  119429. /**
  119430. * Update a dynamic index buffer
  119431. * @param indexBuffer defines the target index buffer
  119432. * @param indices defines the data to update
  119433. * @param offset defines the offset in the target index buffer where update should start
  119434. */
  119435. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  119436. /**
  119437. * Updates a dynamic vertex buffer.
  119438. * @param vertexBuffer the vertex buffer to update
  119439. * @param vertices the data used to update the vertex buffer
  119440. * @param byteOffset the byte offset of the data (optional)
  119441. * @param byteLength the byte length of the data (optional)
  119442. */
  119443. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  119444. /** @hidden */
  119445. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  119446. /** @hidden */
  119447. _bindTexture(channel: number, texture: InternalTexture): void;
  119448. protected _deleteBuffer(buffer: WebGLBuffer): void;
  119449. /**
  119450. * 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
  119451. */
  119452. releaseEffects(): void;
  119453. displayLoadingUI(): void;
  119454. hideLoadingUI(): void;
  119455. /** @hidden */
  119456. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119457. /** @hidden */
  119458. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119459. /** @hidden */
  119460. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119461. /** @hidden */
  119462. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  119463. }
  119464. }
  119465. declare module BABYLON {
  119466. /** @hidden */
  119467. export class _OcclusionDataStorage {
  119468. /** @hidden */
  119469. occlusionInternalRetryCounter: number;
  119470. /** @hidden */
  119471. isOcclusionQueryInProgress: boolean;
  119472. /** @hidden */
  119473. isOccluded: boolean;
  119474. /** @hidden */
  119475. occlusionRetryCount: number;
  119476. /** @hidden */
  119477. occlusionType: number;
  119478. /** @hidden */
  119479. occlusionQueryAlgorithmType: number;
  119480. }
  119481. interface Engine {
  119482. /**
  119483. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  119484. * @return the new query
  119485. */
  119486. createQuery(): WebGLQuery;
  119487. /**
  119488. * Delete and release a webGL query
  119489. * @param query defines the query to delete
  119490. * @return the current engine
  119491. */
  119492. deleteQuery(query: WebGLQuery): Engine;
  119493. /**
  119494. * Check if a given query has resolved and got its value
  119495. * @param query defines the query to check
  119496. * @returns true if the query got its value
  119497. */
  119498. isQueryResultAvailable(query: WebGLQuery): boolean;
  119499. /**
  119500. * Gets the value of a given query
  119501. * @param query defines the query to check
  119502. * @returns the value of the query
  119503. */
  119504. getQueryResult(query: WebGLQuery): number;
  119505. /**
  119506. * Initiates an occlusion query
  119507. * @param algorithmType defines the algorithm to use
  119508. * @param query defines the query to use
  119509. * @returns the current engine
  119510. * @see http://doc.babylonjs.com/features/occlusionquery
  119511. */
  119512. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  119513. /**
  119514. * Ends an occlusion query
  119515. * @see http://doc.babylonjs.com/features/occlusionquery
  119516. * @param algorithmType defines the algorithm to use
  119517. * @returns the current engine
  119518. */
  119519. endOcclusionQuery(algorithmType: number): Engine;
  119520. /**
  119521. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  119522. * Please note that only one query can be issued at a time
  119523. * @returns a time token used to track the time span
  119524. */
  119525. startTimeQuery(): Nullable<_TimeToken>;
  119526. /**
  119527. * Ends a time query
  119528. * @param token defines the token used to measure the time span
  119529. * @returns the time spent (in ns)
  119530. */
  119531. endTimeQuery(token: _TimeToken): int;
  119532. /** @hidden */
  119533. _currentNonTimestampToken: Nullable<_TimeToken>;
  119534. /** @hidden */
  119535. _createTimeQuery(): WebGLQuery;
  119536. /** @hidden */
  119537. _deleteTimeQuery(query: WebGLQuery): void;
  119538. /** @hidden */
  119539. _getGlAlgorithmType(algorithmType: number): number;
  119540. /** @hidden */
  119541. _getTimeQueryResult(query: WebGLQuery): any;
  119542. /** @hidden */
  119543. _getTimeQueryAvailability(query: WebGLQuery): any;
  119544. }
  119545. interface AbstractMesh {
  119546. /**
  119547. * Backing filed
  119548. * @hidden
  119549. */
  119550. __occlusionDataStorage: _OcclusionDataStorage;
  119551. /**
  119552. * Access property
  119553. * @hidden
  119554. */
  119555. _occlusionDataStorage: _OcclusionDataStorage;
  119556. /**
  119557. * 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.
  119558. * The default value is -1 which means don't break the query and wait till the result
  119559. * @see http://doc.babylonjs.com/features/occlusionquery
  119560. */
  119561. occlusionRetryCount: number;
  119562. /**
  119563. * 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:
  119564. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  119565. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  119566. * * 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.
  119567. * @see http://doc.babylonjs.com/features/occlusionquery
  119568. */
  119569. occlusionType: number;
  119570. /**
  119571. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  119572. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  119573. * * 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.
  119574. * @see http://doc.babylonjs.com/features/occlusionquery
  119575. */
  119576. occlusionQueryAlgorithmType: number;
  119577. /**
  119578. * 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
  119579. * @see http://doc.babylonjs.com/features/occlusionquery
  119580. */
  119581. isOccluded: boolean;
  119582. /**
  119583. * Flag to check the progress status of the query
  119584. * @see http://doc.babylonjs.com/features/occlusionquery
  119585. */
  119586. isOcclusionQueryInProgress: boolean;
  119587. }
  119588. }
  119589. declare module BABYLON {
  119590. /** @hidden */
  119591. export var _forceTransformFeedbackToBundle: boolean;
  119592. interface Engine {
  119593. /**
  119594. * Creates a webGL transform feedback object
  119595. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  119596. * @returns the webGL transform feedback object
  119597. */
  119598. createTransformFeedback(): WebGLTransformFeedback;
  119599. /**
  119600. * Delete a webGL transform feedback object
  119601. * @param value defines the webGL transform feedback object to delete
  119602. */
  119603. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  119604. /**
  119605. * Bind a webGL transform feedback object to the webgl context
  119606. * @param value defines the webGL transform feedback object to bind
  119607. */
  119608. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  119609. /**
  119610. * Begins a transform feedback operation
  119611. * @param usePoints defines if points or triangles must be used
  119612. */
  119613. beginTransformFeedback(usePoints: boolean): void;
  119614. /**
  119615. * Ends a transform feedback operation
  119616. */
  119617. endTransformFeedback(): void;
  119618. /**
  119619. * Specify the varyings to use with transform feedback
  119620. * @param program defines the associated webGL program
  119621. * @param value defines the list of strings representing the varying names
  119622. */
  119623. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  119624. /**
  119625. * Bind a webGL buffer for a transform feedback operation
  119626. * @param value defines the webGL buffer to bind
  119627. */
  119628. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  119629. }
  119630. }
  119631. declare module BABYLON {
  119632. /**
  119633. * Creation options of the multi render target texture.
  119634. */
  119635. export interface IMultiRenderTargetOptions {
  119636. /**
  119637. * Define if the texture needs to create mip maps after render.
  119638. */
  119639. generateMipMaps?: boolean;
  119640. /**
  119641. * Define the types of all the draw buffers we want to create
  119642. */
  119643. types?: number[];
  119644. /**
  119645. * Define the sampling modes of all the draw buffers we want to create
  119646. */
  119647. samplingModes?: number[];
  119648. /**
  119649. * Define if a depth buffer is required
  119650. */
  119651. generateDepthBuffer?: boolean;
  119652. /**
  119653. * Define if a stencil buffer is required
  119654. */
  119655. generateStencilBuffer?: boolean;
  119656. /**
  119657. * Define if a depth texture is required instead of a depth buffer
  119658. */
  119659. generateDepthTexture?: boolean;
  119660. /**
  119661. * Define the number of desired draw buffers
  119662. */
  119663. textureCount?: number;
  119664. /**
  119665. * Define if aspect ratio should be adapted to the texture or stay the scene one
  119666. */
  119667. doNotChangeAspectRatio?: boolean;
  119668. /**
  119669. * Define the default type of the buffers we are creating
  119670. */
  119671. defaultType?: number;
  119672. }
  119673. /**
  119674. * A multi render target, like a render target provides the ability to render to a texture.
  119675. * Unlike the render target, it can render to several draw buffers in one draw.
  119676. * This is specially interesting in deferred rendering or for any effects requiring more than
  119677. * just one color from a single pass.
  119678. */
  119679. export class MultiRenderTarget extends RenderTargetTexture {
  119680. private _internalTextures;
  119681. private _textures;
  119682. private _multiRenderTargetOptions;
  119683. /**
  119684. * Get if draw buffers are currently supported by the used hardware and browser.
  119685. */
  119686. get isSupported(): boolean;
  119687. /**
  119688. * Get the list of textures generated by the multi render target.
  119689. */
  119690. get textures(): Texture[];
  119691. /**
  119692. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  119693. */
  119694. get depthTexture(): Texture;
  119695. /**
  119696. * Set the wrapping mode on U of all the textures we are rendering to.
  119697. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119698. */
  119699. set wrapU(wrap: number);
  119700. /**
  119701. * Set the wrapping mode on V of all the textures we are rendering to.
  119702. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119703. */
  119704. set wrapV(wrap: number);
  119705. /**
  119706. * Instantiate a new multi render target texture.
  119707. * A multi render target, like a render target provides the ability to render to a texture.
  119708. * Unlike the render target, it can render to several draw buffers in one draw.
  119709. * This is specially interesting in deferred rendering or for any effects requiring more than
  119710. * just one color from a single pass.
  119711. * @param name Define the name of the texture
  119712. * @param size Define the size of the buffers to render to
  119713. * @param count Define the number of target we are rendering into
  119714. * @param scene Define the scene the texture belongs to
  119715. * @param options Define the options used to create the multi render target
  119716. */
  119717. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  119718. /** @hidden */
  119719. _rebuild(): void;
  119720. private _createInternalTextures;
  119721. private _createTextures;
  119722. /**
  119723. * Define the number of samples used if MSAA is enabled.
  119724. */
  119725. get samples(): number;
  119726. set samples(value: number);
  119727. /**
  119728. * Resize all the textures in the multi render target.
  119729. * Be carrefull as it will recreate all the data in the new texture.
  119730. * @param size Define the new size
  119731. */
  119732. resize(size: any): void;
  119733. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119734. /**
  119735. * Dispose the render targets and their associated resources
  119736. */
  119737. dispose(): void;
  119738. /**
  119739. * Release all the underlying texture used as draw buffers.
  119740. */
  119741. releaseInternalTextures(): void;
  119742. }
  119743. }
  119744. declare module BABYLON {
  119745. interface ThinEngine {
  119746. /**
  119747. * Unbind a list of render target textures from the webGL context
  119748. * This is used only when drawBuffer extension or webGL2 are active
  119749. * @param textures defines the render target textures to unbind
  119750. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119751. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119752. */
  119753. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  119754. /**
  119755. * Create a multi render target texture
  119756. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  119757. * @param size defines the size of the texture
  119758. * @param options defines the creation options
  119759. * @returns the cube texture as an InternalTexture
  119760. */
  119761. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  119762. /**
  119763. * Update the sample count for a given multiple render target texture
  119764. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  119765. * @param textures defines the textures to update
  119766. * @param samples defines the sample count to set
  119767. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  119768. */
  119769. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  119770. }
  119771. }
  119772. declare module BABYLON {
  119773. /**
  119774. * Class used to define an additional view for the engine
  119775. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119776. */
  119777. export class EngineView {
  119778. /** Defines the canvas where to render the view */
  119779. target: HTMLCanvasElement;
  119780. /** Defines an optional camera used to render the view (will use active camera else) */
  119781. camera?: Camera;
  119782. }
  119783. interface Engine {
  119784. /**
  119785. * Gets or sets the HTML element to use for attaching events
  119786. */
  119787. inputElement: Nullable<HTMLElement>;
  119788. /**
  119789. * Gets the current engine view
  119790. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119791. */
  119792. activeView: Nullable<EngineView>;
  119793. /** Gets or sets the list of views */
  119794. views: EngineView[];
  119795. /**
  119796. * Register a new child canvas
  119797. * @param canvas defines the canvas to register
  119798. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  119799. * @returns the associated view
  119800. */
  119801. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  119802. /**
  119803. * Remove a registered child canvas
  119804. * @param canvas defines the canvas to remove
  119805. * @returns the current engine
  119806. */
  119807. unRegisterView(canvas: HTMLCanvasElement): Engine;
  119808. }
  119809. }
  119810. declare module BABYLON {
  119811. /**
  119812. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  119813. */
  119814. export interface CubeMapInfo {
  119815. /**
  119816. * The pixel array for the front face.
  119817. * This is stored in format, left to right, up to down format.
  119818. */
  119819. front: Nullable<ArrayBufferView>;
  119820. /**
  119821. * The pixel array for the back face.
  119822. * This is stored in format, left to right, up to down format.
  119823. */
  119824. back: Nullable<ArrayBufferView>;
  119825. /**
  119826. * The pixel array for the left face.
  119827. * This is stored in format, left to right, up to down format.
  119828. */
  119829. left: Nullable<ArrayBufferView>;
  119830. /**
  119831. * The pixel array for the right face.
  119832. * This is stored in format, left to right, up to down format.
  119833. */
  119834. right: Nullable<ArrayBufferView>;
  119835. /**
  119836. * The pixel array for the up face.
  119837. * This is stored in format, left to right, up to down format.
  119838. */
  119839. up: Nullable<ArrayBufferView>;
  119840. /**
  119841. * The pixel array for the down face.
  119842. * This is stored in format, left to right, up to down format.
  119843. */
  119844. down: Nullable<ArrayBufferView>;
  119845. /**
  119846. * The size of the cubemap stored.
  119847. *
  119848. * Each faces will be size * size pixels.
  119849. */
  119850. size: number;
  119851. /**
  119852. * The format of the texture.
  119853. *
  119854. * RGBA, RGB.
  119855. */
  119856. format: number;
  119857. /**
  119858. * The type of the texture data.
  119859. *
  119860. * UNSIGNED_INT, FLOAT.
  119861. */
  119862. type: number;
  119863. /**
  119864. * Specifies whether the texture is in gamma space.
  119865. */
  119866. gammaSpace: boolean;
  119867. }
  119868. /**
  119869. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  119870. */
  119871. export class PanoramaToCubeMapTools {
  119872. private static FACE_FRONT;
  119873. private static FACE_BACK;
  119874. private static FACE_RIGHT;
  119875. private static FACE_LEFT;
  119876. private static FACE_DOWN;
  119877. private static FACE_UP;
  119878. /**
  119879. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  119880. *
  119881. * @param float32Array The source data.
  119882. * @param inputWidth The width of the input panorama.
  119883. * @param inputHeight The height of the input panorama.
  119884. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  119885. * @return The cubemap data
  119886. */
  119887. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  119888. private static CreateCubemapTexture;
  119889. private static CalcProjectionSpherical;
  119890. }
  119891. }
  119892. declare module BABYLON {
  119893. /**
  119894. * Helper class dealing with the extraction of spherical polynomial dataArray
  119895. * from a cube map.
  119896. */
  119897. export class CubeMapToSphericalPolynomialTools {
  119898. private static FileFaces;
  119899. /**
  119900. * Converts a texture to the according Spherical Polynomial data.
  119901. * This extracts the first 3 orders only as they are the only one used in the lighting.
  119902. *
  119903. * @param texture The texture to extract the information from.
  119904. * @return The Spherical Polynomial data.
  119905. */
  119906. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  119907. /**
  119908. * Converts a cubemap to the according Spherical Polynomial data.
  119909. * This extracts the first 3 orders only as they are the only one used in the lighting.
  119910. *
  119911. * @param cubeInfo The Cube map to extract the information from.
  119912. * @return The Spherical Polynomial data.
  119913. */
  119914. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  119915. }
  119916. }
  119917. declare module BABYLON {
  119918. interface BaseTexture {
  119919. /**
  119920. * Get the polynomial representation of the texture data.
  119921. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  119922. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  119923. */
  119924. sphericalPolynomial: Nullable<SphericalPolynomial>;
  119925. }
  119926. }
  119927. declare module BABYLON {
  119928. /** @hidden */
  119929. export var rgbdEncodePixelShader: {
  119930. name: string;
  119931. shader: string;
  119932. };
  119933. }
  119934. declare module BABYLON {
  119935. /** @hidden */
  119936. export var rgbdDecodePixelShader: {
  119937. name: string;
  119938. shader: string;
  119939. };
  119940. }
  119941. declare module BABYLON {
  119942. /**
  119943. * Raw texture data and descriptor sufficient for WebGL texture upload
  119944. */
  119945. export interface EnvironmentTextureInfo {
  119946. /**
  119947. * Version of the environment map
  119948. */
  119949. version: number;
  119950. /**
  119951. * Width of image
  119952. */
  119953. width: number;
  119954. /**
  119955. * Irradiance information stored in the file.
  119956. */
  119957. irradiance: any;
  119958. /**
  119959. * Specular information stored in the file.
  119960. */
  119961. specular: any;
  119962. }
  119963. /**
  119964. * Defines One Image in the file. It requires only the position in the file
  119965. * as well as the length.
  119966. */
  119967. interface BufferImageData {
  119968. /**
  119969. * Length of the image data.
  119970. */
  119971. length: number;
  119972. /**
  119973. * Position of the data from the null terminator delimiting the end of the JSON.
  119974. */
  119975. position: number;
  119976. }
  119977. /**
  119978. * Defines the specular data enclosed in the file.
  119979. * This corresponds to the version 1 of the data.
  119980. */
  119981. export interface EnvironmentTextureSpecularInfoV1 {
  119982. /**
  119983. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  119984. */
  119985. specularDataPosition?: number;
  119986. /**
  119987. * This contains all the images data needed to reconstruct the cubemap.
  119988. */
  119989. mipmaps: Array<BufferImageData>;
  119990. /**
  119991. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  119992. */
  119993. lodGenerationScale: number;
  119994. }
  119995. /**
  119996. * Sets of helpers addressing the serialization and deserialization of environment texture
  119997. * stored in a BabylonJS env file.
  119998. * Those files are usually stored as .env files.
  119999. */
  120000. export class EnvironmentTextureTools {
  120001. /**
  120002. * Magic number identifying the env file.
  120003. */
  120004. private static _MagicBytes;
  120005. /**
  120006. * Gets the environment info from an env file.
  120007. * @param data The array buffer containing the .env bytes.
  120008. * @returns the environment file info (the json header) if successfully parsed.
  120009. */
  120010. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  120011. /**
  120012. * Creates an environment texture from a loaded cube texture.
  120013. * @param texture defines the cube texture to convert in env file
  120014. * @return a promise containing the environment data if succesfull.
  120015. */
  120016. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120017. /**
  120018. * Creates a JSON representation of the spherical data.
  120019. * @param texture defines the texture containing the polynomials
  120020. * @return the JSON representation of the spherical info
  120021. */
  120022. private static _CreateEnvTextureIrradiance;
  120023. /**
  120024. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120025. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  120026. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120027. * @return the views described by info providing access to the underlying buffer
  120028. */
  120029. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120030. /**
  120031. * Uploads the texture info contained in the env file to the GPU.
  120032. * @param texture defines the internal texture to upload to
  120033. * @param arrayBuffer defines the buffer cotaining the data to load
  120034. * @param info defines the texture info retrieved through the GetEnvInfo method
  120035. * @returns a promise
  120036. */
  120037. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  120038. private static _OnImageReadyAsync;
  120039. /**
  120040. * Uploads the levels of image data to the GPU.
  120041. * @param texture defines the internal texture to upload to
  120042. * @param imageData defines the array buffer views of image data [mipmap][face]
  120043. * @returns a promise
  120044. */
  120045. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120046. /**
  120047. * Uploads spherical polynomials information to the texture.
  120048. * @param texture defines the texture we are trying to upload the information to
  120049. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120050. */
  120051. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120052. /** @hidden */
  120053. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120054. }
  120055. }
  120056. declare module BABYLON {
  120057. /**
  120058. * Contains position and normal vectors for a vertex
  120059. */
  120060. export class PositionNormalVertex {
  120061. /** the position of the vertex (defaut: 0,0,0) */
  120062. position: Vector3;
  120063. /** the normal of the vertex (defaut: 0,1,0) */
  120064. normal: Vector3;
  120065. /**
  120066. * Creates a PositionNormalVertex
  120067. * @param position the position of the vertex (defaut: 0,0,0)
  120068. * @param normal the normal of the vertex (defaut: 0,1,0)
  120069. */
  120070. constructor(
  120071. /** the position of the vertex (defaut: 0,0,0) */
  120072. position?: Vector3,
  120073. /** the normal of the vertex (defaut: 0,1,0) */
  120074. normal?: Vector3);
  120075. /**
  120076. * Clones the PositionNormalVertex
  120077. * @returns the cloned PositionNormalVertex
  120078. */
  120079. clone(): PositionNormalVertex;
  120080. }
  120081. /**
  120082. * Contains position, normal and uv vectors for a vertex
  120083. */
  120084. export class PositionNormalTextureVertex {
  120085. /** the position of the vertex (defaut: 0,0,0) */
  120086. position: Vector3;
  120087. /** the normal of the vertex (defaut: 0,1,0) */
  120088. normal: Vector3;
  120089. /** the uv of the vertex (default: 0,0) */
  120090. uv: Vector2;
  120091. /**
  120092. * Creates a PositionNormalTextureVertex
  120093. * @param position the position of the vertex (defaut: 0,0,0)
  120094. * @param normal the normal of the vertex (defaut: 0,1,0)
  120095. * @param uv the uv of the vertex (default: 0,0)
  120096. */
  120097. constructor(
  120098. /** the position of the vertex (defaut: 0,0,0) */
  120099. position?: Vector3,
  120100. /** the normal of the vertex (defaut: 0,1,0) */
  120101. normal?: Vector3,
  120102. /** the uv of the vertex (default: 0,0) */
  120103. uv?: Vector2);
  120104. /**
  120105. * Clones the PositionNormalTextureVertex
  120106. * @returns the cloned PositionNormalTextureVertex
  120107. */
  120108. clone(): PositionNormalTextureVertex;
  120109. }
  120110. }
  120111. declare module BABYLON {
  120112. /** @hidden */
  120113. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120114. private _genericAttributeLocation;
  120115. private _varyingLocationCount;
  120116. private _varyingLocationMap;
  120117. private _replacements;
  120118. private _textureCount;
  120119. private _uniforms;
  120120. lineProcessor(line: string): string;
  120121. attributeProcessor(attribute: string): string;
  120122. varyingProcessor(varying: string, isFragment: boolean): string;
  120123. uniformProcessor(uniform: string): string;
  120124. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120125. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120126. }
  120127. }
  120128. declare module BABYLON {
  120129. /**
  120130. * Container for accessors for natively-stored mesh data buffers.
  120131. */
  120132. class NativeDataBuffer extends DataBuffer {
  120133. /**
  120134. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120135. */
  120136. nativeIndexBuffer?: any;
  120137. /**
  120138. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120139. */
  120140. nativeVertexBuffer?: any;
  120141. }
  120142. /** @hidden */
  120143. class NativeTexture extends InternalTexture {
  120144. getInternalTexture(): InternalTexture;
  120145. getViewCount(): number;
  120146. }
  120147. /** @hidden */
  120148. export class NativeEngine extends Engine {
  120149. private readonly _native;
  120150. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120151. private readonly INVALID_HANDLE;
  120152. getHardwareScalingLevel(): number;
  120153. constructor();
  120154. /**
  120155. * Can be used to override the current requestAnimationFrame requester.
  120156. * @hidden
  120157. */
  120158. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120159. /**
  120160. * Override default engine behavior.
  120161. * @param color
  120162. * @param backBuffer
  120163. * @param depth
  120164. * @param stencil
  120165. */
  120166. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120167. /**
  120168. * Gets host document
  120169. * @returns the host document object
  120170. */
  120171. getHostDocument(): Nullable<Document>;
  120172. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120173. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120174. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120175. recordVertexArrayObject(vertexBuffers: {
  120176. [key: string]: VertexBuffer;
  120177. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120178. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120179. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120180. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120181. /**
  120182. * Draw a list of indexed primitives
  120183. * @param fillMode defines the primitive to use
  120184. * @param indexStart defines the starting index
  120185. * @param indexCount defines the number of index to draw
  120186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120187. */
  120188. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120189. /**
  120190. * Draw a list of unindexed primitives
  120191. * @param fillMode defines the primitive to use
  120192. * @param verticesStart defines the index of first vertex to draw
  120193. * @param verticesCount defines the count of vertices to draw
  120194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120195. */
  120196. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120197. createPipelineContext(): IPipelineContext;
  120198. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120199. /** @hidden */
  120200. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120201. /** @hidden */
  120202. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120203. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120204. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120205. protected _setProgram(program: WebGLProgram): void;
  120206. _releaseEffect(effect: Effect): void;
  120207. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120208. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120209. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120210. bindSamplers(effect: Effect): void;
  120211. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120212. getRenderWidth(useScreen?: boolean): number;
  120213. getRenderHeight(useScreen?: boolean): number;
  120214. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120215. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120216. /**
  120217. * Set the z offset to apply to current rendering
  120218. * @param value defines the offset to apply
  120219. */
  120220. setZOffset(value: number): void;
  120221. /**
  120222. * Gets the current value of the zOffset
  120223. * @returns the current zOffset state
  120224. */
  120225. getZOffset(): number;
  120226. /**
  120227. * Enable or disable depth buffering
  120228. * @param enable defines the state to set
  120229. */
  120230. setDepthBuffer(enable: boolean): void;
  120231. /**
  120232. * Gets a boolean indicating if depth writing is enabled
  120233. * @returns the current depth writing state
  120234. */
  120235. getDepthWrite(): boolean;
  120236. /**
  120237. * Enable or disable depth writing
  120238. * @param enable defines the state to set
  120239. */
  120240. setDepthWrite(enable: boolean): void;
  120241. /**
  120242. * Enable or disable color writing
  120243. * @param enable defines the state to set
  120244. */
  120245. setColorWrite(enable: boolean): void;
  120246. /**
  120247. * Gets a boolean indicating if color writing is enabled
  120248. * @returns the current color writing state
  120249. */
  120250. getColorWrite(): boolean;
  120251. /**
  120252. * Sets alpha constants used by some alpha blending modes
  120253. * @param r defines the red component
  120254. * @param g defines the green component
  120255. * @param b defines the blue component
  120256. * @param a defines the alpha component
  120257. */
  120258. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120259. /**
  120260. * Sets the current alpha mode
  120261. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120262. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120263. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120264. */
  120265. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120266. /**
  120267. * Gets the current alpha mode
  120268. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120269. * @returns the current alpha mode
  120270. */
  120271. getAlphaMode(): number;
  120272. setInt(uniform: WebGLUniformLocation, int: number): void;
  120273. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120274. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120275. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120276. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120277. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120278. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120279. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120280. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120281. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120282. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120283. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120284. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120285. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120286. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120287. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120288. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120289. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120290. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120291. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120292. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120293. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120294. wipeCaches(bruteForce?: boolean): void;
  120295. _createTexture(): WebGLTexture;
  120296. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120297. /**
  120298. * Usually called from BABYLON.Texture.ts.
  120299. * Passed information to create a WebGLTexture
  120300. * @param urlArg defines a value which contains one of the following:
  120301. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120302. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120303. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120304. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120305. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120306. * @param scene needed for loading to the correct scene
  120307. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120308. * @param onLoad optional callback to be called upon successful completion
  120309. * @param onError optional callback to be called upon failure
  120310. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120311. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120312. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120313. * @param forcedExtension defines the extension to use to pick the right loader
  120314. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120315. */
  120316. 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;
  120317. /**
  120318. * Creates a cube texture
  120319. * @param rootUrl defines the url where the files to load is located
  120320. * @param scene defines the current scene
  120321. * @param files defines the list of files to load (1 per face)
  120322. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120323. * @param onLoad defines an optional callback raised when the texture is loaded
  120324. * @param onError defines an optional callback raised if there is an issue to load the texture
  120325. * @param format defines the format of the data
  120326. * @param forcedExtension defines the extension to use to pick the right loader
  120327. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120328. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120329. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120330. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120331. * @returns the cube texture as an InternalTexture
  120332. */
  120333. 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;
  120334. private _getSamplingFilter;
  120335. private static _GetNativeTextureFormat;
  120336. createRenderTargetTexture(size: number | {
  120337. width: number;
  120338. height: number;
  120339. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120340. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120341. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120342. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120343. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120344. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120345. /**
  120346. * Updates a dynamic vertex buffer.
  120347. * @param vertexBuffer the vertex buffer to update
  120348. * @param data the data used to update the vertex buffer
  120349. * @param byteOffset the byte offset of the data (optional)
  120350. * @param byteLength the byte length of the data (optional)
  120351. */
  120352. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120353. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120354. private _updateAnisotropicLevel;
  120355. private _getAddressMode;
  120356. /** @hidden */
  120357. _bindTexture(channel: number, texture: InternalTexture): void;
  120358. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120359. releaseEffects(): void;
  120360. /** @hidden */
  120361. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120362. /** @hidden */
  120363. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120364. /** @hidden */
  120365. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120366. /** @hidden */
  120367. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120368. }
  120369. }
  120370. declare module BABYLON {
  120371. /**
  120372. * Gather the list of clipboard event types as constants.
  120373. */
  120374. export class ClipboardEventTypes {
  120375. /**
  120376. * The clipboard event is fired when a copy command is active (pressed).
  120377. */
  120378. static readonly COPY: number;
  120379. /**
  120380. * The clipboard event is fired when a cut command is active (pressed).
  120381. */
  120382. static readonly CUT: number;
  120383. /**
  120384. * The clipboard event is fired when a paste command is active (pressed).
  120385. */
  120386. static readonly PASTE: number;
  120387. }
  120388. /**
  120389. * This class is used to store clipboard related info for the onClipboardObservable event.
  120390. */
  120391. export class ClipboardInfo {
  120392. /**
  120393. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120394. */
  120395. type: number;
  120396. /**
  120397. * Defines the related dom event
  120398. */
  120399. event: ClipboardEvent;
  120400. /**
  120401. *Creates an instance of ClipboardInfo.
  120402. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120403. * @param event Defines the related dom event
  120404. */
  120405. constructor(
  120406. /**
  120407. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120408. */
  120409. type: number,
  120410. /**
  120411. * Defines the related dom event
  120412. */
  120413. event: ClipboardEvent);
  120414. /**
  120415. * Get the clipboard event's type from the keycode.
  120416. * @param keyCode Defines the keyCode for the current keyboard event.
  120417. * @return {number}
  120418. */
  120419. static GetTypeFromCharacter(keyCode: number): number;
  120420. }
  120421. }
  120422. declare module BABYLON {
  120423. /**
  120424. * Google Daydream controller
  120425. */
  120426. export class DaydreamController extends WebVRController {
  120427. /**
  120428. * Base Url for the controller model.
  120429. */
  120430. static MODEL_BASE_URL: string;
  120431. /**
  120432. * File name for the controller model.
  120433. */
  120434. static MODEL_FILENAME: string;
  120435. /**
  120436. * Gamepad Id prefix used to identify Daydream Controller.
  120437. */
  120438. static readonly GAMEPAD_ID_PREFIX: string;
  120439. /**
  120440. * Creates a new DaydreamController from a gamepad
  120441. * @param vrGamepad the gamepad that the controller should be created from
  120442. */
  120443. constructor(vrGamepad: any);
  120444. /**
  120445. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120446. * @param scene scene in which to add meshes
  120447. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120448. */
  120449. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120450. /**
  120451. * Called once for each button that changed state since the last frame
  120452. * @param buttonIdx Which button index changed
  120453. * @param state New state of the button
  120454. * @param changes Which properties on the state changed since last frame
  120455. */
  120456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120457. }
  120458. }
  120459. declare module BABYLON {
  120460. /**
  120461. * Gear VR Controller
  120462. */
  120463. export class GearVRController extends WebVRController {
  120464. /**
  120465. * Base Url for the controller model.
  120466. */
  120467. static MODEL_BASE_URL: string;
  120468. /**
  120469. * File name for the controller model.
  120470. */
  120471. static MODEL_FILENAME: string;
  120472. /**
  120473. * Gamepad Id prefix used to identify this controller.
  120474. */
  120475. static readonly GAMEPAD_ID_PREFIX: string;
  120476. private readonly _buttonIndexToObservableNameMap;
  120477. /**
  120478. * Creates a new GearVRController from a gamepad
  120479. * @param vrGamepad the gamepad that the controller should be created from
  120480. */
  120481. constructor(vrGamepad: any);
  120482. /**
  120483. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120484. * @param scene scene in which to add meshes
  120485. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120486. */
  120487. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120488. /**
  120489. * Called once for each button that changed state since the last frame
  120490. * @param buttonIdx Which button index changed
  120491. * @param state New state of the button
  120492. * @param changes Which properties on the state changed since last frame
  120493. */
  120494. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120495. }
  120496. }
  120497. declare module BABYLON {
  120498. /**
  120499. * Generic Controller
  120500. */
  120501. export class GenericController extends WebVRController {
  120502. /**
  120503. * Base Url for the controller model.
  120504. */
  120505. static readonly MODEL_BASE_URL: string;
  120506. /**
  120507. * File name for the controller model.
  120508. */
  120509. static readonly MODEL_FILENAME: string;
  120510. /**
  120511. * Creates a new GenericController from a gamepad
  120512. * @param vrGamepad the gamepad that the controller should be created from
  120513. */
  120514. constructor(vrGamepad: any);
  120515. /**
  120516. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120517. * @param scene scene in which to add meshes
  120518. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120519. */
  120520. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120521. /**
  120522. * Called once for each button that changed state since the last frame
  120523. * @param buttonIdx Which button index changed
  120524. * @param state New state of the button
  120525. * @param changes Which properties on the state changed since last frame
  120526. */
  120527. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120528. }
  120529. }
  120530. declare module BABYLON {
  120531. /**
  120532. * Oculus Touch Controller
  120533. */
  120534. export class OculusTouchController extends WebVRController {
  120535. /**
  120536. * Base Url for the controller model.
  120537. */
  120538. static MODEL_BASE_URL: string;
  120539. /**
  120540. * File name for the left controller model.
  120541. */
  120542. static MODEL_LEFT_FILENAME: string;
  120543. /**
  120544. * File name for the right controller model.
  120545. */
  120546. static MODEL_RIGHT_FILENAME: string;
  120547. /**
  120548. * Base Url for the Quest controller model.
  120549. */
  120550. static QUEST_MODEL_BASE_URL: string;
  120551. /**
  120552. * @hidden
  120553. * If the controllers are running on a device that needs the updated Quest controller models
  120554. */
  120555. static _IsQuest: boolean;
  120556. /**
  120557. * Fired when the secondary trigger on this controller is modified
  120558. */
  120559. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  120560. /**
  120561. * Fired when the thumb rest on this controller is modified
  120562. */
  120563. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  120564. /**
  120565. * Creates a new OculusTouchController from a gamepad
  120566. * @param vrGamepad the gamepad that the controller should be created from
  120567. */
  120568. constructor(vrGamepad: any);
  120569. /**
  120570. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120571. * @param scene scene in which to add meshes
  120572. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120573. */
  120574. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120575. /**
  120576. * Fired when the A button on this controller is modified
  120577. */
  120578. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120579. /**
  120580. * Fired when the B button on this controller is modified
  120581. */
  120582. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120583. /**
  120584. * Fired when the X button on this controller is modified
  120585. */
  120586. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120587. /**
  120588. * Fired when the Y button on this controller is modified
  120589. */
  120590. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120591. /**
  120592. * Called once for each button that changed state since the last frame
  120593. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  120594. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  120595. * 2) secondary trigger (same)
  120596. * 3) A (right) X (left), touch, pressed = value
  120597. * 4) B / Y
  120598. * 5) thumb rest
  120599. * @param buttonIdx Which button index changed
  120600. * @param state New state of the button
  120601. * @param changes Which properties on the state changed since last frame
  120602. */
  120603. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120604. }
  120605. }
  120606. declare module BABYLON {
  120607. /**
  120608. * Vive Controller
  120609. */
  120610. export class ViveController extends WebVRController {
  120611. /**
  120612. * Base Url for the controller model.
  120613. */
  120614. static MODEL_BASE_URL: string;
  120615. /**
  120616. * File name for the controller model.
  120617. */
  120618. static MODEL_FILENAME: string;
  120619. /**
  120620. * Creates a new ViveController from a gamepad
  120621. * @param vrGamepad the gamepad that the controller should be created from
  120622. */
  120623. constructor(vrGamepad: any);
  120624. /**
  120625. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120626. * @param scene scene in which to add meshes
  120627. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120628. */
  120629. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120630. /**
  120631. * Fired when the left button on this controller is modified
  120632. */
  120633. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120634. /**
  120635. * Fired when the right button on this controller is modified
  120636. */
  120637. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120638. /**
  120639. * Fired when the menu button on this controller is modified
  120640. */
  120641. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120642. /**
  120643. * Called once for each button that changed state since the last frame
  120644. * Vive mapping:
  120645. * 0: touchpad
  120646. * 1: trigger
  120647. * 2: left AND right buttons
  120648. * 3: menu button
  120649. * @param buttonIdx Which button index changed
  120650. * @param state New state of the button
  120651. * @param changes Which properties on the state changed since last frame
  120652. */
  120653. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120654. }
  120655. }
  120656. declare module BABYLON {
  120657. /**
  120658. * Defines the WindowsMotionController object that the state of the windows motion controller
  120659. */
  120660. export class WindowsMotionController extends WebVRController {
  120661. /**
  120662. * The base url used to load the left and right controller models
  120663. */
  120664. static MODEL_BASE_URL: string;
  120665. /**
  120666. * The name of the left controller model file
  120667. */
  120668. static MODEL_LEFT_FILENAME: string;
  120669. /**
  120670. * The name of the right controller model file
  120671. */
  120672. static MODEL_RIGHT_FILENAME: string;
  120673. /**
  120674. * The controller name prefix for this controller type
  120675. */
  120676. static readonly GAMEPAD_ID_PREFIX: string;
  120677. /**
  120678. * The controller id pattern for this controller type
  120679. */
  120680. private static readonly GAMEPAD_ID_PATTERN;
  120681. private _loadedMeshInfo;
  120682. protected readonly _mapping: {
  120683. buttons: string[];
  120684. buttonMeshNames: {
  120685. 'trigger': string;
  120686. 'menu': string;
  120687. 'grip': string;
  120688. 'thumbstick': string;
  120689. 'trackpad': string;
  120690. };
  120691. buttonObservableNames: {
  120692. 'trigger': string;
  120693. 'menu': string;
  120694. 'grip': string;
  120695. 'thumbstick': string;
  120696. 'trackpad': string;
  120697. };
  120698. axisMeshNames: string[];
  120699. pointingPoseMeshName: string;
  120700. };
  120701. /**
  120702. * Fired when the trackpad on this controller is clicked
  120703. */
  120704. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120705. /**
  120706. * Fired when the trackpad on this controller is modified
  120707. */
  120708. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120709. /**
  120710. * The current x and y values of this controller's trackpad
  120711. */
  120712. trackpad: StickValues;
  120713. /**
  120714. * Creates a new WindowsMotionController from a gamepad
  120715. * @param vrGamepad the gamepad that the controller should be created from
  120716. */
  120717. constructor(vrGamepad: any);
  120718. /**
  120719. * Fired when the trigger on this controller is modified
  120720. */
  120721. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120722. /**
  120723. * Fired when the menu button on this controller is modified
  120724. */
  120725. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120726. /**
  120727. * Fired when the grip button on this controller is modified
  120728. */
  120729. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120730. /**
  120731. * Fired when the thumbstick button on this controller is modified
  120732. */
  120733. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120734. /**
  120735. * Fired when the touchpad button on this controller is modified
  120736. */
  120737. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120738. /**
  120739. * Fired when the touchpad values on this controller are modified
  120740. */
  120741. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  120742. protected _updateTrackpad(): void;
  120743. /**
  120744. * Called once per frame by the engine.
  120745. */
  120746. update(): void;
  120747. /**
  120748. * Called once for each button that changed state since the last frame
  120749. * @param buttonIdx Which button index changed
  120750. * @param state New state of the button
  120751. * @param changes Which properties on the state changed since last frame
  120752. */
  120753. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120754. /**
  120755. * Moves the buttons on the controller mesh based on their current state
  120756. * @param buttonName the name of the button to move
  120757. * @param buttonValue the value of the button which determines the buttons new position
  120758. */
  120759. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  120760. /**
  120761. * Moves the axis on the controller mesh based on its current state
  120762. * @param axis the index of the axis
  120763. * @param axisValue the value of the axis which determines the meshes new position
  120764. * @hidden
  120765. */
  120766. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  120767. /**
  120768. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120769. * @param scene scene in which to add meshes
  120770. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120771. */
  120772. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  120773. /**
  120774. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  120775. * can be transformed by button presses and axes values, based on this._mapping.
  120776. *
  120777. * @param scene scene in which the meshes exist
  120778. * @param meshes list of meshes that make up the controller model to process
  120779. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  120780. */
  120781. private processModel;
  120782. private createMeshInfo;
  120783. /**
  120784. * Gets the ray of the controller in the direction the controller is pointing
  120785. * @param length the length the resulting ray should be
  120786. * @returns a ray in the direction the controller is pointing
  120787. */
  120788. getForwardRay(length?: number): Ray;
  120789. /**
  120790. * Disposes of the controller
  120791. */
  120792. dispose(): void;
  120793. }
  120794. /**
  120795. * This class represents a new windows motion controller in XR.
  120796. */
  120797. export class XRWindowsMotionController extends WindowsMotionController {
  120798. /**
  120799. * Changing the original WIndowsMotionController mapping to fir the new mapping
  120800. */
  120801. protected readonly _mapping: {
  120802. buttons: string[];
  120803. buttonMeshNames: {
  120804. 'trigger': string;
  120805. 'menu': string;
  120806. 'grip': string;
  120807. 'thumbstick': string;
  120808. 'trackpad': string;
  120809. };
  120810. buttonObservableNames: {
  120811. 'trigger': string;
  120812. 'menu': string;
  120813. 'grip': string;
  120814. 'thumbstick': string;
  120815. 'trackpad': string;
  120816. };
  120817. axisMeshNames: string[];
  120818. pointingPoseMeshName: string;
  120819. };
  120820. /**
  120821. * Construct a new XR-Based windows motion controller
  120822. *
  120823. * @param gamepadInfo the gamepad object from the browser
  120824. */
  120825. constructor(gamepadInfo: any);
  120826. /**
  120827. * holds the thumbstick values (X,Y)
  120828. */
  120829. thumbstickValues: StickValues;
  120830. /**
  120831. * Fired when the thumbstick on this controller is clicked
  120832. */
  120833. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  120834. /**
  120835. * Fired when the thumbstick on this controller is modified
  120836. */
  120837. onThumbstickValuesChangedObservable: Observable<StickValues>;
  120838. /**
  120839. * Fired when the touchpad button on this controller is modified
  120840. */
  120841. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120842. /**
  120843. * Fired when the touchpad values on this controller are modified
  120844. */
  120845. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120846. /**
  120847. * Fired when the thumbstick button on this controller is modified
  120848. * here to prevent breaking changes
  120849. */
  120850. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120851. /**
  120852. * updating the thumbstick(!) and not the trackpad.
  120853. * This is named this way due to the difference between WebVR and XR and to avoid
  120854. * changing the parent class.
  120855. */
  120856. protected _updateTrackpad(): void;
  120857. /**
  120858. * Disposes the class with joy
  120859. */
  120860. dispose(): void;
  120861. }
  120862. }
  120863. declare module BABYLON {
  120864. /**
  120865. * Class containing static functions to help procedurally build meshes
  120866. */
  120867. export class PolyhedronBuilder {
  120868. /**
  120869. * Creates a polyhedron mesh
  120870. * * 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
  120871. * * The parameter `size` (positive float, default 1) sets the polygon size
  120872. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  120873. * * 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`
  120874. * * 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
  120875. * * 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)`)
  120876. * * 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
  120877. * * 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
  120878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120881. * @param name defines the name of the mesh
  120882. * @param options defines the options used to create the mesh
  120883. * @param scene defines the hosting scene
  120884. * @returns the polyhedron mesh
  120885. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  120886. */
  120887. static CreatePolyhedron(name: string, options: {
  120888. type?: number;
  120889. size?: number;
  120890. sizeX?: number;
  120891. sizeY?: number;
  120892. sizeZ?: number;
  120893. custom?: any;
  120894. faceUV?: Vector4[];
  120895. faceColors?: Color4[];
  120896. flat?: boolean;
  120897. updatable?: boolean;
  120898. sideOrientation?: number;
  120899. frontUVs?: Vector4;
  120900. backUVs?: Vector4;
  120901. }, scene?: Nullable<Scene>): Mesh;
  120902. }
  120903. }
  120904. declare module BABYLON {
  120905. /**
  120906. * Gizmo that enables scaling a mesh along 3 axis
  120907. */
  120908. export class ScaleGizmo extends Gizmo {
  120909. /**
  120910. * Internal gizmo used for interactions on the x axis
  120911. */
  120912. xGizmo: AxisScaleGizmo;
  120913. /**
  120914. * Internal gizmo used for interactions on the y axis
  120915. */
  120916. yGizmo: AxisScaleGizmo;
  120917. /**
  120918. * Internal gizmo used for interactions on the z axis
  120919. */
  120920. zGizmo: AxisScaleGizmo;
  120921. /**
  120922. * Internal gizmo used to scale all axis equally
  120923. */
  120924. uniformScaleGizmo: AxisScaleGizmo;
  120925. private _meshAttached;
  120926. private _updateGizmoRotationToMatchAttachedMesh;
  120927. private _snapDistance;
  120928. private _scaleRatio;
  120929. private _uniformScalingMesh;
  120930. private _octahedron;
  120931. private _sensitivity;
  120932. /** Fires an event when any of it's sub gizmos are dragged */
  120933. onDragStartObservable: Observable<unknown>;
  120934. /** Fires an event when any of it's sub gizmos are released from dragging */
  120935. onDragEndObservable: Observable<unknown>;
  120936. get attachedMesh(): Nullable<AbstractMesh>;
  120937. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120938. /**
  120939. * Creates a ScaleGizmo
  120940. * @param gizmoLayer The utility layer the gizmo will be added to
  120941. */
  120942. constructor(gizmoLayer?: UtilityLayerRenderer);
  120943. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120944. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120945. /**
  120946. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120947. */
  120948. set snapDistance(value: number);
  120949. get snapDistance(): number;
  120950. /**
  120951. * Ratio for the scale of the gizmo (Default: 1)
  120952. */
  120953. set scaleRatio(value: number);
  120954. get scaleRatio(): number;
  120955. /**
  120956. * Sensitivity factor for dragging (Default: 1)
  120957. */
  120958. set sensitivity(value: number);
  120959. get sensitivity(): number;
  120960. /**
  120961. * Disposes of the gizmo
  120962. */
  120963. dispose(): void;
  120964. }
  120965. }
  120966. declare module BABYLON {
  120967. /**
  120968. * Single axis scale gizmo
  120969. */
  120970. export class AxisScaleGizmo extends Gizmo {
  120971. /**
  120972. * Drag behavior responsible for the gizmos dragging interactions
  120973. */
  120974. dragBehavior: PointerDragBehavior;
  120975. private _pointerObserver;
  120976. /**
  120977. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120978. */
  120979. snapDistance: number;
  120980. /**
  120981. * Event that fires each time the gizmo snaps to a new location.
  120982. * * snapDistance is the the change in distance
  120983. */
  120984. onSnapObservable: Observable<{
  120985. snapDistance: number;
  120986. }>;
  120987. /**
  120988. * If the scaling operation should be done on all axis (default: false)
  120989. */
  120990. uniformScaling: boolean;
  120991. /**
  120992. * Custom sensitivity value for the drag strength
  120993. */
  120994. sensitivity: number;
  120995. private _isEnabled;
  120996. private _parent;
  120997. private _arrow;
  120998. private _coloredMaterial;
  120999. private _hoverMaterial;
  121000. /**
  121001. * Creates an AxisScaleGizmo
  121002. * @param gizmoLayer The utility layer the gizmo will be added to
  121003. * @param dragAxis The axis which the gizmo will be able to scale on
  121004. * @param color The color of the gizmo
  121005. */
  121006. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121007. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121008. /**
  121009. * If the gizmo is enabled
  121010. */
  121011. set isEnabled(value: boolean);
  121012. get isEnabled(): boolean;
  121013. /**
  121014. * Disposes of the gizmo
  121015. */
  121016. dispose(): void;
  121017. /**
  121018. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121019. * @param mesh The mesh to replace the default mesh of the gizmo
  121020. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121021. */
  121022. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121023. }
  121024. }
  121025. declare module BABYLON {
  121026. /**
  121027. * Bounding box gizmo
  121028. */
  121029. export class BoundingBoxGizmo extends Gizmo {
  121030. private _lineBoundingBox;
  121031. private _rotateSpheresParent;
  121032. private _scaleBoxesParent;
  121033. private _boundingDimensions;
  121034. private _renderObserver;
  121035. private _pointerObserver;
  121036. private _scaleDragSpeed;
  121037. private _tmpQuaternion;
  121038. private _tmpVector;
  121039. private _tmpRotationMatrix;
  121040. /**
  121041. * 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)
  121042. */
  121043. ignoreChildren: boolean;
  121044. /**
  121045. * 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)
  121046. */
  121047. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121048. /**
  121049. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121050. */
  121051. rotationSphereSize: number;
  121052. /**
  121053. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121054. */
  121055. scaleBoxSize: number;
  121056. /**
  121057. * 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)
  121058. */
  121059. fixedDragMeshScreenSize: boolean;
  121060. /**
  121061. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121062. */
  121063. fixedDragMeshScreenSizeDistanceFactor: number;
  121064. /**
  121065. * Fired when a rotation sphere or scale box is dragged
  121066. */
  121067. onDragStartObservable: Observable<{}>;
  121068. /**
  121069. * Fired when a scale box is dragged
  121070. */
  121071. onScaleBoxDragObservable: Observable<{}>;
  121072. /**
  121073. * Fired when a scale box drag is ended
  121074. */
  121075. onScaleBoxDragEndObservable: Observable<{}>;
  121076. /**
  121077. * Fired when a rotation sphere is dragged
  121078. */
  121079. onRotationSphereDragObservable: Observable<{}>;
  121080. /**
  121081. * Fired when a rotation sphere drag is ended
  121082. */
  121083. onRotationSphereDragEndObservable: Observable<{}>;
  121084. /**
  121085. * 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)
  121086. */
  121087. scalePivot: Nullable<Vector3>;
  121088. /**
  121089. * Mesh used as a pivot to rotate the attached mesh
  121090. */
  121091. private _anchorMesh;
  121092. private _existingMeshScale;
  121093. private _dragMesh;
  121094. private pointerDragBehavior;
  121095. private coloredMaterial;
  121096. private hoverColoredMaterial;
  121097. /**
  121098. * Sets the color of the bounding box gizmo
  121099. * @param color the color to set
  121100. */
  121101. setColor(color: Color3): void;
  121102. /**
  121103. * Creates an BoundingBoxGizmo
  121104. * @param gizmoLayer The utility layer the gizmo will be added to
  121105. * @param color The color of the gizmo
  121106. */
  121107. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121108. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121109. private _selectNode;
  121110. /**
  121111. * Updates the bounding box information for the Gizmo
  121112. */
  121113. updateBoundingBox(): void;
  121114. private _updateRotationSpheres;
  121115. private _updateScaleBoxes;
  121116. /**
  121117. * Enables rotation on the specified axis and disables rotation on the others
  121118. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121119. */
  121120. setEnabledRotationAxis(axis: string): void;
  121121. /**
  121122. * Enables/disables scaling
  121123. * @param enable if scaling should be enabled
  121124. */
  121125. setEnabledScaling(enable: boolean): void;
  121126. private _updateDummy;
  121127. /**
  121128. * Enables a pointer drag behavior on the bounding box of the gizmo
  121129. */
  121130. enableDragBehavior(): void;
  121131. /**
  121132. * Disposes of the gizmo
  121133. */
  121134. dispose(): void;
  121135. /**
  121136. * 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)
  121137. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121138. * @returns the bounding box mesh with the passed in mesh as a child
  121139. */
  121140. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121141. /**
  121142. * CustomMeshes are not supported by this gizmo
  121143. * @param mesh The mesh to replace the default mesh of the gizmo
  121144. */
  121145. setCustomMesh(mesh: Mesh): void;
  121146. }
  121147. }
  121148. declare module BABYLON {
  121149. /**
  121150. * Single plane rotation gizmo
  121151. */
  121152. export class PlaneRotationGizmo extends Gizmo {
  121153. /**
  121154. * Drag behavior responsible for the gizmos dragging interactions
  121155. */
  121156. dragBehavior: PointerDragBehavior;
  121157. private _pointerObserver;
  121158. /**
  121159. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121160. */
  121161. snapDistance: number;
  121162. /**
  121163. * Event that fires each time the gizmo snaps to a new location.
  121164. * * snapDistance is the the change in distance
  121165. */
  121166. onSnapObservable: Observable<{
  121167. snapDistance: number;
  121168. }>;
  121169. private _isEnabled;
  121170. private _parent;
  121171. /**
  121172. * Creates a PlaneRotationGizmo
  121173. * @param gizmoLayer The utility layer the gizmo will be added to
  121174. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121175. * @param color The color of the gizmo
  121176. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121177. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121178. */
  121179. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121180. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121181. /**
  121182. * If the gizmo is enabled
  121183. */
  121184. set isEnabled(value: boolean);
  121185. get isEnabled(): boolean;
  121186. /**
  121187. * Disposes of the gizmo
  121188. */
  121189. dispose(): void;
  121190. }
  121191. }
  121192. declare module BABYLON {
  121193. /**
  121194. * Gizmo that enables rotating a mesh along 3 axis
  121195. */
  121196. export class RotationGizmo extends Gizmo {
  121197. /**
  121198. * Internal gizmo used for interactions on the x axis
  121199. */
  121200. xGizmo: PlaneRotationGizmo;
  121201. /**
  121202. * Internal gizmo used for interactions on the y axis
  121203. */
  121204. yGizmo: PlaneRotationGizmo;
  121205. /**
  121206. * Internal gizmo used for interactions on the z axis
  121207. */
  121208. zGizmo: PlaneRotationGizmo;
  121209. /** Fires an event when any of it's sub gizmos are dragged */
  121210. onDragStartObservable: Observable<unknown>;
  121211. /** Fires an event when any of it's sub gizmos are released from dragging */
  121212. onDragEndObservable: Observable<unknown>;
  121213. private _meshAttached;
  121214. get attachedMesh(): Nullable<AbstractMesh>;
  121215. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121216. /**
  121217. * Creates a RotationGizmo
  121218. * @param gizmoLayer The utility layer the gizmo will be added to
  121219. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121220. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121221. */
  121222. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121223. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121224. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121225. /**
  121226. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121227. */
  121228. set snapDistance(value: number);
  121229. get snapDistance(): number;
  121230. /**
  121231. * Ratio for the scale of the gizmo (Default: 1)
  121232. */
  121233. set scaleRatio(value: number);
  121234. get scaleRatio(): number;
  121235. /**
  121236. * Disposes of the gizmo
  121237. */
  121238. dispose(): void;
  121239. /**
  121240. * CustomMeshes are not supported by this gizmo
  121241. * @param mesh The mesh to replace the default mesh of the gizmo
  121242. */
  121243. setCustomMesh(mesh: Mesh): void;
  121244. }
  121245. }
  121246. declare module BABYLON {
  121247. /**
  121248. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121249. */
  121250. export class GizmoManager implements IDisposable {
  121251. private scene;
  121252. /**
  121253. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121254. */
  121255. gizmos: {
  121256. positionGizmo: Nullable<PositionGizmo>;
  121257. rotationGizmo: Nullable<RotationGizmo>;
  121258. scaleGizmo: Nullable<ScaleGizmo>;
  121259. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121260. };
  121261. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121262. clearGizmoOnEmptyPointerEvent: boolean;
  121263. /** Fires an event when the manager is attached to a mesh */
  121264. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121265. private _gizmosEnabled;
  121266. private _pointerObserver;
  121267. private _attachedMesh;
  121268. private _boundingBoxColor;
  121269. private _defaultUtilityLayer;
  121270. private _defaultKeepDepthUtilityLayer;
  121271. /**
  121272. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121273. */
  121274. boundingBoxDragBehavior: SixDofDragBehavior;
  121275. /**
  121276. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121277. */
  121278. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121279. /**
  121280. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121281. */
  121282. usePointerToAttachGizmos: boolean;
  121283. /**
  121284. * Utility layer that the bounding box gizmo belongs to
  121285. */
  121286. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121287. /**
  121288. * Utility layer that all gizmos besides bounding box belong to
  121289. */
  121290. get utilityLayer(): UtilityLayerRenderer;
  121291. /**
  121292. * Instatiates a gizmo manager
  121293. * @param scene the scene to overlay the gizmos on top of
  121294. */
  121295. constructor(scene: Scene);
  121296. /**
  121297. * Attaches a set of gizmos to the specified mesh
  121298. * @param mesh The mesh the gizmo's should be attached to
  121299. */
  121300. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121301. /**
  121302. * If the position gizmo is enabled
  121303. */
  121304. set positionGizmoEnabled(value: boolean);
  121305. get positionGizmoEnabled(): boolean;
  121306. /**
  121307. * If the rotation gizmo is enabled
  121308. */
  121309. set rotationGizmoEnabled(value: boolean);
  121310. get rotationGizmoEnabled(): boolean;
  121311. /**
  121312. * If the scale gizmo is enabled
  121313. */
  121314. set scaleGizmoEnabled(value: boolean);
  121315. get scaleGizmoEnabled(): boolean;
  121316. /**
  121317. * If the boundingBox gizmo is enabled
  121318. */
  121319. set boundingBoxGizmoEnabled(value: boolean);
  121320. get boundingBoxGizmoEnabled(): boolean;
  121321. /**
  121322. * Disposes of the gizmo manager
  121323. */
  121324. dispose(): void;
  121325. }
  121326. }
  121327. declare module BABYLON {
  121328. /**
  121329. * A directional light is defined by a direction (what a surprise!).
  121330. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121331. * 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.
  121332. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121333. */
  121334. export class DirectionalLight extends ShadowLight {
  121335. private _shadowFrustumSize;
  121336. /**
  121337. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121338. */
  121339. get shadowFrustumSize(): number;
  121340. /**
  121341. * Specifies a fix frustum size for the shadow generation.
  121342. */
  121343. set shadowFrustumSize(value: number);
  121344. private _shadowOrthoScale;
  121345. /**
  121346. * Gets the shadow projection scale against the optimal computed one.
  121347. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121348. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121349. */
  121350. get shadowOrthoScale(): number;
  121351. /**
  121352. * Sets the shadow projection scale against the optimal computed one.
  121353. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121354. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121355. */
  121356. set shadowOrthoScale(value: number);
  121357. /**
  121358. * Automatically compute the projection matrix to best fit (including all the casters)
  121359. * on each frame.
  121360. */
  121361. autoUpdateExtends: boolean;
  121362. /**
  121363. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121364. * on each frame. autoUpdateExtends must be set to true for this to work
  121365. */
  121366. autoCalcShadowZBounds: boolean;
  121367. private _orthoLeft;
  121368. private _orthoRight;
  121369. private _orthoTop;
  121370. private _orthoBottom;
  121371. /**
  121372. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121373. * The directional light is emitted from everywhere in the given direction.
  121374. * It can cast shadows.
  121375. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121376. * @param name The friendly name of the light
  121377. * @param direction The direction of the light
  121378. * @param scene The scene the light belongs to
  121379. */
  121380. constructor(name: string, direction: Vector3, scene: Scene);
  121381. /**
  121382. * Returns the string "DirectionalLight".
  121383. * @return The class name
  121384. */
  121385. getClassName(): string;
  121386. /**
  121387. * Returns the integer 1.
  121388. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121389. */
  121390. getTypeID(): number;
  121391. /**
  121392. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121393. * Returns the DirectionalLight Shadow projection matrix.
  121394. */
  121395. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121396. /**
  121397. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121398. * Returns the DirectionalLight Shadow projection matrix.
  121399. */
  121400. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121401. /**
  121402. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121403. * Returns the DirectionalLight Shadow projection matrix.
  121404. */
  121405. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121406. protected _buildUniformLayout(): void;
  121407. /**
  121408. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  121409. * @param effect The effect to update
  121410. * @param lightIndex The index of the light in the effect to update
  121411. * @returns The directional light
  121412. */
  121413. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  121414. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  121415. /**
  121416. * Gets the minZ used for shadow according to both the scene and the light.
  121417. *
  121418. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121419. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121420. * @param activeCamera The camera we are returning the min for
  121421. * @returns the depth min z
  121422. */
  121423. getDepthMinZ(activeCamera: Camera): number;
  121424. /**
  121425. * Gets the maxZ used for shadow according to both the scene and the light.
  121426. *
  121427. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121428. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121429. * @param activeCamera The camera we are returning the max for
  121430. * @returns the depth max z
  121431. */
  121432. getDepthMaxZ(activeCamera: Camera): number;
  121433. /**
  121434. * Prepares the list of defines specific to the light type.
  121435. * @param defines the list of defines
  121436. * @param lightIndex defines the index of the light for the effect
  121437. */
  121438. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121439. }
  121440. }
  121441. declare module BABYLON {
  121442. /**
  121443. * Class containing static functions to help procedurally build meshes
  121444. */
  121445. export class HemisphereBuilder {
  121446. /**
  121447. * Creates a hemisphere mesh
  121448. * @param name defines the name of the mesh
  121449. * @param options defines the options used to create the mesh
  121450. * @param scene defines the hosting scene
  121451. * @returns the hemisphere mesh
  121452. */
  121453. static CreateHemisphere(name: string, options: {
  121454. segments?: number;
  121455. diameter?: number;
  121456. sideOrientation?: number;
  121457. }, scene: any): Mesh;
  121458. }
  121459. }
  121460. declare module BABYLON {
  121461. /**
  121462. * A spot light is defined by a position, a direction, an angle, and an exponent.
  121463. * These values define a cone of light starting from the position, emitting toward the direction.
  121464. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  121465. * and the exponent defines the speed of the decay of the light with distance (reach).
  121466. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121467. */
  121468. export class SpotLight extends ShadowLight {
  121469. private _angle;
  121470. private _innerAngle;
  121471. private _cosHalfAngle;
  121472. private _lightAngleScale;
  121473. private _lightAngleOffset;
  121474. /**
  121475. * Gets the cone angle of the spot light in Radians.
  121476. */
  121477. get angle(): number;
  121478. /**
  121479. * Sets the cone angle of the spot light in Radians.
  121480. */
  121481. set angle(value: number);
  121482. /**
  121483. * Only used in gltf falloff mode, this defines the angle where
  121484. * the directional falloff will start before cutting at angle which could be seen
  121485. * as outer angle.
  121486. */
  121487. get innerAngle(): number;
  121488. /**
  121489. * Only used in gltf falloff mode, this defines the angle where
  121490. * the directional falloff will start before cutting at angle which could be seen
  121491. * as outer angle.
  121492. */
  121493. set innerAngle(value: number);
  121494. private _shadowAngleScale;
  121495. /**
  121496. * Allows scaling the angle of the light for shadow generation only.
  121497. */
  121498. get shadowAngleScale(): number;
  121499. /**
  121500. * Allows scaling the angle of the light for shadow generation only.
  121501. */
  121502. set shadowAngleScale(value: number);
  121503. /**
  121504. * The light decay speed with the distance from the emission spot.
  121505. */
  121506. exponent: number;
  121507. private _projectionTextureMatrix;
  121508. /**
  121509. * Allows reading the projecton texture
  121510. */
  121511. get projectionTextureMatrix(): Matrix;
  121512. protected _projectionTextureLightNear: number;
  121513. /**
  121514. * Gets the near clip of the Spotlight for texture projection.
  121515. */
  121516. get projectionTextureLightNear(): number;
  121517. /**
  121518. * Sets the near clip of the Spotlight for texture projection.
  121519. */
  121520. set projectionTextureLightNear(value: number);
  121521. protected _projectionTextureLightFar: number;
  121522. /**
  121523. * Gets the far clip of the Spotlight for texture projection.
  121524. */
  121525. get projectionTextureLightFar(): number;
  121526. /**
  121527. * Sets the far clip of the Spotlight for texture projection.
  121528. */
  121529. set projectionTextureLightFar(value: number);
  121530. protected _projectionTextureUpDirection: Vector3;
  121531. /**
  121532. * Gets the Up vector of the Spotlight for texture projection.
  121533. */
  121534. get projectionTextureUpDirection(): Vector3;
  121535. /**
  121536. * Sets the Up vector of the Spotlight for texture projection.
  121537. */
  121538. set projectionTextureUpDirection(value: Vector3);
  121539. private _projectionTexture;
  121540. /**
  121541. * Gets the projection texture of the light.
  121542. */
  121543. get projectionTexture(): Nullable<BaseTexture>;
  121544. /**
  121545. * Sets the projection texture of the light.
  121546. */
  121547. set projectionTexture(value: Nullable<BaseTexture>);
  121548. private _projectionTextureViewLightDirty;
  121549. private _projectionTextureProjectionLightDirty;
  121550. private _projectionTextureDirty;
  121551. private _projectionTextureViewTargetVector;
  121552. private _projectionTextureViewLightMatrix;
  121553. private _projectionTextureProjectionLightMatrix;
  121554. private _projectionTextureScalingMatrix;
  121555. /**
  121556. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  121557. * It can cast shadows.
  121558. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121559. * @param name The light friendly name
  121560. * @param position The position of the spot light in the scene
  121561. * @param direction The direction of the light in the scene
  121562. * @param angle The cone angle of the light in Radians
  121563. * @param exponent The light decay speed with the distance from the emission spot
  121564. * @param scene The scene the lights belongs to
  121565. */
  121566. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  121567. /**
  121568. * Returns the string "SpotLight".
  121569. * @returns the class name
  121570. */
  121571. getClassName(): string;
  121572. /**
  121573. * Returns the integer 2.
  121574. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121575. */
  121576. getTypeID(): number;
  121577. /**
  121578. * Overrides the direction setter to recompute the projection texture view light Matrix.
  121579. */
  121580. protected _setDirection(value: Vector3): void;
  121581. /**
  121582. * Overrides the position setter to recompute the projection texture view light Matrix.
  121583. */
  121584. protected _setPosition(value: Vector3): void;
  121585. /**
  121586. * 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.
  121587. * Returns the SpotLight.
  121588. */
  121589. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121590. protected _computeProjectionTextureViewLightMatrix(): void;
  121591. protected _computeProjectionTextureProjectionLightMatrix(): void;
  121592. /**
  121593. * Main function for light texture projection matrix computing.
  121594. */
  121595. protected _computeProjectionTextureMatrix(): void;
  121596. protected _buildUniformLayout(): void;
  121597. private _computeAngleValues;
  121598. /**
  121599. * Sets the passed Effect "effect" with the Light textures.
  121600. * @param effect The effect to update
  121601. * @param lightIndex The index of the light in the effect to update
  121602. * @returns The light
  121603. */
  121604. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  121605. /**
  121606. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  121607. * @param effect The effect to update
  121608. * @param lightIndex The index of the light in the effect to update
  121609. * @returns The spot light
  121610. */
  121611. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  121612. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  121613. /**
  121614. * Disposes the light and the associated resources.
  121615. */
  121616. dispose(): void;
  121617. /**
  121618. * Prepares the list of defines specific to the light type.
  121619. * @param defines the list of defines
  121620. * @param lightIndex defines the index of the light for the effect
  121621. */
  121622. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121623. }
  121624. }
  121625. declare module BABYLON {
  121626. /**
  121627. * Gizmo that enables viewing a light
  121628. */
  121629. export class LightGizmo extends Gizmo {
  121630. private _lightMesh;
  121631. private _material;
  121632. private _cachedPosition;
  121633. private _cachedForward;
  121634. private _attachedMeshParent;
  121635. /**
  121636. * Creates a LightGizmo
  121637. * @param gizmoLayer The utility layer the gizmo will be added to
  121638. */
  121639. constructor(gizmoLayer?: UtilityLayerRenderer);
  121640. private _light;
  121641. /**
  121642. * The light that the gizmo is attached to
  121643. */
  121644. set light(light: Nullable<Light>);
  121645. get light(): Nullable<Light>;
  121646. /**
  121647. * Gets the material used to render the light gizmo
  121648. */
  121649. get material(): StandardMaterial;
  121650. /**
  121651. * @hidden
  121652. * Updates the gizmo to match the attached mesh's position/rotation
  121653. */
  121654. protected _update(): void;
  121655. private static _Scale;
  121656. /**
  121657. * Creates the lines for a light mesh
  121658. */
  121659. private static _CreateLightLines;
  121660. /**
  121661. * Disposes of the light gizmo
  121662. */
  121663. dispose(): void;
  121664. private static _CreateHemisphericLightMesh;
  121665. private static _CreatePointLightMesh;
  121666. private static _CreateSpotLightMesh;
  121667. private static _CreateDirectionalLightMesh;
  121668. }
  121669. }
  121670. declare module BABYLON {
  121671. /** @hidden */
  121672. export var backgroundFragmentDeclaration: {
  121673. name: string;
  121674. shader: string;
  121675. };
  121676. }
  121677. declare module BABYLON {
  121678. /** @hidden */
  121679. export var backgroundUboDeclaration: {
  121680. name: string;
  121681. shader: string;
  121682. };
  121683. }
  121684. declare module BABYLON {
  121685. /** @hidden */
  121686. export var backgroundPixelShader: {
  121687. name: string;
  121688. shader: string;
  121689. };
  121690. }
  121691. declare module BABYLON {
  121692. /** @hidden */
  121693. export var backgroundVertexDeclaration: {
  121694. name: string;
  121695. shader: string;
  121696. };
  121697. }
  121698. declare module BABYLON {
  121699. /** @hidden */
  121700. export var backgroundVertexShader: {
  121701. name: string;
  121702. shader: string;
  121703. };
  121704. }
  121705. declare module BABYLON {
  121706. /**
  121707. * Background material used to create an efficient environement around your scene.
  121708. */
  121709. export class BackgroundMaterial extends PushMaterial {
  121710. /**
  121711. * Standard reflectance value at parallel view angle.
  121712. */
  121713. static StandardReflectance0: number;
  121714. /**
  121715. * Standard reflectance value at grazing angle.
  121716. */
  121717. static StandardReflectance90: number;
  121718. protected _primaryColor: Color3;
  121719. /**
  121720. * Key light Color (multiply against the environement texture)
  121721. */
  121722. primaryColor: Color3;
  121723. protected __perceptualColor: Nullable<Color3>;
  121724. /**
  121725. * Experimental Internal Use Only.
  121726. *
  121727. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  121728. * This acts as a helper to set the primary color to a more "human friendly" value.
  121729. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  121730. * output color as close as possible from the chosen value.
  121731. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  121732. * part of lighting setup.)
  121733. */
  121734. get _perceptualColor(): Nullable<Color3>;
  121735. set _perceptualColor(value: Nullable<Color3>);
  121736. protected _primaryColorShadowLevel: float;
  121737. /**
  121738. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  121739. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  121740. */
  121741. get primaryColorShadowLevel(): float;
  121742. set primaryColorShadowLevel(value: float);
  121743. protected _primaryColorHighlightLevel: float;
  121744. /**
  121745. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  121746. * The primary color is used at the level chosen to define what the white area would look.
  121747. */
  121748. get primaryColorHighlightLevel(): float;
  121749. set primaryColorHighlightLevel(value: float);
  121750. protected _reflectionTexture: Nullable<BaseTexture>;
  121751. /**
  121752. * Reflection Texture used in the material.
  121753. * Should be author in a specific way for the best result (refer to the documentation).
  121754. */
  121755. reflectionTexture: Nullable<BaseTexture>;
  121756. protected _reflectionBlur: float;
  121757. /**
  121758. * Reflection Texture level of blur.
  121759. *
  121760. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  121761. * texture twice.
  121762. */
  121763. reflectionBlur: float;
  121764. protected _diffuseTexture: Nullable<BaseTexture>;
  121765. /**
  121766. * Diffuse Texture used in the material.
  121767. * Should be author in a specific way for the best result (refer to the documentation).
  121768. */
  121769. diffuseTexture: Nullable<BaseTexture>;
  121770. protected _shadowLights: Nullable<IShadowLight[]>;
  121771. /**
  121772. * Specify the list of lights casting shadow on the material.
  121773. * All scene shadow lights will be included if null.
  121774. */
  121775. shadowLights: Nullable<IShadowLight[]>;
  121776. protected _shadowLevel: float;
  121777. /**
  121778. * Helps adjusting the shadow to a softer level if required.
  121779. * 0 means black shadows and 1 means no shadows.
  121780. */
  121781. shadowLevel: float;
  121782. protected _sceneCenter: Vector3;
  121783. /**
  121784. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  121785. * It is usually zero but might be interesting to modify according to your setup.
  121786. */
  121787. sceneCenter: Vector3;
  121788. protected _opacityFresnel: boolean;
  121789. /**
  121790. * This helps specifying that the material is falling off to the sky box at grazing angle.
  121791. * This helps ensuring a nice transition when the camera goes under the ground.
  121792. */
  121793. opacityFresnel: boolean;
  121794. protected _reflectionFresnel: boolean;
  121795. /**
  121796. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  121797. * This helps adding a mirror texture on the ground.
  121798. */
  121799. reflectionFresnel: boolean;
  121800. protected _reflectionFalloffDistance: number;
  121801. /**
  121802. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  121803. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  121804. */
  121805. reflectionFalloffDistance: number;
  121806. protected _reflectionAmount: number;
  121807. /**
  121808. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  121809. */
  121810. reflectionAmount: number;
  121811. protected _reflectionReflectance0: number;
  121812. /**
  121813. * This specifies the weight of the reflection at grazing angle.
  121814. */
  121815. reflectionReflectance0: number;
  121816. protected _reflectionReflectance90: number;
  121817. /**
  121818. * This specifies the weight of the reflection at a perpendicular point of view.
  121819. */
  121820. reflectionReflectance90: number;
  121821. /**
  121822. * Sets the reflection reflectance fresnel values according to the default standard
  121823. * empirically know to work well :-)
  121824. */
  121825. set reflectionStandardFresnelWeight(value: number);
  121826. protected _useRGBColor: boolean;
  121827. /**
  121828. * Helps to directly use the maps channels instead of their level.
  121829. */
  121830. useRGBColor: boolean;
  121831. protected _enableNoise: boolean;
  121832. /**
  121833. * This helps reducing the banding effect that could occur on the background.
  121834. */
  121835. enableNoise: boolean;
  121836. /**
  121837. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121838. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  121839. * Recommended to be keep at 1.0 except for special cases.
  121840. */
  121841. get fovMultiplier(): number;
  121842. set fovMultiplier(value: number);
  121843. private _fovMultiplier;
  121844. /**
  121845. * Enable the FOV adjustment feature controlled by fovMultiplier.
  121846. */
  121847. useEquirectangularFOV: boolean;
  121848. private _maxSimultaneousLights;
  121849. /**
  121850. * Number of Simultaneous lights allowed on the material.
  121851. */
  121852. maxSimultaneousLights: int;
  121853. /**
  121854. * Default configuration related to image processing available in the Background Material.
  121855. */
  121856. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121857. /**
  121858. * Keep track of the image processing observer to allow dispose and replace.
  121859. */
  121860. private _imageProcessingObserver;
  121861. /**
  121862. * Attaches a new image processing configuration to the PBR Material.
  121863. * @param configuration (if null the scene configuration will be use)
  121864. */
  121865. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121866. /**
  121867. * Gets the image processing configuration used either in this material.
  121868. */
  121869. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  121870. /**
  121871. * Sets the Default image processing configuration used either in the this material.
  121872. *
  121873. * If sets to null, the scene one is in use.
  121874. */
  121875. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  121876. /**
  121877. * Gets wether the color curves effect is enabled.
  121878. */
  121879. get cameraColorCurvesEnabled(): boolean;
  121880. /**
  121881. * Sets wether the color curves effect is enabled.
  121882. */
  121883. set cameraColorCurvesEnabled(value: boolean);
  121884. /**
  121885. * Gets wether the color grading effect is enabled.
  121886. */
  121887. get cameraColorGradingEnabled(): boolean;
  121888. /**
  121889. * Gets wether the color grading effect is enabled.
  121890. */
  121891. set cameraColorGradingEnabled(value: boolean);
  121892. /**
  121893. * Gets wether tonemapping is enabled or not.
  121894. */
  121895. get cameraToneMappingEnabled(): boolean;
  121896. /**
  121897. * Sets wether tonemapping is enabled or not
  121898. */
  121899. set cameraToneMappingEnabled(value: boolean);
  121900. /**
  121901. * The camera exposure used on this material.
  121902. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121903. * This corresponds to a photographic exposure.
  121904. */
  121905. get cameraExposure(): float;
  121906. /**
  121907. * The camera exposure used on this material.
  121908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121909. * This corresponds to a photographic exposure.
  121910. */
  121911. set cameraExposure(value: float);
  121912. /**
  121913. * Gets The camera contrast used on this material.
  121914. */
  121915. get cameraContrast(): float;
  121916. /**
  121917. * Sets The camera contrast used on this material.
  121918. */
  121919. set cameraContrast(value: float);
  121920. /**
  121921. * Gets the Color Grading 2D Lookup Texture.
  121922. */
  121923. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121924. /**
  121925. * Sets the Color Grading 2D Lookup Texture.
  121926. */
  121927. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121928. /**
  121929. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121930. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121931. * 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;
  121932. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121933. */
  121934. get cameraColorCurves(): Nullable<ColorCurves>;
  121935. /**
  121936. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121937. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121938. * 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;
  121939. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121940. */
  121941. set cameraColorCurves(value: Nullable<ColorCurves>);
  121942. /**
  121943. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  121944. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  121945. */
  121946. switchToBGR: boolean;
  121947. private _renderTargets;
  121948. private _reflectionControls;
  121949. private _white;
  121950. private _primaryShadowColor;
  121951. private _primaryHighlightColor;
  121952. /**
  121953. * Instantiates a Background Material in the given scene
  121954. * @param name The friendly name of the material
  121955. * @param scene The scene to add the material to
  121956. */
  121957. constructor(name: string, scene: Scene);
  121958. /**
  121959. * Gets a boolean indicating that current material needs to register RTT
  121960. */
  121961. get hasRenderTargetTextures(): boolean;
  121962. /**
  121963. * The entire material has been created in order to prevent overdraw.
  121964. * @returns false
  121965. */
  121966. needAlphaTesting(): boolean;
  121967. /**
  121968. * The entire material has been created in order to prevent overdraw.
  121969. * @returns true if blending is enable
  121970. */
  121971. needAlphaBlending(): boolean;
  121972. /**
  121973. * Checks wether the material is ready to be rendered for a given mesh.
  121974. * @param mesh The mesh to render
  121975. * @param subMesh The submesh to check against
  121976. * @param useInstances Specify wether or not the material is used with instances
  121977. * @returns true if all the dependencies are ready (Textures, Effects...)
  121978. */
  121979. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121980. /**
  121981. * Compute the primary color according to the chosen perceptual color.
  121982. */
  121983. private _computePrimaryColorFromPerceptualColor;
  121984. /**
  121985. * Compute the highlights and shadow colors according to their chosen levels.
  121986. */
  121987. private _computePrimaryColors;
  121988. /**
  121989. * Build the uniform buffer used in the material.
  121990. */
  121991. buildUniformLayout(): void;
  121992. /**
  121993. * Unbind the material.
  121994. */
  121995. unbind(): void;
  121996. /**
  121997. * Bind only the world matrix to the material.
  121998. * @param world The world matrix to bind.
  121999. */
  122000. bindOnlyWorldMatrix(world: Matrix): void;
  122001. /**
  122002. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122003. * @param world The world matrix to bind.
  122004. * @param subMesh The submesh to bind for.
  122005. */
  122006. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122007. /**
  122008. * Checks to see if a texture is used in the material.
  122009. * @param texture - Base texture to use.
  122010. * @returns - Boolean specifying if a texture is used in the material.
  122011. */
  122012. hasTexture(texture: BaseTexture): boolean;
  122013. /**
  122014. * Dispose the material.
  122015. * @param forceDisposeEffect Force disposal of the associated effect.
  122016. * @param forceDisposeTextures Force disposal of the associated textures.
  122017. */
  122018. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122019. /**
  122020. * Clones the material.
  122021. * @param name The cloned name.
  122022. * @returns The cloned material.
  122023. */
  122024. clone(name: string): BackgroundMaterial;
  122025. /**
  122026. * Serializes the current material to its JSON representation.
  122027. * @returns The JSON representation.
  122028. */
  122029. serialize(): any;
  122030. /**
  122031. * Gets the class name of the material
  122032. * @returns "BackgroundMaterial"
  122033. */
  122034. getClassName(): string;
  122035. /**
  122036. * Parse a JSON input to create back a background material.
  122037. * @param source The JSON data to parse
  122038. * @param scene The scene to create the parsed material in
  122039. * @param rootUrl The root url of the assets the material depends upon
  122040. * @returns the instantiated BackgroundMaterial.
  122041. */
  122042. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122043. }
  122044. }
  122045. declare module BABYLON {
  122046. /**
  122047. * Represents the different options available during the creation of
  122048. * a Environment helper.
  122049. *
  122050. * This can control the default ground, skybox and image processing setup of your scene.
  122051. */
  122052. export interface IEnvironmentHelperOptions {
  122053. /**
  122054. * Specifies wether or not to create a ground.
  122055. * True by default.
  122056. */
  122057. createGround: boolean;
  122058. /**
  122059. * Specifies the ground size.
  122060. * 15 by default.
  122061. */
  122062. groundSize: number;
  122063. /**
  122064. * The texture used on the ground for the main color.
  122065. * Comes from the BabylonJS CDN by default.
  122066. *
  122067. * Remarks: Can be either a texture or a url.
  122068. */
  122069. groundTexture: string | BaseTexture;
  122070. /**
  122071. * The color mixed in the ground texture by default.
  122072. * BabylonJS clearColor by default.
  122073. */
  122074. groundColor: Color3;
  122075. /**
  122076. * Specifies the ground opacity.
  122077. * 1 by default.
  122078. */
  122079. groundOpacity: number;
  122080. /**
  122081. * Enables the ground to receive shadows.
  122082. * True by default.
  122083. */
  122084. enableGroundShadow: boolean;
  122085. /**
  122086. * Helps preventing the shadow to be fully black on the ground.
  122087. * 0.5 by default.
  122088. */
  122089. groundShadowLevel: number;
  122090. /**
  122091. * Creates a mirror texture attach to the ground.
  122092. * false by default.
  122093. */
  122094. enableGroundMirror: boolean;
  122095. /**
  122096. * Specifies the ground mirror size ratio.
  122097. * 0.3 by default as the default kernel is 64.
  122098. */
  122099. groundMirrorSizeRatio: number;
  122100. /**
  122101. * Specifies the ground mirror blur kernel size.
  122102. * 64 by default.
  122103. */
  122104. groundMirrorBlurKernel: number;
  122105. /**
  122106. * Specifies the ground mirror visibility amount.
  122107. * 1 by default
  122108. */
  122109. groundMirrorAmount: number;
  122110. /**
  122111. * Specifies the ground mirror reflectance weight.
  122112. * This uses the standard weight of the background material to setup the fresnel effect
  122113. * of the mirror.
  122114. * 1 by default.
  122115. */
  122116. groundMirrorFresnelWeight: number;
  122117. /**
  122118. * Specifies the ground mirror Falloff distance.
  122119. * This can helps reducing the size of the reflection.
  122120. * 0 by Default.
  122121. */
  122122. groundMirrorFallOffDistance: number;
  122123. /**
  122124. * Specifies the ground mirror texture type.
  122125. * Unsigned Int by Default.
  122126. */
  122127. groundMirrorTextureType: number;
  122128. /**
  122129. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122130. * the shown objects.
  122131. */
  122132. groundYBias: number;
  122133. /**
  122134. * Specifies wether or not to create a skybox.
  122135. * True by default.
  122136. */
  122137. createSkybox: boolean;
  122138. /**
  122139. * Specifies the skybox size.
  122140. * 20 by default.
  122141. */
  122142. skyboxSize: number;
  122143. /**
  122144. * The texture used on the skybox for the main color.
  122145. * Comes from the BabylonJS CDN by default.
  122146. *
  122147. * Remarks: Can be either a texture or a url.
  122148. */
  122149. skyboxTexture: string | BaseTexture;
  122150. /**
  122151. * The color mixed in the skybox texture by default.
  122152. * BabylonJS clearColor by default.
  122153. */
  122154. skyboxColor: Color3;
  122155. /**
  122156. * The background rotation around the Y axis of the scene.
  122157. * This helps aligning the key lights of your scene with the background.
  122158. * 0 by default.
  122159. */
  122160. backgroundYRotation: number;
  122161. /**
  122162. * Compute automatically the size of the elements to best fit with the scene.
  122163. */
  122164. sizeAuto: boolean;
  122165. /**
  122166. * Default position of the rootMesh if autoSize is not true.
  122167. */
  122168. rootPosition: Vector3;
  122169. /**
  122170. * Sets up the image processing in the scene.
  122171. * true by default.
  122172. */
  122173. setupImageProcessing: boolean;
  122174. /**
  122175. * The texture used as your environment texture in the scene.
  122176. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122177. *
  122178. * Remarks: Can be either a texture or a url.
  122179. */
  122180. environmentTexture: string | BaseTexture;
  122181. /**
  122182. * The value of the exposure to apply to the scene.
  122183. * 0.6 by default if setupImageProcessing is true.
  122184. */
  122185. cameraExposure: number;
  122186. /**
  122187. * The value of the contrast to apply to the scene.
  122188. * 1.6 by default if setupImageProcessing is true.
  122189. */
  122190. cameraContrast: number;
  122191. /**
  122192. * Specifies wether or not tonemapping should be enabled in the scene.
  122193. * true by default if setupImageProcessing is true.
  122194. */
  122195. toneMappingEnabled: boolean;
  122196. }
  122197. /**
  122198. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122199. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122200. * It also helps with the default setup of your imageProcessing configuration.
  122201. */
  122202. export class EnvironmentHelper {
  122203. /**
  122204. * Default ground texture URL.
  122205. */
  122206. private static _groundTextureCDNUrl;
  122207. /**
  122208. * Default skybox texture URL.
  122209. */
  122210. private static _skyboxTextureCDNUrl;
  122211. /**
  122212. * Default environment texture URL.
  122213. */
  122214. private static _environmentTextureCDNUrl;
  122215. /**
  122216. * Creates the default options for the helper.
  122217. */
  122218. private static _getDefaultOptions;
  122219. private _rootMesh;
  122220. /**
  122221. * Gets the root mesh created by the helper.
  122222. */
  122223. get rootMesh(): Mesh;
  122224. private _skybox;
  122225. /**
  122226. * Gets the skybox created by the helper.
  122227. */
  122228. get skybox(): Nullable<Mesh>;
  122229. private _skyboxTexture;
  122230. /**
  122231. * Gets the skybox texture created by the helper.
  122232. */
  122233. get skyboxTexture(): Nullable<BaseTexture>;
  122234. private _skyboxMaterial;
  122235. /**
  122236. * Gets the skybox material created by the helper.
  122237. */
  122238. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122239. private _ground;
  122240. /**
  122241. * Gets the ground mesh created by the helper.
  122242. */
  122243. get ground(): Nullable<Mesh>;
  122244. private _groundTexture;
  122245. /**
  122246. * Gets the ground texture created by the helper.
  122247. */
  122248. get groundTexture(): Nullable<BaseTexture>;
  122249. private _groundMirror;
  122250. /**
  122251. * Gets the ground mirror created by the helper.
  122252. */
  122253. get groundMirror(): Nullable<MirrorTexture>;
  122254. /**
  122255. * Gets the ground mirror render list to helps pushing the meshes
  122256. * you wish in the ground reflection.
  122257. */
  122258. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122259. private _groundMaterial;
  122260. /**
  122261. * Gets the ground material created by the helper.
  122262. */
  122263. get groundMaterial(): Nullable<BackgroundMaterial>;
  122264. /**
  122265. * Stores the creation options.
  122266. */
  122267. private readonly _scene;
  122268. private _options;
  122269. /**
  122270. * This observable will be notified with any error during the creation of the environment,
  122271. * mainly texture creation errors.
  122272. */
  122273. onErrorObservable: Observable<{
  122274. message?: string;
  122275. exception?: any;
  122276. }>;
  122277. /**
  122278. * constructor
  122279. * @param options Defines the options we want to customize the helper
  122280. * @param scene The scene to add the material to
  122281. */
  122282. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122283. /**
  122284. * Updates the background according to the new options
  122285. * @param options
  122286. */
  122287. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122288. /**
  122289. * Sets the primary color of all the available elements.
  122290. * @param color the main color to affect to the ground and the background
  122291. */
  122292. setMainColor(color: Color3): void;
  122293. /**
  122294. * Setup the image processing according to the specified options.
  122295. */
  122296. private _setupImageProcessing;
  122297. /**
  122298. * Setup the environment texture according to the specified options.
  122299. */
  122300. private _setupEnvironmentTexture;
  122301. /**
  122302. * Setup the background according to the specified options.
  122303. */
  122304. private _setupBackground;
  122305. /**
  122306. * Get the scene sizes according to the setup.
  122307. */
  122308. private _getSceneSize;
  122309. /**
  122310. * Setup the ground according to the specified options.
  122311. */
  122312. private _setupGround;
  122313. /**
  122314. * Setup the ground material according to the specified options.
  122315. */
  122316. private _setupGroundMaterial;
  122317. /**
  122318. * Setup the ground diffuse texture according to the specified options.
  122319. */
  122320. private _setupGroundDiffuseTexture;
  122321. /**
  122322. * Setup the ground mirror texture according to the specified options.
  122323. */
  122324. private _setupGroundMirrorTexture;
  122325. /**
  122326. * Setup the ground to receive the mirror texture.
  122327. */
  122328. private _setupMirrorInGroundMaterial;
  122329. /**
  122330. * Setup the skybox according to the specified options.
  122331. */
  122332. private _setupSkybox;
  122333. /**
  122334. * Setup the skybox material according to the specified options.
  122335. */
  122336. private _setupSkyboxMaterial;
  122337. /**
  122338. * Setup the skybox reflection texture according to the specified options.
  122339. */
  122340. private _setupSkyboxReflectionTexture;
  122341. private _errorHandler;
  122342. /**
  122343. * Dispose all the elements created by the Helper.
  122344. */
  122345. dispose(): void;
  122346. }
  122347. }
  122348. declare module BABYLON {
  122349. /**
  122350. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122351. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122352. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122353. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122354. */
  122355. export class PhotoDome extends TransformNode {
  122356. /**
  122357. * Define the image as a Monoscopic panoramic 360 image.
  122358. */
  122359. static readonly MODE_MONOSCOPIC: number;
  122360. /**
  122361. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122362. */
  122363. static readonly MODE_TOPBOTTOM: number;
  122364. /**
  122365. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122366. */
  122367. static readonly MODE_SIDEBYSIDE: number;
  122368. private _useDirectMapping;
  122369. /**
  122370. * The texture being displayed on the sphere
  122371. */
  122372. protected _photoTexture: Texture;
  122373. /**
  122374. * Gets or sets the texture being displayed on the sphere
  122375. */
  122376. get photoTexture(): Texture;
  122377. set photoTexture(value: Texture);
  122378. /**
  122379. * Observable raised when an error occured while loading the 360 image
  122380. */
  122381. onLoadErrorObservable: Observable<string>;
  122382. /**
  122383. * The skybox material
  122384. */
  122385. protected _material: BackgroundMaterial;
  122386. /**
  122387. * The surface used for the skybox
  122388. */
  122389. protected _mesh: Mesh;
  122390. /**
  122391. * Gets the mesh used for the skybox.
  122392. */
  122393. get mesh(): Mesh;
  122394. /**
  122395. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122396. * Also see the options.resolution property.
  122397. */
  122398. get fovMultiplier(): number;
  122399. set fovMultiplier(value: number);
  122400. private _imageMode;
  122401. /**
  122402. * Gets or set the current video mode for the video. It can be:
  122403. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122404. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122405. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122406. */
  122407. get imageMode(): number;
  122408. set imageMode(value: number);
  122409. /**
  122410. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  122411. * @param name Element's name, child elements will append suffixes for their own names.
  122412. * @param urlsOfPhoto defines the url of the photo to display
  122413. * @param options defines an object containing optional or exposed sub element properties
  122414. * @param onError defines a callback called when an error occured while loading the texture
  122415. */
  122416. constructor(name: string, urlOfPhoto: string, options: {
  122417. resolution?: number;
  122418. size?: number;
  122419. useDirectMapping?: boolean;
  122420. faceForward?: boolean;
  122421. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  122422. private _onBeforeCameraRenderObserver;
  122423. private _changeImageMode;
  122424. /**
  122425. * Releases resources associated with this node.
  122426. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122427. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122428. */
  122429. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122430. }
  122431. }
  122432. declare module BABYLON {
  122433. /**
  122434. * Class used to host RGBD texture specific utilities
  122435. */
  122436. export class RGBDTextureTools {
  122437. /**
  122438. * Expand the RGBD Texture from RGBD to Half Float if possible.
  122439. * @param texture the texture to expand.
  122440. */
  122441. static ExpandRGBDTexture(texture: Texture): void;
  122442. }
  122443. }
  122444. declare module BABYLON {
  122445. /**
  122446. * Class used to host texture specific utilities
  122447. */
  122448. export class BRDFTextureTools {
  122449. /**
  122450. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  122451. * @param scene defines the hosting scene
  122452. * @returns the environment BRDF texture
  122453. */
  122454. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  122455. private static _environmentBRDFBase64Texture;
  122456. }
  122457. }
  122458. declare module BABYLON {
  122459. /**
  122460. * @hidden
  122461. */
  122462. export interface IMaterialClearCoatDefines {
  122463. CLEARCOAT: boolean;
  122464. CLEARCOAT_DEFAULTIOR: boolean;
  122465. CLEARCOAT_TEXTURE: boolean;
  122466. CLEARCOAT_TEXTUREDIRECTUV: number;
  122467. CLEARCOAT_BUMP: boolean;
  122468. CLEARCOAT_BUMPDIRECTUV: number;
  122469. CLEARCOAT_TINT: boolean;
  122470. CLEARCOAT_TINT_TEXTURE: boolean;
  122471. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  122472. /** @hidden */
  122473. _areTexturesDirty: boolean;
  122474. }
  122475. /**
  122476. * Define the code related to the clear coat parameters of the pbr material.
  122477. */
  122478. export class PBRClearCoatConfiguration {
  122479. /**
  122480. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122481. * The default fits with a polyurethane material.
  122482. */
  122483. private static readonly _DefaultIndexOfRefraction;
  122484. private _isEnabled;
  122485. /**
  122486. * Defines if the clear coat is enabled in the material.
  122487. */
  122488. isEnabled: boolean;
  122489. /**
  122490. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  122491. */
  122492. intensity: number;
  122493. /**
  122494. * Defines the clear coat layer roughness.
  122495. */
  122496. roughness: number;
  122497. private _indexOfRefraction;
  122498. /**
  122499. * Defines the index of refraction of the clear coat.
  122500. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122501. * The default fits with a polyurethane material.
  122502. * Changing the default value is more performance intensive.
  122503. */
  122504. indexOfRefraction: number;
  122505. private _texture;
  122506. /**
  122507. * Stores the clear coat values in a texture.
  122508. */
  122509. texture: Nullable<BaseTexture>;
  122510. private _bumpTexture;
  122511. /**
  122512. * Define the clear coat specific bump texture.
  122513. */
  122514. bumpTexture: Nullable<BaseTexture>;
  122515. private _isTintEnabled;
  122516. /**
  122517. * Defines if the clear coat tint is enabled in the material.
  122518. */
  122519. isTintEnabled: boolean;
  122520. /**
  122521. * Defines the clear coat tint of the material.
  122522. * This is only use if tint is enabled
  122523. */
  122524. tintColor: Color3;
  122525. /**
  122526. * Defines the distance at which the tint color should be found in the
  122527. * clear coat media.
  122528. * This is only use if tint is enabled
  122529. */
  122530. tintColorAtDistance: number;
  122531. /**
  122532. * Defines the clear coat layer thickness.
  122533. * This is only use if tint is enabled
  122534. */
  122535. tintThickness: number;
  122536. private _tintTexture;
  122537. /**
  122538. * Stores the clear tint values in a texture.
  122539. * rgb is tint
  122540. * a is a thickness factor
  122541. */
  122542. tintTexture: Nullable<BaseTexture>;
  122543. /** @hidden */
  122544. private _internalMarkAllSubMeshesAsTexturesDirty;
  122545. /** @hidden */
  122546. _markAllSubMeshesAsTexturesDirty(): void;
  122547. /**
  122548. * Instantiate a new istance of clear coat configuration.
  122549. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122550. */
  122551. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122552. /**
  122553. * Gets wehter the submesh is ready to be used or not.
  122554. * @param defines the list of "defines" to update.
  122555. * @param scene defines the scene the material belongs to.
  122556. * @param engine defines the engine the material belongs to.
  122557. * @param disableBumpMap defines wether the material disables bump or not.
  122558. * @returns - boolean indicating that the submesh is ready or not.
  122559. */
  122560. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  122561. /**
  122562. * Checks to see if a texture is used in the material.
  122563. * @param defines the list of "defines" to update.
  122564. * @param scene defines the scene to the material belongs to.
  122565. */
  122566. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  122567. /**
  122568. * Binds the material data.
  122569. * @param uniformBuffer defines the Uniform buffer to fill in.
  122570. * @param scene defines the scene the material belongs to.
  122571. * @param engine defines the engine the material belongs to.
  122572. * @param disableBumpMap defines wether the material disables bump or not.
  122573. * @param isFrozen defines wether the material is frozen or not.
  122574. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  122575. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  122576. */
  122577. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  122578. /**
  122579. * Checks to see if a texture is used in the material.
  122580. * @param texture - Base texture to use.
  122581. * @returns - Boolean specifying if a texture is used in the material.
  122582. */
  122583. hasTexture(texture: BaseTexture): boolean;
  122584. /**
  122585. * Returns an array of the actively used textures.
  122586. * @param activeTextures Array of BaseTextures
  122587. */
  122588. getActiveTextures(activeTextures: BaseTexture[]): void;
  122589. /**
  122590. * Returns the animatable textures.
  122591. * @param animatables Array of animatable textures.
  122592. */
  122593. getAnimatables(animatables: IAnimatable[]): void;
  122594. /**
  122595. * Disposes the resources of the material.
  122596. * @param forceDisposeTextures - Forces the disposal of all textures.
  122597. */
  122598. dispose(forceDisposeTextures?: boolean): void;
  122599. /**
  122600. * Get the current class name of the texture useful for serialization or dynamic coding.
  122601. * @returns "PBRClearCoatConfiguration"
  122602. */
  122603. getClassName(): string;
  122604. /**
  122605. * Add fallbacks to the effect fallbacks list.
  122606. * @param defines defines the Base texture to use.
  122607. * @param fallbacks defines the current fallback list.
  122608. * @param currentRank defines the current fallback rank.
  122609. * @returns the new fallback rank.
  122610. */
  122611. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122612. /**
  122613. * Add the required uniforms to the current list.
  122614. * @param uniforms defines the current uniform list.
  122615. */
  122616. static AddUniforms(uniforms: string[]): void;
  122617. /**
  122618. * Add the required samplers to the current list.
  122619. * @param samplers defines the current sampler list.
  122620. */
  122621. static AddSamplers(samplers: string[]): void;
  122622. /**
  122623. * Add the required uniforms to the current buffer.
  122624. * @param uniformBuffer defines the current uniform buffer.
  122625. */
  122626. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122627. /**
  122628. * Makes a duplicate of the current configuration into another one.
  122629. * @param clearCoatConfiguration define the config where to copy the info
  122630. */
  122631. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  122632. /**
  122633. * Serializes this clear coat configuration.
  122634. * @returns - An object with the serialized config.
  122635. */
  122636. serialize(): any;
  122637. /**
  122638. * Parses a anisotropy Configuration from a serialized object.
  122639. * @param source - Serialized object.
  122640. * @param scene Defines the scene we are parsing for
  122641. * @param rootUrl Defines the rootUrl to load from
  122642. */
  122643. parse(source: any, scene: Scene, rootUrl: string): void;
  122644. }
  122645. }
  122646. declare module BABYLON {
  122647. /**
  122648. * @hidden
  122649. */
  122650. export interface IMaterialAnisotropicDefines {
  122651. ANISOTROPIC: boolean;
  122652. ANISOTROPIC_TEXTURE: boolean;
  122653. ANISOTROPIC_TEXTUREDIRECTUV: number;
  122654. MAINUV1: boolean;
  122655. _areTexturesDirty: boolean;
  122656. _needUVs: boolean;
  122657. }
  122658. /**
  122659. * Define the code related to the anisotropic parameters of the pbr material.
  122660. */
  122661. export class PBRAnisotropicConfiguration {
  122662. private _isEnabled;
  122663. /**
  122664. * Defines if the anisotropy is enabled in the material.
  122665. */
  122666. isEnabled: boolean;
  122667. /**
  122668. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  122669. */
  122670. intensity: number;
  122671. /**
  122672. * Defines if the effect is along the tangents, bitangents or in between.
  122673. * By default, the effect is "strectching" the highlights along the tangents.
  122674. */
  122675. direction: Vector2;
  122676. private _texture;
  122677. /**
  122678. * Stores the anisotropy values in a texture.
  122679. * rg is direction (like normal from -1 to 1)
  122680. * b is a intensity
  122681. */
  122682. texture: Nullable<BaseTexture>;
  122683. /** @hidden */
  122684. private _internalMarkAllSubMeshesAsTexturesDirty;
  122685. /** @hidden */
  122686. _markAllSubMeshesAsTexturesDirty(): void;
  122687. /**
  122688. * Instantiate a new istance of anisotropy configuration.
  122689. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122690. */
  122691. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122692. /**
  122693. * Specifies that the submesh is ready to be used.
  122694. * @param defines the list of "defines" to update.
  122695. * @param scene defines the scene the material belongs to.
  122696. * @returns - boolean indicating that the submesh is ready or not.
  122697. */
  122698. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  122699. /**
  122700. * Checks to see if a texture is used in the material.
  122701. * @param defines the list of "defines" to update.
  122702. * @param mesh the mesh we are preparing the defines for.
  122703. * @param scene defines the scene the material belongs to.
  122704. */
  122705. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  122706. /**
  122707. * Binds the material data.
  122708. * @param uniformBuffer defines the Uniform buffer to fill in.
  122709. * @param scene defines the scene the material belongs to.
  122710. * @param isFrozen defines wether the material is frozen or not.
  122711. */
  122712. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  122713. /**
  122714. * Checks to see if a texture is used in the material.
  122715. * @param texture - Base texture to use.
  122716. * @returns - Boolean specifying if a texture is used in the material.
  122717. */
  122718. hasTexture(texture: BaseTexture): boolean;
  122719. /**
  122720. * Returns an array of the actively used textures.
  122721. * @param activeTextures Array of BaseTextures
  122722. */
  122723. getActiveTextures(activeTextures: BaseTexture[]): void;
  122724. /**
  122725. * Returns the animatable textures.
  122726. * @param animatables Array of animatable textures.
  122727. */
  122728. getAnimatables(animatables: IAnimatable[]): void;
  122729. /**
  122730. * Disposes the resources of the material.
  122731. * @param forceDisposeTextures - Forces the disposal of all textures.
  122732. */
  122733. dispose(forceDisposeTextures?: boolean): void;
  122734. /**
  122735. * Get the current class name of the texture useful for serialization or dynamic coding.
  122736. * @returns "PBRAnisotropicConfiguration"
  122737. */
  122738. getClassName(): string;
  122739. /**
  122740. * Add fallbacks to the effect fallbacks list.
  122741. * @param defines defines the Base texture to use.
  122742. * @param fallbacks defines the current fallback list.
  122743. * @param currentRank defines the current fallback rank.
  122744. * @returns the new fallback rank.
  122745. */
  122746. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122747. /**
  122748. * Add the required uniforms to the current list.
  122749. * @param uniforms defines the current uniform list.
  122750. */
  122751. static AddUniforms(uniforms: string[]): void;
  122752. /**
  122753. * Add the required uniforms to the current buffer.
  122754. * @param uniformBuffer defines the current uniform buffer.
  122755. */
  122756. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122757. /**
  122758. * Add the required samplers to the current list.
  122759. * @param samplers defines the current sampler list.
  122760. */
  122761. static AddSamplers(samplers: string[]): void;
  122762. /**
  122763. * Makes a duplicate of the current configuration into another one.
  122764. * @param anisotropicConfiguration define the config where to copy the info
  122765. */
  122766. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  122767. /**
  122768. * Serializes this anisotropy configuration.
  122769. * @returns - An object with the serialized config.
  122770. */
  122771. serialize(): any;
  122772. /**
  122773. * Parses a anisotropy Configuration from a serialized object.
  122774. * @param source - Serialized object.
  122775. * @param scene Defines the scene we are parsing for
  122776. * @param rootUrl Defines the rootUrl to load from
  122777. */
  122778. parse(source: any, scene: Scene, rootUrl: string): void;
  122779. }
  122780. }
  122781. declare module BABYLON {
  122782. /**
  122783. * @hidden
  122784. */
  122785. export interface IMaterialBRDFDefines {
  122786. BRDF_V_HEIGHT_CORRELATED: boolean;
  122787. MS_BRDF_ENERGY_CONSERVATION: boolean;
  122788. SPHERICAL_HARMONICS: boolean;
  122789. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  122790. /** @hidden */
  122791. _areMiscDirty: boolean;
  122792. }
  122793. /**
  122794. * Define the code related to the BRDF parameters of the pbr material.
  122795. */
  122796. export class PBRBRDFConfiguration {
  122797. /**
  122798. * Default value used for the energy conservation.
  122799. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122800. */
  122801. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  122802. /**
  122803. * Default value used for the Smith Visibility Height Correlated mode.
  122804. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122805. */
  122806. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  122807. /**
  122808. * Default value used for the IBL diffuse part.
  122809. * This can help switching back to the polynomials mode globally which is a tiny bit
  122810. * less GPU intensive at the drawback of a lower quality.
  122811. */
  122812. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  122813. /**
  122814. * Default value used for activating energy conservation for the specular workflow.
  122815. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122816. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122817. */
  122818. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  122819. private _useEnergyConservation;
  122820. /**
  122821. * Defines if the material uses energy conservation.
  122822. */
  122823. useEnergyConservation: boolean;
  122824. private _useSmithVisibilityHeightCorrelated;
  122825. /**
  122826. * LEGACY Mode set to false
  122827. * Defines if the material uses height smith correlated visibility term.
  122828. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  122829. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  122830. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  122831. * Not relying on height correlated will also disable energy conservation.
  122832. */
  122833. useSmithVisibilityHeightCorrelated: boolean;
  122834. private _useSphericalHarmonics;
  122835. /**
  122836. * LEGACY Mode set to false
  122837. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  122838. * diffuse part of the IBL.
  122839. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  122840. * to the ground truth.
  122841. */
  122842. useSphericalHarmonics: boolean;
  122843. private _useSpecularGlossinessInputEnergyConservation;
  122844. /**
  122845. * Defines if the material uses energy conservation, when the specular workflow is active.
  122846. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122847. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122848. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  122849. */
  122850. useSpecularGlossinessInputEnergyConservation: boolean;
  122851. /** @hidden */
  122852. private _internalMarkAllSubMeshesAsMiscDirty;
  122853. /** @hidden */
  122854. _markAllSubMeshesAsMiscDirty(): void;
  122855. /**
  122856. * Instantiate a new istance of clear coat configuration.
  122857. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  122858. */
  122859. constructor(markAllSubMeshesAsMiscDirty: () => void);
  122860. /**
  122861. * Checks to see if a texture is used in the material.
  122862. * @param defines the list of "defines" to update.
  122863. */
  122864. prepareDefines(defines: IMaterialBRDFDefines): void;
  122865. /**
  122866. * Get the current class name of the texture useful for serialization or dynamic coding.
  122867. * @returns "PBRClearCoatConfiguration"
  122868. */
  122869. getClassName(): string;
  122870. /**
  122871. * Makes a duplicate of the current configuration into another one.
  122872. * @param brdfConfiguration define the config where to copy the info
  122873. */
  122874. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  122875. /**
  122876. * Serializes this BRDF configuration.
  122877. * @returns - An object with the serialized config.
  122878. */
  122879. serialize(): any;
  122880. /**
  122881. * Parses a anisotropy Configuration from a serialized object.
  122882. * @param source - Serialized object.
  122883. * @param scene Defines the scene we are parsing for
  122884. * @param rootUrl Defines the rootUrl to load from
  122885. */
  122886. parse(source: any, scene: Scene, rootUrl: string): void;
  122887. }
  122888. }
  122889. declare module BABYLON {
  122890. /**
  122891. * @hidden
  122892. */
  122893. export interface IMaterialSheenDefines {
  122894. SHEEN: boolean;
  122895. SHEEN_TEXTURE: boolean;
  122896. SHEEN_TEXTUREDIRECTUV: number;
  122897. SHEEN_LINKWITHALBEDO: boolean;
  122898. /** @hidden */
  122899. _areTexturesDirty: boolean;
  122900. }
  122901. /**
  122902. * Define the code related to the Sheen parameters of the pbr material.
  122903. */
  122904. export class PBRSheenConfiguration {
  122905. private _isEnabled;
  122906. /**
  122907. * Defines if the material uses sheen.
  122908. */
  122909. isEnabled: boolean;
  122910. private _linkSheenWithAlbedo;
  122911. /**
  122912. * Defines if the sheen is linked to the sheen color.
  122913. */
  122914. linkSheenWithAlbedo: boolean;
  122915. /**
  122916. * Defines the sheen intensity.
  122917. */
  122918. intensity: number;
  122919. /**
  122920. * Defines the sheen color.
  122921. */
  122922. color: Color3;
  122923. private _texture;
  122924. /**
  122925. * Stores the sheen tint values in a texture.
  122926. * rgb is tint
  122927. * a is a intensity
  122928. */
  122929. texture: Nullable<BaseTexture>;
  122930. /** @hidden */
  122931. private _internalMarkAllSubMeshesAsTexturesDirty;
  122932. /** @hidden */
  122933. _markAllSubMeshesAsTexturesDirty(): void;
  122934. /**
  122935. * Instantiate a new istance of clear coat configuration.
  122936. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122937. */
  122938. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122939. /**
  122940. * Specifies that the submesh is ready to be used.
  122941. * @param defines the list of "defines" to update.
  122942. * @param scene defines the scene the material belongs to.
  122943. * @returns - boolean indicating that the submesh is ready or not.
  122944. */
  122945. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  122946. /**
  122947. * Checks to see if a texture is used in the material.
  122948. * @param defines the list of "defines" to update.
  122949. * @param scene defines the scene the material belongs to.
  122950. */
  122951. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  122952. /**
  122953. * Binds the material data.
  122954. * @param uniformBuffer defines the Uniform buffer to fill in.
  122955. * @param scene defines the scene the material belongs to.
  122956. * @param isFrozen defines wether the material is frozen or not.
  122957. */
  122958. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  122959. /**
  122960. * Checks to see if a texture is used in the material.
  122961. * @param texture - Base texture to use.
  122962. * @returns - Boolean specifying if a texture is used in the material.
  122963. */
  122964. hasTexture(texture: BaseTexture): boolean;
  122965. /**
  122966. * Returns an array of the actively used textures.
  122967. * @param activeTextures Array of BaseTextures
  122968. */
  122969. getActiveTextures(activeTextures: BaseTexture[]): void;
  122970. /**
  122971. * Returns the animatable textures.
  122972. * @param animatables Array of animatable textures.
  122973. */
  122974. getAnimatables(animatables: IAnimatable[]): void;
  122975. /**
  122976. * Disposes the resources of the material.
  122977. * @param forceDisposeTextures - Forces the disposal of all textures.
  122978. */
  122979. dispose(forceDisposeTextures?: boolean): void;
  122980. /**
  122981. * Get the current class name of the texture useful for serialization or dynamic coding.
  122982. * @returns "PBRSheenConfiguration"
  122983. */
  122984. getClassName(): string;
  122985. /**
  122986. * Add fallbacks to the effect fallbacks list.
  122987. * @param defines defines the Base texture to use.
  122988. * @param fallbacks defines the current fallback list.
  122989. * @param currentRank defines the current fallback rank.
  122990. * @returns the new fallback rank.
  122991. */
  122992. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122993. /**
  122994. * Add the required uniforms to the current list.
  122995. * @param uniforms defines the current uniform list.
  122996. */
  122997. static AddUniforms(uniforms: string[]): void;
  122998. /**
  122999. * Add the required uniforms to the current buffer.
  123000. * @param uniformBuffer defines the current uniform buffer.
  123001. */
  123002. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123003. /**
  123004. * Add the required samplers to the current list.
  123005. * @param samplers defines the current sampler list.
  123006. */
  123007. static AddSamplers(samplers: string[]): void;
  123008. /**
  123009. * Makes a duplicate of the current configuration into another one.
  123010. * @param sheenConfiguration define the config where to copy the info
  123011. */
  123012. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123013. /**
  123014. * Serializes this BRDF configuration.
  123015. * @returns - An object with the serialized config.
  123016. */
  123017. serialize(): any;
  123018. /**
  123019. * Parses a anisotropy Configuration from a serialized object.
  123020. * @param source - Serialized object.
  123021. * @param scene Defines the scene we are parsing for
  123022. * @param rootUrl Defines the rootUrl to load from
  123023. */
  123024. parse(source: any, scene: Scene, rootUrl: string): void;
  123025. }
  123026. }
  123027. declare module BABYLON {
  123028. /**
  123029. * @hidden
  123030. */
  123031. export interface IMaterialSubSurfaceDefines {
  123032. SUBSURFACE: boolean;
  123033. SS_REFRACTION: boolean;
  123034. SS_TRANSLUCENCY: boolean;
  123035. SS_SCATERRING: boolean;
  123036. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123037. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123038. SS_REFRACTIONMAP_3D: boolean;
  123039. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123040. SS_LODINREFRACTIONALPHA: boolean;
  123041. SS_GAMMAREFRACTION: boolean;
  123042. SS_RGBDREFRACTION: boolean;
  123043. SS_LINEARSPECULARREFRACTION: boolean;
  123044. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123045. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123046. /** @hidden */
  123047. _areTexturesDirty: boolean;
  123048. }
  123049. /**
  123050. * Define the code related to the sub surface parameters of the pbr material.
  123051. */
  123052. export class PBRSubSurfaceConfiguration {
  123053. private _isRefractionEnabled;
  123054. /**
  123055. * Defines if the refraction is enabled in the material.
  123056. */
  123057. isRefractionEnabled: boolean;
  123058. private _isTranslucencyEnabled;
  123059. /**
  123060. * Defines if the translucency is enabled in the material.
  123061. */
  123062. isTranslucencyEnabled: boolean;
  123063. private _isScatteringEnabled;
  123064. /**
  123065. * Defines the refraction intensity of the material.
  123066. * The refraction when enabled replaces the Diffuse part of the material.
  123067. * The intensity helps transitionning between diffuse and refraction.
  123068. */
  123069. refractionIntensity: number;
  123070. /**
  123071. * Defines the translucency intensity of the material.
  123072. * When translucency has been enabled, this defines how much of the "translucency"
  123073. * is addded to the diffuse part of the material.
  123074. */
  123075. translucencyIntensity: number;
  123076. /**
  123077. * Defines the scattering intensity of the material.
  123078. * When scattering has been enabled, this defines how much of the "scattered light"
  123079. * is addded to the diffuse part of the material.
  123080. */
  123081. scatteringIntensity: number;
  123082. private _thicknessTexture;
  123083. /**
  123084. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123085. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123086. * 0 would mean minimumThickness
  123087. * 1 would mean maximumThickness
  123088. * The other channels might be use as a mask to vary the different effects intensity.
  123089. */
  123090. thicknessTexture: Nullable<BaseTexture>;
  123091. private _refractionTexture;
  123092. /**
  123093. * Defines the texture to use for refraction.
  123094. */
  123095. refractionTexture: Nullable<BaseTexture>;
  123096. private _indexOfRefraction;
  123097. /**
  123098. * Defines the index of refraction used in the material.
  123099. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123100. */
  123101. indexOfRefraction: number;
  123102. private _invertRefractionY;
  123103. /**
  123104. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123105. */
  123106. invertRefractionY: boolean;
  123107. private _linkRefractionWithTransparency;
  123108. /**
  123109. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123110. * Materials half opaque for instance using refraction could benefit from this control.
  123111. */
  123112. linkRefractionWithTransparency: boolean;
  123113. /**
  123114. * Defines the minimum thickness stored in the thickness map.
  123115. * If no thickness map is defined, this value will be used to simulate thickness.
  123116. */
  123117. minimumThickness: number;
  123118. /**
  123119. * Defines the maximum thickness stored in the thickness map.
  123120. */
  123121. maximumThickness: number;
  123122. /**
  123123. * Defines the volume tint of the material.
  123124. * This is used for both translucency and scattering.
  123125. */
  123126. tintColor: Color3;
  123127. /**
  123128. * Defines the distance at which the tint color should be found in the media.
  123129. * This is used for refraction only.
  123130. */
  123131. tintColorAtDistance: number;
  123132. /**
  123133. * Defines how far each channel transmit through the media.
  123134. * It is defined as a color to simplify it selection.
  123135. */
  123136. diffusionDistance: Color3;
  123137. private _useMaskFromThicknessTexture;
  123138. /**
  123139. * Stores the intensity of the different subsurface effects in the thickness texture.
  123140. * * the green channel is the translucency intensity.
  123141. * * the blue channel is the scattering intensity.
  123142. * * the alpha channel is the refraction intensity.
  123143. */
  123144. useMaskFromThicknessTexture: boolean;
  123145. /** @hidden */
  123146. private _internalMarkAllSubMeshesAsTexturesDirty;
  123147. /** @hidden */
  123148. _markAllSubMeshesAsTexturesDirty(): void;
  123149. /**
  123150. * Instantiate a new istance of sub surface configuration.
  123151. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123152. */
  123153. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123154. /**
  123155. * Gets wehter the submesh is ready to be used or not.
  123156. * @param defines the list of "defines" to update.
  123157. * @param scene defines the scene the material belongs to.
  123158. * @returns - boolean indicating that the submesh is ready or not.
  123159. */
  123160. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123161. /**
  123162. * Checks to see if a texture is used in the material.
  123163. * @param defines the list of "defines" to update.
  123164. * @param scene defines the scene to the material belongs to.
  123165. */
  123166. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123167. /**
  123168. * Binds the material data.
  123169. * @param uniformBuffer defines the Uniform buffer to fill in.
  123170. * @param scene defines the scene the material belongs to.
  123171. * @param engine defines the engine the material belongs to.
  123172. * @param isFrozen defines wether the material is frozen or not.
  123173. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123174. */
  123175. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123176. /**
  123177. * Unbinds the material from the mesh.
  123178. * @param activeEffect defines the effect that should be unbound from.
  123179. * @returns true if unbound, otherwise false
  123180. */
  123181. unbind(activeEffect: Effect): boolean;
  123182. /**
  123183. * Returns the texture used for refraction or null if none is used.
  123184. * @param scene defines the scene the material belongs to.
  123185. * @returns - Refraction texture if present. If no refraction texture and refraction
  123186. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123187. */
  123188. private _getRefractionTexture;
  123189. /**
  123190. * Returns true if alpha blending should be disabled.
  123191. */
  123192. get disableAlphaBlending(): boolean;
  123193. /**
  123194. * Fills the list of render target textures.
  123195. * @param renderTargets the list of render targets to update
  123196. */
  123197. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123198. /**
  123199. * Checks to see if a texture is used in the material.
  123200. * @param texture - Base texture to use.
  123201. * @returns - Boolean specifying if a texture is used in the material.
  123202. */
  123203. hasTexture(texture: BaseTexture): boolean;
  123204. /**
  123205. * Gets a boolean indicating that current material needs to register RTT
  123206. * @returns true if this uses a render target otherwise false.
  123207. */
  123208. hasRenderTargetTextures(): boolean;
  123209. /**
  123210. * Returns an array of the actively used textures.
  123211. * @param activeTextures Array of BaseTextures
  123212. */
  123213. getActiveTextures(activeTextures: BaseTexture[]): void;
  123214. /**
  123215. * Returns the animatable textures.
  123216. * @param animatables Array of animatable textures.
  123217. */
  123218. getAnimatables(animatables: IAnimatable[]): void;
  123219. /**
  123220. * Disposes the resources of the material.
  123221. * @param forceDisposeTextures - Forces the disposal of all textures.
  123222. */
  123223. dispose(forceDisposeTextures?: boolean): void;
  123224. /**
  123225. * Get the current class name of the texture useful for serialization or dynamic coding.
  123226. * @returns "PBRSubSurfaceConfiguration"
  123227. */
  123228. getClassName(): string;
  123229. /**
  123230. * Add fallbacks to the effect fallbacks list.
  123231. * @param defines defines the Base texture to use.
  123232. * @param fallbacks defines the current fallback list.
  123233. * @param currentRank defines the current fallback rank.
  123234. * @returns the new fallback rank.
  123235. */
  123236. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123237. /**
  123238. * Add the required uniforms to the current list.
  123239. * @param uniforms defines the current uniform list.
  123240. */
  123241. static AddUniforms(uniforms: string[]): void;
  123242. /**
  123243. * Add the required samplers to the current list.
  123244. * @param samplers defines the current sampler list.
  123245. */
  123246. static AddSamplers(samplers: string[]): void;
  123247. /**
  123248. * Add the required uniforms to the current buffer.
  123249. * @param uniformBuffer defines the current uniform buffer.
  123250. */
  123251. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123252. /**
  123253. * Makes a duplicate of the current configuration into another one.
  123254. * @param configuration define the config where to copy the info
  123255. */
  123256. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123257. /**
  123258. * Serializes this Sub Surface configuration.
  123259. * @returns - An object with the serialized config.
  123260. */
  123261. serialize(): any;
  123262. /**
  123263. * Parses a anisotropy Configuration from a serialized object.
  123264. * @param source - Serialized object.
  123265. * @param scene Defines the scene we are parsing for
  123266. * @param rootUrl Defines the rootUrl to load from
  123267. */
  123268. parse(source: any, scene: Scene, rootUrl: string): void;
  123269. }
  123270. }
  123271. declare module BABYLON {
  123272. /** @hidden */
  123273. export var pbrFragmentDeclaration: {
  123274. name: string;
  123275. shader: string;
  123276. };
  123277. }
  123278. declare module BABYLON {
  123279. /** @hidden */
  123280. export var pbrUboDeclaration: {
  123281. name: string;
  123282. shader: string;
  123283. };
  123284. }
  123285. declare module BABYLON {
  123286. /** @hidden */
  123287. export var pbrFragmentExtraDeclaration: {
  123288. name: string;
  123289. shader: string;
  123290. };
  123291. }
  123292. declare module BABYLON {
  123293. /** @hidden */
  123294. export var pbrFragmentSamplersDeclaration: {
  123295. name: string;
  123296. shader: string;
  123297. };
  123298. }
  123299. declare module BABYLON {
  123300. /** @hidden */
  123301. export var pbrHelperFunctions: {
  123302. name: string;
  123303. shader: string;
  123304. };
  123305. }
  123306. declare module BABYLON {
  123307. /** @hidden */
  123308. export var harmonicsFunctions: {
  123309. name: string;
  123310. shader: string;
  123311. };
  123312. }
  123313. declare module BABYLON {
  123314. /** @hidden */
  123315. export var pbrDirectLightingSetupFunctions: {
  123316. name: string;
  123317. shader: string;
  123318. };
  123319. }
  123320. declare module BABYLON {
  123321. /** @hidden */
  123322. export var pbrDirectLightingFalloffFunctions: {
  123323. name: string;
  123324. shader: string;
  123325. };
  123326. }
  123327. declare module BABYLON {
  123328. /** @hidden */
  123329. export var pbrBRDFFunctions: {
  123330. name: string;
  123331. shader: string;
  123332. };
  123333. }
  123334. declare module BABYLON {
  123335. /** @hidden */
  123336. export var pbrDirectLightingFunctions: {
  123337. name: string;
  123338. shader: string;
  123339. };
  123340. }
  123341. declare module BABYLON {
  123342. /** @hidden */
  123343. export var pbrIBLFunctions: {
  123344. name: string;
  123345. shader: string;
  123346. };
  123347. }
  123348. declare module BABYLON {
  123349. /** @hidden */
  123350. export var pbrDebug: {
  123351. name: string;
  123352. shader: string;
  123353. };
  123354. }
  123355. declare module BABYLON {
  123356. /** @hidden */
  123357. export var pbrPixelShader: {
  123358. name: string;
  123359. shader: string;
  123360. };
  123361. }
  123362. declare module BABYLON {
  123363. /** @hidden */
  123364. export var pbrVertexDeclaration: {
  123365. name: string;
  123366. shader: string;
  123367. };
  123368. }
  123369. declare module BABYLON {
  123370. /** @hidden */
  123371. export var pbrVertexShader: {
  123372. name: string;
  123373. shader: string;
  123374. };
  123375. }
  123376. declare module BABYLON {
  123377. /**
  123378. * Manages the defines for the PBR Material.
  123379. * @hidden
  123380. */
  123381. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123382. PBR: boolean;
  123383. MAINUV1: boolean;
  123384. MAINUV2: boolean;
  123385. UV1: boolean;
  123386. UV2: boolean;
  123387. ALBEDO: boolean;
  123388. ALBEDODIRECTUV: number;
  123389. VERTEXCOLOR: boolean;
  123390. AMBIENT: boolean;
  123391. AMBIENTDIRECTUV: number;
  123392. AMBIENTINGRAYSCALE: boolean;
  123393. OPACITY: boolean;
  123394. VERTEXALPHA: boolean;
  123395. OPACITYDIRECTUV: number;
  123396. OPACITYRGB: boolean;
  123397. ALPHATEST: boolean;
  123398. DEPTHPREPASS: boolean;
  123399. ALPHABLEND: boolean;
  123400. ALPHAFROMALBEDO: boolean;
  123401. ALPHATESTVALUE: string;
  123402. SPECULAROVERALPHA: boolean;
  123403. RADIANCEOVERALPHA: boolean;
  123404. ALPHAFRESNEL: boolean;
  123405. LINEARALPHAFRESNEL: boolean;
  123406. PREMULTIPLYALPHA: boolean;
  123407. EMISSIVE: boolean;
  123408. EMISSIVEDIRECTUV: number;
  123409. REFLECTIVITY: boolean;
  123410. REFLECTIVITYDIRECTUV: number;
  123411. SPECULARTERM: boolean;
  123412. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  123413. MICROSURFACEAUTOMATIC: boolean;
  123414. LODBASEDMICROSFURACE: boolean;
  123415. MICROSURFACEMAP: boolean;
  123416. MICROSURFACEMAPDIRECTUV: number;
  123417. METALLICWORKFLOW: boolean;
  123418. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  123419. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  123420. METALLNESSSTOREINMETALMAPBLUE: boolean;
  123421. AOSTOREINMETALMAPRED: boolean;
  123422. METALLICF0FACTORFROMMETALLICMAP: boolean;
  123423. ENVIRONMENTBRDF: boolean;
  123424. ENVIRONMENTBRDF_RGBD: boolean;
  123425. NORMAL: boolean;
  123426. TANGENT: boolean;
  123427. BUMP: boolean;
  123428. BUMPDIRECTUV: number;
  123429. OBJECTSPACE_NORMALMAP: boolean;
  123430. PARALLAX: boolean;
  123431. PARALLAXOCCLUSION: boolean;
  123432. NORMALXYSCALE: boolean;
  123433. LIGHTMAP: boolean;
  123434. LIGHTMAPDIRECTUV: number;
  123435. USELIGHTMAPASSHADOWMAP: boolean;
  123436. GAMMALIGHTMAP: boolean;
  123437. RGBDLIGHTMAP: boolean;
  123438. REFLECTION: boolean;
  123439. REFLECTIONMAP_3D: boolean;
  123440. REFLECTIONMAP_SPHERICAL: boolean;
  123441. REFLECTIONMAP_PLANAR: boolean;
  123442. REFLECTIONMAP_CUBIC: boolean;
  123443. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  123444. REFLECTIONMAP_PROJECTION: boolean;
  123445. REFLECTIONMAP_SKYBOX: boolean;
  123446. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  123447. REFLECTIONMAP_EXPLICIT: boolean;
  123448. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  123449. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  123450. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  123451. INVERTCUBICMAP: boolean;
  123452. USESPHERICALFROMREFLECTIONMAP: boolean;
  123453. USEIRRADIANCEMAP: boolean;
  123454. SPHERICAL_HARMONICS: boolean;
  123455. USESPHERICALINVERTEX: boolean;
  123456. REFLECTIONMAP_OPPOSITEZ: boolean;
  123457. LODINREFLECTIONALPHA: boolean;
  123458. GAMMAREFLECTION: boolean;
  123459. RGBDREFLECTION: boolean;
  123460. LINEARSPECULARREFLECTION: boolean;
  123461. RADIANCEOCCLUSION: boolean;
  123462. HORIZONOCCLUSION: boolean;
  123463. INSTANCES: boolean;
  123464. NUM_BONE_INFLUENCERS: number;
  123465. BonesPerMesh: number;
  123466. BONETEXTURE: boolean;
  123467. NONUNIFORMSCALING: boolean;
  123468. MORPHTARGETS: boolean;
  123469. MORPHTARGETS_NORMAL: boolean;
  123470. MORPHTARGETS_TANGENT: boolean;
  123471. MORPHTARGETS_UV: boolean;
  123472. NUM_MORPH_INFLUENCERS: number;
  123473. IMAGEPROCESSING: boolean;
  123474. VIGNETTE: boolean;
  123475. VIGNETTEBLENDMODEMULTIPLY: boolean;
  123476. VIGNETTEBLENDMODEOPAQUE: boolean;
  123477. TONEMAPPING: boolean;
  123478. TONEMAPPING_ACES: boolean;
  123479. CONTRAST: boolean;
  123480. COLORCURVES: boolean;
  123481. COLORGRADING: boolean;
  123482. COLORGRADING3D: boolean;
  123483. SAMPLER3DGREENDEPTH: boolean;
  123484. SAMPLER3DBGRMAP: boolean;
  123485. IMAGEPROCESSINGPOSTPROCESS: boolean;
  123486. EXPOSURE: boolean;
  123487. MULTIVIEW: boolean;
  123488. USEPHYSICALLIGHTFALLOFF: boolean;
  123489. USEGLTFLIGHTFALLOFF: boolean;
  123490. TWOSIDEDLIGHTING: boolean;
  123491. SHADOWFLOAT: boolean;
  123492. CLIPPLANE: boolean;
  123493. CLIPPLANE2: boolean;
  123494. CLIPPLANE3: boolean;
  123495. CLIPPLANE4: boolean;
  123496. CLIPPLANE5: boolean;
  123497. CLIPPLANE6: boolean;
  123498. POINTSIZE: boolean;
  123499. FOG: boolean;
  123500. LOGARITHMICDEPTH: boolean;
  123501. FORCENORMALFORWARD: boolean;
  123502. SPECULARAA: boolean;
  123503. CLEARCOAT: boolean;
  123504. CLEARCOAT_DEFAULTIOR: boolean;
  123505. CLEARCOAT_TEXTURE: boolean;
  123506. CLEARCOAT_TEXTUREDIRECTUV: number;
  123507. CLEARCOAT_BUMP: boolean;
  123508. CLEARCOAT_BUMPDIRECTUV: number;
  123509. CLEARCOAT_TINT: boolean;
  123510. CLEARCOAT_TINT_TEXTURE: boolean;
  123511. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123512. ANISOTROPIC: boolean;
  123513. ANISOTROPIC_TEXTURE: boolean;
  123514. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123515. BRDF_V_HEIGHT_CORRELATED: boolean;
  123516. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123517. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123518. SHEEN: boolean;
  123519. SHEEN_TEXTURE: boolean;
  123520. SHEEN_TEXTUREDIRECTUV: number;
  123521. SHEEN_LINKWITHALBEDO: boolean;
  123522. SUBSURFACE: boolean;
  123523. SS_REFRACTION: boolean;
  123524. SS_TRANSLUCENCY: boolean;
  123525. SS_SCATERRING: boolean;
  123526. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123527. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123528. SS_REFRACTIONMAP_3D: boolean;
  123529. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123530. SS_LODINREFRACTIONALPHA: boolean;
  123531. SS_GAMMAREFRACTION: boolean;
  123532. SS_RGBDREFRACTION: boolean;
  123533. SS_LINEARSPECULARREFRACTION: boolean;
  123534. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123535. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123536. UNLIT: boolean;
  123537. DEBUGMODE: number;
  123538. /**
  123539. * Initializes the PBR Material defines.
  123540. */
  123541. constructor();
  123542. /**
  123543. * Resets the PBR Material defines.
  123544. */
  123545. reset(): void;
  123546. }
  123547. /**
  123548. * The Physically based material base class of BJS.
  123549. *
  123550. * This offers the main features of a standard PBR material.
  123551. * For more information, please refer to the documentation :
  123552. * https://doc.babylonjs.com/how_to/physically_based_rendering
  123553. */
  123554. export abstract class PBRBaseMaterial extends PushMaterial {
  123555. /**
  123556. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  123557. */
  123558. static readonly PBRMATERIAL_OPAQUE: number;
  123559. /**
  123560. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  123561. */
  123562. static readonly PBRMATERIAL_ALPHATEST: number;
  123563. /**
  123564. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123565. */
  123566. static readonly PBRMATERIAL_ALPHABLEND: number;
  123567. /**
  123568. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123569. * They are also discarded below the alpha cutoff threshold to improve performances.
  123570. */
  123571. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  123572. /**
  123573. * Defines the default value of how much AO map is occluding the analytical lights
  123574. * (point spot...).
  123575. */
  123576. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  123577. /**
  123578. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  123579. */
  123580. static readonly LIGHTFALLOFF_PHYSICAL: number;
  123581. /**
  123582. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  123583. * to enhance interoperability with other engines.
  123584. */
  123585. static readonly LIGHTFALLOFF_GLTF: number;
  123586. /**
  123587. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  123588. * to enhance interoperability with other materials.
  123589. */
  123590. static readonly LIGHTFALLOFF_STANDARD: number;
  123591. /**
  123592. * Intensity of the direct lights e.g. the four lights available in your scene.
  123593. * This impacts both the direct diffuse and specular highlights.
  123594. */
  123595. protected _directIntensity: number;
  123596. /**
  123597. * Intensity of the emissive part of the material.
  123598. * This helps controlling the emissive effect without modifying the emissive color.
  123599. */
  123600. protected _emissiveIntensity: number;
  123601. /**
  123602. * Intensity of the environment e.g. how much the environment will light the object
  123603. * either through harmonics for rough material or through the refelction for shiny ones.
  123604. */
  123605. protected _environmentIntensity: number;
  123606. /**
  123607. * This is a special control allowing the reduction of the specular highlights coming from the
  123608. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  123609. */
  123610. protected _specularIntensity: number;
  123611. /**
  123612. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  123613. */
  123614. private _lightingInfos;
  123615. /**
  123616. * Debug Control allowing disabling the bump map on this material.
  123617. */
  123618. protected _disableBumpMap: boolean;
  123619. /**
  123620. * AKA Diffuse Texture in standard nomenclature.
  123621. */
  123622. protected _albedoTexture: Nullable<BaseTexture>;
  123623. /**
  123624. * AKA Occlusion Texture in other nomenclature.
  123625. */
  123626. protected _ambientTexture: Nullable<BaseTexture>;
  123627. /**
  123628. * AKA Occlusion Texture Intensity in other nomenclature.
  123629. */
  123630. protected _ambientTextureStrength: number;
  123631. /**
  123632. * Defines how much the AO map is occluding the analytical lights (point spot...).
  123633. * 1 means it completely occludes it
  123634. * 0 mean it has no impact
  123635. */
  123636. protected _ambientTextureImpactOnAnalyticalLights: number;
  123637. /**
  123638. * Stores the alpha values in a texture.
  123639. */
  123640. protected _opacityTexture: Nullable<BaseTexture>;
  123641. /**
  123642. * Stores the reflection values in a texture.
  123643. */
  123644. protected _reflectionTexture: Nullable<BaseTexture>;
  123645. /**
  123646. * Stores the emissive values in a texture.
  123647. */
  123648. protected _emissiveTexture: Nullable<BaseTexture>;
  123649. /**
  123650. * AKA Specular texture in other nomenclature.
  123651. */
  123652. protected _reflectivityTexture: Nullable<BaseTexture>;
  123653. /**
  123654. * Used to switch from specular/glossiness to metallic/roughness workflow.
  123655. */
  123656. protected _metallicTexture: Nullable<BaseTexture>;
  123657. /**
  123658. * Specifies the metallic scalar of the metallic/roughness workflow.
  123659. * Can also be used to scale the metalness values of the metallic texture.
  123660. */
  123661. protected _metallic: Nullable<number>;
  123662. /**
  123663. * Specifies the roughness scalar of the metallic/roughness workflow.
  123664. * Can also be used to scale the roughness values of the metallic texture.
  123665. */
  123666. protected _roughness: Nullable<number>;
  123667. /**
  123668. * Specifies the an F0 factor to help configuring the material F0.
  123669. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  123670. * to 0.5 the previously hard coded value stays the same.
  123671. * Can also be used to scale the F0 values of the metallic texture.
  123672. */
  123673. protected _metallicF0Factor: number;
  123674. /**
  123675. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  123676. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  123677. * your expectation as it multiplies with the texture data.
  123678. */
  123679. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  123680. /**
  123681. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  123682. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  123683. */
  123684. protected _microSurfaceTexture: Nullable<BaseTexture>;
  123685. /**
  123686. * Stores surface normal data used to displace a mesh in a texture.
  123687. */
  123688. protected _bumpTexture: Nullable<BaseTexture>;
  123689. /**
  123690. * Stores the pre-calculated light information of a mesh in a texture.
  123691. */
  123692. protected _lightmapTexture: Nullable<BaseTexture>;
  123693. /**
  123694. * The color of a material in ambient lighting.
  123695. */
  123696. protected _ambientColor: Color3;
  123697. /**
  123698. * AKA Diffuse Color in other nomenclature.
  123699. */
  123700. protected _albedoColor: Color3;
  123701. /**
  123702. * AKA Specular Color in other nomenclature.
  123703. */
  123704. protected _reflectivityColor: Color3;
  123705. /**
  123706. * The color applied when light is reflected from a material.
  123707. */
  123708. protected _reflectionColor: Color3;
  123709. /**
  123710. * The color applied when light is emitted from a material.
  123711. */
  123712. protected _emissiveColor: Color3;
  123713. /**
  123714. * AKA Glossiness in other nomenclature.
  123715. */
  123716. protected _microSurface: number;
  123717. /**
  123718. * Specifies that the material will use the light map as a show map.
  123719. */
  123720. protected _useLightmapAsShadowmap: boolean;
  123721. /**
  123722. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  123723. * makes the reflect vector face the model (under horizon).
  123724. */
  123725. protected _useHorizonOcclusion: boolean;
  123726. /**
  123727. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  123728. * too much the area relying on ambient texture to define their ambient occlusion.
  123729. */
  123730. protected _useRadianceOcclusion: boolean;
  123731. /**
  123732. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  123733. */
  123734. protected _useAlphaFromAlbedoTexture: boolean;
  123735. /**
  123736. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  123737. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  123738. */
  123739. protected _useSpecularOverAlpha: boolean;
  123740. /**
  123741. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  123742. */
  123743. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  123744. /**
  123745. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  123746. */
  123747. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  123748. /**
  123749. * Specifies if the metallic texture contains the roughness information in its green channel.
  123750. */
  123751. protected _useRoughnessFromMetallicTextureGreen: boolean;
  123752. /**
  123753. * Specifies if the metallic texture contains the metallness information in its blue channel.
  123754. */
  123755. protected _useMetallnessFromMetallicTextureBlue: boolean;
  123756. /**
  123757. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  123758. */
  123759. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  123760. /**
  123761. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  123762. */
  123763. protected _useAmbientInGrayScale: boolean;
  123764. /**
  123765. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  123766. * The material will try to infer what glossiness each pixel should be.
  123767. */
  123768. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  123769. /**
  123770. * Defines the falloff type used in this material.
  123771. * It by default is Physical.
  123772. */
  123773. protected _lightFalloff: number;
  123774. /**
  123775. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  123776. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  123777. */
  123778. protected _useRadianceOverAlpha: boolean;
  123779. /**
  123780. * Allows using an object space normal map (instead of tangent space).
  123781. */
  123782. protected _useObjectSpaceNormalMap: boolean;
  123783. /**
  123784. * Allows using the bump map in parallax mode.
  123785. */
  123786. protected _useParallax: boolean;
  123787. /**
  123788. * Allows using the bump map in parallax occlusion mode.
  123789. */
  123790. protected _useParallaxOcclusion: boolean;
  123791. /**
  123792. * Controls the scale bias of the parallax mode.
  123793. */
  123794. protected _parallaxScaleBias: number;
  123795. /**
  123796. * If sets to true, disables all the lights affecting the material.
  123797. */
  123798. protected _disableLighting: boolean;
  123799. /**
  123800. * Number of Simultaneous lights allowed on the material.
  123801. */
  123802. protected _maxSimultaneousLights: number;
  123803. /**
  123804. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123805. */
  123806. protected _invertNormalMapX: boolean;
  123807. /**
  123808. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123809. */
  123810. protected _invertNormalMapY: boolean;
  123811. /**
  123812. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  123813. */
  123814. protected _twoSidedLighting: boolean;
  123815. /**
  123816. * Defines the alpha limits in alpha test mode.
  123817. */
  123818. protected _alphaCutOff: number;
  123819. /**
  123820. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  123821. */
  123822. protected _forceAlphaTest: boolean;
  123823. /**
  123824. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123825. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  123826. */
  123827. protected _useAlphaFresnel: boolean;
  123828. /**
  123829. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123830. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  123831. */
  123832. protected _useLinearAlphaFresnel: boolean;
  123833. /**
  123834. * The transparency mode of the material.
  123835. */
  123836. protected _transparencyMode: Nullable<number>;
  123837. /**
  123838. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  123839. * from cos thetav and roughness:
  123840. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  123841. */
  123842. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  123843. /**
  123844. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  123845. */
  123846. protected _forceIrradianceInFragment: boolean;
  123847. /**
  123848. * Force normal to face away from face.
  123849. */
  123850. protected _forceNormalForward: boolean;
  123851. /**
  123852. * Enables specular anti aliasing in the PBR shader.
  123853. * It will both interacts on the Geometry for analytical and IBL lighting.
  123854. * It also prefilter the roughness map based on the bump values.
  123855. */
  123856. protected _enableSpecularAntiAliasing: boolean;
  123857. /**
  123858. * Default configuration related to image processing available in the PBR Material.
  123859. */
  123860. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123861. /**
  123862. * Keep track of the image processing observer to allow dispose and replace.
  123863. */
  123864. private _imageProcessingObserver;
  123865. /**
  123866. * Attaches a new image processing configuration to the PBR Material.
  123867. * @param configuration
  123868. */
  123869. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123870. /**
  123871. * Stores the available render targets.
  123872. */
  123873. private _renderTargets;
  123874. /**
  123875. * Sets the global ambient color for the material used in lighting calculations.
  123876. */
  123877. private _globalAmbientColor;
  123878. /**
  123879. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  123880. */
  123881. private _useLogarithmicDepth;
  123882. /**
  123883. * If set to true, no lighting calculations will be applied.
  123884. */
  123885. private _unlit;
  123886. private _debugMode;
  123887. /**
  123888. * @hidden
  123889. * This is reserved for the inspector.
  123890. * Defines the material debug mode.
  123891. * It helps seeing only some components of the material while troubleshooting.
  123892. */
  123893. debugMode: number;
  123894. /**
  123895. * @hidden
  123896. * This is reserved for the inspector.
  123897. * Specify from where on screen the debug mode should start.
  123898. * The value goes from -1 (full screen) to 1 (not visible)
  123899. * It helps with side by side comparison against the final render
  123900. * This defaults to -1
  123901. */
  123902. private debugLimit;
  123903. /**
  123904. * @hidden
  123905. * This is reserved for the inspector.
  123906. * As the default viewing range might not be enough (if the ambient is really small for instance)
  123907. * You can use the factor to better multiply the final value.
  123908. */
  123909. private debugFactor;
  123910. /**
  123911. * Defines the clear coat layer parameters for the material.
  123912. */
  123913. readonly clearCoat: PBRClearCoatConfiguration;
  123914. /**
  123915. * Defines the anisotropic parameters for the material.
  123916. */
  123917. readonly anisotropy: PBRAnisotropicConfiguration;
  123918. /**
  123919. * Defines the BRDF parameters for the material.
  123920. */
  123921. readonly brdf: PBRBRDFConfiguration;
  123922. /**
  123923. * Defines the Sheen parameters for the material.
  123924. */
  123925. readonly sheen: PBRSheenConfiguration;
  123926. /**
  123927. * Defines the SubSurface parameters for the material.
  123928. */
  123929. readonly subSurface: PBRSubSurfaceConfiguration;
  123930. /**
  123931. * Custom callback helping to override the default shader used in the material.
  123932. */
  123933. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  123934. protected _rebuildInParallel: boolean;
  123935. /**
  123936. * Instantiates a new PBRMaterial instance.
  123937. *
  123938. * @param name The material name
  123939. * @param scene The scene the material will be use in.
  123940. */
  123941. constructor(name: string, scene: Scene);
  123942. /**
  123943. * Gets a boolean indicating that current material needs to register RTT
  123944. */
  123945. get hasRenderTargetTextures(): boolean;
  123946. /**
  123947. * Gets the name of the material class.
  123948. */
  123949. getClassName(): string;
  123950. /**
  123951. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  123952. */
  123953. get useLogarithmicDepth(): boolean;
  123954. /**
  123955. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  123956. */
  123957. set useLogarithmicDepth(value: boolean);
  123958. /**
  123959. * Gets the current transparency mode.
  123960. */
  123961. get transparencyMode(): Nullable<number>;
  123962. /**
  123963. * Sets the transparency mode of the material.
  123964. *
  123965. * | Value | Type | Description |
  123966. * | ----- | ----------------------------------- | ----------- |
  123967. * | 0 | OPAQUE | |
  123968. * | 1 | ALPHATEST | |
  123969. * | 2 | ALPHABLEND | |
  123970. * | 3 | ALPHATESTANDBLEND | |
  123971. *
  123972. */
  123973. set transparencyMode(value: Nullable<number>);
  123974. /**
  123975. * Returns true if alpha blending should be disabled.
  123976. */
  123977. private get _disableAlphaBlending();
  123978. /**
  123979. * Specifies whether or not this material should be rendered in alpha blend mode.
  123980. */
  123981. needAlphaBlending(): boolean;
  123982. /**
  123983. * Specifies if the mesh will require alpha blending.
  123984. * @param mesh - BJS mesh.
  123985. */
  123986. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  123987. /**
  123988. * Specifies whether or not this material should be rendered in alpha test mode.
  123989. */
  123990. needAlphaTesting(): boolean;
  123991. /**
  123992. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  123993. */
  123994. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  123995. /**
  123996. * Gets the texture used for the alpha test.
  123997. */
  123998. getAlphaTestTexture(): Nullable<BaseTexture>;
  123999. /**
  124000. * Specifies that the submesh is ready to be used.
  124001. * @param mesh - BJS mesh.
  124002. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124003. * @param useInstances - Specifies that instances should be used.
  124004. * @returns - boolean indicating that the submesh is ready or not.
  124005. */
  124006. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124007. /**
  124008. * Specifies if the material uses metallic roughness workflow.
  124009. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124010. */
  124011. isMetallicWorkflow(): boolean;
  124012. private _prepareEffect;
  124013. private _prepareDefines;
  124014. /**
  124015. * Force shader compilation
  124016. */
  124017. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124018. /**
  124019. * Initializes the uniform buffer layout for the shader.
  124020. */
  124021. buildUniformLayout(): void;
  124022. /**
  124023. * Unbinds the material from the mesh
  124024. */
  124025. unbind(): void;
  124026. /**
  124027. * Binds the submesh data.
  124028. * @param world - The world matrix.
  124029. * @param mesh - The BJS mesh.
  124030. * @param subMesh - A submesh of the BJS mesh.
  124031. */
  124032. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124033. /**
  124034. * Returns the animatable textures.
  124035. * @returns - Array of animatable textures.
  124036. */
  124037. getAnimatables(): IAnimatable[];
  124038. /**
  124039. * Returns the texture used for reflections.
  124040. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124041. */
  124042. private _getReflectionTexture;
  124043. /**
  124044. * Returns an array of the actively used textures.
  124045. * @returns - Array of BaseTextures
  124046. */
  124047. getActiveTextures(): BaseTexture[];
  124048. /**
  124049. * Checks to see if a texture is used in the material.
  124050. * @param texture - Base texture to use.
  124051. * @returns - Boolean specifying if a texture is used in the material.
  124052. */
  124053. hasTexture(texture: BaseTexture): boolean;
  124054. /**
  124055. * Disposes the resources of the material.
  124056. * @param forceDisposeEffect - Forces the disposal of effects.
  124057. * @param forceDisposeTextures - Forces the disposal of all textures.
  124058. */
  124059. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124060. }
  124061. }
  124062. declare module BABYLON {
  124063. /**
  124064. * The Physically based material of BJS.
  124065. *
  124066. * This offers the main features of a standard PBR material.
  124067. * For more information, please refer to the documentation :
  124068. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124069. */
  124070. export class PBRMaterial extends PBRBaseMaterial {
  124071. /**
  124072. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124073. */
  124074. static readonly PBRMATERIAL_OPAQUE: number;
  124075. /**
  124076. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124077. */
  124078. static readonly PBRMATERIAL_ALPHATEST: number;
  124079. /**
  124080. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124081. */
  124082. static readonly PBRMATERIAL_ALPHABLEND: number;
  124083. /**
  124084. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124085. * They are also discarded below the alpha cutoff threshold to improve performances.
  124086. */
  124087. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124088. /**
  124089. * Defines the default value of how much AO map is occluding the analytical lights
  124090. * (point spot...).
  124091. */
  124092. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124093. /**
  124094. * Intensity of the direct lights e.g. the four lights available in your scene.
  124095. * This impacts both the direct diffuse and specular highlights.
  124096. */
  124097. directIntensity: number;
  124098. /**
  124099. * Intensity of the emissive part of the material.
  124100. * This helps controlling the emissive effect without modifying the emissive color.
  124101. */
  124102. emissiveIntensity: number;
  124103. /**
  124104. * Intensity of the environment e.g. how much the environment will light the object
  124105. * either through harmonics for rough material or through the refelction for shiny ones.
  124106. */
  124107. environmentIntensity: number;
  124108. /**
  124109. * This is a special control allowing the reduction of the specular highlights coming from the
  124110. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124111. */
  124112. specularIntensity: number;
  124113. /**
  124114. * Debug Control allowing disabling the bump map on this material.
  124115. */
  124116. disableBumpMap: boolean;
  124117. /**
  124118. * AKA Diffuse Texture in standard nomenclature.
  124119. */
  124120. albedoTexture: BaseTexture;
  124121. /**
  124122. * AKA Occlusion Texture in other nomenclature.
  124123. */
  124124. ambientTexture: BaseTexture;
  124125. /**
  124126. * AKA Occlusion Texture Intensity in other nomenclature.
  124127. */
  124128. ambientTextureStrength: number;
  124129. /**
  124130. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124131. * 1 means it completely occludes it
  124132. * 0 mean it has no impact
  124133. */
  124134. ambientTextureImpactOnAnalyticalLights: number;
  124135. /**
  124136. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124137. */
  124138. opacityTexture: BaseTexture;
  124139. /**
  124140. * Stores the reflection values in a texture.
  124141. */
  124142. reflectionTexture: Nullable<BaseTexture>;
  124143. /**
  124144. * Stores the emissive values in a texture.
  124145. */
  124146. emissiveTexture: BaseTexture;
  124147. /**
  124148. * AKA Specular texture in other nomenclature.
  124149. */
  124150. reflectivityTexture: BaseTexture;
  124151. /**
  124152. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124153. */
  124154. metallicTexture: BaseTexture;
  124155. /**
  124156. * Specifies the metallic scalar of the metallic/roughness workflow.
  124157. * Can also be used to scale the metalness values of the metallic texture.
  124158. */
  124159. metallic: Nullable<number>;
  124160. /**
  124161. * Specifies the roughness scalar of the metallic/roughness workflow.
  124162. * Can also be used to scale the roughness values of the metallic texture.
  124163. */
  124164. roughness: Nullable<number>;
  124165. /**
  124166. * Specifies the an F0 factor to help configuring the material F0.
  124167. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124168. * to 0.5 the previously hard coded value stays the same.
  124169. * Can also be used to scale the F0 values of the metallic texture.
  124170. */
  124171. metallicF0Factor: number;
  124172. /**
  124173. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124174. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124175. * your expectation as it multiplies with the texture data.
  124176. */
  124177. useMetallicF0FactorFromMetallicTexture: boolean;
  124178. /**
  124179. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124180. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124181. */
  124182. microSurfaceTexture: BaseTexture;
  124183. /**
  124184. * Stores surface normal data used to displace a mesh in a texture.
  124185. */
  124186. bumpTexture: BaseTexture;
  124187. /**
  124188. * Stores the pre-calculated light information of a mesh in a texture.
  124189. */
  124190. lightmapTexture: BaseTexture;
  124191. /**
  124192. * Stores the refracted light information in a texture.
  124193. */
  124194. get refractionTexture(): Nullable<BaseTexture>;
  124195. set refractionTexture(value: Nullable<BaseTexture>);
  124196. /**
  124197. * The color of a material in ambient lighting.
  124198. */
  124199. ambientColor: Color3;
  124200. /**
  124201. * AKA Diffuse Color in other nomenclature.
  124202. */
  124203. albedoColor: Color3;
  124204. /**
  124205. * AKA Specular Color in other nomenclature.
  124206. */
  124207. reflectivityColor: Color3;
  124208. /**
  124209. * The color reflected from the material.
  124210. */
  124211. reflectionColor: Color3;
  124212. /**
  124213. * The color emitted from the material.
  124214. */
  124215. emissiveColor: Color3;
  124216. /**
  124217. * AKA Glossiness in other nomenclature.
  124218. */
  124219. microSurface: number;
  124220. /**
  124221. * source material index of refraction (IOR)' / 'destination material IOR.
  124222. */
  124223. get indexOfRefraction(): number;
  124224. set indexOfRefraction(value: number);
  124225. /**
  124226. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124227. */
  124228. get invertRefractionY(): boolean;
  124229. set invertRefractionY(value: boolean);
  124230. /**
  124231. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124232. * Materials half opaque for instance using refraction could benefit from this control.
  124233. */
  124234. get linkRefractionWithTransparency(): boolean;
  124235. set linkRefractionWithTransparency(value: boolean);
  124236. /**
  124237. * If true, the light map contains occlusion information instead of lighting info.
  124238. */
  124239. useLightmapAsShadowmap: boolean;
  124240. /**
  124241. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124242. */
  124243. useAlphaFromAlbedoTexture: boolean;
  124244. /**
  124245. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124246. */
  124247. forceAlphaTest: boolean;
  124248. /**
  124249. * Defines the alpha limits in alpha test mode.
  124250. */
  124251. alphaCutOff: number;
  124252. /**
  124253. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124254. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124255. */
  124256. useSpecularOverAlpha: boolean;
  124257. /**
  124258. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124259. */
  124260. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124261. /**
  124262. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124263. */
  124264. useRoughnessFromMetallicTextureAlpha: boolean;
  124265. /**
  124266. * Specifies if the metallic texture contains the roughness information in its green channel.
  124267. */
  124268. useRoughnessFromMetallicTextureGreen: boolean;
  124269. /**
  124270. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124271. */
  124272. useMetallnessFromMetallicTextureBlue: boolean;
  124273. /**
  124274. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124275. */
  124276. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124277. /**
  124278. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124279. */
  124280. useAmbientInGrayScale: boolean;
  124281. /**
  124282. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124283. * The material will try to infer what glossiness each pixel should be.
  124284. */
  124285. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124286. /**
  124287. * BJS is using an harcoded light falloff based on a manually sets up range.
  124288. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124289. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124290. */
  124291. get usePhysicalLightFalloff(): boolean;
  124292. /**
  124293. * BJS is using an harcoded light falloff based on a manually sets up range.
  124294. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124295. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124296. */
  124297. set usePhysicalLightFalloff(value: boolean);
  124298. /**
  124299. * In order to support the falloff compatibility with gltf, a special mode has been added
  124300. * to reproduce the gltf light falloff.
  124301. */
  124302. get useGLTFLightFalloff(): boolean;
  124303. /**
  124304. * In order to support the falloff compatibility with gltf, a special mode has been added
  124305. * to reproduce the gltf light falloff.
  124306. */
  124307. set useGLTFLightFalloff(value: boolean);
  124308. /**
  124309. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124310. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124311. */
  124312. useRadianceOverAlpha: boolean;
  124313. /**
  124314. * Allows using an object space normal map (instead of tangent space).
  124315. */
  124316. useObjectSpaceNormalMap: boolean;
  124317. /**
  124318. * Allows using the bump map in parallax mode.
  124319. */
  124320. useParallax: boolean;
  124321. /**
  124322. * Allows using the bump map in parallax occlusion mode.
  124323. */
  124324. useParallaxOcclusion: boolean;
  124325. /**
  124326. * Controls the scale bias of the parallax mode.
  124327. */
  124328. parallaxScaleBias: number;
  124329. /**
  124330. * If sets to true, disables all the lights affecting the material.
  124331. */
  124332. disableLighting: boolean;
  124333. /**
  124334. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124335. */
  124336. forceIrradianceInFragment: boolean;
  124337. /**
  124338. * Number of Simultaneous lights allowed on the material.
  124339. */
  124340. maxSimultaneousLights: number;
  124341. /**
  124342. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124343. */
  124344. invertNormalMapX: boolean;
  124345. /**
  124346. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124347. */
  124348. invertNormalMapY: boolean;
  124349. /**
  124350. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124351. */
  124352. twoSidedLighting: boolean;
  124353. /**
  124354. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124355. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124356. */
  124357. useAlphaFresnel: boolean;
  124358. /**
  124359. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124360. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124361. */
  124362. useLinearAlphaFresnel: boolean;
  124363. /**
  124364. * Let user defines the brdf lookup texture used for IBL.
  124365. * A default 8bit version is embedded but you could point at :
  124366. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124367. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124368. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124369. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124370. */
  124371. environmentBRDFTexture: Nullable<BaseTexture>;
  124372. /**
  124373. * Force normal to face away from face.
  124374. */
  124375. forceNormalForward: boolean;
  124376. /**
  124377. * Enables specular anti aliasing in the PBR shader.
  124378. * It will both interacts on the Geometry for analytical and IBL lighting.
  124379. * It also prefilter the roughness map based on the bump values.
  124380. */
  124381. enableSpecularAntiAliasing: boolean;
  124382. /**
  124383. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124384. * makes the reflect vector face the model (under horizon).
  124385. */
  124386. useHorizonOcclusion: boolean;
  124387. /**
  124388. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124389. * too much the area relying on ambient texture to define their ambient occlusion.
  124390. */
  124391. useRadianceOcclusion: boolean;
  124392. /**
  124393. * If set to true, no lighting calculations will be applied.
  124394. */
  124395. unlit: boolean;
  124396. /**
  124397. * Gets the image processing configuration used either in this material.
  124398. */
  124399. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124400. /**
  124401. * Sets the Default image processing configuration used either in the this material.
  124402. *
  124403. * If sets to null, the scene one is in use.
  124404. */
  124405. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124406. /**
  124407. * Gets wether the color curves effect is enabled.
  124408. */
  124409. get cameraColorCurvesEnabled(): boolean;
  124410. /**
  124411. * Sets wether the color curves effect is enabled.
  124412. */
  124413. set cameraColorCurvesEnabled(value: boolean);
  124414. /**
  124415. * Gets wether the color grading effect is enabled.
  124416. */
  124417. get cameraColorGradingEnabled(): boolean;
  124418. /**
  124419. * Gets wether the color grading effect is enabled.
  124420. */
  124421. set cameraColorGradingEnabled(value: boolean);
  124422. /**
  124423. * Gets wether tonemapping is enabled or not.
  124424. */
  124425. get cameraToneMappingEnabled(): boolean;
  124426. /**
  124427. * Sets wether tonemapping is enabled or not
  124428. */
  124429. set cameraToneMappingEnabled(value: boolean);
  124430. /**
  124431. * The camera exposure used on this material.
  124432. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124433. * This corresponds to a photographic exposure.
  124434. */
  124435. get cameraExposure(): number;
  124436. /**
  124437. * The camera exposure used on this material.
  124438. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124439. * This corresponds to a photographic exposure.
  124440. */
  124441. set cameraExposure(value: number);
  124442. /**
  124443. * Gets The camera contrast used on this material.
  124444. */
  124445. get cameraContrast(): number;
  124446. /**
  124447. * Sets The camera contrast used on this material.
  124448. */
  124449. set cameraContrast(value: number);
  124450. /**
  124451. * Gets the Color Grading 2D Lookup Texture.
  124452. */
  124453. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124454. /**
  124455. * Sets the Color Grading 2D Lookup Texture.
  124456. */
  124457. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124458. /**
  124459. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124460. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124461. * 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;
  124462. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124463. */
  124464. get cameraColorCurves(): Nullable<ColorCurves>;
  124465. /**
  124466. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124467. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124468. * 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;
  124469. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124470. */
  124471. set cameraColorCurves(value: Nullable<ColorCurves>);
  124472. /**
  124473. * Instantiates a new PBRMaterial instance.
  124474. *
  124475. * @param name The material name
  124476. * @param scene The scene the material will be use in.
  124477. */
  124478. constructor(name: string, scene: Scene);
  124479. /**
  124480. * Returns the name of this material class.
  124481. */
  124482. getClassName(): string;
  124483. /**
  124484. * Makes a duplicate of the current material.
  124485. * @param name - name to use for the new material.
  124486. */
  124487. clone(name: string): PBRMaterial;
  124488. /**
  124489. * Serializes this PBR Material.
  124490. * @returns - An object with the serialized material.
  124491. */
  124492. serialize(): any;
  124493. /**
  124494. * Parses a PBR Material from a serialized object.
  124495. * @param source - Serialized object.
  124496. * @param scene - BJS scene instance.
  124497. * @param rootUrl - url for the scene object
  124498. * @returns - PBRMaterial
  124499. */
  124500. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  124501. }
  124502. }
  124503. declare module BABYLON {
  124504. /**
  124505. * Direct draw surface info
  124506. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  124507. */
  124508. export interface DDSInfo {
  124509. /**
  124510. * Width of the texture
  124511. */
  124512. width: number;
  124513. /**
  124514. * Width of the texture
  124515. */
  124516. height: number;
  124517. /**
  124518. * Number of Mipmaps for the texture
  124519. * @see https://en.wikipedia.org/wiki/Mipmap
  124520. */
  124521. mipmapCount: number;
  124522. /**
  124523. * If the textures format is a known fourCC format
  124524. * @see https://www.fourcc.org/
  124525. */
  124526. isFourCC: boolean;
  124527. /**
  124528. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  124529. */
  124530. isRGB: boolean;
  124531. /**
  124532. * If the texture is a lumincance format
  124533. */
  124534. isLuminance: boolean;
  124535. /**
  124536. * If this is a cube texture
  124537. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  124538. */
  124539. isCube: boolean;
  124540. /**
  124541. * If the texture is a compressed format eg. FOURCC_DXT1
  124542. */
  124543. isCompressed: boolean;
  124544. /**
  124545. * The dxgiFormat of the texture
  124546. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  124547. */
  124548. dxgiFormat: number;
  124549. /**
  124550. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  124551. */
  124552. textureType: number;
  124553. /**
  124554. * Sphericle polynomial created for the dds texture
  124555. */
  124556. sphericalPolynomial?: SphericalPolynomial;
  124557. }
  124558. /**
  124559. * Class used to provide DDS decompression tools
  124560. */
  124561. export class DDSTools {
  124562. /**
  124563. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  124564. */
  124565. static StoreLODInAlphaChannel: boolean;
  124566. /**
  124567. * Gets DDS information from an array buffer
  124568. * @param arrayBuffer defines the array buffer to read data from
  124569. * @returns the DDS information
  124570. */
  124571. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  124572. private static _FloatView;
  124573. private static _Int32View;
  124574. private static _ToHalfFloat;
  124575. private static _FromHalfFloat;
  124576. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  124577. private static _GetHalfFloatRGBAArrayBuffer;
  124578. private static _GetFloatRGBAArrayBuffer;
  124579. private static _GetFloatAsUIntRGBAArrayBuffer;
  124580. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  124581. private static _GetRGBAArrayBuffer;
  124582. private static _ExtractLongWordOrder;
  124583. private static _GetRGBArrayBuffer;
  124584. private static _GetLuminanceArrayBuffer;
  124585. /**
  124586. * Uploads DDS Levels to a Babylon Texture
  124587. * @hidden
  124588. */
  124589. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  124590. }
  124591. interface ThinEngine {
  124592. /**
  124593. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  124594. * @param rootUrl defines the url where the file to load is located
  124595. * @param scene defines the current scene
  124596. * @param lodScale defines scale to apply to the mip map selection
  124597. * @param lodOffset defines offset to apply to the mip map selection
  124598. * @param onLoad defines an optional callback raised when the texture is loaded
  124599. * @param onError defines an optional callback raised if there is an issue to load the texture
  124600. * @param format defines the format of the data
  124601. * @param forcedExtension defines the extension to use to pick the right loader
  124602. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  124603. * @returns the cube texture as an InternalTexture
  124604. */
  124605. 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;
  124606. }
  124607. }
  124608. declare module BABYLON {
  124609. /**
  124610. * Implementation of the DDS Texture Loader.
  124611. * @hidden
  124612. */
  124613. export class _DDSTextureLoader implements IInternalTextureLoader {
  124614. /**
  124615. * Defines wether the loader supports cascade loading the different faces.
  124616. */
  124617. readonly supportCascades: boolean;
  124618. /**
  124619. * This returns if the loader support the current file information.
  124620. * @param extension defines the file extension of the file being loaded
  124621. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124622. * @param fallback defines the fallback internal texture if any
  124623. * @param isBase64 defines whether the texture is encoded as a base64
  124624. * @param isBuffer defines whether the texture data are stored as a buffer
  124625. * @returns true if the loader can load the specified file
  124626. */
  124627. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124628. /**
  124629. * Transform the url before loading if required.
  124630. * @param rootUrl the url of the texture
  124631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124632. * @returns the transformed texture
  124633. */
  124634. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124635. /**
  124636. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124637. * @param rootUrl the url of the texture
  124638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124639. * @returns the fallback texture
  124640. */
  124641. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124642. /**
  124643. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124644. * @param data contains the texture data
  124645. * @param texture defines the BabylonJS internal texture
  124646. * @param createPolynomials will be true if polynomials have been requested
  124647. * @param onLoad defines the callback to trigger once the texture is ready
  124648. * @param onError defines the callback to trigger in case of error
  124649. */
  124650. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124651. /**
  124652. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124653. * @param data contains the texture data
  124654. * @param texture defines the BabylonJS internal texture
  124655. * @param callback defines the method to call once ready to upload
  124656. */
  124657. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124658. }
  124659. }
  124660. declare module BABYLON {
  124661. /**
  124662. * Implementation of the ENV Texture Loader.
  124663. * @hidden
  124664. */
  124665. export class _ENVTextureLoader implements IInternalTextureLoader {
  124666. /**
  124667. * Defines wether the loader supports cascade loading the different faces.
  124668. */
  124669. readonly supportCascades: boolean;
  124670. /**
  124671. * This returns if the loader support the current file information.
  124672. * @param extension defines the file extension of the file being loaded
  124673. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124674. * @param fallback defines the fallback internal texture if any
  124675. * @param isBase64 defines whether the texture is encoded as a base64
  124676. * @param isBuffer defines whether the texture data are stored as a buffer
  124677. * @returns true if the loader can load the specified file
  124678. */
  124679. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124680. /**
  124681. * Transform the url before loading if required.
  124682. * @param rootUrl the url of the texture
  124683. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124684. * @returns the transformed texture
  124685. */
  124686. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124687. /**
  124688. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124689. * @param rootUrl the url of the texture
  124690. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124691. * @returns the fallback texture
  124692. */
  124693. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124694. /**
  124695. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124696. * @param data contains the texture data
  124697. * @param texture defines the BabylonJS internal texture
  124698. * @param createPolynomials will be true if polynomials have been requested
  124699. * @param onLoad defines the callback to trigger once the texture is ready
  124700. * @param onError defines the callback to trigger in case of error
  124701. */
  124702. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124703. /**
  124704. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124705. * @param data contains the texture data
  124706. * @param texture defines the BabylonJS internal texture
  124707. * @param callback defines the method to call once ready to upload
  124708. */
  124709. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124710. }
  124711. }
  124712. declare module BABYLON {
  124713. /**
  124714. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  124715. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  124716. */
  124717. export class KhronosTextureContainer {
  124718. /** contents of the KTX container file */
  124719. arrayBuffer: any;
  124720. private static HEADER_LEN;
  124721. private static COMPRESSED_2D;
  124722. private static COMPRESSED_3D;
  124723. private static TEX_2D;
  124724. private static TEX_3D;
  124725. /**
  124726. * Gets the openGL type
  124727. */
  124728. glType: number;
  124729. /**
  124730. * Gets the openGL type size
  124731. */
  124732. glTypeSize: number;
  124733. /**
  124734. * Gets the openGL format
  124735. */
  124736. glFormat: number;
  124737. /**
  124738. * Gets the openGL internal format
  124739. */
  124740. glInternalFormat: number;
  124741. /**
  124742. * Gets the base internal format
  124743. */
  124744. glBaseInternalFormat: number;
  124745. /**
  124746. * Gets image width in pixel
  124747. */
  124748. pixelWidth: number;
  124749. /**
  124750. * Gets image height in pixel
  124751. */
  124752. pixelHeight: number;
  124753. /**
  124754. * Gets image depth in pixels
  124755. */
  124756. pixelDepth: number;
  124757. /**
  124758. * Gets the number of array elements
  124759. */
  124760. numberOfArrayElements: number;
  124761. /**
  124762. * Gets the number of faces
  124763. */
  124764. numberOfFaces: number;
  124765. /**
  124766. * Gets the number of mipmap levels
  124767. */
  124768. numberOfMipmapLevels: number;
  124769. /**
  124770. * Gets the bytes of key value data
  124771. */
  124772. bytesOfKeyValueData: number;
  124773. /**
  124774. * Gets the load type
  124775. */
  124776. loadType: number;
  124777. /**
  124778. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  124779. */
  124780. isInvalid: boolean;
  124781. /**
  124782. * Creates a new KhronosTextureContainer
  124783. * @param arrayBuffer contents of the KTX container file
  124784. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  124785. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  124786. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  124787. */
  124788. constructor(
  124789. /** contents of the KTX container file */
  124790. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  124791. /**
  124792. * Uploads KTX content to a Babylon Texture.
  124793. * It is assumed that the texture has already been created & is currently bound
  124794. * @hidden
  124795. */
  124796. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  124797. private _upload2DCompressedLevels;
  124798. }
  124799. }
  124800. declare module BABYLON {
  124801. /**
  124802. * Implementation of the KTX Texture Loader.
  124803. * @hidden
  124804. */
  124805. export class _KTXTextureLoader implements IInternalTextureLoader {
  124806. /**
  124807. * Defines wether the loader supports cascade loading the different faces.
  124808. */
  124809. readonly supportCascades: boolean;
  124810. /**
  124811. * This returns if the loader support the current file information.
  124812. * @param extension defines the file extension of the file being loaded
  124813. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124814. * @param fallback defines the fallback internal texture if any
  124815. * @param isBase64 defines whether the texture is encoded as a base64
  124816. * @param isBuffer defines whether the texture data are stored as a buffer
  124817. * @returns true if the loader can load the specified file
  124818. */
  124819. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124820. /**
  124821. * Transform the url before loading if required.
  124822. * @param rootUrl the url of the texture
  124823. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124824. * @returns the transformed texture
  124825. */
  124826. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124827. /**
  124828. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124829. * @param rootUrl the url of the texture
  124830. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124831. * @returns the fallback texture
  124832. */
  124833. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124834. /**
  124835. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124836. * @param data contains the texture data
  124837. * @param texture defines the BabylonJS internal texture
  124838. * @param createPolynomials will be true if polynomials have been requested
  124839. * @param onLoad defines the callback to trigger once the texture is ready
  124840. * @param onError defines the callback to trigger in case of error
  124841. */
  124842. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124843. /**
  124844. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124845. * @param data contains the texture data
  124846. * @param texture defines the BabylonJS internal texture
  124847. * @param callback defines the method to call once ready to upload
  124848. */
  124849. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  124850. }
  124851. }
  124852. declare module BABYLON {
  124853. /** @hidden */
  124854. export var _forceSceneHelpersToBundle: boolean;
  124855. interface Scene {
  124856. /**
  124857. * Creates a default light for the scene.
  124858. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  124859. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  124860. */
  124861. createDefaultLight(replace?: boolean): void;
  124862. /**
  124863. * Creates a default camera for the scene.
  124864. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  124865. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124866. * @param replace has default false, when true replaces the active camera in the scene
  124867. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  124868. */
  124869. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124870. /**
  124871. * Creates a default camera and a default light.
  124872. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  124873. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124874. * @param replace has the default false, when true replaces the active camera/light in the scene
  124875. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  124876. */
  124877. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124878. /**
  124879. * Creates a new sky box
  124880. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  124881. * @param environmentTexture defines the texture to use as environment texture
  124882. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  124883. * @param scale defines the overall scale of the skybox
  124884. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  124885. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  124886. * @returns a new mesh holding the sky box
  124887. */
  124888. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  124889. /**
  124890. * Creates a new environment
  124891. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  124892. * @param options defines the options you can use to configure the environment
  124893. * @returns the new EnvironmentHelper
  124894. */
  124895. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  124896. /**
  124897. * Creates a new VREXperienceHelper
  124898. * @see http://doc.babylonjs.com/how_to/webvr_helper
  124899. * @param webVROptions defines the options used to create the new VREXperienceHelper
  124900. * @returns a new VREXperienceHelper
  124901. */
  124902. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  124903. /**
  124904. * Creates a new WebXRDefaultExperience
  124905. * @see http://doc.babylonjs.com/how_to/webxr
  124906. * @param options experience options
  124907. * @returns a promise for a new WebXRDefaultExperience
  124908. */
  124909. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  124910. }
  124911. }
  124912. declare module BABYLON {
  124913. /**
  124914. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  124915. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  124916. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  124917. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124918. */
  124919. export class VideoDome extends TransformNode {
  124920. /**
  124921. * Define the video source as a Monoscopic panoramic 360 video.
  124922. */
  124923. static readonly MODE_MONOSCOPIC: number;
  124924. /**
  124925. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  124926. */
  124927. static readonly MODE_TOPBOTTOM: number;
  124928. /**
  124929. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  124930. */
  124931. static readonly MODE_SIDEBYSIDE: number;
  124932. private _halfDome;
  124933. private _useDirectMapping;
  124934. /**
  124935. * The video texture being displayed on the sphere
  124936. */
  124937. protected _videoTexture: VideoTexture;
  124938. /**
  124939. * Gets the video texture being displayed on the sphere
  124940. */
  124941. get videoTexture(): VideoTexture;
  124942. /**
  124943. * The skybox material
  124944. */
  124945. protected _material: BackgroundMaterial;
  124946. /**
  124947. * The surface used for the skybox
  124948. */
  124949. protected _mesh: Mesh;
  124950. /**
  124951. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  124952. */
  124953. private _halfDomeMask;
  124954. /**
  124955. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124956. * Also see the options.resolution property.
  124957. */
  124958. get fovMultiplier(): number;
  124959. set fovMultiplier(value: number);
  124960. private _videoMode;
  124961. /**
  124962. * Gets or set the current video mode for the video. It can be:
  124963. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  124964. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  124965. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  124966. */
  124967. get videoMode(): number;
  124968. set videoMode(value: number);
  124969. /**
  124970. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  124971. *
  124972. */
  124973. get halfDome(): boolean;
  124974. /**
  124975. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  124976. */
  124977. set halfDome(enabled: boolean);
  124978. /**
  124979. * Oberserver used in Stereoscopic VR Mode.
  124980. */
  124981. private _onBeforeCameraRenderObserver;
  124982. /**
  124983. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  124984. * @param name Element's name, child elements will append suffixes for their own names.
  124985. * @param urlsOrVideo defines the url(s) or the video element to use
  124986. * @param options An object containing optional or exposed sub element properties
  124987. */
  124988. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  124989. resolution?: number;
  124990. clickToPlay?: boolean;
  124991. autoPlay?: boolean;
  124992. loop?: boolean;
  124993. size?: number;
  124994. poster?: string;
  124995. faceForward?: boolean;
  124996. useDirectMapping?: boolean;
  124997. halfDomeMode?: boolean;
  124998. }, scene: Scene);
  124999. private _changeVideoMode;
  125000. /**
  125001. * Releases resources associated with this node.
  125002. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125003. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125004. */
  125005. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125006. }
  125007. }
  125008. declare module BABYLON {
  125009. /**
  125010. * This class can be used to get instrumentation data from a Babylon engine
  125011. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125012. */
  125013. export class EngineInstrumentation implements IDisposable {
  125014. /**
  125015. * Define the instrumented engine.
  125016. */
  125017. engine: Engine;
  125018. private _captureGPUFrameTime;
  125019. private _gpuFrameTimeToken;
  125020. private _gpuFrameTime;
  125021. private _captureShaderCompilationTime;
  125022. private _shaderCompilationTime;
  125023. private _onBeginFrameObserver;
  125024. private _onEndFrameObserver;
  125025. private _onBeforeShaderCompilationObserver;
  125026. private _onAfterShaderCompilationObserver;
  125027. /**
  125028. * Gets the perf counter used for GPU frame time
  125029. */
  125030. get gpuFrameTimeCounter(): PerfCounter;
  125031. /**
  125032. * Gets the GPU frame time capture status
  125033. */
  125034. get captureGPUFrameTime(): boolean;
  125035. /**
  125036. * Enable or disable the GPU frame time capture
  125037. */
  125038. set captureGPUFrameTime(value: boolean);
  125039. /**
  125040. * Gets the perf counter used for shader compilation time
  125041. */
  125042. get shaderCompilationTimeCounter(): PerfCounter;
  125043. /**
  125044. * Gets the shader compilation time capture status
  125045. */
  125046. get captureShaderCompilationTime(): boolean;
  125047. /**
  125048. * Enable or disable the shader compilation time capture
  125049. */
  125050. set captureShaderCompilationTime(value: boolean);
  125051. /**
  125052. * Instantiates a new engine instrumentation.
  125053. * This class can be used to get instrumentation data from a Babylon engine
  125054. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125055. * @param engine Defines the engine to instrument
  125056. */
  125057. constructor(
  125058. /**
  125059. * Define the instrumented engine.
  125060. */
  125061. engine: Engine);
  125062. /**
  125063. * Dispose and release associated resources.
  125064. */
  125065. dispose(): void;
  125066. }
  125067. }
  125068. declare module BABYLON {
  125069. /**
  125070. * This class can be used to get instrumentation data from a Babylon engine
  125071. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125072. */
  125073. export class SceneInstrumentation implements IDisposable {
  125074. /**
  125075. * Defines the scene to instrument
  125076. */
  125077. scene: Scene;
  125078. private _captureActiveMeshesEvaluationTime;
  125079. private _activeMeshesEvaluationTime;
  125080. private _captureRenderTargetsRenderTime;
  125081. private _renderTargetsRenderTime;
  125082. private _captureFrameTime;
  125083. private _frameTime;
  125084. private _captureRenderTime;
  125085. private _renderTime;
  125086. private _captureInterFrameTime;
  125087. private _interFrameTime;
  125088. private _captureParticlesRenderTime;
  125089. private _particlesRenderTime;
  125090. private _captureSpritesRenderTime;
  125091. private _spritesRenderTime;
  125092. private _capturePhysicsTime;
  125093. private _physicsTime;
  125094. private _captureAnimationsTime;
  125095. private _animationsTime;
  125096. private _captureCameraRenderTime;
  125097. private _cameraRenderTime;
  125098. private _onBeforeActiveMeshesEvaluationObserver;
  125099. private _onAfterActiveMeshesEvaluationObserver;
  125100. private _onBeforeRenderTargetsRenderObserver;
  125101. private _onAfterRenderTargetsRenderObserver;
  125102. private _onAfterRenderObserver;
  125103. private _onBeforeDrawPhaseObserver;
  125104. private _onAfterDrawPhaseObserver;
  125105. private _onBeforeAnimationsObserver;
  125106. private _onBeforeParticlesRenderingObserver;
  125107. private _onAfterParticlesRenderingObserver;
  125108. private _onBeforeSpritesRenderingObserver;
  125109. private _onAfterSpritesRenderingObserver;
  125110. private _onBeforePhysicsObserver;
  125111. private _onAfterPhysicsObserver;
  125112. private _onAfterAnimationsObserver;
  125113. private _onBeforeCameraRenderObserver;
  125114. private _onAfterCameraRenderObserver;
  125115. /**
  125116. * Gets the perf counter used for active meshes evaluation time
  125117. */
  125118. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125119. /**
  125120. * Gets the active meshes evaluation time capture status
  125121. */
  125122. get captureActiveMeshesEvaluationTime(): boolean;
  125123. /**
  125124. * Enable or disable the active meshes evaluation time capture
  125125. */
  125126. set captureActiveMeshesEvaluationTime(value: boolean);
  125127. /**
  125128. * Gets the perf counter used for render targets render time
  125129. */
  125130. get renderTargetsRenderTimeCounter(): PerfCounter;
  125131. /**
  125132. * Gets the render targets render time capture status
  125133. */
  125134. get captureRenderTargetsRenderTime(): boolean;
  125135. /**
  125136. * Enable or disable the render targets render time capture
  125137. */
  125138. set captureRenderTargetsRenderTime(value: boolean);
  125139. /**
  125140. * Gets the perf counter used for particles render time
  125141. */
  125142. get particlesRenderTimeCounter(): PerfCounter;
  125143. /**
  125144. * Gets the particles render time capture status
  125145. */
  125146. get captureParticlesRenderTime(): boolean;
  125147. /**
  125148. * Enable or disable the particles render time capture
  125149. */
  125150. set captureParticlesRenderTime(value: boolean);
  125151. /**
  125152. * Gets the perf counter used for sprites render time
  125153. */
  125154. get spritesRenderTimeCounter(): PerfCounter;
  125155. /**
  125156. * Gets the sprites render time capture status
  125157. */
  125158. get captureSpritesRenderTime(): boolean;
  125159. /**
  125160. * Enable or disable the sprites render time capture
  125161. */
  125162. set captureSpritesRenderTime(value: boolean);
  125163. /**
  125164. * Gets the perf counter used for physics time
  125165. */
  125166. get physicsTimeCounter(): PerfCounter;
  125167. /**
  125168. * Gets the physics time capture status
  125169. */
  125170. get capturePhysicsTime(): boolean;
  125171. /**
  125172. * Enable or disable the physics time capture
  125173. */
  125174. set capturePhysicsTime(value: boolean);
  125175. /**
  125176. * Gets the perf counter used for animations time
  125177. */
  125178. get animationsTimeCounter(): PerfCounter;
  125179. /**
  125180. * Gets the animations time capture status
  125181. */
  125182. get captureAnimationsTime(): boolean;
  125183. /**
  125184. * Enable or disable the animations time capture
  125185. */
  125186. set captureAnimationsTime(value: boolean);
  125187. /**
  125188. * Gets the perf counter used for frame time capture
  125189. */
  125190. get frameTimeCounter(): PerfCounter;
  125191. /**
  125192. * Gets the frame time capture status
  125193. */
  125194. get captureFrameTime(): boolean;
  125195. /**
  125196. * Enable or disable the frame time capture
  125197. */
  125198. set captureFrameTime(value: boolean);
  125199. /**
  125200. * Gets the perf counter used for inter-frames time capture
  125201. */
  125202. get interFrameTimeCounter(): PerfCounter;
  125203. /**
  125204. * Gets the inter-frames time capture status
  125205. */
  125206. get captureInterFrameTime(): boolean;
  125207. /**
  125208. * Enable or disable the inter-frames time capture
  125209. */
  125210. set captureInterFrameTime(value: boolean);
  125211. /**
  125212. * Gets the perf counter used for render time capture
  125213. */
  125214. get renderTimeCounter(): PerfCounter;
  125215. /**
  125216. * Gets the render time capture status
  125217. */
  125218. get captureRenderTime(): boolean;
  125219. /**
  125220. * Enable or disable the render time capture
  125221. */
  125222. set captureRenderTime(value: boolean);
  125223. /**
  125224. * Gets the perf counter used for camera render time capture
  125225. */
  125226. get cameraRenderTimeCounter(): PerfCounter;
  125227. /**
  125228. * Gets the camera render time capture status
  125229. */
  125230. get captureCameraRenderTime(): boolean;
  125231. /**
  125232. * Enable or disable the camera render time capture
  125233. */
  125234. set captureCameraRenderTime(value: boolean);
  125235. /**
  125236. * Gets the perf counter used for draw calls
  125237. */
  125238. get drawCallsCounter(): PerfCounter;
  125239. /**
  125240. * Instantiates a new scene instrumentation.
  125241. * This class can be used to get instrumentation data from a Babylon engine
  125242. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125243. * @param scene Defines the scene to instrument
  125244. */
  125245. constructor(
  125246. /**
  125247. * Defines the scene to instrument
  125248. */
  125249. scene: Scene);
  125250. /**
  125251. * Dispose and release associated resources.
  125252. */
  125253. dispose(): void;
  125254. }
  125255. }
  125256. declare module BABYLON {
  125257. /** @hidden */
  125258. export var glowMapGenerationPixelShader: {
  125259. name: string;
  125260. shader: string;
  125261. };
  125262. }
  125263. declare module BABYLON {
  125264. /** @hidden */
  125265. export var glowMapGenerationVertexShader: {
  125266. name: string;
  125267. shader: string;
  125268. };
  125269. }
  125270. declare module BABYLON {
  125271. /**
  125272. * Effect layer options. This helps customizing the behaviour
  125273. * of the effect layer.
  125274. */
  125275. export interface IEffectLayerOptions {
  125276. /**
  125277. * Multiplication factor apply to the canvas size to compute the render target size
  125278. * used to generated the objects (the smaller the faster).
  125279. */
  125280. mainTextureRatio: number;
  125281. /**
  125282. * Enforces a fixed size texture to ensure effect stability across devices.
  125283. */
  125284. mainTextureFixedSize?: number;
  125285. /**
  125286. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125287. */
  125288. alphaBlendingMode: number;
  125289. /**
  125290. * The camera attached to the layer.
  125291. */
  125292. camera: Nullable<Camera>;
  125293. /**
  125294. * The rendering group to draw the layer in.
  125295. */
  125296. renderingGroupId: number;
  125297. }
  125298. /**
  125299. * The effect layer Helps adding post process effect blended with the main pass.
  125300. *
  125301. * This can be for instance use to generate glow or higlight effects on the scene.
  125302. *
  125303. * The effect layer class can not be used directly and is intented to inherited from to be
  125304. * customized per effects.
  125305. */
  125306. export abstract class EffectLayer {
  125307. private _vertexBuffers;
  125308. private _indexBuffer;
  125309. private _cachedDefines;
  125310. private _effectLayerMapGenerationEffect;
  125311. private _effectLayerOptions;
  125312. private _mergeEffect;
  125313. protected _scene: Scene;
  125314. protected _engine: Engine;
  125315. protected _maxSize: number;
  125316. protected _mainTextureDesiredSize: ISize;
  125317. protected _mainTexture: RenderTargetTexture;
  125318. protected _shouldRender: boolean;
  125319. protected _postProcesses: PostProcess[];
  125320. protected _textures: BaseTexture[];
  125321. protected _emissiveTextureAndColor: {
  125322. texture: Nullable<BaseTexture>;
  125323. color: Color4;
  125324. };
  125325. /**
  125326. * The name of the layer
  125327. */
  125328. name: string;
  125329. /**
  125330. * The clear color of the texture used to generate the glow map.
  125331. */
  125332. neutralColor: Color4;
  125333. /**
  125334. * Specifies wether the highlight layer is enabled or not.
  125335. */
  125336. isEnabled: boolean;
  125337. /**
  125338. * Gets the camera attached to the layer.
  125339. */
  125340. get camera(): Nullable<Camera>;
  125341. /**
  125342. * Gets the rendering group id the layer should render in.
  125343. */
  125344. get renderingGroupId(): number;
  125345. set renderingGroupId(renderingGroupId: number);
  125346. /**
  125347. * An event triggered when the effect layer has been disposed.
  125348. */
  125349. onDisposeObservable: Observable<EffectLayer>;
  125350. /**
  125351. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125352. */
  125353. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125354. /**
  125355. * An event triggered when the generated texture is being merged in the scene.
  125356. */
  125357. onBeforeComposeObservable: Observable<EffectLayer>;
  125358. /**
  125359. * An event triggered when the mesh is rendered into the effect render target.
  125360. */
  125361. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125362. /**
  125363. * An event triggered after the mesh has been rendered into the effect render target.
  125364. */
  125365. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125366. /**
  125367. * An event triggered when the generated texture has been merged in the scene.
  125368. */
  125369. onAfterComposeObservable: Observable<EffectLayer>;
  125370. /**
  125371. * An event triggered when the efffect layer changes its size.
  125372. */
  125373. onSizeChangedObservable: Observable<EffectLayer>;
  125374. /** @hidden */
  125375. static _SceneComponentInitialization: (scene: Scene) => void;
  125376. /**
  125377. * Instantiates a new effect Layer and references it in the scene.
  125378. * @param name The name of the layer
  125379. * @param scene The scene to use the layer in
  125380. */
  125381. constructor(
  125382. /** The Friendly of the effect in the scene */
  125383. name: string, scene: Scene);
  125384. /**
  125385. * Get the effect name of the layer.
  125386. * @return The effect name
  125387. */
  125388. abstract getEffectName(): string;
  125389. /**
  125390. * Checks for the readiness of the element composing the layer.
  125391. * @param subMesh the mesh to check for
  125392. * @param useInstances specify wether or not to use instances to render the mesh
  125393. * @return true if ready otherwise, false
  125394. */
  125395. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125396. /**
  125397. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  125398. * @returns true if the effect requires stencil during the main canvas render pass.
  125399. */
  125400. abstract needStencil(): boolean;
  125401. /**
  125402. * Create the merge effect. This is the shader use to blit the information back
  125403. * to the main canvas at the end of the scene rendering.
  125404. * @returns The effect containing the shader used to merge the effect on the main canvas
  125405. */
  125406. protected abstract _createMergeEffect(): Effect;
  125407. /**
  125408. * Creates the render target textures and post processes used in the effect layer.
  125409. */
  125410. protected abstract _createTextureAndPostProcesses(): void;
  125411. /**
  125412. * Implementation specific of rendering the generating effect on the main canvas.
  125413. * @param effect The effect used to render through
  125414. */
  125415. protected abstract _internalRender(effect: Effect): void;
  125416. /**
  125417. * Sets the required values for both the emissive texture and and the main color.
  125418. */
  125419. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125420. /**
  125421. * Free any resources and references associated to a mesh.
  125422. * Internal use
  125423. * @param mesh The mesh to free.
  125424. */
  125425. abstract _disposeMesh(mesh: Mesh): void;
  125426. /**
  125427. * Serializes this layer (Glow or Highlight for example)
  125428. * @returns a serialized layer object
  125429. */
  125430. abstract serialize?(): any;
  125431. /**
  125432. * Initializes the effect layer with the required options.
  125433. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  125434. */
  125435. protected _init(options: Partial<IEffectLayerOptions>): void;
  125436. /**
  125437. * Generates the index buffer of the full screen quad blending to the main canvas.
  125438. */
  125439. private _generateIndexBuffer;
  125440. /**
  125441. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  125442. */
  125443. private _generateVertexBuffer;
  125444. /**
  125445. * Sets the main texture desired size which is the closest power of two
  125446. * of the engine canvas size.
  125447. */
  125448. private _setMainTextureSize;
  125449. /**
  125450. * Creates the main texture for the effect layer.
  125451. */
  125452. protected _createMainTexture(): void;
  125453. /**
  125454. * Adds specific effects defines.
  125455. * @param defines The defines to add specifics to.
  125456. */
  125457. protected _addCustomEffectDefines(defines: string[]): void;
  125458. /**
  125459. * Checks for the readiness of the element composing the layer.
  125460. * @param subMesh the mesh to check for
  125461. * @param useInstances specify wether or not to use instances to render the mesh
  125462. * @param emissiveTexture the associated emissive texture used to generate the glow
  125463. * @return true if ready otherwise, false
  125464. */
  125465. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  125466. /**
  125467. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  125468. */
  125469. render(): void;
  125470. /**
  125471. * Determine if a given mesh will be used in the current effect.
  125472. * @param mesh mesh to test
  125473. * @returns true if the mesh will be used
  125474. */
  125475. hasMesh(mesh: AbstractMesh): boolean;
  125476. /**
  125477. * Returns true if the layer contains information to display, otherwise false.
  125478. * @returns true if the glow layer should be rendered
  125479. */
  125480. shouldRender(): boolean;
  125481. /**
  125482. * Returns true if the mesh should render, otherwise false.
  125483. * @param mesh The mesh to render
  125484. * @returns true if it should render otherwise false
  125485. */
  125486. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  125487. /**
  125488. * Returns true if the mesh can be rendered, otherwise false.
  125489. * @param mesh The mesh to render
  125490. * @param material The material used on the mesh
  125491. * @returns true if it can be rendered otherwise false
  125492. */
  125493. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125494. /**
  125495. * Returns true if the mesh should render, otherwise false.
  125496. * @param mesh The mesh to render
  125497. * @returns true if it should render otherwise false
  125498. */
  125499. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  125500. /**
  125501. * Renders the submesh passed in parameter to the generation map.
  125502. */
  125503. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  125504. /**
  125505. * Defines wether the current material of the mesh should be use to render the effect.
  125506. * @param mesh defines the current mesh to render
  125507. */
  125508. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125509. /**
  125510. * Rebuild the required buffers.
  125511. * @hidden Internal use only.
  125512. */
  125513. _rebuild(): void;
  125514. /**
  125515. * Dispose only the render target textures and post process.
  125516. */
  125517. private _disposeTextureAndPostProcesses;
  125518. /**
  125519. * Dispose the highlight layer and free resources.
  125520. */
  125521. dispose(): void;
  125522. /**
  125523. * Gets the class name of the effect layer
  125524. * @returns the string with the class name of the effect layer
  125525. */
  125526. getClassName(): string;
  125527. /**
  125528. * Creates an effect layer from parsed effect layer data
  125529. * @param parsedEffectLayer defines effect layer data
  125530. * @param scene defines the current scene
  125531. * @param rootUrl defines the root URL containing the effect layer information
  125532. * @returns a parsed effect Layer
  125533. */
  125534. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  125535. }
  125536. }
  125537. declare module BABYLON {
  125538. interface AbstractScene {
  125539. /**
  125540. * The list of effect layers (highlights/glow) added to the scene
  125541. * @see http://doc.babylonjs.com/how_to/highlight_layer
  125542. * @see http://doc.babylonjs.com/how_to/glow_layer
  125543. */
  125544. effectLayers: Array<EffectLayer>;
  125545. /**
  125546. * Removes the given effect layer from this scene.
  125547. * @param toRemove defines the effect layer to remove
  125548. * @returns the index of the removed effect layer
  125549. */
  125550. removeEffectLayer(toRemove: EffectLayer): number;
  125551. /**
  125552. * Adds the given effect layer to this scene
  125553. * @param newEffectLayer defines the effect layer to add
  125554. */
  125555. addEffectLayer(newEffectLayer: EffectLayer): void;
  125556. }
  125557. /**
  125558. * Defines the layer scene component responsible to manage any effect layers
  125559. * in a given scene.
  125560. */
  125561. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  125562. /**
  125563. * The component name helpfull to identify the component in the list of scene components.
  125564. */
  125565. readonly name: string;
  125566. /**
  125567. * The scene the component belongs to.
  125568. */
  125569. scene: Scene;
  125570. private _engine;
  125571. private _renderEffects;
  125572. private _needStencil;
  125573. private _previousStencilState;
  125574. /**
  125575. * Creates a new instance of the component for the given scene
  125576. * @param scene Defines the scene to register the component in
  125577. */
  125578. constructor(scene: Scene);
  125579. /**
  125580. * Registers the component in a given scene
  125581. */
  125582. register(): void;
  125583. /**
  125584. * Rebuilds the elements related to this component in case of
  125585. * context lost for instance.
  125586. */
  125587. rebuild(): void;
  125588. /**
  125589. * Serializes the component data to the specified json object
  125590. * @param serializationObject The object to serialize to
  125591. */
  125592. serialize(serializationObject: any): void;
  125593. /**
  125594. * Adds all the elements from the container to the scene
  125595. * @param container the container holding the elements
  125596. */
  125597. addFromContainer(container: AbstractScene): void;
  125598. /**
  125599. * Removes all the elements in the container from the scene
  125600. * @param container contains the elements to remove
  125601. * @param dispose if the removed element should be disposed (default: false)
  125602. */
  125603. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125604. /**
  125605. * Disposes the component and the associated ressources.
  125606. */
  125607. dispose(): void;
  125608. private _isReadyForMesh;
  125609. private _renderMainTexture;
  125610. private _setStencil;
  125611. private _setStencilBack;
  125612. private _draw;
  125613. private _drawCamera;
  125614. private _drawRenderingGroup;
  125615. }
  125616. }
  125617. declare module BABYLON {
  125618. /** @hidden */
  125619. export var glowMapMergePixelShader: {
  125620. name: string;
  125621. shader: string;
  125622. };
  125623. }
  125624. declare module BABYLON {
  125625. /** @hidden */
  125626. export var glowMapMergeVertexShader: {
  125627. name: string;
  125628. shader: string;
  125629. };
  125630. }
  125631. declare module BABYLON {
  125632. interface AbstractScene {
  125633. /**
  125634. * Return a the first highlight layer of the scene with a given name.
  125635. * @param name The name of the highlight layer to look for.
  125636. * @return The highlight layer if found otherwise null.
  125637. */
  125638. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  125639. }
  125640. /**
  125641. * Glow layer options. This helps customizing the behaviour
  125642. * of the glow layer.
  125643. */
  125644. export interface IGlowLayerOptions {
  125645. /**
  125646. * Multiplication factor apply to the canvas size to compute the render target size
  125647. * used to generated the glowing objects (the smaller the faster).
  125648. */
  125649. mainTextureRatio: number;
  125650. /**
  125651. * Enforces a fixed size texture to ensure resize independant blur.
  125652. */
  125653. mainTextureFixedSize?: number;
  125654. /**
  125655. * How big is the kernel of the blur texture.
  125656. */
  125657. blurKernelSize: number;
  125658. /**
  125659. * The camera attached to the layer.
  125660. */
  125661. camera: Nullable<Camera>;
  125662. /**
  125663. * Enable MSAA by chosing the number of samples.
  125664. */
  125665. mainTextureSamples?: number;
  125666. /**
  125667. * The rendering group to draw the layer in.
  125668. */
  125669. renderingGroupId: number;
  125670. }
  125671. /**
  125672. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  125673. *
  125674. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  125675. *
  125676. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  125677. */
  125678. export class GlowLayer extends EffectLayer {
  125679. /**
  125680. * Effect Name of the layer.
  125681. */
  125682. static readonly EffectName: string;
  125683. /**
  125684. * The default blur kernel size used for the glow.
  125685. */
  125686. static DefaultBlurKernelSize: number;
  125687. /**
  125688. * The default texture size ratio used for the glow.
  125689. */
  125690. static DefaultTextureRatio: number;
  125691. /**
  125692. * Sets the kernel size of the blur.
  125693. */
  125694. set blurKernelSize(value: number);
  125695. /**
  125696. * Gets the kernel size of the blur.
  125697. */
  125698. get blurKernelSize(): number;
  125699. /**
  125700. * Sets the glow intensity.
  125701. */
  125702. set intensity(value: number);
  125703. /**
  125704. * Gets the glow intensity.
  125705. */
  125706. get intensity(): number;
  125707. private _options;
  125708. private _intensity;
  125709. private _horizontalBlurPostprocess1;
  125710. private _verticalBlurPostprocess1;
  125711. private _horizontalBlurPostprocess2;
  125712. private _verticalBlurPostprocess2;
  125713. private _blurTexture1;
  125714. private _blurTexture2;
  125715. private _postProcesses1;
  125716. private _postProcesses2;
  125717. private _includedOnlyMeshes;
  125718. private _excludedMeshes;
  125719. private _meshesUsingTheirOwnMaterials;
  125720. /**
  125721. * Callback used to let the user override the color selection on a per mesh basis
  125722. */
  125723. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  125724. /**
  125725. * Callback used to let the user override the texture selection on a per mesh basis
  125726. */
  125727. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  125728. /**
  125729. * Instantiates a new glow Layer and references it to the scene.
  125730. * @param name The name of the layer
  125731. * @param scene The scene to use the layer in
  125732. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  125733. */
  125734. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  125735. /**
  125736. * Get the effect name of the layer.
  125737. * @return The effect name
  125738. */
  125739. getEffectName(): string;
  125740. /**
  125741. * Create the merge effect. This is the shader use to blit the information back
  125742. * to the main canvas at the end of the scene rendering.
  125743. */
  125744. protected _createMergeEffect(): Effect;
  125745. /**
  125746. * Creates the render target textures and post processes used in the glow layer.
  125747. */
  125748. protected _createTextureAndPostProcesses(): void;
  125749. /**
  125750. * Checks for the readiness of the element composing the layer.
  125751. * @param subMesh the mesh to check for
  125752. * @param useInstances specify wether or not to use instances to render the mesh
  125753. * @param emissiveTexture the associated emissive texture used to generate the glow
  125754. * @return true if ready otherwise, false
  125755. */
  125756. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125757. /**
  125758. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  125759. */
  125760. needStencil(): boolean;
  125761. /**
  125762. * Returns true if the mesh can be rendered, otherwise false.
  125763. * @param mesh The mesh to render
  125764. * @param material The material used on the mesh
  125765. * @returns true if it can be rendered otherwise false
  125766. */
  125767. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125768. /**
  125769. * Implementation specific of rendering the generating effect on the main canvas.
  125770. * @param effect The effect used to render through
  125771. */
  125772. protected _internalRender(effect: Effect): void;
  125773. /**
  125774. * Sets the required values for both the emissive texture and and the main color.
  125775. */
  125776. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125777. /**
  125778. * Returns true if the mesh should render, otherwise false.
  125779. * @param mesh The mesh to render
  125780. * @returns true if it should render otherwise false
  125781. */
  125782. protected _shouldRenderMesh(mesh: Mesh): boolean;
  125783. /**
  125784. * Adds specific effects defines.
  125785. * @param defines The defines to add specifics to.
  125786. */
  125787. protected _addCustomEffectDefines(defines: string[]): void;
  125788. /**
  125789. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  125790. * @param mesh The mesh to exclude from the glow layer
  125791. */
  125792. addExcludedMesh(mesh: Mesh): void;
  125793. /**
  125794. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  125795. * @param mesh The mesh to remove
  125796. */
  125797. removeExcludedMesh(mesh: Mesh): void;
  125798. /**
  125799. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  125800. * @param mesh The mesh to include in the glow layer
  125801. */
  125802. addIncludedOnlyMesh(mesh: Mesh): void;
  125803. /**
  125804. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  125805. * @param mesh The mesh to remove
  125806. */
  125807. removeIncludedOnlyMesh(mesh: Mesh): void;
  125808. /**
  125809. * Determine if a given mesh will be used in the glow layer
  125810. * @param mesh The mesh to test
  125811. * @returns true if the mesh will be highlighted by the current glow layer
  125812. */
  125813. hasMesh(mesh: AbstractMesh): boolean;
  125814. /**
  125815. * Defines wether the current material of the mesh should be use to render the effect.
  125816. * @param mesh defines the current mesh to render
  125817. */
  125818. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125819. /**
  125820. * Add a mesh to be rendered through its own material and not with emissive only.
  125821. * @param mesh The mesh for which we need to use its material
  125822. */
  125823. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  125824. /**
  125825. * Remove a mesh from being rendered through its own material and not with emissive only.
  125826. * @param mesh The mesh for which we need to not use its material
  125827. */
  125828. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  125829. /**
  125830. * Free any resources and references associated to a mesh.
  125831. * Internal use
  125832. * @param mesh The mesh to free.
  125833. * @hidden
  125834. */
  125835. _disposeMesh(mesh: Mesh): void;
  125836. /**
  125837. * Gets the class name of the effect layer
  125838. * @returns the string with the class name of the effect layer
  125839. */
  125840. getClassName(): string;
  125841. /**
  125842. * Serializes this glow layer
  125843. * @returns a serialized glow layer object
  125844. */
  125845. serialize(): any;
  125846. /**
  125847. * Creates a Glow Layer from parsed glow layer data
  125848. * @param parsedGlowLayer defines glow layer data
  125849. * @param scene defines the current scene
  125850. * @param rootUrl defines the root URL containing the glow layer information
  125851. * @returns a parsed Glow Layer
  125852. */
  125853. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  125854. }
  125855. }
  125856. declare module BABYLON {
  125857. /** @hidden */
  125858. export var glowBlurPostProcessPixelShader: {
  125859. name: string;
  125860. shader: string;
  125861. };
  125862. }
  125863. declare module BABYLON {
  125864. interface AbstractScene {
  125865. /**
  125866. * Return a the first highlight layer of the scene with a given name.
  125867. * @param name The name of the highlight layer to look for.
  125868. * @return The highlight layer if found otherwise null.
  125869. */
  125870. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  125871. }
  125872. /**
  125873. * Highlight layer options. This helps customizing the behaviour
  125874. * of the highlight layer.
  125875. */
  125876. export interface IHighlightLayerOptions {
  125877. /**
  125878. * Multiplication factor apply to the canvas size to compute the render target size
  125879. * used to generated the glowing objects (the smaller the faster).
  125880. */
  125881. mainTextureRatio: number;
  125882. /**
  125883. * Enforces a fixed size texture to ensure resize independant blur.
  125884. */
  125885. mainTextureFixedSize?: number;
  125886. /**
  125887. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  125888. * of the picture to blur (the smaller the faster).
  125889. */
  125890. blurTextureSizeRatio: number;
  125891. /**
  125892. * How big in texel of the blur texture is the vertical blur.
  125893. */
  125894. blurVerticalSize: number;
  125895. /**
  125896. * How big in texel of the blur texture is the horizontal blur.
  125897. */
  125898. blurHorizontalSize: number;
  125899. /**
  125900. * Alpha blending mode used to apply the blur. Default is combine.
  125901. */
  125902. alphaBlendingMode: number;
  125903. /**
  125904. * The camera attached to the layer.
  125905. */
  125906. camera: Nullable<Camera>;
  125907. /**
  125908. * Should we display highlight as a solid stroke?
  125909. */
  125910. isStroke?: boolean;
  125911. /**
  125912. * The rendering group to draw the layer in.
  125913. */
  125914. renderingGroupId: number;
  125915. }
  125916. /**
  125917. * The highlight layer Helps adding a glow effect around a mesh.
  125918. *
  125919. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  125920. * glowy meshes to your scene.
  125921. *
  125922. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  125923. */
  125924. export class HighlightLayer extends EffectLayer {
  125925. name: string;
  125926. /**
  125927. * Effect Name of the highlight layer.
  125928. */
  125929. static readonly EffectName: string;
  125930. /**
  125931. * The neutral color used during the preparation of the glow effect.
  125932. * This is black by default as the blend operation is a blend operation.
  125933. */
  125934. static NeutralColor: Color4;
  125935. /**
  125936. * Stencil value used for glowing meshes.
  125937. */
  125938. static GlowingMeshStencilReference: number;
  125939. /**
  125940. * Stencil value used for the other meshes in the scene.
  125941. */
  125942. static NormalMeshStencilReference: number;
  125943. /**
  125944. * Specifies whether or not the inner glow is ACTIVE in the layer.
  125945. */
  125946. innerGlow: boolean;
  125947. /**
  125948. * Specifies whether or not the outer glow is ACTIVE in the layer.
  125949. */
  125950. outerGlow: boolean;
  125951. /**
  125952. * Specifies the horizontal size of the blur.
  125953. */
  125954. set blurHorizontalSize(value: number);
  125955. /**
  125956. * Specifies the vertical size of the blur.
  125957. */
  125958. set blurVerticalSize(value: number);
  125959. /**
  125960. * Gets the horizontal size of the blur.
  125961. */
  125962. get blurHorizontalSize(): number;
  125963. /**
  125964. * Gets the vertical size of the blur.
  125965. */
  125966. get blurVerticalSize(): number;
  125967. /**
  125968. * An event triggered when the highlight layer is being blurred.
  125969. */
  125970. onBeforeBlurObservable: Observable<HighlightLayer>;
  125971. /**
  125972. * An event triggered when the highlight layer has been blurred.
  125973. */
  125974. onAfterBlurObservable: Observable<HighlightLayer>;
  125975. private _instanceGlowingMeshStencilReference;
  125976. private _options;
  125977. private _downSamplePostprocess;
  125978. private _horizontalBlurPostprocess;
  125979. private _verticalBlurPostprocess;
  125980. private _blurTexture;
  125981. private _meshes;
  125982. private _excludedMeshes;
  125983. /**
  125984. * Instantiates a new highlight Layer and references it to the scene..
  125985. * @param name The name of the layer
  125986. * @param scene The scene to use the layer in
  125987. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  125988. */
  125989. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  125990. /**
  125991. * Get the effect name of the layer.
  125992. * @return The effect name
  125993. */
  125994. getEffectName(): string;
  125995. /**
  125996. * Create the merge effect. This is the shader use to blit the information back
  125997. * to the main canvas at the end of the scene rendering.
  125998. */
  125999. protected _createMergeEffect(): Effect;
  126000. /**
  126001. * Creates the render target textures and post processes used in the highlight layer.
  126002. */
  126003. protected _createTextureAndPostProcesses(): void;
  126004. /**
  126005. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126006. */
  126007. needStencil(): boolean;
  126008. /**
  126009. * Checks for the readiness of the element composing the layer.
  126010. * @param subMesh the mesh to check for
  126011. * @param useInstances specify wether or not to use instances to render the mesh
  126012. * @param emissiveTexture the associated emissive texture used to generate the glow
  126013. * @return true if ready otherwise, false
  126014. */
  126015. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126016. /**
  126017. * Implementation specific of rendering the generating effect on the main canvas.
  126018. * @param effect The effect used to render through
  126019. */
  126020. protected _internalRender(effect: Effect): void;
  126021. /**
  126022. * Returns true if the layer contains information to display, otherwise false.
  126023. */
  126024. shouldRender(): boolean;
  126025. /**
  126026. * Returns true if the mesh should render, otherwise false.
  126027. * @param mesh The mesh to render
  126028. * @returns true if it should render otherwise false
  126029. */
  126030. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126031. /**
  126032. * Sets the required values for both the emissive texture and and the main color.
  126033. */
  126034. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126035. /**
  126036. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126037. * @param mesh The mesh to exclude from the highlight layer
  126038. */
  126039. addExcludedMesh(mesh: Mesh): void;
  126040. /**
  126041. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126042. * @param mesh The mesh to highlight
  126043. */
  126044. removeExcludedMesh(mesh: Mesh): void;
  126045. /**
  126046. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126047. * @param mesh mesh to test
  126048. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126049. */
  126050. hasMesh(mesh: AbstractMesh): boolean;
  126051. /**
  126052. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126053. * @param mesh The mesh to highlight
  126054. * @param color The color of the highlight
  126055. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126056. */
  126057. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126058. /**
  126059. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126060. * @param mesh The mesh to highlight
  126061. */
  126062. removeMesh(mesh: Mesh): void;
  126063. /**
  126064. * Force the stencil to the normal expected value for none glowing parts
  126065. */
  126066. private _defaultStencilReference;
  126067. /**
  126068. * Free any resources and references associated to a mesh.
  126069. * Internal use
  126070. * @param mesh The mesh to free.
  126071. * @hidden
  126072. */
  126073. _disposeMesh(mesh: Mesh): void;
  126074. /**
  126075. * Dispose the highlight layer and free resources.
  126076. */
  126077. dispose(): void;
  126078. /**
  126079. * Gets the class name of the effect layer
  126080. * @returns the string with the class name of the effect layer
  126081. */
  126082. getClassName(): string;
  126083. /**
  126084. * Serializes this Highlight layer
  126085. * @returns a serialized Highlight layer object
  126086. */
  126087. serialize(): any;
  126088. /**
  126089. * Creates a Highlight layer from parsed Highlight layer data
  126090. * @param parsedHightlightLayer defines the Highlight layer data
  126091. * @param scene defines the current scene
  126092. * @param rootUrl defines the root URL containing the Highlight layer information
  126093. * @returns a parsed Highlight layer
  126094. */
  126095. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126096. }
  126097. }
  126098. declare module BABYLON {
  126099. interface AbstractScene {
  126100. /**
  126101. * The list of layers (background and foreground) of the scene
  126102. */
  126103. layers: Array<Layer>;
  126104. }
  126105. /**
  126106. * Defines the layer scene component responsible to manage any layers
  126107. * in a given scene.
  126108. */
  126109. export class LayerSceneComponent implements ISceneComponent {
  126110. /**
  126111. * The component name helpfull to identify the component in the list of scene components.
  126112. */
  126113. readonly name: string;
  126114. /**
  126115. * The scene the component belongs to.
  126116. */
  126117. scene: Scene;
  126118. private _engine;
  126119. /**
  126120. * Creates a new instance of the component for the given scene
  126121. * @param scene Defines the scene to register the component in
  126122. */
  126123. constructor(scene: Scene);
  126124. /**
  126125. * Registers the component in a given scene
  126126. */
  126127. register(): void;
  126128. /**
  126129. * Rebuilds the elements related to this component in case of
  126130. * context lost for instance.
  126131. */
  126132. rebuild(): void;
  126133. /**
  126134. * Disposes the component and the associated ressources.
  126135. */
  126136. dispose(): void;
  126137. private _draw;
  126138. private _drawCameraPredicate;
  126139. private _drawCameraBackground;
  126140. private _drawCameraForeground;
  126141. private _drawRenderTargetPredicate;
  126142. private _drawRenderTargetBackground;
  126143. private _drawRenderTargetForeground;
  126144. /**
  126145. * Adds all the elements from the container to the scene
  126146. * @param container the container holding the elements
  126147. */
  126148. addFromContainer(container: AbstractScene): void;
  126149. /**
  126150. * Removes all the elements in the container from the scene
  126151. * @param container contains the elements to remove
  126152. * @param dispose if the removed element should be disposed (default: false)
  126153. */
  126154. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126155. }
  126156. }
  126157. declare module BABYLON {
  126158. /** @hidden */
  126159. export var layerPixelShader: {
  126160. name: string;
  126161. shader: string;
  126162. };
  126163. }
  126164. declare module BABYLON {
  126165. /** @hidden */
  126166. export var layerVertexShader: {
  126167. name: string;
  126168. shader: string;
  126169. };
  126170. }
  126171. declare module BABYLON {
  126172. /**
  126173. * This represents a full screen 2d layer.
  126174. * This can be useful to display a picture in the background of your scene for instance.
  126175. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126176. */
  126177. export class Layer {
  126178. /**
  126179. * Define the name of the layer.
  126180. */
  126181. name: string;
  126182. /**
  126183. * Define the texture the layer should display.
  126184. */
  126185. texture: Nullable<Texture>;
  126186. /**
  126187. * Is the layer in background or foreground.
  126188. */
  126189. isBackground: boolean;
  126190. /**
  126191. * Define the color of the layer (instead of texture).
  126192. */
  126193. color: Color4;
  126194. /**
  126195. * Define the scale of the layer in order to zoom in out of the texture.
  126196. */
  126197. scale: Vector2;
  126198. /**
  126199. * Define an offset for the layer in order to shift the texture.
  126200. */
  126201. offset: Vector2;
  126202. /**
  126203. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126204. */
  126205. alphaBlendingMode: number;
  126206. /**
  126207. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126208. * Alpha test will not mix with the background color in case of transparency.
  126209. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126210. */
  126211. alphaTest: boolean;
  126212. /**
  126213. * Define a mask to restrict the layer to only some of the scene cameras.
  126214. */
  126215. layerMask: number;
  126216. /**
  126217. * Define the list of render target the layer is visible into.
  126218. */
  126219. renderTargetTextures: RenderTargetTexture[];
  126220. /**
  126221. * Define if the layer is only used in renderTarget or if it also
  126222. * renders in the main frame buffer of the canvas.
  126223. */
  126224. renderOnlyInRenderTargetTextures: boolean;
  126225. private _scene;
  126226. private _vertexBuffers;
  126227. private _indexBuffer;
  126228. private _effect;
  126229. private _previousDefines;
  126230. /**
  126231. * An event triggered when the layer is disposed.
  126232. */
  126233. onDisposeObservable: Observable<Layer>;
  126234. private _onDisposeObserver;
  126235. /**
  126236. * Back compatibility with callback before the onDisposeObservable existed.
  126237. * The set callback will be triggered when the layer has been disposed.
  126238. */
  126239. set onDispose(callback: () => void);
  126240. /**
  126241. * An event triggered before rendering the scene
  126242. */
  126243. onBeforeRenderObservable: Observable<Layer>;
  126244. private _onBeforeRenderObserver;
  126245. /**
  126246. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126247. * The set callback will be triggered just before rendering the layer.
  126248. */
  126249. set onBeforeRender(callback: () => void);
  126250. /**
  126251. * An event triggered after rendering the scene
  126252. */
  126253. onAfterRenderObservable: Observable<Layer>;
  126254. private _onAfterRenderObserver;
  126255. /**
  126256. * Back compatibility with callback before the onAfterRenderObservable existed.
  126257. * The set callback will be triggered just after rendering the layer.
  126258. */
  126259. set onAfterRender(callback: () => void);
  126260. /**
  126261. * Instantiates a new layer.
  126262. * This represents a full screen 2d layer.
  126263. * This can be useful to display a picture in the background of your scene for instance.
  126264. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126265. * @param name Define the name of the layer in the scene
  126266. * @param imgUrl Define the url of the texture to display in the layer
  126267. * @param scene Define the scene the layer belongs to
  126268. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126269. * @param color Defines a color for the layer
  126270. */
  126271. constructor(
  126272. /**
  126273. * Define the name of the layer.
  126274. */
  126275. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126276. private _createIndexBuffer;
  126277. /** @hidden */
  126278. _rebuild(): void;
  126279. /**
  126280. * Renders the layer in the scene.
  126281. */
  126282. render(): void;
  126283. /**
  126284. * Disposes and releases the associated ressources.
  126285. */
  126286. dispose(): void;
  126287. }
  126288. }
  126289. declare module BABYLON {
  126290. /** @hidden */
  126291. export var lensFlarePixelShader: {
  126292. name: string;
  126293. shader: string;
  126294. };
  126295. }
  126296. declare module BABYLON {
  126297. /** @hidden */
  126298. export var lensFlareVertexShader: {
  126299. name: string;
  126300. shader: string;
  126301. };
  126302. }
  126303. declare module BABYLON {
  126304. /**
  126305. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126306. * It is usually composed of several `lensFlare`.
  126307. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126308. */
  126309. export class LensFlareSystem {
  126310. /**
  126311. * Define the name of the lens flare system
  126312. */
  126313. name: string;
  126314. /**
  126315. * List of lens flares used in this system.
  126316. */
  126317. lensFlares: LensFlare[];
  126318. /**
  126319. * Define a limit from the border the lens flare can be visible.
  126320. */
  126321. borderLimit: number;
  126322. /**
  126323. * Define a viewport border we do not want to see the lens flare in.
  126324. */
  126325. viewportBorder: number;
  126326. /**
  126327. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126328. */
  126329. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126330. /**
  126331. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126332. */
  126333. layerMask: number;
  126334. /**
  126335. * Define the id of the lens flare system in the scene.
  126336. * (equal to name by default)
  126337. */
  126338. id: string;
  126339. private _scene;
  126340. private _emitter;
  126341. private _vertexBuffers;
  126342. private _indexBuffer;
  126343. private _effect;
  126344. private _positionX;
  126345. private _positionY;
  126346. private _isEnabled;
  126347. /** @hidden */
  126348. static _SceneComponentInitialization: (scene: Scene) => void;
  126349. /**
  126350. * Instantiates a lens flare system.
  126351. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126352. * It is usually composed of several `lensFlare`.
  126353. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126354. * @param name Define the name of the lens flare system in the scene
  126355. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126356. * @param scene Define the scene the lens flare system belongs to
  126357. */
  126358. constructor(
  126359. /**
  126360. * Define the name of the lens flare system
  126361. */
  126362. name: string, emitter: any, scene: Scene);
  126363. /**
  126364. * Define if the lens flare system is enabled.
  126365. */
  126366. get isEnabled(): boolean;
  126367. set isEnabled(value: boolean);
  126368. /**
  126369. * Get the scene the effects belongs to.
  126370. * @returns the scene holding the lens flare system
  126371. */
  126372. getScene(): Scene;
  126373. /**
  126374. * Get the emitter of the lens flare system.
  126375. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126376. * @returns the emitter of the lens flare system
  126377. */
  126378. getEmitter(): any;
  126379. /**
  126380. * Set the emitter of the lens flare system.
  126381. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126382. * @param newEmitter Define the new emitter of the system
  126383. */
  126384. setEmitter(newEmitter: any): void;
  126385. /**
  126386. * Get the lens flare system emitter position.
  126387. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126388. * @returns the position
  126389. */
  126390. getEmitterPosition(): Vector3;
  126391. /**
  126392. * @hidden
  126393. */
  126394. computeEffectivePosition(globalViewport: Viewport): boolean;
  126395. /** @hidden */
  126396. _isVisible(): boolean;
  126397. /**
  126398. * @hidden
  126399. */
  126400. render(): boolean;
  126401. /**
  126402. * Dispose and release the lens flare with its associated resources.
  126403. */
  126404. dispose(): void;
  126405. /**
  126406. * Parse a lens flare system from a JSON repressentation
  126407. * @param parsedLensFlareSystem Define the JSON to parse
  126408. * @param scene Define the scene the parsed system should be instantiated in
  126409. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126410. * @returns the parsed system
  126411. */
  126412. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126413. /**
  126414. * Serialize the current Lens Flare System into a JSON representation.
  126415. * @returns the serialized JSON
  126416. */
  126417. serialize(): any;
  126418. }
  126419. }
  126420. declare module BABYLON {
  126421. /**
  126422. * This represents one of the lens effect in a `lensFlareSystem`.
  126423. * It controls one of the indiviual texture used in the effect.
  126424. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126425. */
  126426. export class LensFlare {
  126427. /**
  126428. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126429. */
  126430. size: number;
  126431. /**
  126432. * 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.
  126433. */
  126434. position: number;
  126435. /**
  126436. * Define the lens color.
  126437. */
  126438. color: Color3;
  126439. /**
  126440. * Define the lens texture.
  126441. */
  126442. texture: Nullable<Texture>;
  126443. /**
  126444. * Define the alpha mode to render this particular lens.
  126445. */
  126446. alphaMode: number;
  126447. private _system;
  126448. /**
  126449. * Creates a new Lens Flare.
  126450. * This represents one of the lens effect in a `lensFlareSystem`.
  126451. * It controls one of the indiviual texture used in the effect.
  126452. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126453. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  126454. * @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.
  126455. * @param color Define the lens color
  126456. * @param imgUrl Define the lens texture url
  126457. * @param system Define the `lensFlareSystem` this flare is part of
  126458. * @returns The newly created Lens Flare
  126459. */
  126460. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  126461. /**
  126462. * Instantiates a new Lens Flare.
  126463. * This represents one of the lens effect in a `lensFlareSystem`.
  126464. * It controls one of the indiviual texture used in the effect.
  126465. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126466. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  126467. * @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.
  126468. * @param color Define the lens color
  126469. * @param imgUrl Define the lens texture url
  126470. * @param system Define the `lensFlareSystem` this flare is part of
  126471. */
  126472. constructor(
  126473. /**
  126474. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126475. */
  126476. size: number,
  126477. /**
  126478. * 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.
  126479. */
  126480. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  126481. /**
  126482. * Dispose and release the lens flare with its associated resources.
  126483. */
  126484. dispose(): void;
  126485. }
  126486. }
  126487. declare module BABYLON {
  126488. interface AbstractScene {
  126489. /**
  126490. * The list of lens flare system added to the scene
  126491. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126492. */
  126493. lensFlareSystems: Array<LensFlareSystem>;
  126494. /**
  126495. * Removes the given lens flare system from this scene.
  126496. * @param toRemove The lens flare system to remove
  126497. * @returns The index of the removed lens flare system
  126498. */
  126499. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  126500. /**
  126501. * Adds the given lens flare system to this scene
  126502. * @param newLensFlareSystem The lens flare system to add
  126503. */
  126504. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  126505. /**
  126506. * Gets a lens flare system using its name
  126507. * @param name defines the name to look for
  126508. * @returns the lens flare system or null if not found
  126509. */
  126510. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  126511. /**
  126512. * Gets a lens flare system using its id
  126513. * @param id defines the id to look for
  126514. * @returns the lens flare system or null if not found
  126515. */
  126516. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  126517. }
  126518. /**
  126519. * Defines the lens flare scene component responsible to manage any lens flares
  126520. * in a given scene.
  126521. */
  126522. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  126523. /**
  126524. * The component name helpfull to identify the component in the list of scene components.
  126525. */
  126526. readonly name: string;
  126527. /**
  126528. * The scene the component belongs to.
  126529. */
  126530. scene: Scene;
  126531. /**
  126532. * Creates a new instance of the component for the given scene
  126533. * @param scene Defines the scene to register the component in
  126534. */
  126535. constructor(scene: Scene);
  126536. /**
  126537. * Registers the component in a given scene
  126538. */
  126539. register(): void;
  126540. /**
  126541. * Rebuilds the elements related to this component in case of
  126542. * context lost for instance.
  126543. */
  126544. rebuild(): void;
  126545. /**
  126546. * Adds all the elements from the container to the scene
  126547. * @param container the container holding the elements
  126548. */
  126549. addFromContainer(container: AbstractScene): void;
  126550. /**
  126551. * Removes all the elements in the container from the scene
  126552. * @param container contains the elements to remove
  126553. * @param dispose if the removed element should be disposed (default: false)
  126554. */
  126555. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126556. /**
  126557. * Serializes the component data to the specified json object
  126558. * @param serializationObject The object to serialize to
  126559. */
  126560. serialize(serializationObject: any): void;
  126561. /**
  126562. * Disposes the component and the associated ressources.
  126563. */
  126564. dispose(): void;
  126565. private _draw;
  126566. }
  126567. }
  126568. declare module BABYLON {
  126569. /** @hidden */
  126570. export var depthPixelShader: {
  126571. name: string;
  126572. shader: string;
  126573. };
  126574. }
  126575. declare module BABYLON {
  126576. /** @hidden */
  126577. export var depthVertexShader: {
  126578. name: string;
  126579. shader: string;
  126580. };
  126581. }
  126582. declare module BABYLON {
  126583. /**
  126584. * This represents a depth renderer in Babylon.
  126585. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126586. */
  126587. export class DepthRenderer {
  126588. private _scene;
  126589. private _depthMap;
  126590. private _effect;
  126591. private readonly _storeNonLinearDepth;
  126592. private readonly _clearColor;
  126593. /** Get if the depth renderer is using packed depth or not */
  126594. readonly isPacked: boolean;
  126595. private _cachedDefines;
  126596. private _camera;
  126597. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  126598. enabled: boolean;
  126599. /**
  126600. * Specifiess that the depth renderer will only be used within
  126601. * the camera it is created for.
  126602. * This can help forcing its rendering during the camera processing.
  126603. */
  126604. useOnlyInActiveCamera: boolean;
  126605. /** @hidden */
  126606. static _SceneComponentInitialization: (scene: Scene) => void;
  126607. /**
  126608. * Instantiates a depth renderer
  126609. * @param scene The scene the renderer belongs to
  126610. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126611. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126612. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126613. */
  126614. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126615. /**
  126616. * Creates the depth rendering effect and checks if the effect is ready.
  126617. * @param subMesh The submesh to be used to render the depth map of
  126618. * @param useInstances If multiple world instances should be used
  126619. * @returns if the depth renderer is ready to render the depth map
  126620. */
  126621. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126622. /**
  126623. * Gets the texture which the depth map will be written to.
  126624. * @returns The depth map texture
  126625. */
  126626. getDepthMap(): RenderTargetTexture;
  126627. /**
  126628. * Disposes of the depth renderer.
  126629. */
  126630. dispose(): void;
  126631. }
  126632. }
  126633. declare module BABYLON {
  126634. /** @hidden */
  126635. export var minmaxReduxPixelShader: {
  126636. name: string;
  126637. shader: string;
  126638. };
  126639. }
  126640. declare module BABYLON {
  126641. /**
  126642. * This class computes a min/max reduction from a texture: it means it computes the minimum
  126643. * and maximum values from all values of the texture.
  126644. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  126645. * The source values are read from the red channel of the texture.
  126646. */
  126647. export class MinMaxReducer {
  126648. /**
  126649. * Observable triggered when the computation has been performed
  126650. */
  126651. onAfterReductionPerformed: Observable<{
  126652. min: number;
  126653. max: number;
  126654. }>;
  126655. protected _camera: Camera;
  126656. protected _sourceTexture: Nullable<RenderTargetTexture>;
  126657. protected _reductionSteps: Nullable<Array<PostProcess>>;
  126658. protected _postProcessManager: PostProcessManager;
  126659. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  126660. protected _forceFullscreenViewport: boolean;
  126661. /**
  126662. * Creates a min/max reducer
  126663. * @param camera The camera to use for the post processes
  126664. */
  126665. constructor(camera: Camera);
  126666. /**
  126667. * Gets the texture used to read the values from.
  126668. */
  126669. get sourceTexture(): Nullable<RenderTargetTexture>;
  126670. /**
  126671. * Sets the source texture to read the values from.
  126672. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  126673. * because in such textures '1' value must not be taken into account to compute the maximum
  126674. * as this value is used to clear the texture.
  126675. * Note that the computation is not activated by calling this function, you must call activate() for that!
  126676. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  126677. * @param depthRedux Indicates if the texture is a depth texture or not
  126678. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  126679. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126680. */
  126681. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126682. /**
  126683. * Defines the refresh rate of the computation.
  126684. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  126685. */
  126686. get refreshRate(): number;
  126687. set refreshRate(value: number);
  126688. protected _activated: boolean;
  126689. /**
  126690. * Gets the activation status of the reducer
  126691. */
  126692. get activated(): boolean;
  126693. /**
  126694. * Activates the reduction computation.
  126695. * When activated, the observers registered in onAfterReductionPerformed are
  126696. * called after the compuation is performed
  126697. */
  126698. activate(): void;
  126699. /**
  126700. * Deactivates the reduction computation.
  126701. */
  126702. deactivate(): void;
  126703. /**
  126704. * Disposes the min/max reducer
  126705. * @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.
  126706. */
  126707. dispose(disposeAll?: boolean): void;
  126708. }
  126709. }
  126710. declare module BABYLON {
  126711. /**
  126712. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  126713. */
  126714. export class DepthReducer extends MinMaxReducer {
  126715. private _depthRenderer;
  126716. private _depthRendererId;
  126717. /**
  126718. * Gets the depth renderer used for the computation.
  126719. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  126720. */
  126721. get depthRenderer(): Nullable<DepthRenderer>;
  126722. /**
  126723. * Creates a depth reducer
  126724. * @param camera The camera used to render the depth texture
  126725. */
  126726. constructor(camera: Camera);
  126727. /**
  126728. * Sets the depth renderer to use to generate the depth map
  126729. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  126730. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  126731. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126732. */
  126733. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  126734. /** @hidden */
  126735. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126736. /**
  126737. * Activates the reduction computation.
  126738. * When activated, the observers registered in onAfterReductionPerformed are
  126739. * called after the compuation is performed
  126740. */
  126741. activate(): void;
  126742. /**
  126743. * Deactivates the reduction computation.
  126744. */
  126745. deactivate(): void;
  126746. /**
  126747. * Disposes the depth reducer
  126748. * @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.
  126749. */
  126750. dispose(disposeAll?: boolean): void;
  126751. }
  126752. }
  126753. declare module BABYLON {
  126754. /**
  126755. * A CSM implementation allowing casting shadows on large scenes.
  126756. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  126757. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  126758. */
  126759. export class CascadedShadowGenerator extends ShadowGenerator {
  126760. private static readonly frustumCornersNDCSpace;
  126761. /**
  126762. * Name of the CSM class
  126763. */
  126764. static CLASSNAME: string;
  126765. /**
  126766. * Defines the default number of cascades used by the CSM.
  126767. */
  126768. static readonly DEFAULT_CASCADES_COUNT: number;
  126769. /**
  126770. * Defines the minimum number of cascades used by the CSM.
  126771. */
  126772. static readonly MIN_CASCADES_COUNT: number;
  126773. /**
  126774. * Defines the maximum number of cascades used by the CSM.
  126775. */
  126776. static readonly MAX_CASCADES_COUNT: number;
  126777. protected _validateFilter(filter: number): number;
  126778. /**
  126779. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  126780. */
  126781. penumbraDarkness: number;
  126782. private _numCascades;
  126783. /**
  126784. * Gets or set the number of cascades used by the CSM.
  126785. */
  126786. get numCascades(): number;
  126787. set numCascades(value: number);
  126788. /**
  126789. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  126790. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  126791. */
  126792. stabilizeCascades: boolean;
  126793. private _freezeShadowCastersBoundingInfo;
  126794. private _freezeShadowCastersBoundingInfoObservable;
  126795. /**
  126796. * Enables or disables the shadow casters bounding info computation.
  126797. * If your shadow casters don't move, you can disable this feature.
  126798. * If it is enabled, the bounding box computation is done every frame.
  126799. */
  126800. get freezeShadowCastersBoundingInfo(): boolean;
  126801. set freezeShadowCastersBoundingInfo(freeze: boolean);
  126802. private _scbiMin;
  126803. private _scbiMax;
  126804. protected _computeShadowCastersBoundingInfo(): void;
  126805. protected _shadowCastersBoundingInfo: BoundingInfo;
  126806. /**
  126807. * Gets or sets the shadow casters bounding info.
  126808. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  126809. * so that the system won't overwrite the bounds you provide
  126810. */
  126811. get shadowCastersBoundingInfo(): BoundingInfo;
  126812. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  126813. protected _breaksAreDirty: boolean;
  126814. protected _minDistance: number;
  126815. protected _maxDistance: number;
  126816. /**
  126817. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  126818. *
  126819. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  126820. * If you don't know these values, simply leave them to their defaults and don't call this function.
  126821. * @param min minimal distance for the breaks (default to 0.)
  126822. * @param max maximal distance for the breaks (default to 1.)
  126823. */
  126824. setMinMaxDistance(min: number, max: number): void;
  126825. /** Gets the minimal distance used in the cascade break computation */
  126826. get minDistance(): number;
  126827. /** Gets the maximal distance used in the cascade break computation */
  126828. get maxDistance(): number;
  126829. /**
  126830. * Gets the class name of that object
  126831. * @returns "CascadedShadowGenerator"
  126832. */
  126833. getClassName(): string;
  126834. private _cascadeMinExtents;
  126835. private _cascadeMaxExtents;
  126836. /**
  126837. * Gets a cascade minimum extents
  126838. * @param cascadeIndex index of the cascade
  126839. * @returns the minimum cascade extents
  126840. */
  126841. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  126842. /**
  126843. * Gets a cascade maximum extents
  126844. * @param cascadeIndex index of the cascade
  126845. * @returns the maximum cascade extents
  126846. */
  126847. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  126848. private _cascades;
  126849. private _currentLayer;
  126850. private _viewSpaceFrustumsZ;
  126851. private _viewMatrices;
  126852. private _projectionMatrices;
  126853. private _transformMatrices;
  126854. private _transformMatricesAsArray;
  126855. private _frustumLengths;
  126856. private _lightSizeUVCorrection;
  126857. private _depthCorrection;
  126858. private _frustumCornersWorldSpace;
  126859. private _frustumCenter;
  126860. private _shadowCameraPos;
  126861. private _shadowMaxZ;
  126862. /**
  126863. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  126864. * It defaults to camera.maxZ
  126865. */
  126866. get shadowMaxZ(): number;
  126867. /**
  126868. * Sets the shadow max z distance.
  126869. */
  126870. set shadowMaxZ(value: number);
  126871. protected _debug: boolean;
  126872. /**
  126873. * Gets or sets the debug flag.
  126874. * When enabled, the cascades are materialized by different colors on the screen.
  126875. */
  126876. get debug(): boolean;
  126877. set debug(dbg: boolean);
  126878. private _depthClamp;
  126879. /**
  126880. * Gets or sets the depth clamping value.
  126881. *
  126882. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  126883. * to account for the shadow casters far away.
  126884. *
  126885. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  126886. */
  126887. get depthClamp(): boolean;
  126888. set depthClamp(value: boolean);
  126889. private _cascadeBlendPercentage;
  126890. /**
  126891. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  126892. * It defaults to 0.1 (10% blending).
  126893. */
  126894. get cascadeBlendPercentage(): number;
  126895. set cascadeBlendPercentage(value: number);
  126896. private _lambda;
  126897. /**
  126898. * Gets or set the lambda parameter.
  126899. * This parameter is used to split the camera frustum and create the cascades.
  126900. * 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.
  126901. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  126902. */
  126903. get lambda(): number;
  126904. set lambda(value: number);
  126905. /**
  126906. * Gets the view matrix corresponding to a given cascade
  126907. * @param cascadeNum cascade to retrieve the view matrix from
  126908. * @returns the cascade view matrix
  126909. */
  126910. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  126911. /**
  126912. * Gets the projection matrix corresponding to a given cascade
  126913. * @param cascadeNum cascade to retrieve the projection matrix from
  126914. * @returns the cascade projection matrix
  126915. */
  126916. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  126917. /**
  126918. * Gets the transformation matrix corresponding to a given cascade
  126919. * @param cascadeNum cascade to retrieve the transformation matrix from
  126920. * @returns the cascade transformation matrix
  126921. */
  126922. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  126923. private _depthRenderer;
  126924. /**
  126925. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  126926. *
  126927. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  126928. *
  126929. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  126930. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  126931. * @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
  126932. */
  126933. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  126934. private _depthReducer;
  126935. private _autoCalcDepthBounds;
  126936. /**
  126937. * Gets or sets the autoCalcDepthBounds property.
  126938. *
  126939. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  126940. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  126941. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  126942. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  126943. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  126944. */
  126945. get autoCalcDepthBounds(): boolean;
  126946. set autoCalcDepthBounds(value: boolean);
  126947. /**
  126948. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  126949. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  126950. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  126951. * for setting the refresh rate on the renderer yourself!
  126952. */
  126953. get autoCalcDepthBoundsRefreshRate(): number;
  126954. set autoCalcDepthBoundsRefreshRate(value: number);
  126955. /**
  126956. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  126957. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  126958. * you change the camera near/far planes!
  126959. */
  126960. splitFrustum(): void;
  126961. private _splitFrustum;
  126962. private _computeMatrices;
  126963. private _computeFrustumInWorldSpace;
  126964. private _computeCascadeFrustum;
  126965. /** @hidden */
  126966. static _SceneComponentInitialization: (scene: Scene) => void;
  126967. /**
  126968. * Creates a Cascaded Shadow Generator object.
  126969. * A ShadowGenerator is the required tool to use the shadows.
  126970. * Each directional light casting shadows needs to use its own ShadowGenerator.
  126971. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  126972. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  126973. * @param light The directional light object generating the shadows.
  126974. * @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.
  126975. */
  126976. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  126977. protected _initializeGenerator(): void;
  126978. protected _createTargetRenderTexture(): void;
  126979. protected _initializeShadowMap(): void;
  126980. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  126981. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  126982. /**
  126983. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  126984. * @param defines Defines of the material we want to update
  126985. * @param lightIndex Index of the light in the enabled light list of the material
  126986. */
  126987. prepareDefines(defines: any, lightIndex: number): void;
  126988. /**
  126989. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  126990. * defined in the generator but impacting the effect).
  126991. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  126992. * @param effect The effect we are binfing the information for
  126993. */
  126994. bindShadowLight(lightIndex: string, effect: Effect): void;
  126995. /**
  126996. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  126997. * (eq to view projection * shadow projection matrices)
  126998. * @returns The transform matrix used to create the shadow map
  126999. */
  127000. getTransformMatrix(): Matrix;
  127001. /**
  127002. * Disposes the ShadowGenerator.
  127003. * Returns nothing.
  127004. */
  127005. dispose(): void;
  127006. /**
  127007. * Serializes the shadow generator setup to a json object.
  127008. * @returns The serialized JSON object
  127009. */
  127010. serialize(): any;
  127011. /**
  127012. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127013. * @param parsedShadowGenerator The JSON object to parse
  127014. * @param scene The scene to create the shadow map for
  127015. * @returns The parsed shadow generator
  127016. */
  127017. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127018. }
  127019. }
  127020. declare module BABYLON {
  127021. /**
  127022. * Defines the shadow generator component responsible to manage any shadow generators
  127023. * in a given scene.
  127024. */
  127025. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127026. /**
  127027. * The component name helpfull to identify the component in the list of scene components.
  127028. */
  127029. readonly name: string;
  127030. /**
  127031. * The scene the component belongs to.
  127032. */
  127033. scene: Scene;
  127034. /**
  127035. * Creates a new instance of the component for the given scene
  127036. * @param scene Defines the scene to register the component in
  127037. */
  127038. constructor(scene: Scene);
  127039. /**
  127040. * Registers the component in a given scene
  127041. */
  127042. register(): void;
  127043. /**
  127044. * Rebuilds the elements related to this component in case of
  127045. * context lost for instance.
  127046. */
  127047. rebuild(): void;
  127048. /**
  127049. * Serializes the component data to the specified json object
  127050. * @param serializationObject The object to serialize to
  127051. */
  127052. serialize(serializationObject: any): void;
  127053. /**
  127054. * Adds all the elements from the container to the scene
  127055. * @param container the container holding the elements
  127056. */
  127057. addFromContainer(container: AbstractScene): void;
  127058. /**
  127059. * Removes all the elements in the container from the scene
  127060. * @param container contains the elements to remove
  127061. * @param dispose if the removed element should be disposed (default: false)
  127062. */
  127063. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127064. /**
  127065. * Rebuilds the elements related to this component in case of
  127066. * context lost for instance.
  127067. */
  127068. dispose(): void;
  127069. private _gatherRenderTargets;
  127070. }
  127071. }
  127072. declare module BABYLON {
  127073. /**
  127074. * A point light is a light defined by an unique point in world space.
  127075. * The light is emitted in every direction from this point.
  127076. * A good example of a point light is a standard light bulb.
  127077. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127078. */
  127079. export class PointLight extends ShadowLight {
  127080. private _shadowAngle;
  127081. /**
  127082. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127083. * This specifies what angle the shadow will use to be created.
  127084. *
  127085. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127086. */
  127087. get shadowAngle(): number;
  127088. /**
  127089. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127090. * This specifies what angle the shadow will use to be created.
  127091. *
  127092. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127093. */
  127094. set shadowAngle(value: number);
  127095. /**
  127096. * Gets the direction if it has been set.
  127097. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127098. */
  127099. get direction(): Vector3;
  127100. /**
  127101. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127102. */
  127103. set direction(value: Vector3);
  127104. /**
  127105. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127106. * A PointLight emits the light in every direction.
  127107. * It can cast shadows.
  127108. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127109. * ```javascript
  127110. * var pointLight = new PointLight("pl", camera.position, scene);
  127111. * ```
  127112. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127113. * @param name The light friendly name
  127114. * @param position The position of the point light in the scene
  127115. * @param scene The scene the lights belongs to
  127116. */
  127117. constructor(name: string, position: Vector3, scene: Scene);
  127118. /**
  127119. * Returns the string "PointLight"
  127120. * @returns the class name
  127121. */
  127122. getClassName(): string;
  127123. /**
  127124. * Returns the integer 0.
  127125. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127126. */
  127127. getTypeID(): number;
  127128. /**
  127129. * Specifies wether or not the shadowmap should be a cube texture.
  127130. * @returns true if the shadowmap needs to be a cube texture.
  127131. */
  127132. needCube(): boolean;
  127133. /**
  127134. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127135. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127136. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127137. */
  127138. getShadowDirection(faceIndex?: number): Vector3;
  127139. /**
  127140. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127141. * - fov = PI / 2
  127142. * - aspect ratio : 1.0
  127143. * - z-near and far equal to the active camera minZ and maxZ.
  127144. * Returns the PointLight.
  127145. */
  127146. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127147. protected _buildUniformLayout(): void;
  127148. /**
  127149. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127150. * @param effect The effect to update
  127151. * @param lightIndex The index of the light in the effect to update
  127152. * @returns The point light
  127153. */
  127154. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127155. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127156. /**
  127157. * Prepares the list of defines specific to the light type.
  127158. * @param defines the list of defines
  127159. * @param lightIndex defines the index of the light for the effect
  127160. */
  127161. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127162. }
  127163. }
  127164. declare module BABYLON {
  127165. /**
  127166. * Header information of HDR texture files.
  127167. */
  127168. export interface HDRInfo {
  127169. /**
  127170. * The height of the texture in pixels.
  127171. */
  127172. height: number;
  127173. /**
  127174. * The width of the texture in pixels.
  127175. */
  127176. width: number;
  127177. /**
  127178. * The index of the beginning of the data in the binary file.
  127179. */
  127180. dataPosition: number;
  127181. }
  127182. /**
  127183. * This groups tools to convert HDR texture to native colors array.
  127184. */
  127185. export class HDRTools {
  127186. private static Ldexp;
  127187. private static Rgbe2float;
  127188. private static readStringLine;
  127189. /**
  127190. * Reads header information from an RGBE texture stored in a native array.
  127191. * More information on this format are available here:
  127192. * https://en.wikipedia.org/wiki/RGBE_image_format
  127193. *
  127194. * @param uint8array The binary file stored in native array.
  127195. * @return The header information.
  127196. */
  127197. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127198. /**
  127199. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127200. * This RGBE texture needs to store the information as a panorama.
  127201. *
  127202. * More information on this format are available here:
  127203. * https://en.wikipedia.org/wiki/RGBE_image_format
  127204. *
  127205. * @param buffer The binary file stored in an array buffer.
  127206. * @param size The expected size of the extracted cubemap.
  127207. * @return The Cube Map information.
  127208. */
  127209. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127210. /**
  127211. * Returns the pixels data extracted from an RGBE texture.
  127212. * This pixels will be stored left to right up to down in the R G B order in one array.
  127213. *
  127214. * More information on this format are available here:
  127215. * https://en.wikipedia.org/wiki/RGBE_image_format
  127216. *
  127217. * @param uint8array The binary file stored in an array buffer.
  127218. * @param hdrInfo The header information of the file.
  127219. * @return The pixels data in RGB right to left up to down order.
  127220. */
  127221. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127222. private static RGBE_ReadPixels_RLE;
  127223. }
  127224. }
  127225. declare module BABYLON {
  127226. /**
  127227. * This represents a texture coming from an HDR input.
  127228. *
  127229. * The only supported format is currently panorama picture stored in RGBE format.
  127230. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127231. */
  127232. export class HDRCubeTexture extends BaseTexture {
  127233. private static _facesMapping;
  127234. private _generateHarmonics;
  127235. private _noMipmap;
  127236. private _textureMatrix;
  127237. private _size;
  127238. private _onLoad;
  127239. private _onError;
  127240. /**
  127241. * The texture URL.
  127242. */
  127243. url: string;
  127244. /**
  127245. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127246. */
  127247. coordinatesMode: number;
  127248. protected _isBlocking: boolean;
  127249. /**
  127250. * Sets wether or not the texture is blocking during loading.
  127251. */
  127252. set isBlocking(value: boolean);
  127253. /**
  127254. * Gets wether or not the texture is blocking during loading.
  127255. */
  127256. get isBlocking(): boolean;
  127257. protected _rotationY: number;
  127258. /**
  127259. * Sets texture matrix rotation angle around Y axis in radians.
  127260. */
  127261. set rotationY(value: number);
  127262. /**
  127263. * Gets texture matrix rotation angle around Y axis radians.
  127264. */
  127265. get rotationY(): number;
  127266. /**
  127267. * Gets or sets the center of the bounding box associated with the cube texture
  127268. * It must define where the camera used to render the texture was set
  127269. */
  127270. boundingBoxPosition: Vector3;
  127271. private _boundingBoxSize;
  127272. /**
  127273. * Gets or sets the size of the bounding box associated with the cube texture
  127274. * When defined, the cubemap will switch to local mode
  127275. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127276. * @example https://www.babylonjs-playground.com/#RNASML
  127277. */
  127278. set boundingBoxSize(value: Vector3);
  127279. get boundingBoxSize(): Vector3;
  127280. /**
  127281. * Instantiates an HDRTexture from the following parameters.
  127282. *
  127283. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127284. * @param scene The scene the texture will be used in
  127285. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127286. * @param noMipmap Forces to not generate the mipmap if true
  127287. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127288. * @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)
  127289. * @param reserved Reserved flag for internal use.
  127290. */
  127291. 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>);
  127292. /**
  127293. * Get the current class name of the texture useful for serialization or dynamic coding.
  127294. * @returns "HDRCubeTexture"
  127295. */
  127296. getClassName(): string;
  127297. /**
  127298. * Occurs when the file is raw .hdr file.
  127299. */
  127300. private loadTexture;
  127301. clone(): HDRCubeTexture;
  127302. delayLoad(): void;
  127303. /**
  127304. * Get the texture reflection matrix used to rotate/transform the reflection.
  127305. * @returns the reflection matrix
  127306. */
  127307. getReflectionTextureMatrix(): Matrix;
  127308. /**
  127309. * Set the texture reflection matrix used to rotate/transform the reflection.
  127310. * @param value Define the reflection matrix to set
  127311. */
  127312. setReflectionTextureMatrix(value: Matrix): void;
  127313. /**
  127314. * Parses a JSON representation of an HDR Texture in order to create the texture
  127315. * @param parsedTexture Define the JSON representation
  127316. * @param scene Define the scene the texture should be created in
  127317. * @param rootUrl Define the root url in case we need to load relative dependencies
  127318. * @returns the newly created texture after parsing
  127319. */
  127320. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127321. serialize(): any;
  127322. }
  127323. }
  127324. declare module BABYLON {
  127325. /**
  127326. * Class used to control physics engine
  127327. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127328. */
  127329. export class PhysicsEngine implements IPhysicsEngine {
  127330. private _physicsPlugin;
  127331. /**
  127332. * Global value used to control the smallest number supported by the simulation
  127333. */
  127334. static Epsilon: number;
  127335. private _impostors;
  127336. private _joints;
  127337. private _subTimeStep;
  127338. /**
  127339. * Gets the gravity vector used by the simulation
  127340. */
  127341. gravity: Vector3;
  127342. /**
  127343. * Factory used to create the default physics plugin.
  127344. * @returns The default physics plugin
  127345. */
  127346. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127347. /**
  127348. * Creates a new Physics Engine
  127349. * @param gravity defines the gravity vector used by the simulation
  127350. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127351. */
  127352. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127353. /**
  127354. * Sets the gravity vector used by the simulation
  127355. * @param gravity defines the gravity vector to use
  127356. */
  127357. setGravity(gravity: Vector3): void;
  127358. /**
  127359. * Set the time step of the physics engine.
  127360. * Default is 1/60.
  127361. * To slow it down, enter 1/600 for example.
  127362. * To speed it up, 1/30
  127363. * @param newTimeStep defines the new timestep to apply to this world.
  127364. */
  127365. setTimeStep(newTimeStep?: number): void;
  127366. /**
  127367. * Get the time step of the physics engine.
  127368. * @returns the current time step
  127369. */
  127370. getTimeStep(): number;
  127371. /**
  127372. * Set the sub time step of the physics engine.
  127373. * Default is 0 meaning there is no sub steps
  127374. * To increase physics resolution precision, set a small value (like 1 ms)
  127375. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127376. */
  127377. setSubTimeStep(subTimeStep?: number): void;
  127378. /**
  127379. * Get the sub time step of the physics engine.
  127380. * @returns the current sub time step
  127381. */
  127382. getSubTimeStep(): number;
  127383. /**
  127384. * Release all resources
  127385. */
  127386. dispose(): void;
  127387. /**
  127388. * Gets the name of the current physics plugin
  127389. * @returns the name of the plugin
  127390. */
  127391. getPhysicsPluginName(): string;
  127392. /**
  127393. * Adding a new impostor for the impostor tracking.
  127394. * This will be done by the impostor itself.
  127395. * @param impostor the impostor to add
  127396. */
  127397. addImpostor(impostor: PhysicsImpostor): void;
  127398. /**
  127399. * Remove an impostor from the engine.
  127400. * This impostor and its mesh will not longer be updated by the physics engine.
  127401. * @param impostor the impostor to remove
  127402. */
  127403. removeImpostor(impostor: PhysicsImpostor): void;
  127404. /**
  127405. * Add a joint to the physics engine
  127406. * @param mainImpostor defines the main impostor to which the joint is added.
  127407. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127408. * @param joint defines the joint that will connect both impostors.
  127409. */
  127410. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127411. /**
  127412. * Removes a joint from the simulation
  127413. * @param mainImpostor defines the impostor used with the joint
  127414. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127415. * @param joint defines the joint to remove
  127416. */
  127417. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127418. /**
  127419. * Called by the scene. No need to call it.
  127420. * @param delta defines the timespam between frames
  127421. */
  127422. _step(delta: number): void;
  127423. /**
  127424. * Gets the current plugin used to run the simulation
  127425. * @returns current plugin
  127426. */
  127427. getPhysicsPlugin(): IPhysicsEnginePlugin;
  127428. /**
  127429. * Gets the list of physic impostors
  127430. * @returns an array of PhysicsImpostor
  127431. */
  127432. getImpostors(): Array<PhysicsImpostor>;
  127433. /**
  127434. * Gets the impostor for a physics enabled object
  127435. * @param object defines the object impersonated by the impostor
  127436. * @returns the PhysicsImpostor or null if not found
  127437. */
  127438. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  127439. /**
  127440. * Gets the impostor for a physics body object
  127441. * @param body defines physics body used by the impostor
  127442. * @returns the PhysicsImpostor or null if not found
  127443. */
  127444. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  127445. /**
  127446. * Does a raycast in the physics world
  127447. * @param from when should the ray start?
  127448. * @param to when should the ray end?
  127449. * @returns PhysicsRaycastResult
  127450. */
  127451. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127452. }
  127453. }
  127454. declare module BABYLON {
  127455. /** @hidden */
  127456. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  127457. private _useDeltaForWorldStep;
  127458. world: any;
  127459. name: string;
  127460. private _physicsMaterials;
  127461. private _fixedTimeStep;
  127462. private _cannonRaycastResult;
  127463. private _raycastResult;
  127464. private _physicsBodysToRemoveAfterStep;
  127465. BJSCANNON: any;
  127466. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  127467. setGravity(gravity: Vector3): void;
  127468. setTimeStep(timeStep: number): void;
  127469. getTimeStep(): number;
  127470. executeStep(delta: number): void;
  127471. private _removeMarkedPhysicsBodiesFromWorld;
  127472. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127473. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127474. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127475. private _processChildMeshes;
  127476. removePhysicsBody(impostor: PhysicsImpostor): void;
  127477. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127478. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127479. private _addMaterial;
  127480. private _checkWithEpsilon;
  127481. private _createShape;
  127482. private _createHeightmap;
  127483. private _minus90X;
  127484. private _plus90X;
  127485. private _tmpPosition;
  127486. private _tmpDeltaPosition;
  127487. private _tmpUnityRotation;
  127488. private _updatePhysicsBodyTransformation;
  127489. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127490. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127491. isSupported(): boolean;
  127492. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127493. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127494. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127495. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127496. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127497. getBodyMass(impostor: PhysicsImpostor): number;
  127498. getBodyFriction(impostor: PhysicsImpostor): number;
  127499. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127500. getBodyRestitution(impostor: PhysicsImpostor): number;
  127501. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127502. sleepBody(impostor: PhysicsImpostor): void;
  127503. wakeUpBody(impostor: PhysicsImpostor): void;
  127504. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  127505. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  127506. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  127507. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127508. getRadius(impostor: PhysicsImpostor): number;
  127509. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127510. dispose(): void;
  127511. private _extendNamespace;
  127512. /**
  127513. * Does a raycast in the physics world
  127514. * @param from when should the ray start?
  127515. * @param to when should the ray end?
  127516. * @returns PhysicsRaycastResult
  127517. */
  127518. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127519. }
  127520. }
  127521. declare module BABYLON {
  127522. /** @hidden */
  127523. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  127524. world: any;
  127525. name: string;
  127526. BJSOIMO: any;
  127527. private _raycastResult;
  127528. constructor(iterations?: number, oimoInjection?: any);
  127529. setGravity(gravity: Vector3): void;
  127530. setTimeStep(timeStep: number): void;
  127531. getTimeStep(): number;
  127532. private _tmpImpostorsArray;
  127533. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127534. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127535. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127536. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127537. private _tmpPositionVector;
  127538. removePhysicsBody(impostor: PhysicsImpostor): void;
  127539. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127540. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127541. isSupported(): boolean;
  127542. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127543. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127544. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127545. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127546. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127547. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127548. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127549. getBodyMass(impostor: PhysicsImpostor): number;
  127550. getBodyFriction(impostor: PhysicsImpostor): number;
  127551. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127552. getBodyRestitution(impostor: PhysicsImpostor): number;
  127553. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127554. sleepBody(impostor: PhysicsImpostor): void;
  127555. wakeUpBody(impostor: PhysicsImpostor): void;
  127556. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  127557. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  127558. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  127559. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127560. getRadius(impostor: PhysicsImpostor): number;
  127561. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127562. dispose(): void;
  127563. /**
  127564. * Does a raycast in the physics world
  127565. * @param from when should the ray start?
  127566. * @param to when should the ray end?
  127567. * @returns PhysicsRaycastResult
  127568. */
  127569. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127570. }
  127571. }
  127572. declare module BABYLON {
  127573. /**
  127574. * Class containing static functions to help procedurally build meshes
  127575. */
  127576. export class RibbonBuilder {
  127577. /**
  127578. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127579. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127580. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127581. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127582. * * 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
  127583. * * 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
  127584. * * 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
  127585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127588. * * 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
  127589. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127590. * * 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
  127591. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127593. * @param name defines the name of the mesh
  127594. * @param options defines the options used to create the mesh
  127595. * @param scene defines the hosting scene
  127596. * @returns the ribbon mesh
  127597. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127598. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127599. */
  127600. static CreateRibbon(name: string, options: {
  127601. pathArray: Vector3[][];
  127602. closeArray?: boolean;
  127603. closePath?: boolean;
  127604. offset?: number;
  127605. updatable?: boolean;
  127606. sideOrientation?: number;
  127607. frontUVs?: Vector4;
  127608. backUVs?: Vector4;
  127609. instance?: Mesh;
  127610. invertUV?: boolean;
  127611. uvs?: Vector2[];
  127612. colors?: Color4[];
  127613. }, scene?: Nullable<Scene>): Mesh;
  127614. }
  127615. }
  127616. declare module BABYLON {
  127617. /**
  127618. * Class containing static functions to help procedurally build meshes
  127619. */
  127620. export class ShapeBuilder {
  127621. /**
  127622. * 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.
  127623. * * 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.
  127624. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127625. * * 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.
  127626. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127627. * * 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
  127628. * * 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
  127629. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127634. * @param name defines the name of the mesh
  127635. * @param options defines the options used to create the mesh
  127636. * @param scene defines the hosting scene
  127637. * @returns the extruded shape mesh
  127638. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127640. */
  127641. static ExtrudeShape(name: string, options: {
  127642. shape: Vector3[];
  127643. path: Vector3[];
  127644. scale?: number;
  127645. rotation?: number;
  127646. cap?: number;
  127647. updatable?: boolean;
  127648. sideOrientation?: number;
  127649. frontUVs?: Vector4;
  127650. backUVs?: Vector4;
  127651. instance?: Mesh;
  127652. invertUV?: boolean;
  127653. }, scene?: Nullable<Scene>): Mesh;
  127654. /**
  127655. * Creates an custom extruded shape mesh.
  127656. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127657. * * 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.
  127658. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127659. * * 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
  127660. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127661. * * 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
  127662. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127663. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127664. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127665. * * 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
  127666. * * 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
  127667. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127672. * @param name defines the name of the mesh
  127673. * @param options defines the options used to create the mesh
  127674. * @param scene defines the hosting scene
  127675. * @returns the custom extruded shape mesh
  127676. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127677. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127679. */
  127680. static ExtrudeShapeCustom(name: string, options: {
  127681. shape: Vector3[];
  127682. path: Vector3[];
  127683. scaleFunction?: any;
  127684. rotationFunction?: any;
  127685. ribbonCloseArray?: boolean;
  127686. ribbonClosePath?: boolean;
  127687. cap?: number;
  127688. updatable?: boolean;
  127689. sideOrientation?: number;
  127690. frontUVs?: Vector4;
  127691. backUVs?: Vector4;
  127692. instance?: Mesh;
  127693. invertUV?: boolean;
  127694. }, scene?: Nullable<Scene>): Mesh;
  127695. private static _ExtrudeShapeGeneric;
  127696. }
  127697. }
  127698. declare module BABYLON {
  127699. /**
  127700. * AmmoJS Physics plugin
  127701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  127702. * @see https://github.com/kripken/ammo.js/
  127703. */
  127704. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  127705. private _useDeltaForWorldStep;
  127706. /**
  127707. * Reference to the Ammo library
  127708. */
  127709. bjsAMMO: any;
  127710. /**
  127711. * Created ammoJS world which physics bodies are added to
  127712. */
  127713. world: any;
  127714. /**
  127715. * Name of the plugin
  127716. */
  127717. name: string;
  127718. private _timeStep;
  127719. private _fixedTimeStep;
  127720. private _maxSteps;
  127721. private _tmpQuaternion;
  127722. private _tmpAmmoTransform;
  127723. private _tmpAmmoQuaternion;
  127724. private _tmpAmmoConcreteContactResultCallback;
  127725. private _collisionConfiguration;
  127726. private _dispatcher;
  127727. private _overlappingPairCache;
  127728. private _solver;
  127729. private _softBodySolver;
  127730. private _tmpAmmoVectorA;
  127731. private _tmpAmmoVectorB;
  127732. private _tmpAmmoVectorC;
  127733. private _tmpAmmoVectorD;
  127734. private _tmpContactCallbackResult;
  127735. private _tmpAmmoVectorRCA;
  127736. private _tmpAmmoVectorRCB;
  127737. private _raycastResult;
  127738. private static readonly DISABLE_COLLISION_FLAG;
  127739. private static readonly KINEMATIC_FLAG;
  127740. private static readonly DISABLE_DEACTIVATION_FLAG;
  127741. /**
  127742. * Initializes the ammoJS plugin
  127743. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  127744. * @param ammoInjection can be used to inject your own ammo reference
  127745. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  127746. */
  127747. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  127748. /**
  127749. * Sets the gravity of the physics world (m/(s^2))
  127750. * @param gravity Gravity to set
  127751. */
  127752. setGravity(gravity: Vector3): void;
  127753. /**
  127754. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  127755. * @param timeStep timestep to use in seconds
  127756. */
  127757. setTimeStep(timeStep: number): void;
  127758. /**
  127759. * 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)
  127760. * @param fixedTimeStep fixedTimeStep to use in seconds
  127761. */
  127762. setFixedTimeStep(fixedTimeStep: number): void;
  127763. /**
  127764. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  127765. * @param maxSteps the maximum number of steps by the physics engine per frame
  127766. */
  127767. setMaxSteps(maxSteps: number): void;
  127768. /**
  127769. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  127770. * @returns the current timestep in seconds
  127771. */
  127772. getTimeStep(): number;
  127773. /**
  127774. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  127775. */
  127776. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  127777. private _isImpostorInContact;
  127778. private _isImpostorPairInContact;
  127779. private _stepSimulation;
  127780. /**
  127781. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  127782. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  127783. * After the step the babylon meshes are set to the position of the physics imposters
  127784. * @param delta amount of time to step forward
  127785. * @param impostors array of imposters to update before/after the step
  127786. */
  127787. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127788. /**
  127789. * Update babylon mesh to match physics world object
  127790. * @param impostor imposter to match
  127791. */
  127792. private _afterSoftStep;
  127793. /**
  127794. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127795. * @param impostor imposter to match
  127796. */
  127797. private _ropeStep;
  127798. /**
  127799. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127800. * @param impostor imposter to match
  127801. */
  127802. private _softbodyOrClothStep;
  127803. private _tmpVector;
  127804. private _tmpMatrix;
  127805. /**
  127806. * Applies an impulse on the imposter
  127807. * @param impostor imposter to apply impulse to
  127808. * @param force amount of force to be applied to the imposter
  127809. * @param contactPoint the location to apply the impulse on the imposter
  127810. */
  127811. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127812. /**
  127813. * Applies a force on the imposter
  127814. * @param impostor imposter to apply force
  127815. * @param force amount of force to be applied to the imposter
  127816. * @param contactPoint the location to apply the force on the imposter
  127817. */
  127818. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127819. /**
  127820. * Creates a physics body using the plugin
  127821. * @param impostor the imposter to create the physics body on
  127822. */
  127823. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127824. /**
  127825. * Removes the physics body from the imposter and disposes of the body's memory
  127826. * @param impostor imposter to remove the physics body from
  127827. */
  127828. removePhysicsBody(impostor: PhysicsImpostor): void;
  127829. /**
  127830. * Generates a joint
  127831. * @param impostorJoint the imposter joint to create the joint with
  127832. */
  127833. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127834. /**
  127835. * Removes a joint
  127836. * @param impostorJoint the imposter joint to remove the joint from
  127837. */
  127838. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127839. private _addMeshVerts;
  127840. /**
  127841. * Initialise the soft body vertices to match its object's (mesh) vertices
  127842. * Softbody vertices (nodes) are in world space and to match this
  127843. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  127844. * @param impostor to create the softbody for
  127845. */
  127846. private _softVertexData;
  127847. /**
  127848. * Create an impostor's soft body
  127849. * @param impostor to create the softbody for
  127850. */
  127851. private _createSoftbody;
  127852. /**
  127853. * Create cloth for an impostor
  127854. * @param impostor to create the softbody for
  127855. */
  127856. private _createCloth;
  127857. /**
  127858. * Create rope for an impostor
  127859. * @param impostor to create the softbody for
  127860. */
  127861. private _createRope;
  127862. /**
  127863. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  127864. * @param impostor to create the custom physics shape for
  127865. */
  127866. private _createCustom;
  127867. private _addHullVerts;
  127868. private _createShape;
  127869. /**
  127870. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  127871. * @param impostor imposter containing the physics body and babylon object
  127872. */
  127873. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127874. /**
  127875. * Sets the babylon object's position/rotation from the physics body's position/rotation
  127876. * @param impostor imposter containing the physics body and babylon object
  127877. * @param newPosition new position
  127878. * @param newRotation new rotation
  127879. */
  127880. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127881. /**
  127882. * If this plugin is supported
  127883. * @returns true if its supported
  127884. */
  127885. isSupported(): boolean;
  127886. /**
  127887. * Sets the linear velocity of the physics body
  127888. * @param impostor imposter to set the velocity on
  127889. * @param velocity velocity to set
  127890. */
  127891. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127892. /**
  127893. * Sets the angular velocity of the physics body
  127894. * @param impostor imposter to set the velocity on
  127895. * @param velocity velocity to set
  127896. */
  127897. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127898. /**
  127899. * gets the linear velocity
  127900. * @param impostor imposter to get linear velocity from
  127901. * @returns linear velocity
  127902. */
  127903. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127904. /**
  127905. * gets the angular velocity
  127906. * @param impostor imposter to get angular velocity from
  127907. * @returns angular velocity
  127908. */
  127909. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127910. /**
  127911. * Sets the mass of physics body
  127912. * @param impostor imposter to set the mass on
  127913. * @param mass mass to set
  127914. */
  127915. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127916. /**
  127917. * Gets the mass of the physics body
  127918. * @param impostor imposter to get the mass from
  127919. * @returns mass
  127920. */
  127921. getBodyMass(impostor: PhysicsImpostor): number;
  127922. /**
  127923. * Gets friction of the impostor
  127924. * @param impostor impostor to get friction from
  127925. * @returns friction value
  127926. */
  127927. getBodyFriction(impostor: PhysicsImpostor): number;
  127928. /**
  127929. * Sets friction of the impostor
  127930. * @param impostor impostor to set friction on
  127931. * @param friction friction value
  127932. */
  127933. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127934. /**
  127935. * Gets restitution of the impostor
  127936. * @param impostor impostor to get restitution from
  127937. * @returns restitution value
  127938. */
  127939. getBodyRestitution(impostor: PhysicsImpostor): number;
  127940. /**
  127941. * Sets resitution of the impostor
  127942. * @param impostor impostor to set resitution on
  127943. * @param restitution resitution value
  127944. */
  127945. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127946. /**
  127947. * Gets pressure inside the impostor
  127948. * @param impostor impostor to get pressure from
  127949. * @returns pressure value
  127950. */
  127951. getBodyPressure(impostor: PhysicsImpostor): number;
  127952. /**
  127953. * Sets pressure inside a soft body impostor
  127954. * Cloth and rope must remain 0 pressure
  127955. * @param impostor impostor to set pressure on
  127956. * @param pressure pressure value
  127957. */
  127958. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  127959. /**
  127960. * Gets stiffness of the impostor
  127961. * @param impostor impostor to get stiffness from
  127962. * @returns pressure value
  127963. */
  127964. getBodyStiffness(impostor: PhysicsImpostor): number;
  127965. /**
  127966. * Sets stiffness of the impostor
  127967. * @param impostor impostor to set stiffness on
  127968. * @param stiffness stiffness value from 0 to 1
  127969. */
  127970. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  127971. /**
  127972. * Gets velocityIterations of the impostor
  127973. * @param impostor impostor to get velocity iterations from
  127974. * @returns velocityIterations value
  127975. */
  127976. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  127977. /**
  127978. * Sets velocityIterations of the impostor
  127979. * @param impostor impostor to set velocity iterations on
  127980. * @param velocityIterations velocityIterations value
  127981. */
  127982. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  127983. /**
  127984. * Gets positionIterations of the impostor
  127985. * @param impostor impostor to get position iterations from
  127986. * @returns positionIterations value
  127987. */
  127988. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  127989. /**
  127990. * Sets positionIterations of the impostor
  127991. * @param impostor impostor to set position on
  127992. * @param positionIterations positionIterations value
  127993. */
  127994. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  127995. /**
  127996. * Append an anchor to a cloth object
  127997. * @param impostor is the cloth impostor to add anchor to
  127998. * @param otherImpostor is the rigid impostor to anchor to
  127999. * @param width ratio across width from 0 to 1
  128000. * @param height ratio up height from 0 to 1
  128001. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128002. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128003. */
  128004. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128005. /**
  128006. * Append an hook to a rope object
  128007. * @param impostor is the rope impostor to add hook to
  128008. * @param otherImpostor is the rigid impostor to hook to
  128009. * @param length ratio along the rope from 0 to 1
  128010. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128011. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128012. */
  128013. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128014. /**
  128015. * Sleeps the physics body and stops it from being active
  128016. * @param impostor impostor to sleep
  128017. */
  128018. sleepBody(impostor: PhysicsImpostor): void;
  128019. /**
  128020. * Activates the physics body
  128021. * @param impostor impostor to activate
  128022. */
  128023. wakeUpBody(impostor: PhysicsImpostor): void;
  128024. /**
  128025. * Updates the distance parameters of the joint
  128026. * @param joint joint to update
  128027. * @param maxDistance maximum distance of the joint
  128028. * @param minDistance minimum distance of the joint
  128029. */
  128030. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128031. /**
  128032. * Sets a motor on the joint
  128033. * @param joint joint to set motor on
  128034. * @param speed speed of the motor
  128035. * @param maxForce maximum force of the motor
  128036. * @param motorIndex index of the motor
  128037. */
  128038. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128039. /**
  128040. * Sets the motors limit
  128041. * @param joint joint to set limit on
  128042. * @param upperLimit upper limit
  128043. * @param lowerLimit lower limit
  128044. */
  128045. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128046. /**
  128047. * Syncs the position and rotation of a mesh with the impostor
  128048. * @param mesh mesh to sync
  128049. * @param impostor impostor to update the mesh with
  128050. */
  128051. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128052. /**
  128053. * Gets the radius of the impostor
  128054. * @param impostor impostor to get radius from
  128055. * @returns the radius
  128056. */
  128057. getRadius(impostor: PhysicsImpostor): number;
  128058. /**
  128059. * Gets the box size of the impostor
  128060. * @param impostor impostor to get box size from
  128061. * @param result the resulting box size
  128062. */
  128063. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128064. /**
  128065. * Disposes of the impostor
  128066. */
  128067. dispose(): void;
  128068. /**
  128069. * Does a raycast in the physics world
  128070. * @param from when should the ray start?
  128071. * @param to when should the ray end?
  128072. * @returns PhysicsRaycastResult
  128073. */
  128074. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128075. }
  128076. }
  128077. declare module BABYLON {
  128078. interface AbstractScene {
  128079. /**
  128080. * The list of reflection probes added to the scene
  128081. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128082. */
  128083. reflectionProbes: Array<ReflectionProbe>;
  128084. /**
  128085. * Removes the given reflection probe from this scene.
  128086. * @param toRemove The reflection probe to remove
  128087. * @returns The index of the removed reflection probe
  128088. */
  128089. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128090. /**
  128091. * Adds the given reflection probe to this scene.
  128092. * @param newReflectionProbe The reflection probe to add
  128093. */
  128094. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128095. }
  128096. /**
  128097. * Class used to generate realtime reflection / refraction cube textures
  128098. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128099. */
  128100. export class ReflectionProbe {
  128101. /** defines the name of the probe */
  128102. name: string;
  128103. private _scene;
  128104. private _renderTargetTexture;
  128105. private _projectionMatrix;
  128106. private _viewMatrix;
  128107. private _target;
  128108. private _add;
  128109. private _attachedMesh;
  128110. private _invertYAxis;
  128111. /** Gets or sets probe position (center of the cube map) */
  128112. position: Vector3;
  128113. /**
  128114. * Creates a new reflection probe
  128115. * @param name defines the name of the probe
  128116. * @param size defines the texture resolution (for each face)
  128117. * @param scene defines the hosting scene
  128118. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128119. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128120. */
  128121. constructor(
  128122. /** defines the name of the probe */
  128123. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128124. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128125. get samples(): number;
  128126. set samples(value: number);
  128127. /** Gets or sets the refresh rate to use (on every frame by default) */
  128128. get refreshRate(): number;
  128129. set refreshRate(value: number);
  128130. /**
  128131. * Gets the hosting scene
  128132. * @returns a Scene
  128133. */
  128134. getScene(): Scene;
  128135. /** Gets the internal CubeTexture used to render to */
  128136. get cubeTexture(): RenderTargetTexture;
  128137. /** Gets the list of meshes to render */
  128138. get renderList(): Nullable<AbstractMesh[]>;
  128139. /**
  128140. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128141. * @param mesh defines the mesh to attach to
  128142. */
  128143. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128144. /**
  128145. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128146. * @param renderingGroupId The rendering group id corresponding to its index
  128147. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128148. */
  128149. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128150. /**
  128151. * Clean all associated resources
  128152. */
  128153. dispose(): void;
  128154. /**
  128155. * Converts the reflection probe information to a readable string for debug purpose.
  128156. * @param fullDetails Supports for multiple levels of logging within scene loading
  128157. * @returns the human readable reflection probe info
  128158. */
  128159. toString(fullDetails?: boolean): string;
  128160. /**
  128161. * Get the class name of the relfection probe.
  128162. * @returns "ReflectionProbe"
  128163. */
  128164. getClassName(): string;
  128165. /**
  128166. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128167. * @returns The JSON representation of the texture
  128168. */
  128169. serialize(): any;
  128170. /**
  128171. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128172. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128173. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128174. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128175. * @returns The parsed reflection probe if successful
  128176. */
  128177. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128178. }
  128179. }
  128180. declare module BABYLON {
  128181. /** @hidden */
  128182. export var _BabylonLoaderRegistered: boolean;
  128183. /**
  128184. * Helps setting up some configuration for the babylon file loader.
  128185. */
  128186. export class BabylonFileLoaderConfiguration {
  128187. /**
  128188. * The loader does not allow injecting custom physix engine into the plugins.
  128189. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128190. * So you could set this variable to your engine import to make it work.
  128191. */
  128192. static LoaderInjectedPhysicsEngine: any;
  128193. }
  128194. }
  128195. declare module BABYLON {
  128196. /**
  128197. * The Physically based simple base material of BJS.
  128198. *
  128199. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128200. * It is used as the base class for both the specGloss and metalRough conventions.
  128201. */
  128202. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128203. /**
  128204. * Number of Simultaneous lights allowed on the material.
  128205. */
  128206. maxSimultaneousLights: number;
  128207. /**
  128208. * If sets to true, disables all the lights affecting the material.
  128209. */
  128210. disableLighting: boolean;
  128211. /**
  128212. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128213. */
  128214. environmentTexture: BaseTexture;
  128215. /**
  128216. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128217. */
  128218. invertNormalMapX: boolean;
  128219. /**
  128220. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128221. */
  128222. invertNormalMapY: boolean;
  128223. /**
  128224. * Normal map used in the model.
  128225. */
  128226. normalTexture: BaseTexture;
  128227. /**
  128228. * Emissivie color used to self-illuminate the model.
  128229. */
  128230. emissiveColor: Color3;
  128231. /**
  128232. * Emissivie texture used to self-illuminate the model.
  128233. */
  128234. emissiveTexture: BaseTexture;
  128235. /**
  128236. * Occlusion Channel Strenght.
  128237. */
  128238. occlusionStrength: number;
  128239. /**
  128240. * Occlusion Texture of the material (adding extra occlusion effects).
  128241. */
  128242. occlusionTexture: BaseTexture;
  128243. /**
  128244. * Defines the alpha limits in alpha test mode.
  128245. */
  128246. alphaCutOff: number;
  128247. /**
  128248. * Gets the current double sided mode.
  128249. */
  128250. get doubleSided(): boolean;
  128251. /**
  128252. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128253. */
  128254. set doubleSided(value: boolean);
  128255. /**
  128256. * Stores the pre-calculated light information of a mesh in a texture.
  128257. */
  128258. lightmapTexture: BaseTexture;
  128259. /**
  128260. * If true, the light map contains occlusion information instead of lighting info.
  128261. */
  128262. useLightmapAsShadowmap: boolean;
  128263. /**
  128264. * Instantiates a new PBRMaterial instance.
  128265. *
  128266. * @param name The material name
  128267. * @param scene The scene the material will be use in.
  128268. */
  128269. constructor(name: string, scene: Scene);
  128270. getClassName(): string;
  128271. }
  128272. }
  128273. declare module BABYLON {
  128274. /**
  128275. * The PBR material of BJS following the metal roughness convention.
  128276. *
  128277. * This fits to the PBR convention in the GLTF definition:
  128278. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128279. */
  128280. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128281. /**
  128282. * The base color has two different interpretations depending on the value of metalness.
  128283. * When the material is a metal, the base color is the specific measured reflectance value
  128284. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128285. * of the material.
  128286. */
  128287. baseColor: Color3;
  128288. /**
  128289. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128290. * well as opacity information in the alpha channel.
  128291. */
  128292. baseTexture: BaseTexture;
  128293. /**
  128294. * Specifies the metallic scalar value of the material.
  128295. * Can also be used to scale the metalness values of the metallic texture.
  128296. */
  128297. metallic: number;
  128298. /**
  128299. * Specifies the roughness scalar value of the material.
  128300. * Can also be used to scale the roughness values of the metallic texture.
  128301. */
  128302. roughness: number;
  128303. /**
  128304. * Texture containing both the metallic value in the B channel and the
  128305. * roughness value in the G channel to keep better precision.
  128306. */
  128307. metallicRoughnessTexture: BaseTexture;
  128308. /**
  128309. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128310. *
  128311. * @param name The material name
  128312. * @param scene The scene the material will be use in.
  128313. */
  128314. constructor(name: string, scene: Scene);
  128315. /**
  128316. * Return the currrent class name of the material.
  128317. */
  128318. getClassName(): string;
  128319. /**
  128320. * Makes a duplicate of the current material.
  128321. * @param name - name to use for the new material.
  128322. */
  128323. clone(name: string): PBRMetallicRoughnessMaterial;
  128324. /**
  128325. * Serialize the material to a parsable JSON object.
  128326. */
  128327. serialize(): any;
  128328. /**
  128329. * Parses a JSON object correponding to the serialize function.
  128330. */
  128331. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128332. }
  128333. }
  128334. declare module BABYLON {
  128335. /**
  128336. * The PBR material of BJS following the specular glossiness convention.
  128337. *
  128338. * This fits to the PBR convention in the GLTF definition:
  128339. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128340. */
  128341. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128342. /**
  128343. * Specifies the diffuse color of the material.
  128344. */
  128345. diffuseColor: Color3;
  128346. /**
  128347. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128348. * channel.
  128349. */
  128350. diffuseTexture: BaseTexture;
  128351. /**
  128352. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128353. */
  128354. specularColor: Color3;
  128355. /**
  128356. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128357. */
  128358. glossiness: number;
  128359. /**
  128360. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128361. */
  128362. specularGlossinessTexture: BaseTexture;
  128363. /**
  128364. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128365. *
  128366. * @param name The material name
  128367. * @param scene The scene the material will be use in.
  128368. */
  128369. constructor(name: string, scene: Scene);
  128370. /**
  128371. * Return the currrent class name of the material.
  128372. */
  128373. getClassName(): string;
  128374. /**
  128375. * Makes a duplicate of the current material.
  128376. * @param name - name to use for the new material.
  128377. */
  128378. clone(name: string): PBRSpecularGlossinessMaterial;
  128379. /**
  128380. * Serialize the material to a parsable JSON object.
  128381. */
  128382. serialize(): any;
  128383. /**
  128384. * Parses a JSON object correponding to the serialize function.
  128385. */
  128386. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128387. }
  128388. }
  128389. declare module BABYLON {
  128390. /**
  128391. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128392. * It can help converting any input color in a desired output one. This can then be used to create effects
  128393. * from sepia, black and white to sixties or futuristic rendering...
  128394. *
  128395. * The only supported format is currently 3dl.
  128396. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128397. */
  128398. export class ColorGradingTexture extends BaseTexture {
  128399. /**
  128400. * The current texture matrix. (will always be identity in color grading texture)
  128401. */
  128402. private _textureMatrix;
  128403. /**
  128404. * The texture URL.
  128405. */
  128406. url: string;
  128407. /**
  128408. * Empty line regex stored for GC.
  128409. */
  128410. private static _noneEmptyLineRegex;
  128411. private _engine;
  128412. /**
  128413. * Instantiates a ColorGradingTexture from the following parameters.
  128414. *
  128415. * @param url The location of the color gradind data (currently only supporting 3dl)
  128416. * @param scene The scene the texture will be used in
  128417. */
  128418. constructor(url: string, scene: Scene);
  128419. /**
  128420. * Returns the texture matrix used in most of the material.
  128421. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  128422. */
  128423. getTextureMatrix(): Matrix;
  128424. /**
  128425. * Occurs when the file being loaded is a .3dl LUT file.
  128426. */
  128427. private load3dlTexture;
  128428. /**
  128429. * Starts the loading process of the texture.
  128430. */
  128431. private loadTexture;
  128432. /**
  128433. * Clones the color gradind texture.
  128434. */
  128435. clone(): ColorGradingTexture;
  128436. /**
  128437. * Called during delayed load for textures.
  128438. */
  128439. delayLoad(): void;
  128440. /**
  128441. * Parses a color grading texture serialized by Babylon.
  128442. * @param parsedTexture The texture information being parsedTexture
  128443. * @param scene The scene to load the texture in
  128444. * @param rootUrl The root url of the data assets to load
  128445. * @return A color gradind texture
  128446. */
  128447. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  128448. /**
  128449. * Serializes the LUT texture to json format.
  128450. */
  128451. serialize(): any;
  128452. }
  128453. }
  128454. declare module BABYLON {
  128455. /**
  128456. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  128457. */
  128458. export class EquiRectangularCubeTexture extends BaseTexture {
  128459. /** The six faces of the cube. */
  128460. private static _FacesMapping;
  128461. private _noMipmap;
  128462. private _onLoad;
  128463. private _onError;
  128464. /** The size of the cubemap. */
  128465. private _size;
  128466. /** The buffer of the image. */
  128467. private _buffer;
  128468. /** The width of the input image. */
  128469. private _width;
  128470. /** The height of the input image. */
  128471. private _height;
  128472. /** The URL to the image. */
  128473. url: string;
  128474. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  128475. coordinatesMode: number;
  128476. /**
  128477. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  128478. * @param url The location of the image
  128479. * @param scene The scene the texture will be used in
  128480. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128481. * @param noMipmap Forces to not generate the mipmap if true
  128482. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128483. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128484. * @param onLoad — defines a callback called when texture is loaded
  128485. * @param onError — defines a callback called if there is an error
  128486. */
  128487. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  128488. /**
  128489. * Load the image data, by putting the image on a canvas and extracting its buffer.
  128490. */
  128491. private loadImage;
  128492. /**
  128493. * Convert the image buffer into a cubemap and create a CubeTexture.
  128494. */
  128495. private loadTexture;
  128496. /**
  128497. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  128498. * @param buffer The ArrayBuffer that should be converted.
  128499. * @returns The buffer as Float32Array.
  128500. */
  128501. private getFloat32ArrayFromArrayBuffer;
  128502. /**
  128503. * Get the current class name of the texture useful for serialization or dynamic coding.
  128504. * @returns "EquiRectangularCubeTexture"
  128505. */
  128506. getClassName(): string;
  128507. /**
  128508. * Create a clone of the current EquiRectangularCubeTexture and return it.
  128509. * @returns A clone of the current EquiRectangularCubeTexture.
  128510. */
  128511. clone(): EquiRectangularCubeTexture;
  128512. }
  128513. }
  128514. declare module BABYLON {
  128515. /**
  128516. * Based on jsTGALoader - Javascript loader for TGA file
  128517. * By Vincent Thibault
  128518. * @see http://blog.robrowser.com/javascript-tga-loader.html
  128519. */
  128520. export class TGATools {
  128521. private static _TYPE_INDEXED;
  128522. private static _TYPE_RGB;
  128523. private static _TYPE_GREY;
  128524. private static _TYPE_RLE_INDEXED;
  128525. private static _TYPE_RLE_RGB;
  128526. private static _TYPE_RLE_GREY;
  128527. private static _ORIGIN_MASK;
  128528. private static _ORIGIN_SHIFT;
  128529. private static _ORIGIN_BL;
  128530. private static _ORIGIN_BR;
  128531. private static _ORIGIN_UL;
  128532. private static _ORIGIN_UR;
  128533. /**
  128534. * Gets the header of a TGA file
  128535. * @param data defines the TGA data
  128536. * @returns the header
  128537. */
  128538. static GetTGAHeader(data: Uint8Array): any;
  128539. /**
  128540. * Uploads TGA content to a Babylon Texture
  128541. * @hidden
  128542. */
  128543. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  128544. /** @hidden */
  128545. 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;
  128546. /** @hidden */
  128547. 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;
  128548. /** @hidden */
  128549. 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;
  128550. /** @hidden */
  128551. 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;
  128552. /** @hidden */
  128553. 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;
  128554. /** @hidden */
  128555. 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;
  128556. }
  128557. }
  128558. declare module BABYLON {
  128559. /**
  128560. * Implementation of the TGA Texture Loader.
  128561. * @hidden
  128562. */
  128563. export class _TGATextureLoader implements IInternalTextureLoader {
  128564. /**
  128565. * Defines wether the loader supports cascade loading the different faces.
  128566. */
  128567. readonly supportCascades: boolean;
  128568. /**
  128569. * This returns if the loader support the current file information.
  128570. * @param extension defines the file extension of the file being loaded
  128571. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128572. * @param fallback defines the fallback internal texture if any
  128573. * @param isBase64 defines whether the texture is encoded as a base64
  128574. * @param isBuffer defines whether the texture data are stored as a buffer
  128575. * @returns true if the loader can load the specified file
  128576. */
  128577. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128578. /**
  128579. * Transform the url before loading if required.
  128580. * @param rootUrl the url of the texture
  128581. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128582. * @returns the transformed texture
  128583. */
  128584. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128585. /**
  128586. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128587. * @param rootUrl the url of the texture
  128588. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128589. * @returns the fallback texture
  128590. */
  128591. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128592. /**
  128593. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  128594. * @param data contains the texture data
  128595. * @param texture defines the BabylonJS internal texture
  128596. * @param createPolynomials will be true if polynomials have been requested
  128597. * @param onLoad defines the callback to trigger once the texture is ready
  128598. * @param onError defines the callback to trigger in case of error
  128599. */
  128600. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128601. /**
  128602. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128603. * @param data contains the texture data
  128604. * @param texture defines the BabylonJS internal texture
  128605. * @param callback defines the method to call once ready to upload
  128606. */
  128607. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128608. }
  128609. }
  128610. declare module BABYLON {
  128611. /**
  128612. * Info about the .basis files
  128613. */
  128614. class BasisFileInfo {
  128615. /**
  128616. * If the file has alpha
  128617. */
  128618. hasAlpha: boolean;
  128619. /**
  128620. * Info about each image of the basis file
  128621. */
  128622. images: Array<{
  128623. levels: Array<{
  128624. width: number;
  128625. height: number;
  128626. transcodedPixels: ArrayBufferView;
  128627. }>;
  128628. }>;
  128629. }
  128630. /**
  128631. * Result of transcoding a basis file
  128632. */
  128633. class TranscodeResult {
  128634. /**
  128635. * Info about the .basis file
  128636. */
  128637. fileInfo: BasisFileInfo;
  128638. /**
  128639. * Format to use when loading the file
  128640. */
  128641. format: number;
  128642. }
  128643. /**
  128644. * Configuration options for the Basis transcoder
  128645. */
  128646. export class BasisTranscodeConfiguration {
  128647. /**
  128648. * Supported compression formats used to determine the supported output format of the transcoder
  128649. */
  128650. supportedCompressionFormats?: {
  128651. /**
  128652. * etc1 compression format
  128653. */
  128654. etc1?: boolean;
  128655. /**
  128656. * s3tc compression format
  128657. */
  128658. s3tc?: boolean;
  128659. /**
  128660. * pvrtc compression format
  128661. */
  128662. pvrtc?: boolean;
  128663. /**
  128664. * etc2 compression format
  128665. */
  128666. etc2?: boolean;
  128667. };
  128668. /**
  128669. * If mipmap levels should be loaded for transcoded images (Default: true)
  128670. */
  128671. loadMipmapLevels?: boolean;
  128672. /**
  128673. * Index of a single image to load (Default: all images)
  128674. */
  128675. loadSingleImage?: number;
  128676. }
  128677. /**
  128678. * Used to load .Basis files
  128679. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  128680. */
  128681. export class BasisTools {
  128682. private static _IgnoreSupportedFormats;
  128683. /**
  128684. * URL to use when loading the basis transcoder
  128685. */
  128686. static JSModuleURL: string;
  128687. /**
  128688. * URL to use when loading the wasm module for the transcoder
  128689. */
  128690. static WasmModuleURL: string;
  128691. /**
  128692. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  128693. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  128694. * @returns internal format corresponding to the Basis format
  128695. */
  128696. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  128697. private static _WorkerPromise;
  128698. private static _Worker;
  128699. private static _actionId;
  128700. private static _CreateWorkerAsync;
  128701. /**
  128702. * Transcodes a loaded image file to compressed pixel data
  128703. * @param imageData image data to transcode
  128704. * @param config configuration options for the transcoding
  128705. * @returns a promise resulting in the transcoded image
  128706. */
  128707. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  128708. /**
  128709. * Loads a texture from the transcode result
  128710. * @param texture texture load to
  128711. * @param transcodeResult the result of transcoding the basis file to load from
  128712. */
  128713. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  128714. }
  128715. }
  128716. declare module BABYLON {
  128717. /**
  128718. * Loader for .basis file format
  128719. */
  128720. export class _BasisTextureLoader implements IInternalTextureLoader {
  128721. /**
  128722. * Defines whether the loader supports cascade loading the different faces.
  128723. */
  128724. readonly supportCascades: boolean;
  128725. /**
  128726. * This returns if the loader support the current file information.
  128727. * @param extension defines the file extension of the file being loaded
  128728. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128729. * @param fallback defines the fallback internal texture if any
  128730. * @param isBase64 defines whether the texture is encoded as a base64
  128731. * @param isBuffer defines whether the texture data are stored as a buffer
  128732. * @returns true if the loader can load the specified file
  128733. */
  128734. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128735. /**
  128736. * Transform the url before loading if required.
  128737. * @param rootUrl the url of the texture
  128738. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128739. * @returns the transformed texture
  128740. */
  128741. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128742. /**
  128743. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128744. * @param rootUrl the url of the texture
  128745. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128746. * @returns the fallback texture
  128747. */
  128748. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128749. /**
  128750. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  128751. * @param data contains the texture data
  128752. * @param texture defines the BabylonJS internal texture
  128753. * @param createPolynomials will be true if polynomials have been requested
  128754. * @param onLoad defines the callback to trigger once the texture is ready
  128755. * @param onError defines the callback to trigger in case of error
  128756. */
  128757. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128758. /**
  128759. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128760. * @param data contains the texture data
  128761. * @param texture defines the BabylonJS internal texture
  128762. * @param callback defines the method to call once ready to upload
  128763. */
  128764. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128765. }
  128766. }
  128767. declare module BABYLON {
  128768. /**
  128769. * 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.
  128770. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128771. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128772. */
  128773. export class CustomProceduralTexture extends ProceduralTexture {
  128774. private _animate;
  128775. private _time;
  128776. private _config;
  128777. private _texturePath;
  128778. /**
  128779. * Instantiates a new Custom Procedural Texture.
  128780. * 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.
  128781. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128782. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128783. * @param name Define the name of the texture
  128784. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  128785. * @param size Define the size of the texture to create
  128786. * @param scene Define the scene the texture belongs to
  128787. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  128788. * @param generateMipMaps Define if the texture should creates mip maps or not
  128789. */
  128790. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128791. private _loadJson;
  128792. /**
  128793. * Is the texture ready to be used ? (rendered at least once)
  128794. * @returns true if ready, otherwise, false.
  128795. */
  128796. isReady(): boolean;
  128797. /**
  128798. * Render the texture to its associated render target.
  128799. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  128800. */
  128801. render(useCameraPostProcess?: boolean): void;
  128802. /**
  128803. * Update the list of dependant textures samplers in the shader.
  128804. */
  128805. updateTextures(): void;
  128806. /**
  128807. * Update the uniform values of the procedural texture in the shader.
  128808. */
  128809. updateShaderUniforms(): void;
  128810. /**
  128811. * Define if the texture animates or not.
  128812. */
  128813. get animate(): boolean;
  128814. set animate(value: boolean);
  128815. }
  128816. }
  128817. declare module BABYLON {
  128818. /** @hidden */
  128819. export var noisePixelShader: {
  128820. name: string;
  128821. shader: string;
  128822. };
  128823. }
  128824. declare module BABYLON {
  128825. /**
  128826. * Class used to generate noise procedural textures
  128827. */
  128828. export class NoiseProceduralTexture extends ProceduralTexture {
  128829. private _time;
  128830. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  128831. brightness: number;
  128832. /** Defines the number of octaves to process */
  128833. octaves: number;
  128834. /** Defines the level of persistence (0.8 by default) */
  128835. persistence: number;
  128836. /** Gets or sets animation speed factor (default is 1) */
  128837. animationSpeedFactor: number;
  128838. /**
  128839. * Creates a new NoiseProceduralTexture
  128840. * @param name defines the name fo the texture
  128841. * @param size defines the size of the texture (default is 256)
  128842. * @param scene defines the hosting scene
  128843. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  128844. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  128845. */
  128846. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128847. private _updateShaderUniforms;
  128848. protected _getDefines(): string;
  128849. /** Generate the current state of the procedural texture */
  128850. render(useCameraPostProcess?: boolean): void;
  128851. /**
  128852. * Serializes this noise procedural texture
  128853. * @returns a serialized noise procedural texture object
  128854. */
  128855. serialize(): any;
  128856. /**
  128857. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  128858. * @param parsedTexture defines parsed texture data
  128859. * @param scene defines the current scene
  128860. * @param rootUrl defines the root URL containing noise procedural texture information
  128861. * @returns a parsed NoiseProceduralTexture
  128862. */
  128863. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  128864. }
  128865. }
  128866. declare module BABYLON {
  128867. /**
  128868. * Raw cube texture where the raw buffers are passed in
  128869. */
  128870. export class RawCubeTexture extends CubeTexture {
  128871. /**
  128872. * Creates a cube texture where the raw buffers are passed in.
  128873. * @param scene defines the scene the texture is attached to
  128874. * @param data defines the array of data to use to create each face
  128875. * @param size defines the size of the textures
  128876. * @param format defines the format of the data
  128877. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  128878. * @param generateMipMaps defines if the engine should generate the mip levels
  128879. * @param invertY defines if data must be stored with Y axis inverted
  128880. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  128881. * @param compression defines the compression used (null by default)
  128882. */
  128883. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  128884. /**
  128885. * Updates the raw cube texture.
  128886. * @param data defines the data to store
  128887. * @param format defines the data format
  128888. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  128889. * @param invertY defines if data must be stored with Y axis inverted
  128890. * @param compression defines the compression used (null by default)
  128891. * @param level defines which level of the texture to update
  128892. */
  128893. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  128894. /**
  128895. * Updates a raw cube texture with RGBD encoded data.
  128896. * @param data defines the array of data [mipmap][face] to use to create each face
  128897. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  128898. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  128899. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  128900. * @returns a promsie that resolves when the operation is complete
  128901. */
  128902. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  128903. /**
  128904. * Clones the raw cube texture.
  128905. * @return a new cube texture
  128906. */
  128907. clone(): CubeTexture;
  128908. /** @hidden */
  128909. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  128910. }
  128911. }
  128912. declare module BABYLON {
  128913. /**
  128914. * Class used to store 3D textures containing user data
  128915. */
  128916. export class RawTexture3D extends Texture {
  128917. /** Gets or sets the texture format to use */
  128918. format: number;
  128919. private _engine;
  128920. /**
  128921. * Create a new RawTexture3D
  128922. * @param data defines the data of the texture
  128923. * @param width defines the width of the texture
  128924. * @param height defines the height of the texture
  128925. * @param depth defines the depth of the texture
  128926. * @param format defines the texture format to use
  128927. * @param scene defines the hosting scene
  128928. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  128929. * @param invertY defines if texture must be stored with Y axis inverted
  128930. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  128931. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  128932. */
  128933. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  128934. /** Gets or sets the texture format to use */
  128935. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  128936. /**
  128937. * Update the texture with new data
  128938. * @param data defines the data to store in the texture
  128939. */
  128940. update(data: ArrayBufferView): void;
  128941. }
  128942. }
  128943. declare module BABYLON {
  128944. /**
  128945. * Class used to store 2D array textures containing user data
  128946. */
  128947. export class RawTexture2DArray extends Texture {
  128948. /** Gets or sets the texture format to use */
  128949. format: number;
  128950. private _engine;
  128951. /**
  128952. * Create a new RawTexture2DArray
  128953. * @param data defines the data of the texture
  128954. * @param width defines the width of the texture
  128955. * @param height defines the height of the texture
  128956. * @param depth defines the number of layers of the texture
  128957. * @param format defines the texture format to use
  128958. * @param scene defines the hosting scene
  128959. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  128960. * @param invertY defines if texture must be stored with Y axis inverted
  128961. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  128962. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  128963. */
  128964. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  128965. /** Gets or sets the texture format to use */
  128966. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  128967. /**
  128968. * Update the texture with new data
  128969. * @param data defines the data to store in the texture
  128970. */
  128971. update(data: ArrayBufferView): void;
  128972. }
  128973. }
  128974. declare module BABYLON {
  128975. /**
  128976. * Creates a refraction texture used by refraction channel of the standard material.
  128977. * It is like a mirror but to see through a material.
  128978. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  128979. */
  128980. export class RefractionTexture extends RenderTargetTexture {
  128981. /**
  128982. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  128983. * 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.
  128984. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  128985. */
  128986. refractionPlane: Plane;
  128987. /**
  128988. * Define how deep under the surface we should see.
  128989. */
  128990. depth: number;
  128991. /**
  128992. * Creates a refraction texture used by refraction channel of the standard material.
  128993. * It is like a mirror but to see through a material.
  128994. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  128995. * @param name Define the texture name
  128996. * @param size Define the size of the underlying texture
  128997. * @param scene Define the scene the refraction belongs to
  128998. * @param generateMipMaps Define if we need to generate mips level for the refraction
  128999. */
  129000. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129001. /**
  129002. * Clone the refraction texture.
  129003. * @returns the cloned texture
  129004. */
  129005. clone(): RefractionTexture;
  129006. /**
  129007. * Serialize the texture to a JSON representation you could use in Parse later on
  129008. * @returns the serialized JSON representation
  129009. */
  129010. serialize(): any;
  129011. }
  129012. }
  129013. declare module BABYLON {
  129014. /**
  129015. * Defines the options related to the creation of an HtmlElementTexture
  129016. */
  129017. export interface IHtmlElementTextureOptions {
  129018. /**
  129019. * Defines wether mip maps should be created or not.
  129020. */
  129021. generateMipMaps?: boolean;
  129022. /**
  129023. * Defines the sampling mode of the texture.
  129024. */
  129025. samplingMode?: number;
  129026. /**
  129027. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129028. */
  129029. engine: Nullable<ThinEngine>;
  129030. /**
  129031. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129032. */
  129033. scene: Nullable<Scene>;
  129034. }
  129035. /**
  129036. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129037. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129038. * is automatically managed.
  129039. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129040. * in your application.
  129041. *
  129042. * As the update is not automatic, you need to call them manually.
  129043. */
  129044. export class HtmlElementTexture extends BaseTexture {
  129045. /**
  129046. * The texture URL.
  129047. */
  129048. element: HTMLVideoElement | HTMLCanvasElement;
  129049. private static readonly DefaultOptions;
  129050. private _textureMatrix;
  129051. private _engine;
  129052. private _isVideo;
  129053. private _generateMipMaps;
  129054. private _samplingMode;
  129055. /**
  129056. * Instantiates a HtmlElementTexture from the following parameters.
  129057. *
  129058. * @param name Defines the name of the texture
  129059. * @param element Defines the video or canvas the texture is filled with
  129060. * @param options Defines the other none mandatory texture creation options
  129061. */
  129062. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129063. private _createInternalTexture;
  129064. /**
  129065. * Returns the texture matrix used in most of the material.
  129066. */
  129067. getTextureMatrix(): Matrix;
  129068. /**
  129069. * Updates the content of the texture.
  129070. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129071. */
  129072. update(invertY?: Nullable<boolean>): void;
  129073. }
  129074. }
  129075. declare module BABYLON {
  129076. /**
  129077. * Enum used to define the target of a block
  129078. */
  129079. export enum NodeMaterialBlockTargets {
  129080. /** Vertex shader */
  129081. Vertex = 1,
  129082. /** Fragment shader */
  129083. Fragment = 2,
  129084. /** Neutral */
  129085. Neutral = 4,
  129086. /** Vertex and Fragment */
  129087. VertexAndFragment = 3
  129088. }
  129089. }
  129090. declare module BABYLON {
  129091. /**
  129092. * Defines the kind of connection point for node based material
  129093. */
  129094. export enum NodeMaterialBlockConnectionPointTypes {
  129095. /** Float */
  129096. Float = 1,
  129097. /** Int */
  129098. Int = 2,
  129099. /** Vector2 */
  129100. Vector2 = 4,
  129101. /** Vector3 */
  129102. Vector3 = 8,
  129103. /** Vector4 */
  129104. Vector4 = 16,
  129105. /** Color3 */
  129106. Color3 = 32,
  129107. /** Color4 */
  129108. Color4 = 64,
  129109. /** Matrix */
  129110. Matrix = 128,
  129111. /** Detect type based on connection */
  129112. AutoDetect = 1024,
  129113. /** Output type that will be defined by input type */
  129114. BasedOnInput = 2048
  129115. }
  129116. }
  129117. declare module BABYLON {
  129118. /**
  129119. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129120. */
  129121. export enum NodeMaterialBlockConnectionPointMode {
  129122. /** Value is an uniform */
  129123. Uniform = 0,
  129124. /** Value is a mesh attribute */
  129125. Attribute = 1,
  129126. /** Value is a varying between vertex and fragment shaders */
  129127. Varying = 2,
  129128. /** Mode is undefined */
  129129. Undefined = 3
  129130. }
  129131. }
  129132. declare module BABYLON {
  129133. /**
  129134. * Enum used to define system values e.g. values automatically provided by the system
  129135. */
  129136. export enum NodeMaterialSystemValues {
  129137. /** World */
  129138. World = 1,
  129139. /** View */
  129140. View = 2,
  129141. /** Projection */
  129142. Projection = 3,
  129143. /** ViewProjection */
  129144. ViewProjection = 4,
  129145. /** WorldView */
  129146. WorldView = 5,
  129147. /** WorldViewProjection */
  129148. WorldViewProjection = 6,
  129149. /** CameraPosition */
  129150. CameraPosition = 7,
  129151. /** Fog Color */
  129152. FogColor = 8,
  129153. /** Delta time */
  129154. DeltaTime = 9
  129155. }
  129156. }
  129157. declare module BABYLON {
  129158. /**
  129159. * Root class for all node material optimizers
  129160. */
  129161. export class NodeMaterialOptimizer {
  129162. /**
  129163. * Function used to optimize a NodeMaterial graph
  129164. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129165. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129166. */
  129167. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129168. }
  129169. }
  129170. declare module BABYLON {
  129171. /**
  129172. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129173. */
  129174. export class TransformBlock extends NodeMaterialBlock {
  129175. /**
  129176. * Defines the value to use to complement W value to transform it to a Vector4
  129177. */
  129178. complementW: number;
  129179. /**
  129180. * Defines the value to use to complement z value to transform it to a Vector4
  129181. */
  129182. complementZ: number;
  129183. /**
  129184. * Creates a new TransformBlock
  129185. * @param name defines the block name
  129186. */
  129187. constructor(name: string);
  129188. /**
  129189. * Gets the current class name
  129190. * @returns the class name
  129191. */
  129192. getClassName(): string;
  129193. /**
  129194. * Gets the vector input
  129195. */
  129196. get vector(): NodeMaterialConnectionPoint;
  129197. /**
  129198. * Gets the output component
  129199. */
  129200. get output(): NodeMaterialConnectionPoint;
  129201. /**
  129202. * Gets the matrix transform input
  129203. */
  129204. get transform(): NodeMaterialConnectionPoint;
  129205. protected _buildBlock(state: NodeMaterialBuildState): this;
  129206. serialize(): any;
  129207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129208. protected _dumpPropertiesCode(): string;
  129209. }
  129210. }
  129211. declare module BABYLON {
  129212. /**
  129213. * Block used to output the vertex position
  129214. */
  129215. export class VertexOutputBlock extends NodeMaterialBlock {
  129216. /**
  129217. * Creates a new VertexOutputBlock
  129218. * @param name defines the block name
  129219. */
  129220. constructor(name: string);
  129221. /**
  129222. * Gets the current class name
  129223. * @returns the class name
  129224. */
  129225. getClassName(): string;
  129226. /**
  129227. * Gets the vector input component
  129228. */
  129229. get vector(): NodeMaterialConnectionPoint;
  129230. protected _buildBlock(state: NodeMaterialBuildState): this;
  129231. }
  129232. }
  129233. declare module BABYLON {
  129234. /**
  129235. * Block used to output the final color
  129236. */
  129237. export class FragmentOutputBlock extends NodeMaterialBlock {
  129238. /**
  129239. * Create a new FragmentOutputBlock
  129240. * @param name defines the block name
  129241. */
  129242. constructor(name: string);
  129243. /**
  129244. * Gets the current class name
  129245. * @returns the class name
  129246. */
  129247. getClassName(): string;
  129248. /**
  129249. * Gets the rgba input component
  129250. */
  129251. get rgba(): NodeMaterialConnectionPoint;
  129252. /**
  129253. * Gets the rgb input component
  129254. */
  129255. get rgb(): NodeMaterialConnectionPoint;
  129256. /**
  129257. * Gets the a input component
  129258. */
  129259. get a(): NodeMaterialConnectionPoint;
  129260. protected _buildBlock(state: NodeMaterialBuildState): this;
  129261. }
  129262. }
  129263. declare module BABYLON {
  129264. /**
  129265. * Block used to read a reflection texture from a sampler
  129266. */
  129267. export class ReflectionTextureBlock extends NodeMaterialBlock {
  129268. private _define3DName;
  129269. private _defineCubicName;
  129270. private _defineExplicitName;
  129271. private _defineProjectionName;
  129272. private _defineLocalCubicName;
  129273. private _defineSphericalName;
  129274. private _definePlanarName;
  129275. private _defineEquirectangularName;
  129276. private _defineMirroredEquirectangularFixedName;
  129277. private _defineEquirectangularFixedName;
  129278. private _defineSkyboxName;
  129279. private _cubeSamplerName;
  129280. private _2DSamplerName;
  129281. private _positionUVWName;
  129282. private _directionWName;
  129283. private _reflectionCoordsName;
  129284. private _reflection2DCoordsName;
  129285. private _reflectionColorName;
  129286. private _reflectionMatrixName;
  129287. /**
  129288. * Gets or sets the texture associated with the node
  129289. */
  129290. texture: Nullable<BaseTexture>;
  129291. /**
  129292. * Create a new TextureBlock
  129293. * @param name defines the block name
  129294. */
  129295. constructor(name: string);
  129296. /**
  129297. * Gets the current class name
  129298. * @returns the class name
  129299. */
  129300. getClassName(): string;
  129301. /**
  129302. * Gets the world position input component
  129303. */
  129304. get position(): NodeMaterialConnectionPoint;
  129305. /**
  129306. * Gets the world position input component
  129307. */
  129308. get worldPosition(): NodeMaterialConnectionPoint;
  129309. /**
  129310. * Gets the world normal input component
  129311. */
  129312. get worldNormal(): NodeMaterialConnectionPoint;
  129313. /**
  129314. * Gets the world input component
  129315. */
  129316. get world(): NodeMaterialConnectionPoint;
  129317. /**
  129318. * Gets the camera (or eye) position component
  129319. */
  129320. get cameraPosition(): NodeMaterialConnectionPoint;
  129321. /**
  129322. * Gets the view input component
  129323. */
  129324. get view(): NodeMaterialConnectionPoint;
  129325. /**
  129326. * Gets the rgb output component
  129327. */
  129328. get rgb(): NodeMaterialConnectionPoint;
  129329. /**
  129330. * Gets the r output component
  129331. */
  129332. get r(): NodeMaterialConnectionPoint;
  129333. /**
  129334. * Gets the g output component
  129335. */
  129336. get g(): NodeMaterialConnectionPoint;
  129337. /**
  129338. * Gets the b output component
  129339. */
  129340. get b(): NodeMaterialConnectionPoint;
  129341. autoConfigure(material: NodeMaterial): void;
  129342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129343. isReady(): boolean;
  129344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129345. private _injectVertexCode;
  129346. private _writeOutput;
  129347. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129348. protected _dumpPropertiesCode(): string;
  129349. serialize(): any;
  129350. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129351. }
  129352. }
  129353. declare module BABYLON {
  129354. /**
  129355. * Interface used to configure the node material editor
  129356. */
  129357. export interface INodeMaterialEditorOptions {
  129358. /** Define the URl to load node editor script */
  129359. editorURL?: string;
  129360. }
  129361. /** @hidden */
  129362. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  129363. NORMAL: boolean;
  129364. TANGENT: boolean;
  129365. UV1: boolean;
  129366. /** BONES */
  129367. NUM_BONE_INFLUENCERS: number;
  129368. BonesPerMesh: number;
  129369. BONETEXTURE: boolean;
  129370. /** MORPH TARGETS */
  129371. MORPHTARGETS: boolean;
  129372. MORPHTARGETS_NORMAL: boolean;
  129373. MORPHTARGETS_TANGENT: boolean;
  129374. MORPHTARGETS_UV: boolean;
  129375. NUM_MORPH_INFLUENCERS: number;
  129376. /** IMAGE PROCESSING */
  129377. IMAGEPROCESSING: boolean;
  129378. VIGNETTE: boolean;
  129379. VIGNETTEBLENDMODEMULTIPLY: boolean;
  129380. VIGNETTEBLENDMODEOPAQUE: boolean;
  129381. TONEMAPPING: boolean;
  129382. TONEMAPPING_ACES: boolean;
  129383. CONTRAST: boolean;
  129384. EXPOSURE: boolean;
  129385. COLORCURVES: boolean;
  129386. COLORGRADING: boolean;
  129387. COLORGRADING3D: boolean;
  129388. SAMPLER3DGREENDEPTH: boolean;
  129389. SAMPLER3DBGRMAP: boolean;
  129390. IMAGEPROCESSINGPOSTPROCESS: boolean;
  129391. /** MISC. */
  129392. BUMPDIRECTUV: number;
  129393. constructor();
  129394. setValue(name: string, value: boolean): void;
  129395. }
  129396. /**
  129397. * Class used to configure NodeMaterial
  129398. */
  129399. export interface INodeMaterialOptions {
  129400. /**
  129401. * Defines if blocks should emit comments
  129402. */
  129403. emitComments: boolean;
  129404. }
  129405. /**
  129406. * Class used to create a node based material built by assembling shader blocks
  129407. */
  129408. export class NodeMaterial extends PushMaterial {
  129409. private static _BuildIdGenerator;
  129410. private _options;
  129411. private _vertexCompilationState;
  129412. private _fragmentCompilationState;
  129413. private _sharedData;
  129414. private _buildId;
  129415. private _buildWasSuccessful;
  129416. private _cachedWorldViewMatrix;
  129417. private _cachedWorldViewProjectionMatrix;
  129418. private _optimizers;
  129419. private _animationFrame;
  129420. /** Define the Url to load node editor script */
  129421. static EditorURL: string;
  129422. /** Define the Url to load snippets */
  129423. static SnippetUrl: string;
  129424. private BJSNODEMATERIALEDITOR;
  129425. /** Get the inspector from bundle or global */
  129426. private _getGlobalNodeMaterialEditor;
  129427. /**
  129428. * Gets or sets data used by visual editor
  129429. * @see https://nme.babylonjs.com
  129430. */
  129431. editorData: any;
  129432. /**
  129433. * 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)
  129434. */
  129435. ignoreAlpha: boolean;
  129436. /**
  129437. * Defines the maximum number of lights that can be used in the material
  129438. */
  129439. maxSimultaneousLights: number;
  129440. /**
  129441. * Observable raised when the material is built
  129442. */
  129443. onBuildObservable: Observable<NodeMaterial>;
  129444. /**
  129445. * Gets or sets the root nodes of the material vertex shader
  129446. */
  129447. _vertexOutputNodes: NodeMaterialBlock[];
  129448. /**
  129449. * Gets or sets the root nodes of the material fragment (pixel) shader
  129450. */
  129451. _fragmentOutputNodes: NodeMaterialBlock[];
  129452. /** Gets or sets options to control the node material overall behavior */
  129453. get options(): INodeMaterialOptions;
  129454. set options(options: INodeMaterialOptions);
  129455. /**
  129456. * Default configuration related to image processing available in the standard Material.
  129457. */
  129458. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129459. /**
  129460. * Gets the image processing configuration used either in this material.
  129461. */
  129462. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  129463. /**
  129464. * Sets the Default image processing configuration used either in the this material.
  129465. *
  129466. * If sets to null, the scene one is in use.
  129467. */
  129468. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  129469. /**
  129470. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  129471. */
  129472. attachedBlocks: NodeMaterialBlock[];
  129473. /**
  129474. * Create a new node based material
  129475. * @param name defines the material name
  129476. * @param scene defines the hosting scene
  129477. * @param options defines creation option
  129478. */
  129479. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  129480. /**
  129481. * Gets the current class name of the material e.g. "NodeMaterial"
  129482. * @returns the class name
  129483. */
  129484. getClassName(): string;
  129485. /**
  129486. * Keep track of the image processing observer to allow dispose and replace.
  129487. */
  129488. private _imageProcessingObserver;
  129489. /**
  129490. * Attaches a new image processing configuration to the Standard Material.
  129491. * @param configuration
  129492. */
  129493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129494. /**
  129495. * Get a block by its name
  129496. * @param name defines the name of the block to retrieve
  129497. * @returns the required block or null if not found
  129498. */
  129499. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  129500. /**
  129501. * Get a block by its name
  129502. * @param predicate defines the predicate used to find the good candidate
  129503. * @returns the required block or null if not found
  129504. */
  129505. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  129506. /**
  129507. * Get an input block by its name
  129508. * @param predicate defines the predicate used to find the good candidate
  129509. * @returns the required input block or null if not found
  129510. */
  129511. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  129512. /**
  129513. * Gets the list of input blocks attached to this material
  129514. * @returns an array of InputBlocks
  129515. */
  129516. getInputBlocks(): InputBlock[];
  129517. /**
  129518. * Adds a new optimizer to the list of optimizers
  129519. * @param optimizer defines the optimizers to add
  129520. * @returns the current material
  129521. */
  129522. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129523. /**
  129524. * Remove an optimizer from the list of optimizers
  129525. * @param optimizer defines the optimizers to remove
  129526. * @returns the current material
  129527. */
  129528. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129529. /**
  129530. * Add a new block to the list of output nodes
  129531. * @param node defines the node to add
  129532. * @returns the current material
  129533. */
  129534. addOutputNode(node: NodeMaterialBlock): this;
  129535. /**
  129536. * Remove a block from the list of root nodes
  129537. * @param node defines the node to remove
  129538. * @returns the current material
  129539. */
  129540. removeOutputNode(node: NodeMaterialBlock): this;
  129541. private _addVertexOutputNode;
  129542. private _removeVertexOutputNode;
  129543. private _addFragmentOutputNode;
  129544. private _removeFragmentOutputNode;
  129545. /**
  129546. * Specifies if the material will require alpha blending
  129547. * @returns a boolean specifying if alpha blending is needed
  129548. */
  129549. needAlphaBlending(): boolean;
  129550. /**
  129551. * Specifies if this material should be rendered in alpha test mode
  129552. * @returns a boolean specifying if an alpha test is needed.
  129553. */
  129554. needAlphaTesting(): boolean;
  129555. private _initializeBlock;
  129556. private _resetDualBlocks;
  129557. /**
  129558. * Remove a block from the current node material
  129559. * @param block defines the block to remove
  129560. */
  129561. removeBlock(block: NodeMaterialBlock): void;
  129562. /**
  129563. * Build the material and generates the inner effect
  129564. * @param verbose defines if the build should log activity
  129565. */
  129566. build(verbose?: boolean): void;
  129567. /**
  129568. * Runs an otpimization phase to try to improve the shader code
  129569. */
  129570. optimize(): void;
  129571. private _prepareDefinesForAttributes;
  129572. /**
  129573. * Get if the submesh is ready to be used and all its information available.
  129574. * Child classes can use it to update shaders
  129575. * @param mesh defines the mesh to check
  129576. * @param subMesh defines which submesh to check
  129577. * @param useInstances specifies that instances should be used
  129578. * @returns a boolean indicating that the submesh is ready or not
  129579. */
  129580. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  129581. /**
  129582. * Get a string representing the shaders built by the current node graph
  129583. */
  129584. get compiledShaders(): string;
  129585. /**
  129586. * Binds the world matrix to the material
  129587. * @param world defines the world transformation matrix
  129588. */
  129589. bindOnlyWorldMatrix(world: Matrix): void;
  129590. /**
  129591. * Binds the submesh to this material by preparing the effect and shader to draw
  129592. * @param world defines the world transformation matrix
  129593. * @param mesh defines the mesh containing the submesh
  129594. * @param subMesh defines the submesh to bind the material to
  129595. */
  129596. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  129597. /**
  129598. * Gets the active textures from the material
  129599. * @returns an array of textures
  129600. */
  129601. getActiveTextures(): BaseTexture[];
  129602. /**
  129603. * Gets the list of texture blocks
  129604. * @returns an array of texture blocks
  129605. */
  129606. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  129607. /**
  129608. * Specifies if the material uses a texture
  129609. * @param texture defines the texture to check against the material
  129610. * @returns a boolean specifying if the material uses the texture
  129611. */
  129612. hasTexture(texture: BaseTexture): boolean;
  129613. /**
  129614. * Disposes the material
  129615. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  129616. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  129617. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  129618. */
  129619. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  129620. /** Creates the node editor window. */
  129621. private _createNodeEditor;
  129622. /**
  129623. * Launch the node material editor
  129624. * @param config Define the configuration of the editor
  129625. * @return a promise fulfilled when the node editor is visible
  129626. */
  129627. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  129628. /**
  129629. * Clear the current material
  129630. */
  129631. clear(): void;
  129632. /**
  129633. * Clear the current material and set it to a default state
  129634. */
  129635. setToDefault(): void;
  129636. /**
  129637. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  129638. * @param url defines the url to load from
  129639. * @returns a promise that will fullfil when the material is fully loaded
  129640. */
  129641. loadAsync(url: string): Promise<void>;
  129642. private _gatherBlocks;
  129643. /**
  129644. * Generate a string containing the code declaration required to create an equivalent of this material
  129645. * @returns a string
  129646. */
  129647. generateCode(): string;
  129648. /**
  129649. * Serializes this material in a JSON representation
  129650. * @returns the serialized material object
  129651. */
  129652. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  129653. private _restoreConnections;
  129654. /**
  129655. * Clear the current graph and load a new one from a serialization object
  129656. * @param source defines the JSON representation of the material
  129657. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129658. */
  129659. loadFromSerialization(source: any, rootUrl?: string): void;
  129660. /**
  129661. * Creates a node material from parsed material data
  129662. * @param source defines the JSON representation of the material
  129663. * @param scene defines the hosting scene
  129664. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129665. * @returns a new node material
  129666. */
  129667. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  129668. /**
  129669. * Creates a node material from a snippet saved by the node material editor
  129670. * @param snippetId defines the snippet to load
  129671. * @param scene defines the hosting scene
  129672. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129673. * @returns a promise that will resolve to the new node material
  129674. */
  129675. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  129676. /**
  129677. * Creates a new node material set to default basic configuration
  129678. * @param name defines the name of the material
  129679. * @param scene defines the hosting scene
  129680. * @returns a new NodeMaterial
  129681. */
  129682. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  129683. }
  129684. }
  129685. declare module BABYLON {
  129686. /**
  129687. * Block used to read a texture from a sampler
  129688. */
  129689. export class TextureBlock extends NodeMaterialBlock {
  129690. private _defineName;
  129691. private _linearDefineName;
  129692. private _tempTextureRead;
  129693. private _samplerName;
  129694. private _transformedUVName;
  129695. private _textureTransformName;
  129696. private _textureInfoName;
  129697. private _mainUVName;
  129698. private _mainUVDefineName;
  129699. /**
  129700. * Gets or sets the texture associated with the node
  129701. */
  129702. texture: Nullable<Texture>;
  129703. /**
  129704. * Create a new TextureBlock
  129705. * @param name defines the block name
  129706. */
  129707. constructor(name: string);
  129708. /**
  129709. * Gets the current class name
  129710. * @returns the class name
  129711. */
  129712. getClassName(): string;
  129713. /**
  129714. * Gets the uv input component
  129715. */
  129716. get uv(): NodeMaterialConnectionPoint;
  129717. /**
  129718. * Gets the rgba output component
  129719. */
  129720. get rgba(): NodeMaterialConnectionPoint;
  129721. /**
  129722. * Gets the rgb output component
  129723. */
  129724. get rgb(): NodeMaterialConnectionPoint;
  129725. /**
  129726. * Gets the r output component
  129727. */
  129728. get r(): NodeMaterialConnectionPoint;
  129729. /**
  129730. * Gets the g output component
  129731. */
  129732. get g(): NodeMaterialConnectionPoint;
  129733. /**
  129734. * Gets the b output component
  129735. */
  129736. get b(): NodeMaterialConnectionPoint;
  129737. /**
  129738. * Gets the a output component
  129739. */
  129740. get a(): NodeMaterialConnectionPoint;
  129741. get target(): NodeMaterialBlockTargets;
  129742. autoConfigure(material: NodeMaterial): void;
  129743. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  129744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129745. isReady(): boolean;
  129746. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129747. private get _isMixed();
  129748. private _injectVertexCode;
  129749. private _writeTextureRead;
  129750. private _writeOutput;
  129751. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129752. protected _dumpPropertiesCode(): string;
  129753. serialize(): any;
  129754. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129755. }
  129756. }
  129757. declare module BABYLON {
  129758. /**
  129759. * Class used to store shared data between 2 NodeMaterialBuildState
  129760. */
  129761. export class NodeMaterialBuildStateSharedData {
  129762. /**
  129763. * Gets the list of emitted varyings
  129764. */
  129765. temps: string[];
  129766. /**
  129767. * Gets the list of emitted varyings
  129768. */
  129769. varyings: string[];
  129770. /**
  129771. * Gets the varying declaration string
  129772. */
  129773. varyingDeclaration: string;
  129774. /**
  129775. * Input blocks
  129776. */
  129777. inputBlocks: InputBlock[];
  129778. /**
  129779. * Input blocks
  129780. */
  129781. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  129782. /**
  129783. * Bindable blocks (Blocks that need to set data to the effect)
  129784. */
  129785. bindableBlocks: NodeMaterialBlock[];
  129786. /**
  129787. * List of blocks that can provide a compilation fallback
  129788. */
  129789. blocksWithFallbacks: NodeMaterialBlock[];
  129790. /**
  129791. * List of blocks that can provide a define update
  129792. */
  129793. blocksWithDefines: NodeMaterialBlock[];
  129794. /**
  129795. * List of blocks that can provide a repeatable content
  129796. */
  129797. repeatableContentBlocks: NodeMaterialBlock[];
  129798. /**
  129799. * List of blocks that can provide a dynamic list of uniforms
  129800. */
  129801. dynamicUniformBlocks: NodeMaterialBlock[];
  129802. /**
  129803. * List of blocks that can block the isReady function for the material
  129804. */
  129805. blockingBlocks: NodeMaterialBlock[];
  129806. /**
  129807. * Gets the list of animated inputs
  129808. */
  129809. animatedInputs: InputBlock[];
  129810. /**
  129811. * Build Id used to avoid multiple recompilations
  129812. */
  129813. buildId: number;
  129814. /** List of emitted variables */
  129815. variableNames: {
  129816. [key: string]: number;
  129817. };
  129818. /** List of emitted defines */
  129819. defineNames: {
  129820. [key: string]: number;
  129821. };
  129822. /** Should emit comments? */
  129823. emitComments: boolean;
  129824. /** Emit build activity */
  129825. verbose: boolean;
  129826. /** Gets or sets the hosting scene */
  129827. scene: Scene;
  129828. /**
  129829. * Gets the compilation hints emitted at compilation time
  129830. */
  129831. hints: {
  129832. needWorldViewMatrix: boolean;
  129833. needWorldViewProjectionMatrix: boolean;
  129834. needAlphaBlending: boolean;
  129835. needAlphaTesting: boolean;
  129836. };
  129837. /**
  129838. * List of compilation checks
  129839. */
  129840. checks: {
  129841. emitVertex: boolean;
  129842. emitFragment: boolean;
  129843. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  129844. };
  129845. /** Creates a new shared data */
  129846. constructor();
  129847. /**
  129848. * Emits console errors and exceptions if there is a failing check
  129849. */
  129850. emitErrors(): void;
  129851. }
  129852. }
  129853. declare module BABYLON {
  129854. /**
  129855. * Class used to store node based material build state
  129856. */
  129857. export class NodeMaterialBuildState {
  129858. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  129859. supportUniformBuffers: boolean;
  129860. /**
  129861. * Gets the list of emitted attributes
  129862. */
  129863. attributes: string[];
  129864. /**
  129865. * Gets the list of emitted uniforms
  129866. */
  129867. uniforms: string[];
  129868. /**
  129869. * Gets the list of emitted constants
  129870. */
  129871. constants: string[];
  129872. /**
  129873. * Gets the list of emitted samplers
  129874. */
  129875. samplers: string[];
  129876. /**
  129877. * Gets the list of emitted functions
  129878. */
  129879. functions: {
  129880. [key: string]: string;
  129881. };
  129882. /**
  129883. * Gets the list of emitted extensions
  129884. */
  129885. extensions: {
  129886. [key: string]: string;
  129887. };
  129888. /**
  129889. * Gets the target of the compilation state
  129890. */
  129891. target: NodeMaterialBlockTargets;
  129892. /**
  129893. * Gets the list of emitted counters
  129894. */
  129895. counters: {
  129896. [key: string]: number;
  129897. };
  129898. /**
  129899. * Shared data between multiple NodeMaterialBuildState instances
  129900. */
  129901. sharedData: NodeMaterialBuildStateSharedData;
  129902. /** @hidden */
  129903. _vertexState: NodeMaterialBuildState;
  129904. /** @hidden */
  129905. _attributeDeclaration: string;
  129906. /** @hidden */
  129907. _uniformDeclaration: string;
  129908. /** @hidden */
  129909. _constantDeclaration: string;
  129910. /** @hidden */
  129911. _samplerDeclaration: string;
  129912. /** @hidden */
  129913. _varyingTransfer: string;
  129914. private _repeatableContentAnchorIndex;
  129915. /** @hidden */
  129916. _builtCompilationString: string;
  129917. /**
  129918. * Gets the emitted compilation strings
  129919. */
  129920. compilationString: string;
  129921. /**
  129922. * Finalize the compilation strings
  129923. * @param state defines the current compilation state
  129924. */
  129925. finalize(state: NodeMaterialBuildState): void;
  129926. /** @hidden */
  129927. get _repeatableContentAnchor(): string;
  129928. /** @hidden */
  129929. _getFreeVariableName(prefix: string): string;
  129930. /** @hidden */
  129931. _getFreeDefineName(prefix: string): string;
  129932. /** @hidden */
  129933. _excludeVariableName(name: string): void;
  129934. /** @hidden */
  129935. _emit2DSampler(name: string): void;
  129936. /** @hidden */
  129937. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  129938. /** @hidden */
  129939. _emitExtension(name: string, extension: string): void;
  129940. /** @hidden */
  129941. _emitFunction(name: string, code: string, comments: string): void;
  129942. /** @hidden */
  129943. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  129944. replaceStrings?: {
  129945. search: RegExp;
  129946. replace: string;
  129947. }[];
  129948. repeatKey?: string;
  129949. }): string;
  129950. /** @hidden */
  129951. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  129952. repeatKey?: string;
  129953. removeAttributes?: boolean;
  129954. removeUniforms?: boolean;
  129955. removeVaryings?: boolean;
  129956. removeIfDef?: boolean;
  129957. replaceStrings?: {
  129958. search: RegExp;
  129959. replace: string;
  129960. }[];
  129961. }, storeKey?: string): void;
  129962. /** @hidden */
  129963. _registerTempVariable(name: string): boolean;
  129964. /** @hidden */
  129965. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  129966. /** @hidden */
  129967. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  129968. /** @hidden */
  129969. _emitFloat(value: number): string;
  129970. }
  129971. }
  129972. declare module BABYLON {
  129973. /**
  129974. * Defines a block that can be used inside a node based material
  129975. */
  129976. export class NodeMaterialBlock {
  129977. private _buildId;
  129978. private _buildTarget;
  129979. private _target;
  129980. private _isFinalMerger;
  129981. private _isInput;
  129982. protected _isUnique: boolean;
  129983. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  129984. inputsAreExclusive: boolean;
  129985. /** @hidden */
  129986. _codeVariableName: string;
  129987. /** @hidden */
  129988. _inputs: NodeMaterialConnectionPoint[];
  129989. /** @hidden */
  129990. _outputs: NodeMaterialConnectionPoint[];
  129991. /** @hidden */
  129992. _preparationId: number;
  129993. /**
  129994. * Gets or sets the name of the block
  129995. */
  129996. name: string;
  129997. /**
  129998. * Gets or sets the unique id of the node
  129999. */
  130000. uniqueId: number;
  130001. /**
  130002. * Gets or sets the comments associated with this block
  130003. */
  130004. comments: string;
  130005. /**
  130006. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130007. */
  130008. get isUnique(): boolean;
  130009. /**
  130010. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130011. */
  130012. get isFinalMerger(): boolean;
  130013. /**
  130014. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130015. */
  130016. get isInput(): boolean;
  130017. /**
  130018. * Gets or sets the build Id
  130019. */
  130020. get buildId(): number;
  130021. set buildId(value: number);
  130022. /**
  130023. * Gets or sets the target of the block
  130024. */
  130025. get target(): NodeMaterialBlockTargets;
  130026. set target(value: NodeMaterialBlockTargets);
  130027. /**
  130028. * Gets the list of input points
  130029. */
  130030. get inputs(): NodeMaterialConnectionPoint[];
  130031. /** Gets the list of output points */
  130032. get outputs(): NodeMaterialConnectionPoint[];
  130033. /**
  130034. * Find an input by its name
  130035. * @param name defines the name of the input to look for
  130036. * @returns the input or null if not found
  130037. */
  130038. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130039. /**
  130040. * Find an output by its name
  130041. * @param name defines the name of the outputto look for
  130042. * @returns the output or null if not found
  130043. */
  130044. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130045. /**
  130046. * Creates a new NodeMaterialBlock
  130047. * @param name defines the block name
  130048. * @param target defines the target of that block (Vertex by default)
  130049. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130050. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130051. */
  130052. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130053. /**
  130054. * Initialize the block and prepare the context for build
  130055. * @param state defines the state that will be used for the build
  130056. */
  130057. initialize(state: NodeMaterialBuildState): void;
  130058. /**
  130059. * Bind data to effect. Will only be called for blocks with isBindable === true
  130060. * @param effect defines the effect to bind data to
  130061. * @param nodeMaterial defines the hosting NodeMaterial
  130062. * @param mesh defines the mesh that will be rendered
  130063. */
  130064. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130065. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130066. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130067. protected _writeFloat(value: number): string;
  130068. /**
  130069. * Gets the current class name e.g. "NodeMaterialBlock"
  130070. * @returns the class name
  130071. */
  130072. getClassName(): string;
  130073. /**
  130074. * Register a new input. Must be called inside a block constructor
  130075. * @param name defines the connection point name
  130076. * @param type defines the connection point type
  130077. * @param isOptional defines a boolean indicating that this input can be omitted
  130078. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130079. * @returns the current block
  130080. */
  130081. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130082. /**
  130083. * Register a new output. Must be called inside a block constructor
  130084. * @param name defines the connection point name
  130085. * @param type defines the connection point type
  130086. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130087. * @returns the current block
  130088. */
  130089. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130090. /**
  130091. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130092. * @param forOutput defines an optional connection point to check compatibility with
  130093. * @returns the first available input or null
  130094. */
  130095. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130096. /**
  130097. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130098. * @param forBlock defines an optional block to check compatibility with
  130099. * @returns the first available input or null
  130100. */
  130101. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130102. /**
  130103. * Gets the sibling of the given output
  130104. * @param current defines the current output
  130105. * @returns the next output in the list or null
  130106. */
  130107. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130108. /**
  130109. * Connect current block with another block
  130110. * @param other defines the block to connect with
  130111. * @param options define the various options to help pick the right connections
  130112. * @returns the current block
  130113. */
  130114. connectTo(other: NodeMaterialBlock, options?: {
  130115. input?: string;
  130116. output?: string;
  130117. outputSwizzle?: string;
  130118. }): this | undefined;
  130119. protected _buildBlock(state: NodeMaterialBuildState): void;
  130120. /**
  130121. * Add uniforms, samplers and uniform buffers at compilation time
  130122. * @param state defines the state to update
  130123. * @param nodeMaterial defines the node material requesting the update
  130124. * @param defines defines the material defines to update
  130125. * @param uniformBuffers defines the list of uniform buffer names
  130126. */
  130127. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130128. /**
  130129. * Add potential fallbacks if shader compilation fails
  130130. * @param mesh defines the mesh to be rendered
  130131. * @param fallbacks defines the current prioritized list of fallbacks
  130132. */
  130133. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130134. /**
  130135. * Initialize defines for shader compilation
  130136. * @param mesh defines the mesh to be rendered
  130137. * @param nodeMaterial defines the node material requesting the update
  130138. * @param defines defines the material defines to update
  130139. * @param useInstances specifies that instances should be used
  130140. */
  130141. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130142. /**
  130143. * Update defines for shader compilation
  130144. * @param mesh defines the mesh to be rendered
  130145. * @param nodeMaterial defines the node material requesting the update
  130146. * @param defines defines the material defines to update
  130147. * @param useInstances specifies that instances should be used
  130148. */
  130149. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130150. /**
  130151. * Lets the block try to connect some inputs automatically
  130152. * @param material defines the hosting NodeMaterial
  130153. */
  130154. autoConfigure(material: NodeMaterial): void;
  130155. /**
  130156. * Function called when a block is declared as repeatable content generator
  130157. * @param vertexShaderState defines the current compilation state for the vertex shader
  130158. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130159. * @param mesh defines the mesh to be rendered
  130160. * @param defines defines the material defines to update
  130161. */
  130162. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130163. /**
  130164. * Checks if the block is ready
  130165. * @param mesh defines the mesh to be rendered
  130166. * @param nodeMaterial defines the node material requesting the update
  130167. * @param defines defines the material defines to update
  130168. * @param useInstances specifies that instances should be used
  130169. * @returns true if the block is ready
  130170. */
  130171. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130172. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  130173. private _processBuild;
  130174. /**
  130175. * Compile the current node and generate the shader code
  130176. * @param state defines the current compilation state (uniforms, samplers, current string)
  130177. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  130178. * @returns true if already built
  130179. */
  130180. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  130181. protected _inputRename(name: string): string;
  130182. protected _outputRename(name: string): string;
  130183. protected _dumpPropertiesCode(): string;
  130184. /** @hidden */
  130185. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  130186. /** @hidden */
  130187. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  130188. /**
  130189. * Clone the current block to a new identical block
  130190. * @param scene defines the hosting scene
  130191. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130192. * @returns a copy of the current block
  130193. */
  130194. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  130195. /**
  130196. * Serializes this block in a JSON representation
  130197. * @returns the serialized block object
  130198. */
  130199. serialize(): any;
  130200. /** @hidden */
  130201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130202. /**
  130203. * Release resources
  130204. */
  130205. dispose(): void;
  130206. }
  130207. }
  130208. declare module BABYLON {
  130209. /**
  130210. * Enum defining the type of animations supported by InputBlock
  130211. */
  130212. export enum AnimatedInputBlockTypes {
  130213. /** No animation */
  130214. None = 0,
  130215. /** Time based animation. Will only work for floats */
  130216. Time = 1
  130217. }
  130218. }
  130219. declare module BABYLON {
  130220. /**
  130221. * Block used to expose an input value
  130222. */
  130223. export class InputBlock extends NodeMaterialBlock {
  130224. private _mode;
  130225. private _associatedVariableName;
  130226. private _storedValue;
  130227. private _valueCallback;
  130228. private _type;
  130229. private _animationType;
  130230. /** Gets or set a value used to limit the range of float values */
  130231. min: number;
  130232. /** Gets or set a value used to limit the range of float values */
  130233. max: number;
  130234. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  130235. isBoolean: boolean;
  130236. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  130237. matrixMode: number;
  130238. /** @hidden */
  130239. _systemValue: Nullable<NodeMaterialSystemValues>;
  130240. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  130241. visibleInInspector: boolean;
  130242. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  130243. isConstant: boolean;
  130244. /** Gets or sets the group to use to display this block in the Inspector */
  130245. groupInInspector: string;
  130246. /**
  130247. * Gets or sets the connection point type (default is float)
  130248. */
  130249. get type(): NodeMaterialBlockConnectionPointTypes;
  130250. /**
  130251. * Creates a new InputBlock
  130252. * @param name defines the block name
  130253. * @param target defines the target of that block (Vertex by default)
  130254. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  130255. */
  130256. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  130257. /**
  130258. * Gets the output component
  130259. */
  130260. get output(): NodeMaterialConnectionPoint;
  130261. /**
  130262. * Set the source of this connection point to a vertex attribute
  130263. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  130264. * @returns the current connection point
  130265. */
  130266. setAsAttribute(attributeName?: string): InputBlock;
  130267. /**
  130268. * Set the source of this connection point to a system value
  130269. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  130270. * @returns the current connection point
  130271. */
  130272. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  130273. /**
  130274. * Gets or sets the value of that point.
  130275. * Please note that this value will be ignored if valueCallback is defined
  130276. */
  130277. get value(): any;
  130278. set value(value: any);
  130279. /**
  130280. * Gets or sets a callback used to get the value of that point.
  130281. * Please note that setting this value will force the connection point to ignore the value property
  130282. */
  130283. get valueCallback(): () => any;
  130284. set valueCallback(value: () => any);
  130285. /**
  130286. * Gets or sets the associated variable name in the shader
  130287. */
  130288. get associatedVariableName(): string;
  130289. set associatedVariableName(value: string);
  130290. /** Gets or sets the type of animation applied to the input */
  130291. get animationType(): AnimatedInputBlockTypes;
  130292. set animationType(value: AnimatedInputBlockTypes);
  130293. /**
  130294. * Gets a boolean indicating that this connection point not defined yet
  130295. */
  130296. get isUndefined(): boolean;
  130297. /**
  130298. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  130299. * In this case the connection point name must be the name of the uniform to use.
  130300. * Can only be set on inputs
  130301. */
  130302. get isUniform(): boolean;
  130303. set isUniform(value: boolean);
  130304. /**
  130305. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  130306. * In this case the connection point name must be the name of the attribute to use
  130307. * Can only be set on inputs
  130308. */
  130309. get isAttribute(): boolean;
  130310. set isAttribute(value: boolean);
  130311. /**
  130312. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  130313. * Can only be set on exit points
  130314. */
  130315. get isVarying(): boolean;
  130316. set isVarying(value: boolean);
  130317. /**
  130318. * Gets a boolean indicating that the current connection point is a system value
  130319. */
  130320. get isSystemValue(): boolean;
  130321. /**
  130322. * Gets or sets the current well known value or null if not defined as a system value
  130323. */
  130324. get systemValue(): Nullable<NodeMaterialSystemValues>;
  130325. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  130326. /**
  130327. * Gets the current class name
  130328. * @returns the class name
  130329. */
  130330. getClassName(): string;
  130331. /**
  130332. * Animate the input if animationType !== None
  130333. * @param scene defines the rendering scene
  130334. */
  130335. animate(scene: Scene): void;
  130336. private _emitDefine;
  130337. initialize(state: NodeMaterialBuildState): void;
  130338. /**
  130339. * Set the input block to its default value (based on its type)
  130340. */
  130341. setDefaultValue(): void;
  130342. private _emitConstant;
  130343. private _emit;
  130344. /** @hidden */
  130345. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  130346. /** @hidden */
  130347. _transmit(effect: Effect, scene: Scene): void;
  130348. protected _buildBlock(state: NodeMaterialBuildState): void;
  130349. protected _dumpPropertiesCode(): string;
  130350. serialize(): any;
  130351. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130352. }
  130353. }
  130354. declare module BABYLON {
  130355. /**
  130356. * Enum used to define the compatibility state between two connection points
  130357. */
  130358. export enum NodeMaterialConnectionPointCompatibilityStates {
  130359. /** Points are compatibles */
  130360. Compatible = 0,
  130361. /** Points are incompatible because of their types */
  130362. TypeIncompatible = 1,
  130363. /** Points are incompatible because of their targets (vertex vs fragment) */
  130364. TargetIncompatible = 2
  130365. }
  130366. /**
  130367. * Defines the direction of a connection point
  130368. */
  130369. export enum NodeMaterialConnectionPointDirection {
  130370. /** Input */
  130371. Input = 0,
  130372. /** Output */
  130373. Output = 1
  130374. }
  130375. /**
  130376. * Defines a connection point for a block
  130377. */
  130378. export class NodeMaterialConnectionPoint {
  130379. /** @hidden */
  130380. _ownerBlock: NodeMaterialBlock;
  130381. /** @hidden */
  130382. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  130383. private _endpoints;
  130384. private _associatedVariableName;
  130385. private _direction;
  130386. /** @hidden */
  130387. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130388. /** @hidden */
  130389. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130390. private _type;
  130391. /** @hidden */
  130392. _enforceAssociatedVariableName: boolean;
  130393. /** Gets the direction of the point */
  130394. get direction(): NodeMaterialConnectionPointDirection;
  130395. /**
  130396. * Gets or sets the additional types supported by this connection point
  130397. */
  130398. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130399. /**
  130400. * Gets or sets the additional types excluded by this connection point
  130401. */
  130402. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130403. /**
  130404. * Observable triggered when this point is connected
  130405. */
  130406. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  130407. /**
  130408. * Gets or sets the associated variable name in the shader
  130409. */
  130410. get associatedVariableName(): string;
  130411. set associatedVariableName(value: string);
  130412. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  130413. get innerType(): NodeMaterialBlockConnectionPointTypes;
  130414. /**
  130415. * Gets or sets the connection point type (default is float)
  130416. */
  130417. get type(): NodeMaterialBlockConnectionPointTypes;
  130418. set type(value: NodeMaterialBlockConnectionPointTypes);
  130419. /**
  130420. * Gets or sets the connection point name
  130421. */
  130422. name: string;
  130423. /**
  130424. * Gets or sets a boolean indicating that this connection point can be omitted
  130425. */
  130426. isOptional: boolean;
  130427. /**
  130428. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  130429. */
  130430. define: string;
  130431. /** @hidden */
  130432. _prioritizeVertex: boolean;
  130433. private _target;
  130434. /** Gets or sets the target of that connection point */
  130435. get target(): NodeMaterialBlockTargets;
  130436. set target(value: NodeMaterialBlockTargets);
  130437. /**
  130438. * Gets a boolean indicating that the current point is connected
  130439. */
  130440. get isConnected(): boolean;
  130441. /**
  130442. * Gets a boolean indicating that the current point is connected to an input block
  130443. */
  130444. get isConnectedToInputBlock(): boolean;
  130445. /**
  130446. * Gets a the connected input block (if any)
  130447. */
  130448. get connectInputBlock(): Nullable<InputBlock>;
  130449. /** Get the other side of the connection (if any) */
  130450. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  130451. /** Get the block that owns this connection point */
  130452. get ownerBlock(): NodeMaterialBlock;
  130453. /** Get the block connected on the other side of this connection (if any) */
  130454. get sourceBlock(): Nullable<NodeMaterialBlock>;
  130455. /** Get the block connected on the endpoints of this connection (if any) */
  130456. get connectedBlocks(): Array<NodeMaterialBlock>;
  130457. /** Gets the list of connected endpoints */
  130458. get endpoints(): NodeMaterialConnectionPoint[];
  130459. /** Gets a boolean indicating if that output point is connected to at least one input */
  130460. get hasEndpoints(): boolean;
  130461. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  130462. get isConnectedInVertexShader(): boolean;
  130463. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  130464. get isConnectedInFragmentShader(): boolean;
  130465. /**
  130466. * Creates a new connection point
  130467. * @param name defines the connection point name
  130468. * @param ownerBlock defines the block hosting this connection point
  130469. * @param direction defines the direction of the connection point
  130470. */
  130471. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  130472. /**
  130473. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  130474. * @returns the class name
  130475. */
  130476. getClassName(): string;
  130477. /**
  130478. * Gets a boolean indicating if the current point can be connected to another point
  130479. * @param connectionPoint defines the other connection point
  130480. * @returns a boolean
  130481. */
  130482. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  130483. /**
  130484. * Gets a number indicating if the current point can be connected to another point
  130485. * @param connectionPoint defines the other connection point
  130486. * @returns a number defining the compatibility state
  130487. */
  130488. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  130489. /**
  130490. * Connect this point to another connection point
  130491. * @param connectionPoint defines the other connection point
  130492. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  130493. * @returns the current connection point
  130494. */
  130495. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  130496. /**
  130497. * Disconnect this point from one of his endpoint
  130498. * @param endpoint defines the other connection point
  130499. * @returns the current connection point
  130500. */
  130501. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  130502. /**
  130503. * Serializes this point in a JSON representation
  130504. * @returns the serialized point object
  130505. */
  130506. serialize(): any;
  130507. /**
  130508. * Release resources
  130509. */
  130510. dispose(): void;
  130511. }
  130512. }
  130513. declare module BABYLON {
  130514. /**
  130515. * Block used to add support for vertex skinning (bones)
  130516. */
  130517. export class BonesBlock extends NodeMaterialBlock {
  130518. /**
  130519. * Creates a new BonesBlock
  130520. * @param name defines the block name
  130521. */
  130522. constructor(name: string);
  130523. /**
  130524. * Initialize the block and prepare the context for build
  130525. * @param state defines the state that will be used for the build
  130526. */
  130527. initialize(state: NodeMaterialBuildState): void;
  130528. /**
  130529. * Gets the current class name
  130530. * @returns the class name
  130531. */
  130532. getClassName(): string;
  130533. /**
  130534. * Gets the matrix indices input component
  130535. */
  130536. get matricesIndices(): NodeMaterialConnectionPoint;
  130537. /**
  130538. * Gets the matrix weights input component
  130539. */
  130540. get matricesWeights(): NodeMaterialConnectionPoint;
  130541. /**
  130542. * Gets the extra matrix indices input component
  130543. */
  130544. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  130545. /**
  130546. * Gets the extra matrix weights input component
  130547. */
  130548. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  130549. /**
  130550. * Gets the world input component
  130551. */
  130552. get world(): NodeMaterialConnectionPoint;
  130553. /**
  130554. * Gets the output component
  130555. */
  130556. get output(): NodeMaterialConnectionPoint;
  130557. autoConfigure(material: NodeMaterial): void;
  130558. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130561. protected _buildBlock(state: NodeMaterialBuildState): this;
  130562. }
  130563. }
  130564. declare module BABYLON {
  130565. /**
  130566. * Block used to add support for instances
  130567. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  130568. */
  130569. export class InstancesBlock extends NodeMaterialBlock {
  130570. /**
  130571. * Creates a new InstancesBlock
  130572. * @param name defines the block name
  130573. */
  130574. constructor(name: string);
  130575. /**
  130576. * Gets the current class name
  130577. * @returns the class name
  130578. */
  130579. getClassName(): string;
  130580. /**
  130581. * Gets the first world row input component
  130582. */
  130583. get world0(): NodeMaterialConnectionPoint;
  130584. /**
  130585. * Gets the second world row input component
  130586. */
  130587. get world1(): NodeMaterialConnectionPoint;
  130588. /**
  130589. * Gets the third world row input component
  130590. */
  130591. get world2(): NodeMaterialConnectionPoint;
  130592. /**
  130593. * Gets the forth world row input component
  130594. */
  130595. get world3(): NodeMaterialConnectionPoint;
  130596. /**
  130597. * Gets the world input component
  130598. */
  130599. get world(): NodeMaterialConnectionPoint;
  130600. /**
  130601. * Gets the output component
  130602. */
  130603. get output(): NodeMaterialConnectionPoint;
  130604. autoConfigure(material: NodeMaterial): void;
  130605. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130606. protected _buildBlock(state: NodeMaterialBuildState): this;
  130607. }
  130608. }
  130609. declare module BABYLON {
  130610. /**
  130611. * Block used to add morph targets support to vertex shader
  130612. */
  130613. export class MorphTargetsBlock extends NodeMaterialBlock {
  130614. private _repeatableContentAnchor;
  130615. /**
  130616. * Create a new MorphTargetsBlock
  130617. * @param name defines the block name
  130618. */
  130619. constructor(name: string);
  130620. /**
  130621. * Gets the current class name
  130622. * @returns the class name
  130623. */
  130624. getClassName(): string;
  130625. /**
  130626. * Gets the position input component
  130627. */
  130628. get position(): NodeMaterialConnectionPoint;
  130629. /**
  130630. * Gets the normal input component
  130631. */
  130632. get normal(): NodeMaterialConnectionPoint;
  130633. /**
  130634. * Gets the tangent input component
  130635. */
  130636. get tangent(): NodeMaterialConnectionPoint;
  130637. /**
  130638. * Gets the tangent input component
  130639. */
  130640. get uv(): NodeMaterialConnectionPoint;
  130641. /**
  130642. * Gets the position output component
  130643. */
  130644. get positionOutput(): NodeMaterialConnectionPoint;
  130645. /**
  130646. * Gets the normal output component
  130647. */
  130648. get normalOutput(): NodeMaterialConnectionPoint;
  130649. /**
  130650. * Gets the tangent output component
  130651. */
  130652. get tangentOutput(): NodeMaterialConnectionPoint;
  130653. /**
  130654. * Gets the tangent output component
  130655. */
  130656. get uvOutput(): NodeMaterialConnectionPoint;
  130657. initialize(state: NodeMaterialBuildState): void;
  130658. autoConfigure(material: NodeMaterial): void;
  130659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130660. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130661. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130662. protected _buildBlock(state: NodeMaterialBuildState): this;
  130663. }
  130664. }
  130665. declare module BABYLON {
  130666. /**
  130667. * Block used to get data information from a light
  130668. */
  130669. export class LightInformationBlock extends NodeMaterialBlock {
  130670. private _lightDataUniformName;
  130671. private _lightColorUniformName;
  130672. private _lightTypeDefineName;
  130673. /**
  130674. * Gets or sets the light associated with this block
  130675. */
  130676. light: Nullable<Light>;
  130677. /**
  130678. * Creates a new LightInformationBlock
  130679. * @param name defines the block name
  130680. */
  130681. constructor(name: string);
  130682. /**
  130683. * Gets the current class name
  130684. * @returns the class name
  130685. */
  130686. getClassName(): string;
  130687. /**
  130688. * Gets the world position input component
  130689. */
  130690. get worldPosition(): NodeMaterialConnectionPoint;
  130691. /**
  130692. * Gets the direction output component
  130693. */
  130694. get direction(): NodeMaterialConnectionPoint;
  130695. /**
  130696. * Gets the direction output component
  130697. */
  130698. get color(): NodeMaterialConnectionPoint;
  130699. /**
  130700. * Gets the direction output component
  130701. */
  130702. get intensity(): NodeMaterialConnectionPoint;
  130703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130705. protected _buildBlock(state: NodeMaterialBuildState): this;
  130706. serialize(): any;
  130707. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130708. }
  130709. }
  130710. declare module BABYLON {
  130711. /**
  130712. * Block used to add image processing support to fragment shader
  130713. */
  130714. export class ImageProcessingBlock extends NodeMaterialBlock {
  130715. /**
  130716. * Create a new ImageProcessingBlock
  130717. * @param name defines the block name
  130718. */
  130719. constructor(name: string);
  130720. /**
  130721. * Gets the current class name
  130722. * @returns the class name
  130723. */
  130724. getClassName(): string;
  130725. /**
  130726. * Gets the color input component
  130727. */
  130728. get color(): NodeMaterialConnectionPoint;
  130729. /**
  130730. * Gets the output component
  130731. */
  130732. get output(): NodeMaterialConnectionPoint;
  130733. /**
  130734. * Initialize the block and prepare the context for build
  130735. * @param state defines the state that will be used for the build
  130736. */
  130737. initialize(state: NodeMaterialBuildState): void;
  130738. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  130739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130740. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130741. protected _buildBlock(state: NodeMaterialBuildState): this;
  130742. }
  130743. }
  130744. declare module BABYLON {
  130745. /**
  130746. * Block used to pertub normals based on a normal map
  130747. */
  130748. export class PerturbNormalBlock extends NodeMaterialBlock {
  130749. private _tangentSpaceParameterName;
  130750. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  130751. invertX: boolean;
  130752. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  130753. invertY: boolean;
  130754. /**
  130755. * Create a new PerturbNormalBlock
  130756. * @param name defines the block name
  130757. */
  130758. constructor(name: string);
  130759. /**
  130760. * Gets the current class name
  130761. * @returns the class name
  130762. */
  130763. getClassName(): string;
  130764. /**
  130765. * Gets the world position input component
  130766. */
  130767. get worldPosition(): NodeMaterialConnectionPoint;
  130768. /**
  130769. * Gets the world normal input component
  130770. */
  130771. get worldNormal(): NodeMaterialConnectionPoint;
  130772. /**
  130773. * Gets the uv input component
  130774. */
  130775. get uv(): NodeMaterialConnectionPoint;
  130776. /**
  130777. * Gets the normal map color input component
  130778. */
  130779. get normalMapColor(): NodeMaterialConnectionPoint;
  130780. /**
  130781. * Gets the strength input component
  130782. */
  130783. get strength(): NodeMaterialConnectionPoint;
  130784. /**
  130785. * Gets the output component
  130786. */
  130787. get output(): NodeMaterialConnectionPoint;
  130788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130789. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130790. autoConfigure(material: NodeMaterial): void;
  130791. protected _buildBlock(state: NodeMaterialBuildState): this;
  130792. protected _dumpPropertiesCode(): string;
  130793. serialize(): any;
  130794. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130795. }
  130796. }
  130797. declare module BABYLON {
  130798. /**
  130799. * Block used to discard a pixel if a value is smaller than a cutoff
  130800. */
  130801. export class DiscardBlock extends NodeMaterialBlock {
  130802. /**
  130803. * Create a new DiscardBlock
  130804. * @param name defines the block name
  130805. */
  130806. constructor(name: string);
  130807. /**
  130808. * Gets the current class name
  130809. * @returns the class name
  130810. */
  130811. getClassName(): string;
  130812. /**
  130813. * Gets the color input component
  130814. */
  130815. get value(): NodeMaterialConnectionPoint;
  130816. /**
  130817. * Gets the cutoff input component
  130818. */
  130819. get cutoff(): NodeMaterialConnectionPoint;
  130820. protected _buildBlock(state: NodeMaterialBuildState): this;
  130821. }
  130822. }
  130823. declare module BABYLON {
  130824. /**
  130825. * Block used to test if the fragment shader is front facing
  130826. */
  130827. export class FrontFacingBlock extends NodeMaterialBlock {
  130828. /**
  130829. * Creates a new FrontFacingBlock
  130830. * @param name defines the block name
  130831. */
  130832. constructor(name: string);
  130833. /**
  130834. * Gets the current class name
  130835. * @returns the class name
  130836. */
  130837. getClassName(): string;
  130838. /**
  130839. * Gets the output component
  130840. */
  130841. get output(): NodeMaterialConnectionPoint;
  130842. protected _buildBlock(state: NodeMaterialBuildState): this;
  130843. }
  130844. }
  130845. declare module BABYLON {
  130846. /**
  130847. * Block used to get the derivative value on x and y of a given input
  130848. */
  130849. export class DerivativeBlock extends NodeMaterialBlock {
  130850. /**
  130851. * Create a new DerivativeBlock
  130852. * @param name defines the block name
  130853. */
  130854. constructor(name: string);
  130855. /**
  130856. * Gets the current class name
  130857. * @returns the class name
  130858. */
  130859. getClassName(): string;
  130860. /**
  130861. * Gets the input component
  130862. */
  130863. get input(): NodeMaterialConnectionPoint;
  130864. /**
  130865. * Gets the derivative output on x
  130866. */
  130867. get dx(): NodeMaterialConnectionPoint;
  130868. /**
  130869. * Gets the derivative output on y
  130870. */
  130871. get dy(): NodeMaterialConnectionPoint;
  130872. protected _buildBlock(state: NodeMaterialBuildState): this;
  130873. }
  130874. }
  130875. declare module BABYLON {
  130876. /**
  130877. * Block used to add support for scene fog
  130878. */
  130879. export class FogBlock extends NodeMaterialBlock {
  130880. private _fogDistanceName;
  130881. private _fogParameters;
  130882. /**
  130883. * Create a new FogBlock
  130884. * @param name defines the block name
  130885. */
  130886. constructor(name: string);
  130887. /**
  130888. * Gets the current class name
  130889. * @returns the class name
  130890. */
  130891. getClassName(): string;
  130892. /**
  130893. * Gets the world position input component
  130894. */
  130895. get worldPosition(): NodeMaterialConnectionPoint;
  130896. /**
  130897. * Gets the view input component
  130898. */
  130899. get view(): NodeMaterialConnectionPoint;
  130900. /**
  130901. * Gets the color input component
  130902. */
  130903. get input(): NodeMaterialConnectionPoint;
  130904. /**
  130905. * Gets the fog color input component
  130906. */
  130907. get fogColor(): NodeMaterialConnectionPoint;
  130908. /**
  130909. * Gets the output component
  130910. */
  130911. get output(): NodeMaterialConnectionPoint;
  130912. autoConfigure(material: NodeMaterial): void;
  130913. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130914. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130915. protected _buildBlock(state: NodeMaterialBuildState): this;
  130916. }
  130917. }
  130918. declare module BABYLON {
  130919. /**
  130920. * Block used to add light in the fragment shader
  130921. */
  130922. export class LightBlock extends NodeMaterialBlock {
  130923. private _lightId;
  130924. /**
  130925. * Gets or sets the light associated with this block
  130926. */
  130927. light: Nullable<Light>;
  130928. /**
  130929. * Create a new LightBlock
  130930. * @param name defines the block name
  130931. */
  130932. constructor(name: string);
  130933. /**
  130934. * Gets the current class name
  130935. * @returns the class name
  130936. */
  130937. getClassName(): string;
  130938. /**
  130939. * Gets the world position input component
  130940. */
  130941. get worldPosition(): NodeMaterialConnectionPoint;
  130942. /**
  130943. * Gets the world normal input component
  130944. */
  130945. get worldNormal(): NodeMaterialConnectionPoint;
  130946. /**
  130947. * Gets the camera (or eye) position component
  130948. */
  130949. get cameraPosition(): NodeMaterialConnectionPoint;
  130950. /**
  130951. * Gets the glossiness component
  130952. */
  130953. get glossiness(): NodeMaterialConnectionPoint;
  130954. /**
  130955. * Gets the glossinness power component
  130956. */
  130957. get glossPower(): NodeMaterialConnectionPoint;
  130958. /**
  130959. * Gets the diffuse color component
  130960. */
  130961. get diffuseColor(): NodeMaterialConnectionPoint;
  130962. /**
  130963. * Gets the specular color component
  130964. */
  130965. get specularColor(): NodeMaterialConnectionPoint;
  130966. /**
  130967. * Gets the diffuse output component
  130968. */
  130969. get diffuseOutput(): NodeMaterialConnectionPoint;
  130970. /**
  130971. * Gets the specular output component
  130972. */
  130973. get specularOutput(): NodeMaterialConnectionPoint;
  130974. /**
  130975. * Gets the shadow output component
  130976. */
  130977. get shadow(): NodeMaterialConnectionPoint;
  130978. autoConfigure(material: NodeMaterial): void;
  130979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130980. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130981. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130982. private _injectVertexCode;
  130983. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130984. serialize(): any;
  130985. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130986. }
  130987. }
  130988. declare module BABYLON {
  130989. /**
  130990. * Block used to multiply 2 values
  130991. */
  130992. export class MultiplyBlock extends NodeMaterialBlock {
  130993. /**
  130994. * Creates a new MultiplyBlock
  130995. * @param name defines the block name
  130996. */
  130997. constructor(name: string);
  130998. /**
  130999. * Gets the current class name
  131000. * @returns the class name
  131001. */
  131002. getClassName(): string;
  131003. /**
  131004. * Gets the left operand input component
  131005. */
  131006. get left(): NodeMaterialConnectionPoint;
  131007. /**
  131008. * Gets the right operand input component
  131009. */
  131010. get right(): NodeMaterialConnectionPoint;
  131011. /**
  131012. * Gets the output component
  131013. */
  131014. get output(): NodeMaterialConnectionPoint;
  131015. protected _buildBlock(state: NodeMaterialBuildState): this;
  131016. }
  131017. }
  131018. declare module BABYLON {
  131019. /**
  131020. * Block used to add 2 vectors
  131021. */
  131022. export class AddBlock extends NodeMaterialBlock {
  131023. /**
  131024. * Creates a new AddBlock
  131025. * @param name defines the block name
  131026. */
  131027. constructor(name: string);
  131028. /**
  131029. * Gets the current class name
  131030. * @returns the class name
  131031. */
  131032. getClassName(): string;
  131033. /**
  131034. * Gets the left operand input component
  131035. */
  131036. get left(): NodeMaterialConnectionPoint;
  131037. /**
  131038. * Gets the right operand input component
  131039. */
  131040. get right(): NodeMaterialConnectionPoint;
  131041. /**
  131042. * Gets the output component
  131043. */
  131044. get output(): NodeMaterialConnectionPoint;
  131045. protected _buildBlock(state: NodeMaterialBuildState): this;
  131046. }
  131047. }
  131048. declare module BABYLON {
  131049. /**
  131050. * Block used to scale a vector by a float
  131051. */
  131052. export class ScaleBlock extends NodeMaterialBlock {
  131053. /**
  131054. * Creates a new ScaleBlock
  131055. * @param name defines the block name
  131056. */
  131057. constructor(name: string);
  131058. /**
  131059. * Gets the current class name
  131060. * @returns the class name
  131061. */
  131062. getClassName(): string;
  131063. /**
  131064. * Gets the input component
  131065. */
  131066. get input(): NodeMaterialConnectionPoint;
  131067. /**
  131068. * Gets the factor input component
  131069. */
  131070. get factor(): NodeMaterialConnectionPoint;
  131071. /**
  131072. * Gets the output component
  131073. */
  131074. get output(): NodeMaterialConnectionPoint;
  131075. protected _buildBlock(state: NodeMaterialBuildState): this;
  131076. }
  131077. }
  131078. declare module BABYLON {
  131079. /**
  131080. * Block used to clamp a float
  131081. */
  131082. export class ClampBlock extends NodeMaterialBlock {
  131083. /** Gets or sets the minimum range */
  131084. minimum: number;
  131085. /** Gets or sets the maximum range */
  131086. maximum: number;
  131087. /**
  131088. * Creates a new ClampBlock
  131089. * @param name defines the block name
  131090. */
  131091. constructor(name: string);
  131092. /**
  131093. * Gets the current class name
  131094. * @returns the class name
  131095. */
  131096. getClassName(): string;
  131097. /**
  131098. * Gets the value input component
  131099. */
  131100. get value(): NodeMaterialConnectionPoint;
  131101. /**
  131102. * Gets the output component
  131103. */
  131104. get output(): NodeMaterialConnectionPoint;
  131105. protected _buildBlock(state: NodeMaterialBuildState): this;
  131106. protected _dumpPropertiesCode(): string;
  131107. serialize(): any;
  131108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131109. }
  131110. }
  131111. declare module BABYLON {
  131112. /**
  131113. * Block used to apply a cross product between 2 vectors
  131114. */
  131115. export class CrossBlock extends NodeMaterialBlock {
  131116. /**
  131117. * Creates a new CrossBlock
  131118. * @param name defines the block name
  131119. */
  131120. constructor(name: string);
  131121. /**
  131122. * Gets the current class name
  131123. * @returns the class name
  131124. */
  131125. getClassName(): string;
  131126. /**
  131127. * Gets the left operand input component
  131128. */
  131129. get left(): NodeMaterialConnectionPoint;
  131130. /**
  131131. * Gets the right operand input component
  131132. */
  131133. get right(): NodeMaterialConnectionPoint;
  131134. /**
  131135. * Gets the output component
  131136. */
  131137. get output(): NodeMaterialConnectionPoint;
  131138. protected _buildBlock(state: NodeMaterialBuildState): this;
  131139. }
  131140. }
  131141. declare module BABYLON {
  131142. /**
  131143. * Block used to apply a dot product between 2 vectors
  131144. */
  131145. export class DotBlock extends NodeMaterialBlock {
  131146. /**
  131147. * Creates a new DotBlock
  131148. * @param name defines the block name
  131149. */
  131150. constructor(name: string);
  131151. /**
  131152. * Gets the current class name
  131153. * @returns the class name
  131154. */
  131155. getClassName(): string;
  131156. /**
  131157. * Gets the left operand input component
  131158. */
  131159. get left(): NodeMaterialConnectionPoint;
  131160. /**
  131161. * Gets the right operand input component
  131162. */
  131163. get right(): NodeMaterialConnectionPoint;
  131164. /**
  131165. * Gets the output component
  131166. */
  131167. get output(): NodeMaterialConnectionPoint;
  131168. protected _buildBlock(state: NodeMaterialBuildState): this;
  131169. }
  131170. }
  131171. declare module BABYLON {
  131172. /**
  131173. * Block used to remap a float from a range to a new one
  131174. */
  131175. export class RemapBlock extends NodeMaterialBlock {
  131176. /**
  131177. * Gets or sets the source range
  131178. */
  131179. sourceRange: Vector2;
  131180. /**
  131181. * Gets or sets the target range
  131182. */
  131183. targetRange: Vector2;
  131184. /**
  131185. * Creates a new RemapBlock
  131186. * @param name defines the block name
  131187. */
  131188. constructor(name: string);
  131189. /**
  131190. * Gets the current class name
  131191. * @returns the class name
  131192. */
  131193. getClassName(): string;
  131194. /**
  131195. * Gets the input component
  131196. */
  131197. get input(): NodeMaterialConnectionPoint;
  131198. /**
  131199. * Gets the source min input component
  131200. */
  131201. get sourceMin(): NodeMaterialConnectionPoint;
  131202. /**
  131203. * Gets the source max input component
  131204. */
  131205. get sourceMax(): NodeMaterialConnectionPoint;
  131206. /**
  131207. * Gets the target min input component
  131208. */
  131209. get targetMin(): NodeMaterialConnectionPoint;
  131210. /**
  131211. * Gets the target max input component
  131212. */
  131213. get targetMax(): NodeMaterialConnectionPoint;
  131214. /**
  131215. * Gets the output component
  131216. */
  131217. get output(): NodeMaterialConnectionPoint;
  131218. protected _buildBlock(state: NodeMaterialBuildState): this;
  131219. protected _dumpPropertiesCode(): string;
  131220. serialize(): any;
  131221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131222. }
  131223. }
  131224. declare module BABYLON {
  131225. /**
  131226. * Block used to normalize a vector
  131227. */
  131228. export class NormalizeBlock extends NodeMaterialBlock {
  131229. /**
  131230. * Creates a new NormalizeBlock
  131231. * @param name defines the block name
  131232. */
  131233. constructor(name: string);
  131234. /**
  131235. * Gets the current class name
  131236. * @returns the class name
  131237. */
  131238. getClassName(): string;
  131239. /**
  131240. * Gets the input component
  131241. */
  131242. get input(): NodeMaterialConnectionPoint;
  131243. /**
  131244. * Gets the output component
  131245. */
  131246. get output(): NodeMaterialConnectionPoint;
  131247. protected _buildBlock(state: NodeMaterialBuildState): this;
  131248. }
  131249. }
  131250. declare module BABYLON {
  131251. /**
  131252. * Operations supported by the Trigonometry block
  131253. */
  131254. export enum TrigonometryBlockOperations {
  131255. /** Cos */
  131256. Cos = 0,
  131257. /** Sin */
  131258. Sin = 1,
  131259. /** Abs */
  131260. Abs = 2,
  131261. /** Exp */
  131262. Exp = 3,
  131263. /** Exp2 */
  131264. Exp2 = 4,
  131265. /** Round */
  131266. Round = 5,
  131267. /** Floor */
  131268. Floor = 6,
  131269. /** Ceiling */
  131270. Ceiling = 7,
  131271. /** Square root */
  131272. Sqrt = 8,
  131273. /** Log */
  131274. Log = 9,
  131275. /** Tangent */
  131276. Tan = 10,
  131277. /** Arc tangent */
  131278. ArcTan = 11,
  131279. /** Arc cosinus */
  131280. ArcCos = 12,
  131281. /** Arc sinus */
  131282. ArcSin = 13,
  131283. /** Fraction */
  131284. Fract = 14,
  131285. /** Sign */
  131286. Sign = 15,
  131287. /** To radians (from degrees) */
  131288. Radians = 16,
  131289. /** To degrees (from radians) */
  131290. Degrees = 17
  131291. }
  131292. /**
  131293. * Block used to apply trigonometry operation to floats
  131294. */
  131295. export class TrigonometryBlock extends NodeMaterialBlock {
  131296. /**
  131297. * Gets or sets the operation applied by the block
  131298. */
  131299. operation: TrigonometryBlockOperations;
  131300. /**
  131301. * Creates a new TrigonometryBlock
  131302. * @param name defines the block name
  131303. */
  131304. constructor(name: string);
  131305. /**
  131306. * Gets the current class name
  131307. * @returns the class name
  131308. */
  131309. getClassName(): string;
  131310. /**
  131311. * Gets the input component
  131312. */
  131313. get input(): NodeMaterialConnectionPoint;
  131314. /**
  131315. * Gets the output component
  131316. */
  131317. get output(): NodeMaterialConnectionPoint;
  131318. protected _buildBlock(state: NodeMaterialBuildState): this;
  131319. serialize(): any;
  131320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131321. protected _dumpPropertiesCode(): string;
  131322. }
  131323. }
  131324. declare module BABYLON {
  131325. /**
  131326. * Block used to create a Color3/4 out of individual inputs (one for each component)
  131327. */
  131328. export class ColorMergerBlock extends NodeMaterialBlock {
  131329. /**
  131330. * Create a new ColorMergerBlock
  131331. * @param name defines the block name
  131332. */
  131333. constructor(name: string);
  131334. /**
  131335. * Gets the current class name
  131336. * @returns the class name
  131337. */
  131338. getClassName(): string;
  131339. /**
  131340. * Gets the rgb component (input)
  131341. */
  131342. get rgbIn(): NodeMaterialConnectionPoint;
  131343. /**
  131344. * Gets the r component (input)
  131345. */
  131346. get r(): NodeMaterialConnectionPoint;
  131347. /**
  131348. * Gets the g component (input)
  131349. */
  131350. get g(): NodeMaterialConnectionPoint;
  131351. /**
  131352. * Gets the b component (input)
  131353. */
  131354. get b(): NodeMaterialConnectionPoint;
  131355. /**
  131356. * Gets the a component (input)
  131357. */
  131358. get a(): NodeMaterialConnectionPoint;
  131359. /**
  131360. * Gets the rgba component (output)
  131361. */
  131362. get rgba(): NodeMaterialConnectionPoint;
  131363. /**
  131364. * Gets the rgb component (output)
  131365. */
  131366. get rgbOut(): NodeMaterialConnectionPoint;
  131367. /**
  131368. * Gets the rgb component (output)
  131369. * @deprecated Please use rgbOut instead.
  131370. */
  131371. get rgb(): NodeMaterialConnectionPoint;
  131372. protected _buildBlock(state: NodeMaterialBuildState): this;
  131373. }
  131374. }
  131375. declare module BABYLON {
  131376. /**
  131377. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  131378. */
  131379. export class VectorMergerBlock extends NodeMaterialBlock {
  131380. /**
  131381. * Create a new VectorMergerBlock
  131382. * @param name defines the block name
  131383. */
  131384. constructor(name: string);
  131385. /**
  131386. * Gets the current class name
  131387. * @returns the class name
  131388. */
  131389. getClassName(): string;
  131390. /**
  131391. * Gets the xyz component (input)
  131392. */
  131393. get xyzIn(): NodeMaterialConnectionPoint;
  131394. /**
  131395. * Gets the xy component (input)
  131396. */
  131397. get xyIn(): NodeMaterialConnectionPoint;
  131398. /**
  131399. * Gets the x component (input)
  131400. */
  131401. get x(): NodeMaterialConnectionPoint;
  131402. /**
  131403. * Gets the y component (input)
  131404. */
  131405. get y(): NodeMaterialConnectionPoint;
  131406. /**
  131407. * Gets the z component (input)
  131408. */
  131409. get z(): NodeMaterialConnectionPoint;
  131410. /**
  131411. * Gets the w component (input)
  131412. */
  131413. get w(): NodeMaterialConnectionPoint;
  131414. /**
  131415. * Gets the xyzw component (output)
  131416. */
  131417. get xyzw(): NodeMaterialConnectionPoint;
  131418. /**
  131419. * Gets the xyz component (output)
  131420. */
  131421. get xyzOut(): NodeMaterialConnectionPoint;
  131422. /**
  131423. * Gets the xy component (output)
  131424. */
  131425. get xyOut(): NodeMaterialConnectionPoint;
  131426. /**
  131427. * Gets the xy component (output)
  131428. * @deprecated Please use xyOut instead.
  131429. */
  131430. get xy(): NodeMaterialConnectionPoint;
  131431. /**
  131432. * Gets the xyz component (output)
  131433. * @deprecated Please use xyzOut instead.
  131434. */
  131435. get xyz(): NodeMaterialConnectionPoint;
  131436. protected _buildBlock(state: NodeMaterialBuildState): this;
  131437. }
  131438. }
  131439. declare module BABYLON {
  131440. /**
  131441. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  131442. */
  131443. export class ColorSplitterBlock extends NodeMaterialBlock {
  131444. /**
  131445. * Create a new ColorSplitterBlock
  131446. * @param name defines the block name
  131447. */
  131448. constructor(name: string);
  131449. /**
  131450. * Gets the current class name
  131451. * @returns the class name
  131452. */
  131453. getClassName(): string;
  131454. /**
  131455. * Gets the rgba component (input)
  131456. */
  131457. get rgba(): NodeMaterialConnectionPoint;
  131458. /**
  131459. * Gets the rgb component (input)
  131460. */
  131461. get rgbIn(): NodeMaterialConnectionPoint;
  131462. /**
  131463. * Gets the rgb component (output)
  131464. */
  131465. get rgbOut(): NodeMaterialConnectionPoint;
  131466. /**
  131467. * Gets the r component (output)
  131468. */
  131469. get r(): NodeMaterialConnectionPoint;
  131470. /**
  131471. * Gets the g component (output)
  131472. */
  131473. get g(): NodeMaterialConnectionPoint;
  131474. /**
  131475. * Gets the b component (output)
  131476. */
  131477. get b(): NodeMaterialConnectionPoint;
  131478. /**
  131479. * Gets the a component (output)
  131480. */
  131481. get a(): NodeMaterialConnectionPoint;
  131482. protected _inputRename(name: string): string;
  131483. protected _outputRename(name: string): string;
  131484. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131485. }
  131486. }
  131487. declare module BABYLON {
  131488. /**
  131489. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  131490. */
  131491. export class VectorSplitterBlock extends NodeMaterialBlock {
  131492. /**
  131493. * Create a new VectorSplitterBlock
  131494. * @param name defines the block name
  131495. */
  131496. constructor(name: string);
  131497. /**
  131498. * Gets the current class name
  131499. * @returns the class name
  131500. */
  131501. getClassName(): string;
  131502. /**
  131503. * Gets the xyzw component (input)
  131504. */
  131505. get xyzw(): NodeMaterialConnectionPoint;
  131506. /**
  131507. * Gets the xyz component (input)
  131508. */
  131509. get xyzIn(): NodeMaterialConnectionPoint;
  131510. /**
  131511. * Gets the xy component (input)
  131512. */
  131513. get xyIn(): NodeMaterialConnectionPoint;
  131514. /**
  131515. * Gets the xyz component (output)
  131516. */
  131517. get xyzOut(): NodeMaterialConnectionPoint;
  131518. /**
  131519. * Gets the xy component (output)
  131520. */
  131521. get xyOut(): NodeMaterialConnectionPoint;
  131522. /**
  131523. * Gets the x component (output)
  131524. */
  131525. get x(): NodeMaterialConnectionPoint;
  131526. /**
  131527. * Gets the y component (output)
  131528. */
  131529. get y(): NodeMaterialConnectionPoint;
  131530. /**
  131531. * Gets the z component (output)
  131532. */
  131533. get z(): NodeMaterialConnectionPoint;
  131534. /**
  131535. * Gets the w component (output)
  131536. */
  131537. get w(): NodeMaterialConnectionPoint;
  131538. protected _inputRename(name: string): string;
  131539. protected _outputRename(name: string): string;
  131540. protected _buildBlock(state: NodeMaterialBuildState): this;
  131541. }
  131542. }
  131543. declare module BABYLON {
  131544. /**
  131545. * Block used to lerp between 2 values
  131546. */
  131547. export class LerpBlock extends NodeMaterialBlock {
  131548. /**
  131549. * Creates a new LerpBlock
  131550. * @param name defines the block name
  131551. */
  131552. constructor(name: string);
  131553. /**
  131554. * Gets the current class name
  131555. * @returns the class name
  131556. */
  131557. getClassName(): string;
  131558. /**
  131559. * Gets the left operand input component
  131560. */
  131561. get left(): NodeMaterialConnectionPoint;
  131562. /**
  131563. * Gets the right operand input component
  131564. */
  131565. get right(): NodeMaterialConnectionPoint;
  131566. /**
  131567. * Gets the gradient operand input component
  131568. */
  131569. get gradient(): NodeMaterialConnectionPoint;
  131570. /**
  131571. * Gets the output component
  131572. */
  131573. get output(): NodeMaterialConnectionPoint;
  131574. protected _buildBlock(state: NodeMaterialBuildState): this;
  131575. }
  131576. }
  131577. declare module BABYLON {
  131578. /**
  131579. * Block used to divide 2 vectors
  131580. */
  131581. export class DivideBlock extends NodeMaterialBlock {
  131582. /**
  131583. * Creates a new DivideBlock
  131584. * @param name defines the block name
  131585. */
  131586. constructor(name: string);
  131587. /**
  131588. * Gets the current class name
  131589. * @returns the class name
  131590. */
  131591. getClassName(): string;
  131592. /**
  131593. * Gets the left operand input component
  131594. */
  131595. get left(): NodeMaterialConnectionPoint;
  131596. /**
  131597. * Gets the right operand input component
  131598. */
  131599. get right(): NodeMaterialConnectionPoint;
  131600. /**
  131601. * Gets the output component
  131602. */
  131603. get output(): NodeMaterialConnectionPoint;
  131604. protected _buildBlock(state: NodeMaterialBuildState): this;
  131605. }
  131606. }
  131607. declare module BABYLON {
  131608. /**
  131609. * Block used to subtract 2 vectors
  131610. */
  131611. export class SubtractBlock extends NodeMaterialBlock {
  131612. /**
  131613. * Creates a new SubtractBlock
  131614. * @param name defines the block name
  131615. */
  131616. constructor(name: string);
  131617. /**
  131618. * Gets the current class name
  131619. * @returns the class name
  131620. */
  131621. getClassName(): string;
  131622. /**
  131623. * Gets the left operand input component
  131624. */
  131625. get left(): NodeMaterialConnectionPoint;
  131626. /**
  131627. * Gets the right operand input component
  131628. */
  131629. get right(): NodeMaterialConnectionPoint;
  131630. /**
  131631. * Gets the output component
  131632. */
  131633. get output(): NodeMaterialConnectionPoint;
  131634. protected _buildBlock(state: NodeMaterialBuildState): this;
  131635. }
  131636. }
  131637. declare module BABYLON {
  131638. /**
  131639. * Block used to step a value
  131640. */
  131641. export class StepBlock extends NodeMaterialBlock {
  131642. /**
  131643. * Creates a new StepBlock
  131644. * @param name defines the block name
  131645. */
  131646. constructor(name: string);
  131647. /**
  131648. * Gets the current class name
  131649. * @returns the class name
  131650. */
  131651. getClassName(): string;
  131652. /**
  131653. * Gets the value operand input component
  131654. */
  131655. get value(): NodeMaterialConnectionPoint;
  131656. /**
  131657. * Gets the edge operand input component
  131658. */
  131659. get edge(): NodeMaterialConnectionPoint;
  131660. /**
  131661. * Gets the output component
  131662. */
  131663. get output(): NodeMaterialConnectionPoint;
  131664. protected _buildBlock(state: NodeMaterialBuildState): this;
  131665. }
  131666. }
  131667. declare module BABYLON {
  131668. /**
  131669. * Block used to get the opposite (1 - x) of a value
  131670. */
  131671. export class OneMinusBlock extends NodeMaterialBlock {
  131672. /**
  131673. * Creates a new OneMinusBlock
  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 input component
  131684. */
  131685. get input(): NodeMaterialConnectionPoint;
  131686. /**
  131687. * Gets the output component
  131688. */
  131689. get output(): NodeMaterialConnectionPoint;
  131690. protected _buildBlock(state: NodeMaterialBuildState): this;
  131691. }
  131692. }
  131693. declare module BABYLON {
  131694. /**
  131695. * Block used to get the view direction
  131696. */
  131697. export class ViewDirectionBlock extends NodeMaterialBlock {
  131698. /**
  131699. * Creates a new ViewDirectionBlock
  131700. * @param name defines the block name
  131701. */
  131702. constructor(name: string);
  131703. /**
  131704. * Gets the current class name
  131705. * @returns the class name
  131706. */
  131707. getClassName(): string;
  131708. /**
  131709. * Gets the world position component
  131710. */
  131711. get worldPosition(): NodeMaterialConnectionPoint;
  131712. /**
  131713. * Gets the camera position component
  131714. */
  131715. get cameraPosition(): NodeMaterialConnectionPoint;
  131716. /**
  131717. * Gets the output component
  131718. */
  131719. get output(): NodeMaterialConnectionPoint;
  131720. autoConfigure(material: NodeMaterial): void;
  131721. protected _buildBlock(state: NodeMaterialBuildState): this;
  131722. }
  131723. }
  131724. declare module BABYLON {
  131725. /**
  131726. * Block used to compute fresnel value
  131727. */
  131728. export class FresnelBlock extends NodeMaterialBlock {
  131729. /**
  131730. * Create a new FresnelBlock
  131731. * @param name defines the block name
  131732. */
  131733. constructor(name: string);
  131734. /**
  131735. * Gets the current class name
  131736. * @returns the class name
  131737. */
  131738. getClassName(): string;
  131739. /**
  131740. * Gets the world normal input component
  131741. */
  131742. get worldNormal(): NodeMaterialConnectionPoint;
  131743. /**
  131744. * Gets the view direction input component
  131745. */
  131746. get viewDirection(): NodeMaterialConnectionPoint;
  131747. /**
  131748. * Gets the bias input component
  131749. */
  131750. get bias(): NodeMaterialConnectionPoint;
  131751. /**
  131752. * Gets the camera (or eye) position component
  131753. */
  131754. get power(): NodeMaterialConnectionPoint;
  131755. /**
  131756. * Gets the fresnel output component
  131757. */
  131758. get fresnel(): NodeMaterialConnectionPoint;
  131759. autoConfigure(material: NodeMaterial): void;
  131760. protected _buildBlock(state: NodeMaterialBuildState): this;
  131761. }
  131762. }
  131763. declare module BABYLON {
  131764. /**
  131765. * Block used to get the max of 2 values
  131766. */
  131767. export class MaxBlock extends NodeMaterialBlock {
  131768. /**
  131769. * Creates a new MaxBlock
  131770. * @param name defines the block name
  131771. */
  131772. constructor(name: string);
  131773. /**
  131774. * Gets the current class name
  131775. * @returns the class name
  131776. */
  131777. getClassName(): string;
  131778. /**
  131779. * Gets the left operand input component
  131780. */
  131781. get left(): NodeMaterialConnectionPoint;
  131782. /**
  131783. * Gets the right operand input component
  131784. */
  131785. get right(): NodeMaterialConnectionPoint;
  131786. /**
  131787. * Gets the output component
  131788. */
  131789. get output(): NodeMaterialConnectionPoint;
  131790. protected _buildBlock(state: NodeMaterialBuildState): this;
  131791. }
  131792. }
  131793. declare module BABYLON {
  131794. /**
  131795. * Block used to get the min of 2 values
  131796. */
  131797. export class MinBlock extends NodeMaterialBlock {
  131798. /**
  131799. * Creates a new MinBlock
  131800. * @param name defines the block name
  131801. */
  131802. constructor(name: string);
  131803. /**
  131804. * Gets the current class name
  131805. * @returns the class name
  131806. */
  131807. getClassName(): string;
  131808. /**
  131809. * Gets the left operand input component
  131810. */
  131811. get left(): NodeMaterialConnectionPoint;
  131812. /**
  131813. * Gets the right operand input component
  131814. */
  131815. get right(): NodeMaterialConnectionPoint;
  131816. /**
  131817. * Gets the output component
  131818. */
  131819. get output(): NodeMaterialConnectionPoint;
  131820. protected _buildBlock(state: NodeMaterialBuildState): this;
  131821. }
  131822. }
  131823. declare module BABYLON {
  131824. /**
  131825. * Block used to get the distance between 2 values
  131826. */
  131827. export class DistanceBlock extends NodeMaterialBlock {
  131828. /**
  131829. * Creates a new DistanceBlock
  131830. * @param name defines the block name
  131831. */
  131832. constructor(name: string);
  131833. /**
  131834. * Gets the current class name
  131835. * @returns the class name
  131836. */
  131837. getClassName(): string;
  131838. /**
  131839. * Gets the left operand input component
  131840. */
  131841. get left(): NodeMaterialConnectionPoint;
  131842. /**
  131843. * Gets the right operand input component
  131844. */
  131845. get right(): NodeMaterialConnectionPoint;
  131846. /**
  131847. * Gets the output component
  131848. */
  131849. get output(): NodeMaterialConnectionPoint;
  131850. protected _buildBlock(state: NodeMaterialBuildState): this;
  131851. }
  131852. }
  131853. declare module BABYLON {
  131854. /**
  131855. * Block used to get the length of a vector
  131856. */
  131857. export class LengthBlock extends NodeMaterialBlock {
  131858. /**
  131859. * Creates a new LengthBlock
  131860. * @param name defines the block name
  131861. */
  131862. constructor(name: string);
  131863. /**
  131864. * Gets the current class name
  131865. * @returns the class name
  131866. */
  131867. getClassName(): string;
  131868. /**
  131869. * Gets the value input component
  131870. */
  131871. get value(): NodeMaterialConnectionPoint;
  131872. /**
  131873. * Gets the output component
  131874. */
  131875. get output(): NodeMaterialConnectionPoint;
  131876. protected _buildBlock(state: NodeMaterialBuildState): this;
  131877. }
  131878. }
  131879. declare module BABYLON {
  131880. /**
  131881. * Block used to get negative version of a value (i.e. x * -1)
  131882. */
  131883. export class NegateBlock extends NodeMaterialBlock {
  131884. /**
  131885. * Creates a new NegateBlock
  131886. * @param name defines the block name
  131887. */
  131888. constructor(name: string);
  131889. /**
  131890. * Gets the current class name
  131891. * @returns the class name
  131892. */
  131893. getClassName(): string;
  131894. /**
  131895. * Gets the value input component
  131896. */
  131897. get value(): NodeMaterialConnectionPoint;
  131898. /**
  131899. * Gets the output component
  131900. */
  131901. get output(): NodeMaterialConnectionPoint;
  131902. protected _buildBlock(state: NodeMaterialBuildState): this;
  131903. }
  131904. }
  131905. declare module BABYLON {
  131906. /**
  131907. * Block used to get the value of the first parameter raised to the power of the second
  131908. */
  131909. export class PowBlock extends NodeMaterialBlock {
  131910. /**
  131911. * Creates a new PowBlock
  131912. * @param name defines the block name
  131913. */
  131914. constructor(name: string);
  131915. /**
  131916. * Gets the current class name
  131917. * @returns the class name
  131918. */
  131919. getClassName(): string;
  131920. /**
  131921. * Gets the value operand input component
  131922. */
  131923. get value(): NodeMaterialConnectionPoint;
  131924. /**
  131925. * Gets the power operand input component
  131926. */
  131927. get power(): NodeMaterialConnectionPoint;
  131928. /**
  131929. * Gets the output component
  131930. */
  131931. get output(): NodeMaterialConnectionPoint;
  131932. protected _buildBlock(state: NodeMaterialBuildState): this;
  131933. }
  131934. }
  131935. declare module BABYLON {
  131936. /**
  131937. * Block used to get a random number
  131938. */
  131939. export class RandomNumberBlock extends NodeMaterialBlock {
  131940. /**
  131941. * Creates a new RandomNumberBlock
  131942. * @param name defines the block name
  131943. */
  131944. constructor(name: string);
  131945. /**
  131946. * Gets the current class name
  131947. * @returns the class name
  131948. */
  131949. getClassName(): string;
  131950. /**
  131951. * Gets the seed input component
  131952. */
  131953. get seed(): NodeMaterialConnectionPoint;
  131954. /**
  131955. * Gets the output component
  131956. */
  131957. get output(): NodeMaterialConnectionPoint;
  131958. protected _buildBlock(state: NodeMaterialBuildState): this;
  131959. }
  131960. }
  131961. declare module BABYLON {
  131962. /**
  131963. * Block used to compute arc tangent of 2 values
  131964. */
  131965. export class ArcTan2Block extends NodeMaterialBlock {
  131966. /**
  131967. * Creates a new ArcTan2Block
  131968. * @param name defines the block name
  131969. */
  131970. constructor(name: string);
  131971. /**
  131972. * Gets the current class name
  131973. * @returns the class name
  131974. */
  131975. getClassName(): string;
  131976. /**
  131977. * Gets the x operand input component
  131978. */
  131979. get x(): NodeMaterialConnectionPoint;
  131980. /**
  131981. * Gets the y operand input component
  131982. */
  131983. get y(): NodeMaterialConnectionPoint;
  131984. /**
  131985. * Gets the output component
  131986. */
  131987. get output(): NodeMaterialConnectionPoint;
  131988. protected _buildBlock(state: NodeMaterialBuildState): this;
  131989. }
  131990. }
  131991. declare module BABYLON {
  131992. /**
  131993. * Block used to smooth step a value
  131994. */
  131995. export class SmoothStepBlock extends NodeMaterialBlock {
  131996. /**
  131997. * Creates a new SmoothStepBlock
  131998. * @param name defines the block name
  131999. */
  132000. constructor(name: string);
  132001. /**
  132002. * Gets the current class name
  132003. * @returns the class name
  132004. */
  132005. getClassName(): string;
  132006. /**
  132007. * Gets the value operand input component
  132008. */
  132009. get value(): NodeMaterialConnectionPoint;
  132010. /**
  132011. * Gets the first edge operand input component
  132012. */
  132013. get edge0(): NodeMaterialConnectionPoint;
  132014. /**
  132015. * Gets the second edge operand input component
  132016. */
  132017. get edge1(): NodeMaterialConnectionPoint;
  132018. /**
  132019. * Gets the output component
  132020. */
  132021. get output(): NodeMaterialConnectionPoint;
  132022. protected _buildBlock(state: NodeMaterialBuildState): this;
  132023. }
  132024. }
  132025. declare module BABYLON {
  132026. /**
  132027. * Block used to get the reciprocal (1 / x) of a value
  132028. */
  132029. export class ReciprocalBlock extends NodeMaterialBlock {
  132030. /**
  132031. * Creates a new ReciprocalBlock
  132032. * @param name defines the block name
  132033. */
  132034. constructor(name: string);
  132035. /**
  132036. * Gets the current class name
  132037. * @returns the class name
  132038. */
  132039. getClassName(): string;
  132040. /**
  132041. * Gets the input component
  132042. */
  132043. get input(): NodeMaterialConnectionPoint;
  132044. /**
  132045. * Gets the output component
  132046. */
  132047. get output(): NodeMaterialConnectionPoint;
  132048. protected _buildBlock(state: NodeMaterialBuildState): this;
  132049. }
  132050. }
  132051. declare module BABYLON {
  132052. /**
  132053. * Block used to replace a color by another one
  132054. */
  132055. export class ReplaceColorBlock extends NodeMaterialBlock {
  132056. /**
  132057. * Creates a new ReplaceColorBlock
  132058. * @param name defines the block name
  132059. */
  132060. constructor(name: string);
  132061. /**
  132062. * Gets the current class name
  132063. * @returns the class name
  132064. */
  132065. getClassName(): string;
  132066. /**
  132067. * Gets the value input component
  132068. */
  132069. get value(): NodeMaterialConnectionPoint;
  132070. /**
  132071. * Gets the reference input component
  132072. */
  132073. get reference(): NodeMaterialConnectionPoint;
  132074. /**
  132075. * Gets the distance input component
  132076. */
  132077. get distance(): NodeMaterialConnectionPoint;
  132078. /**
  132079. * Gets the replacement input component
  132080. */
  132081. get replacement(): NodeMaterialConnectionPoint;
  132082. /**
  132083. * Gets the output component
  132084. */
  132085. get output(): NodeMaterialConnectionPoint;
  132086. protected _buildBlock(state: NodeMaterialBuildState): this;
  132087. }
  132088. }
  132089. declare module BABYLON {
  132090. /**
  132091. * Block used to posterize a value
  132092. * @see https://en.wikipedia.org/wiki/Posterization
  132093. */
  132094. export class PosterizeBlock extends NodeMaterialBlock {
  132095. /**
  132096. * Creates a new PosterizeBlock
  132097. * @param name defines the block name
  132098. */
  132099. constructor(name: string);
  132100. /**
  132101. * Gets the current class name
  132102. * @returns the class name
  132103. */
  132104. getClassName(): string;
  132105. /**
  132106. * Gets the value input component
  132107. */
  132108. get value(): NodeMaterialConnectionPoint;
  132109. /**
  132110. * Gets the steps input component
  132111. */
  132112. get steps(): NodeMaterialConnectionPoint;
  132113. /**
  132114. * Gets the output component
  132115. */
  132116. get output(): NodeMaterialConnectionPoint;
  132117. protected _buildBlock(state: NodeMaterialBuildState): this;
  132118. }
  132119. }
  132120. declare module BABYLON {
  132121. /**
  132122. * Operations supported by the Wave block
  132123. */
  132124. export enum WaveBlockKind {
  132125. /** SawTooth */
  132126. SawTooth = 0,
  132127. /** Square */
  132128. Square = 1,
  132129. /** Triangle */
  132130. Triangle = 2
  132131. }
  132132. /**
  132133. * Block used to apply wave operation to floats
  132134. */
  132135. export class WaveBlock extends NodeMaterialBlock {
  132136. /**
  132137. * Gets or sets the kibnd of wave to be applied by the block
  132138. */
  132139. kind: WaveBlockKind;
  132140. /**
  132141. * Creates a new WaveBlock
  132142. * @param name defines the block name
  132143. */
  132144. constructor(name: string);
  132145. /**
  132146. * Gets the current class name
  132147. * @returns the class name
  132148. */
  132149. getClassName(): string;
  132150. /**
  132151. * Gets the input component
  132152. */
  132153. get input(): NodeMaterialConnectionPoint;
  132154. /**
  132155. * Gets the output component
  132156. */
  132157. get output(): NodeMaterialConnectionPoint;
  132158. protected _buildBlock(state: NodeMaterialBuildState): this;
  132159. serialize(): any;
  132160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132161. }
  132162. }
  132163. declare module BABYLON {
  132164. /**
  132165. * Class used to store a color step for the GradientBlock
  132166. */
  132167. export class GradientBlockColorStep {
  132168. /**
  132169. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132170. */
  132171. step: number;
  132172. /**
  132173. * Gets or sets the color associated with this step
  132174. */
  132175. color: Color3;
  132176. /**
  132177. * Creates a new GradientBlockColorStep
  132178. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  132179. * @param color defines the color associated with this step
  132180. */
  132181. constructor(
  132182. /**
  132183. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132184. */
  132185. step: number,
  132186. /**
  132187. * Gets or sets the color associated with this step
  132188. */
  132189. color: Color3);
  132190. }
  132191. /**
  132192. * Block used to return a color from a gradient based on an input value between 0 and 1
  132193. */
  132194. export class GradientBlock extends NodeMaterialBlock {
  132195. /**
  132196. * Gets or sets the list of color steps
  132197. */
  132198. colorSteps: GradientBlockColorStep[];
  132199. /**
  132200. * Creates a new GradientBlock
  132201. * @param name defines the block name
  132202. */
  132203. constructor(name: string);
  132204. /**
  132205. * Gets the current class name
  132206. * @returns the class name
  132207. */
  132208. getClassName(): string;
  132209. /**
  132210. * Gets the gradient input component
  132211. */
  132212. get gradient(): NodeMaterialConnectionPoint;
  132213. /**
  132214. * Gets the output component
  132215. */
  132216. get output(): NodeMaterialConnectionPoint;
  132217. private _writeColorConstant;
  132218. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132219. serialize(): any;
  132220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132221. protected _dumpPropertiesCode(): string;
  132222. }
  132223. }
  132224. declare module BABYLON {
  132225. /**
  132226. * Block used to normalize lerp between 2 values
  132227. */
  132228. export class NLerpBlock extends NodeMaterialBlock {
  132229. /**
  132230. * Creates a new NLerpBlock
  132231. * @param name defines the block name
  132232. */
  132233. constructor(name: string);
  132234. /**
  132235. * Gets the current class name
  132236. * @returns the class name
  132237. */
  132238. getClassName(): string;
  132239. /**
  132240. * Gets the left operand input component
  132241. */
  132242. get left(): NodeMaterialConnectionPoint;
  132243. /**
  132244. * Gets the right operand input component
  132245. */
  132246. get right(): NodeMaterialConnectionPoint;
  132247. /**
  132248. * Gets the gradient operand input component
  132249. */
  132250. get gradient(): NodeMaterialConnectionPoint;
  132251. /**
  132252. * Gets the output component
  132253. */
  132254. get output(): NodeMaterialConnectionPoint;
  132255. protected _buildBlock(state: NodeMaterialBuildState): this;
  132256. }
  132257. }
  132258. declare module BABYLON {
  132259. /**
  132260. * block used to Generate a Worley Noise 3D Noise Pattern
  132261. */
  132262. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  132263. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132264. manhattanDistance: boolean;
  132265. /**
  132266. * Creates a new WorleyNoise3DBlock
  132267. * @param name defines the block name
  132268. */
  132269. constructor(name: string);
  132270. /**
  132271. * Gets the current class name
  132272. * @returns the class name
  132273. */
  132274. getClassName(): string;
  132275. /**
  132276. * Gets the seed input component
  132277. */
  132278. get seed(): NodeMaterialConnectionPoint;
  132279. /**
  132280. * Gets the jitter input component
  132281. */
  132282. get jitter(): NodeMaterialConnectionPoint;
  132283. /**
  132284. * Gets the output component
  132285. */
  132286. get output(): NodeMaterialConnectionPoint;
  132287. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132288. /**
  132289. * Exposes the properties to the UI?
  132290. */
  132291. protected _dumpPropertiesCode(): string;
  132292. /**
  132293. * Exposes the properties to the Seralize?
  132294. */
  132295. serialize(): any;
  132296. /**
  132297. * Exposes the properties to the deseralize?
  132298. */
  132299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132300. }
  132301. }
  132302. declare module BABYLON {
  132303. /**
  132304. * block used to Generate a Simplex Perlin 3d Noise Pattern
  132305. */
  132306. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  132307. /**
  132308. * Creates a new SimplexPerlin3DBlock
  132309. * @param name defines the block name
  132310. */
  132311. constructor(name: string);
  132312. /**
  132313. * Gets the current class name
  132314. * @returns the class name
  132315. */
  132316. getClassName(): string;
  132317. /**
  132318. * Gets the seed operand input component
  132319. */
  132320. get seed(): NodeMaterialConnectionPoint;
  132321. /**
  132322. * Gets the output component
  132323. */
  132324. get output(): NodeMaterialConnectionPoint;
  132325. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132326. }
  132327. }
  132328. declare module BABYLON {
  132329. /**
  132330. * Block used to blend normals
  132331. */
  132332. export class NormalBlendBlock extends NodeMaterialBlock {
  132333. /**
  132334. * Creates a new NormalBlendBlock
  132335. * @param name defines the block name
  132336. */
  132337. constructor(name: string);
  132338. /**
  132339. * Gets the current class name
  132340. * @returns the class name
  132341. */
  132342. getClassName(): string;
  132343. /**
  132344. * Gets the first input component
  132345. */
  132346. get normalMap0(): NodeMaterialConnectionPoint;
  132347. /**
  132348. * Gets the second input component
  132349. */
  132350. get normalMap1(): NodeMaterialConnectionPoint;
  132351. /**
  132352. * Gets the output component
  132353. */
  132354. get output(): NodeMaterialConnectionPoint;
  132355. protected _buildBlock(state: NodeMaterialBuildState): this;
  132356. }
  132357. }
  132358. declare module BABYLON {
  132359. /**
  132360. * Block used to rotate a 2d vector by a given angle
  132361. */
  132362. export class Rotate2dBlock extends NodeMaterialBlock {
  132363. /**
  132364. * Creates a new Rotate2dBlock
  132365. * @param name defines the block name
  132366. */
  132367. constructor(name: string);
  132368. /**
  132369. * Gets the current class name
  132370. * @returns the class name
  132371. */
  132372. getClassName(): string;
  132373. /**
  132374. * Gets the input vector
  132375. */
  132376. get input(): NodeMaterialConnectionPoint;
  132377. /**
  132378. * Gets the input angle
  132379. */
  132380. get angle(): NodeMaterialConnectionPoint;
  132381. /**
  132382. * Gets the output component
  132383. */
  132384. get output(): NodeMaterialConnectionPoint;
  132385. autoConfigure(material: NodeMaterial): void;
  132386. protected _buildBlock(state: NodeMaterialBuildState): this;
  132387. }
  132388. }
  132389. declare module BABYLON {
  132390. /**
  132391. * Block used to get the reflected vector from a direction and a normal
  132392. */
  132393. export class ReflectBlock extends NodeMaterialBlock {
  132394. /**
  132395. * Creates a new ReflectBlock
  132396. * @param name defines the block name
  132397. */
  132398. constructor(name: string);
  132399. /**
  132400. * Gets the current class name
  132401. * @returns the class name
  132402. */
  132403. getClassName(): string;
  132404. /**
  132405. * Gets the incident component
  132406. */
  132407. get incident(): NodeMaterialConnectionPoint;
  132408. /**
  132409. * Gets the normal component
  132410. */
  132411. get normal(): NodeMaterialConnectionPoint;
  132412. /**
  132413. * Gets the output component
  132414. */
  132415. get output(): NodeMaterialConnectionPoint;
  132416. protected _buildBlock(state: NodeMaterialBuildState): this;
  132417. }
  132418. }
  132419. declare module BABYLON {
  132420. /**
  132421. * Block used to get the refracted vector from a direction and a normal
  132422. */
  132423. export class RefractBlock extends NodeMaterialBlock {
  132424. /**
  132425. * Creates a new RefractBlock
  132426. * @param name defines the block name
  132427. */
  132428. constructor(name: string);
  132429. /**
  132430. * Gets the current class name
  132431. * @returns the class name
  132432. */
  132433. getClassName(): string;
  132434. /**
  132435. * Gets the incident component
  132436. */
  132437. get incident(): NodeMaterialConnectionPoint;
  132438. /**
  132439. * Gets the normal component
  132440. */
  132441. get normal(): NodeMaterialConnectionPoint;
  132442. /**
  132443. * Gets the index of refraction component
  132444. */
  132445. get ior(): NodeMaterialConnectionPoint;
  132446. /**
  132447. * Gets the output component
  132448. */
  132449. get output(): NodeMaterialConnectionPoint;
  132450. protected _buildBlock(state: NodeMaterialBuildState): this;
  132451. }
  132452. }
  132453. declare module BABYLON {
  132454. /**
  132455. * Block used to desaturate a color
  132456. */
  132457. export class DesaturateBlock extends NodeMaterialBlock {
  132458. /**
  132459. * Creates a new DesaturateBlock
  132460. * @param name defines the block name
  132461. */
  132462. constructor(name: string);
  132463. /**
  132464. * Gets the current class name
  132465. * @returns the class name
  132466. */
  132467. getClassName(): string;
  132468. /**
  132469. * Gets the color operand input component
  132470. */
  132471. get color(): NodeMaterialConnectionPoint;
  132472. /**
  132473. * Gets the level operand input component
  132474. */
  132475. get level(): NodeMaterialConnectionPoint;
  132476. /**
  132477. * Gets the output component
  132478. */
  132479. get output(): NodeMaterialConnectionPoint;
  132480. protected _buildBlock(state: NodeMaterialBuildState): this;
  132481. }
  132482. }
  132483. declare module BABYLON {
  132484. /**
  132485. * Effect Render Options
  132486. */
  132487. export interface IEffectRendererOptions {
  132488. /**
  132489. * Defines the vertices positions.
  132490. */
  132491. positions?: number[];
  132492. /**
  132493. * Defines the indices.
  132494. */
  132495. indices?: number[];
  132496. }
  132497. /**
  132498. * Helper class to render one or more effects
  132499. */
  132500. export class EffectRenderer {
  132501. private engine;
  132502. private static _DefaultOptions;
  132503. private _vertexBuffers;
  132504. private _indexBuffer;
  132505. private _ringBufferIndex;
  132506. private _ringScreenBuffer;
  132507. private _fullscreenViewport;
  132508. private _getNextFrameBuffer;
  132509. /**
  132510. * Creates an effect renderer
  132511. * @param engine the engine to use for rendering
  132512. * @param options defines the options of the effect renderer
  132513. */
  132514. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  132515. /**
  132516. * Sets the current viewport in normalized coordinates 0-1
  132517. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  132518. */
  132519. setViewport(viewport?: Viewport): void;
  132520. /**
  132521. * Binds the embedded attributes buffer to the effect.
  132522. * @param effect Defines the effect to bind the attributes for
  132523. */
  132524. bindBuffers(effect: Effect): void;
  132525. /**
  132526. * Sets the current effect wrapper to use during draw.
  132527. * The effect needs to be ready before calling this api.
  132528. * This also sets the default full screen position attribute.
  132529. * @param effectWrapper Defines the effect to draw with
  132530. */
  132531. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  132532. /**
  132533. * Draws a full screen quad.
  132534. */
  132535. draw(): void;
  132536. /**
  132537. * renders one or more effects to a specified texture
  132538. * @param effectWrappers list of effects to renderer
  132539. * @param outputTexture texture to draw to, if null it will render to the screen
  132540. */
  132541. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  132542. /**
  132543. * Disposes of the effect renderer
  132544. */
  132545. dispose(): void;
  132546. }
  132547. /**
  132548. * Options to create an EffectWrapper
  132549. */
  132550. interface EffectWrapperCreationOptions {
  132551. /**
  132552. * Engine to use to create the effect
  132553. */
  132554. engine: ThinEngine;
  132555. /**
  132556. * Fragment shader for the effect
  132557. */
  132558. fragmentShader: string;
  132559. /**
  132560. * Vertex shader for the effect
  132561. */
  132562. vertexShader?: string;
  132563. /**
  132564. * Attributes to use in the shader
  132565. */
  132566. attributeNames?: Array<string>;
  132567. /**
  132568. * Uniforms to use in the shader
  132569. */
  132570. uniformNames?: Array<string>;
  132571. /**
  132572. * Texture sampler names to use in the shader
  132573. */
  132574. samplerNames?: Array<string>;
  132575. /**
  132576. * The friendly name of the effect displayed in Spector.
  132577. */
  132578. name?: string;
  132579. }
  132580. /**
  132581. * Wraps an effect to be used for rendering
  132582. */
  132583. export class EffectWrapper {
  132584. /**
  132585. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  132586. */
  132587. onApplyObservable: Observable<{}>;
  132588. /**
  132589. * The underlying effect
  132590. */
  132591. effect: Effect;
  132592. /**
  132593. * Creates an effect to be renderer
  132594. * @param creationOptions options to create the effect
  132595. */
  132596. constructor(creationOptions: EffectWrapperCreationOptions);
  132597. /**
  132598. * Disposes of the effect wrapper
  132599. */
  132600. dispose(): void;
  132601. }
  132602. }
  132603. declare module BABYLON {
  132604. /**
  132605. * Helper class to push actions to a pool of workers.
  132606. */
  132607. export class WorkerPool implements IDisposable {
  132608. private _workerInfos;
  132609. private _pendingActions;
  132610. /**
  132611. * Constructor
  132612. * @param workers Array of workers to use for actions
  132613. */
  132614. constructor(workers: Array<Worker>);
  132615. /**
  132616. * Terminates all workers and clears any pending actions.
  132617. */
  132618. dispose(): void;
  132619. /**
  132620. * Pushes an action to the worker pool. If all the workers are active, the action will be
  132621. * pended until a worker has completed its action.
  132622. * @param action The action to perform. Call onComplete when the action is complete.
  132623. */
  132624. push(action: (worker: Worker, onComplete: () => void) => void): void;
  132625. private _execute;
  132626. }
  132627. }
  132628. declare module BABYLON {
  132629. /**
  132630. * Configuration for Draco compression
  132631. */
  132632. export interface IDracoCompressionConfiguration {
  132633. /**
  132634. * Configuration for the decoder.
  132635. */
  132636. decoder: {
  132637. /**
  132638. * The url to the WebAssembly module.
  132639. */
  132640. wasmUrl?: string;
  132641. /**
  132642. * The url to the WebAssembly binary.
  132643. */
  132644. wasmBinaryUrl?: string;
  132645. /**
  132646. * The url to the fallback JavaScript module.
  132647. */
  132648. fallbackUrl?: string;
  132649. };
  132650. }
  132651. /**
  132652. * Draco compression (https://google.github.io/draco/)
  132653. *
  132654. * This class wraps the Draco module.
  132655. *
  132656. * **Encoder**
  132657. *
  132658. * The encoder is not currently implemented.
  132659. *
  132660. * **Decoder**
  132661. *
  132662. * 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.
  132663. *
  132664. * To update the configuration, use the following code:
  132665. * ```javascript
  132666. * DracoCompression.Configuration = {
  132667. * decoder: {
  132668. * wasmUrl: "<url to the WebAssembly library>",
  132669. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  132670. * fallbackUrl: "<url to the fallback JavaScript library>",
  132671. * }
  132672. * };
  132673. * ```
  132674. *
  132675. * 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.
  132676. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  132677. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  132678. *
  132679. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  132680. * ```javascript
  132681. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  132682. * ```
  132683. *
  132684. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  132685. */
  132686. export class DracoCompression implements IDisposable {
  132687. private _workerPoolPromise?;
  132688. private _decoderModulePromise?;
  132689. /**
  132690. * The configuration. Defaults to the following urls:
  132691. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  132692. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  132693. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  132694. */
  132695. static Configuration: IDracoCompressionConfiguration;
  132696. /**
  132697. * Returns true if the decoder configuration is available.
  132698. */
  132699. static get DecoderAvailable(): boolean;
  132700. /**
  132701. * Default number of workers to create when creating the draco compression object.
  132702. */
  132703. static DefaultNumWorkers: number;
  132704. private static GetDefaultNumWorkers;
  132705. private static _Default;
  132706. /**
  132707. * Default instance for the draco compression object.
  132708. */
  132709. static get Default(): DracoCompression;
  132710. /**
  132711. * Constructor
  132712. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  132713. */
  132714. constructor(numWorkers?: number);
  132715. /**
  132716. * Stop all async operations and release resources.
  132717. */
  132718. dispose(): void;
  132719. /**
  132720. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  132721. * @returns a promise that resolves when ready
  132722. */
  132723. whenReadyAsync(): Promise<void>;
  132724. /**
  132725. * Decode Draco compressed mesh data to vertex data.
  132726. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  132727. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  132728. * @returns A promise that resolves with the decoded vertex data
  132729. */
  132730. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  132731. [kind: string]: number;
  132732. }): Promise<VertexData>;
  132733. }
  132734. }
  132735. declare module BABYLON {
  132736. /**
  132737. * Class for building Constructive Solid Geometry
  132738. */
  132739. export class CSG {
  132740. private polygons;
  132741. /**
  132742. * The world matrix
  132743. */
  132744. matrix: Matrix;
  132745. /**
  132746. * Stores the position
  132747. */
  132748. position: Vector3;
  132749. /**
  132750. * Stores the rotation
  132751. */
  132752. rotation: Vector3;
  132753. /**
  132754. * Stores the rotation quaternion
  132755. */
  132756. rotationQuaternion: Nullable<Quaternion>;
  132757. /**
  132758. * Stores the scaling vector
  132759. */
  132760. scaling: Vector3;
  132761. /**
  132762. * Convert the Mesh to CSG
  132763. * @param mesh The Mesh to convert to CSG
  132764. * @returns A new CSG from the Mesh
  132765. */
  132766. static FromMesh(mesh: Mesh): CSG;
  132767. /**
  132768. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  132769. * @param polygons Polygons used to construct a CSG solid
  132770. */
  132771. private static FromPolygons;
  132772. /**
  132773. * Clones, or makes a deep copy, of the CSG
  132774. * @returns A new CSG
  132775. */
  132776. clone(): CSG;
  132777. /**
  132778. * Unions this CSG with another CSG
  132779. * @param csg The CSG to union against this CSG
  132780. * @returns The unioned CSG
  132781. */
  132782. union(csg: CSG): CSG;
  132783. /**
  132784. * Unions this CSG with another CSG in place
  132785. * @param csg The CSG to union against this CSG
  132786. */
  132787. unionInPlace(csg: CSG): void;
  132788. /**
  132789. * Subtracts this CSG with another CSG
  132790. * @param csg The CSG to subtract against this CSG
  132791. * @returns A new CSG
  132792. */
  132793. subtract(csg: CSG): CSG;
  132794. /**
  132795. * Subtracts this CSG with another CSG in place
  132796. * @param csg The CSG to subtact against this CSG
  132797. */
  132798. subtractInPlace(csg: CSG): void;
  132799. /**
  132800. * Intersect this CSG with another CSG
  132801. * @param csg The CSG to intersect against this CSG
  132802. * @returns A new CSG
  132803. */
  132804. intersect(csg: CSG): CSG;
  132805. /**
  132806. * Intersects this CSG with another CSG in place
  132807. * @param csg The CSG to intersect against this CSG
  132808. */
  132809. intersectInPlace(csg: CSG): void;
  132810. /**
  132811. * Return a new CSG solid with solid and empty space switched. This solid is
  132812. * not modified.
  132813. * @returns A new CSG solid with solid and empty space switched
  132814. */
  132815. inverse(): CSG;
  132816. /**
  132817. * Inverses the CSG in place
  132818. */
  132819. inverseInPlace(): void;
  132820. /**
  132821. * This is used to keep meshes transformations so they can be restored
  132822. * when we build back a Babylon Mesh
  132823. * NB : All CSG operations are performed in world coordinates
  132824. * @param csg The CSG to copy the transform attributes from
  132825. * @returns This CSG
  132826. */
  132827. copyTransformAttributes(csg: CSG): CSG;
  132828. /**
  132829. * Build Raw mesh from CSG
  132830. * Coordinates here are in world space
  132831. * @param name The name of the mesh geometry
  132832. * @param scene The Scene
  132833. * @param keepSubMeshes Specifies if the submeshes should be kept
  132834. * @returns A new Mesh
  132835. */
  132836. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132837. /**
  132838. * Build Mesh from CSG taking material and transforms into account
  132839. * @param name The name of the Mesh
  132840. * @param material The material of the Mesh
  132841. * @param scene The Scene
  132842. * @param keepSubMeshes Specifies if submeshes should be kept
  132843. * @returns The new Mesh
  132844. */
  132845. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132846. }
  132847. }
  132848. declare module BABYLON {
  132849. /**
  132850. * Class used to create a trail following a mesh
  132851. */
  132852. export class TrailMesh extends Mesh {
  132853. private _generator;
  132854. private _autoStart;
  132855. private _running;
  132856. private _diameter;
  132857. private _length;
  132858. private _sectionPolygonPointsCount;
  132859. private _sectionVectors;
  132860. private _sectionNormalVectors;
  132861. private _beforeRenderObserver;
  132862. /**
  132863. * @constructor
  132864. * @param name The value used by scene.getMeshByName() to do a lookup.
  132865. * @param generator The mesh or transform node to generate a trail.
  132866. * @param scene The scene to add this mesh to.
  132867. * @param diameter Diameter of trailing mesh. Default is 1.
  132868. * @param length Length of trailing mesh. Default is 60.
  132869. * @param autoStart Automatically start trailing mesh. Default true.
  132870. */
  132871. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  132872. /**
  132873. * "TrailMesh"
  132874. * @returns "TrailMesh"
  132875. */
  132876. getClassName(): string;
  132877. private _createMesh;
  132878. /**
  132879. * Start trailing mesh.
  132880. */
  132881. start(): void;
  132882. /**
  132883. * Stop trailing mesh.
  132884. */
  132885. stop(): void;
  132886. /**
  132887. * Update trailing mesh geometry.
  132888. */
  132889. update(): void;
  132890. /**
  132891. * Returns a new TrailMesh object.
  132892. * @param name is a string, the name given to the new mesh
  132893. * @param newGenerator use new generator object for cloned trail mesh
  132894. * @returns a new mesh
  132895. */
  132896. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  132897. /**
  132898. * Serializes this trail mesh
  132899. * @param serializationObject object to write serialization to
  132900. */
  132901. serialize(serializationObject: any): void;
  132902. /**
  132903. * Parses a serialized trail mesh
  132904. * @param parsedMesh the serialized mesh
  132905. * @param scene the scene to create the trail mesh in
  132906. * @returns the created trail mesh
  132907. */
  132908. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  132909. }
  132910. }
  132911. declare module BABYLON {
  132912. /**
  132913. * Class containing static functions to help procedurally build meshes
  132914. */
  132915. export class TiledBoxBuilder {
  132916. /**
  132917. * Creates a box mesh
  132918. * 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)
  132919. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  132920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132923. * @param name defines the name of the mesh
  132924. * @param options defines the options used to create the mesh
  132925. * @param scene defines the hosting scene
  132926. * @returns the box mesh
  132927. */
  132928. static CreateTiledBox(name: string, options: {
  132929. pattern?: number;
  132930. width?: number;
  132931. height?: number;
  132932. depth?: number;
  132933. tileSize?: number;
  132934. tileWidth?: number;
  132935. tileHeight?: number;
  132936. alignHorizontal?: number;
  132937. alignVertical?: number;
  132938. faceUV?: Vector4[];
  132939. faceColors?: Color4[];
  132940. sideOrientation?: number;
  132941. updatable?: boolean;
  132942. }, scene?: Nullable<Scene>): Mesh;
  132943. }
  132944. }
  132945. declare module BABYLON {
  132946. /**
  132947. * Class containing static functions to help procedurally build meshes
  132948. */
  132949. export class TorusKnotBuilder {
  132950. /**
  132951. * Creates a torus knot mesh
  132952. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  132953. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  132954. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  132955. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  132956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132959. * @param name defines the name of the mesh
  132960. * @param options defines the options used to create the mesh
  132961. * @param scene defines the hosting scene
  132962. * @returns the torus knot mesh
  132963. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  132964. */
  132965. static CreateTorusKnot(name: string, options: {
  132966. radius?: number;
  132967. tube?: number;
  132968. radialSegments?: number;
  132969. tubularSegments?: number;
  132970. p?: number;
  132971. q?: number;
  132972. updatable?: boolean;
  132973. sideOrientation?: number;
  132974. frontUVs?: Vector4;
  132975. backUVs?: Vector4;
  132976. }, scene: any): Mesh;
  132977. }
  132978. }
  132979. declare module BABYLON {
  132980. /**
  132981. * Polygon
  132982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  132983. */
  132984. export class Polygon {
  132985. /**
  132986. * Creates a rectangle
  132987. * @param xmin bottom X coord
  132988. * @param ymin bottom Y coord
  132989. * @param xmax top X coord
  132990. * @param ymax top Y coord
  132991. * @returns points that make the resulting rectation
  132992. */
  132993. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  132994. /**
  132995. * Creates a circle
  132996. * @param radius radius of circle
  132997. * @param cx scale in x
  132998. * @param cy scale in y
  132999. * @param numberOfSides number of sides that make up the circle
  133000. * @returns points that make the resulting circle
  133001. */
  133002. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133003. /**
  133004. * Creates a polygon from input string
  133005. * @param input Input polygon data
  133006. * @returns the parsed points
  133007. */
  133008. static Parse(input: string): Vector2[];
  133009. /**
  133010. * Starts building a polygon from x and y coordinates
  133011. * @param x x coordinate
  133012. * @param y y coordinate
  133013. * @returns the started path2
  133014. */
  133015. static StartingAt(x: number, y: number): Path2;
  133016. }
  133017. /**
  133018. * Builds a polygon
  133019. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133020. */
  133021. export class PolygonMeshBuilder {
  133022. private _points;
  133023. private _outlinepoints;
  133024. private _holes;
  133025. private _name;
  133026. private _scene;
  133027. private _epoints;
  133028. private _eholes;
  133029. private _addToepoint;
  133030. /**
  133031. * Babylon reference to the earcut plugin.
  133032. */
  133033. bjsEarcut: any;
  133034. /**
  133035. * Creates a PolygonMeshBuilder
  133036. * @param name name of the builder
  133037. * @param contours Path of the polygon
  133038. * @param scene scene to add to when creating the mesh
  133039. * @param earcutInjection can be used to inject your own earcut reference
  133040. */
  133041. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133042. /**
  133043. * Adds a whole within the polygon
  133044. * @param hole Array of points defining the hole
  133045. * @returns this
  133046. */
  133047. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133048. /**
  133049. * Creates the polygon
  133050. * @param updatable If the mesh should be updatable
  133051. * @param depth The depth of the mesh created
  133052. * @returns the created mesh
  133053. */
  133054. build(updatable?: boolean, depth?: number): Mesh;
  133055. /**
  133056. * Creates the polygon
  133057. * @param depth The depth of the mesh created
  133058. * @returns the created VertexData
  133059. */
  133060. buildVertexData(depth?: number): VertexData;
  133061. /**
  133062. * Adds a side to the polygon
  133063. * @param positions points that make the polygon
  133064. * @param normals normals of the polygon
  133065. * @param uvs uvs of the polygon
  133066. * @param indices indices of the polygon
  133067. * @param bounds bounds of the polygon
  133068. * @param points points of the polygon
  133069. * @param depth depth of the polygon
  133070. * @param flip flip of the polygon
  133071. */
  133072. private addSide;
  133073. }
  133074. }
  133075. declare module BABYLON {
  133076. /**
  133077. * Class containing static functions to help procedurally build meshes
  133078. */
  133079. export class PolygonBuilder {
  133080. /**
  133081. * Creates a polygon mesh
  133082. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133083. * * 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
  133084. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133087. * * Remember you can only change the shape positions, not their number when updating a polygon
  133088. * @param name defines the name of the mesh
  133089. * @param options defines the options used to create the mesh
  133090. * @param scene defines the hosting scene
  133091. * @param earcutInjection can be used to inject your own earcut reference
  133092. * @returns the polygon mesh
  133093. */
  133094. static CreatePolygon(name: string, options: {
  133095. shape: Vector3[];
  133096. holes?: Vector3[][];
  133097. depth?: number;
  133098. faceUV?: Vector4[];
  133099. faceColors?: Color4[];
  133100. updatable?: boolean;
  133101. sideOrientation?: number;
  133102. frontUVs?: Vector4;
  133103. backUVs?: Vector4;
  133104. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133105. /**
  133106. * Creates an extruded polygon mesh, with depth in the Y direction.
  133107. * * 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)
  133108. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133109. * @param name defines the name of the mesh
  133110. * @param options defines the options used to create the mesh
  133111. * @param scene defines the hosting scene
  133112. * @param earcutInjection can be used to inject your own earcut reference
  133113. * @returns the polygon mesh
  133114. */
  133115. static ExtrudePolygon(name: string, options: {
  133116. shape: Vector3[];
  133117. holes?: Vector3[][];
  133118. depth?: number;
  133119. faceUV?: Vector4[];
  133120. faceColors?: Color4[];
  133121. updatable?: boolean;
  133122. sideOrientation?: number;
  133123. frontUVs?: Vector4;
  133124. backUVs?: Vector4;
  133125. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133126. }
  133127. }
  133128. declare module BABYLON {
  133129. /**
  133130. * Class containing static functions to help procedurally build meshes
  133131. */
  133132. export class LatheBuilder {
  133133. /**
  133134. * Creates lathe mesh.
  133135. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133136. * * 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
  133137. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133138. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133139. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133140. * * 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
  133141. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133142. * * 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
  133143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133145. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133147. * @param name defines the name of the mesh
  133148. * @param options defines the options used to create the mesh
  133149. * @param scene defines the hosting scene
  133150. * @returns the lathe mesh
  133151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133152. */
  133153. static CreateLathe(name: string, options: {
  133154. shape: Vector3[];
  133155. radius?: number;
  133156. tessellation?: number;
  133157. clip?: number;
  133158. arc?: number;
  133159. closed?: boolean;
  133160. updatable?: boolean;
  133161. sideOrientation?: number;
  133162. frontUVs?: Vector4;
  133163. backUVs?: Vector4;
  133164. cap?: number;
  133165. invertUV?: boolean;
  133166. }, scene?: Nullable<Scene>): Mesh;
  133167. }
  133168. }
  133169. declare module BABYLON {
  133170. /**
  133171. * Class containing static functions to help procedurally build meshes
  133172. */
  133173. export class TiledPlaneBuilder {
  133174. /**
  133175. * Creates a tiled plane mesh
  133176. * * The parameter `pattern` will, depending on value, do nothing or
  133177. * * * flip (reflect about central vertical) alternate tiles across and up
  133178. * * * flip every tile on alternate rows
  133179. * * * rotate (180 degs) alternate tiles across and up
  133180. * * * rotate every tile on alternate rows
  133181. * * * flip and rotate alternate tiles across and up
  133182. * * * flip and rotate every tile on alternate rows
  133183. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  133184. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  133185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133187. * * 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)
  133188. * * 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)
  133189. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133190. * @param name defines the name of the mesh
  133191. * @param options defines the options used to create the mesh
  133192. * @param scene defines the hosting scene
  133193. * @returns the box mesh
  133194. */
  133195. static CreateTiledPlane(name: string, options: {
  133196. pattern?: number;
  133197. tileSize?: number;
  133198. tileWidth?: number;
  133199. tileHeight?: number;
  133200. size?: number;
  133201. width?: number;
  133202. height?: number;
  133203. alignHorizontal?: number;
  133204. alignVertical?: number;
  133205. sideOrientation?: number;
  133206. frontUVs?: Vector4;
  133207. backUVs?: Vector4;
  133208. updatable?: boolean;
  133209. }, scene?: Nullable<Scene>): Mesh;
  133210. }
  133211. }
  133212. declare module BABYLON {
  133213. /**
  133214. * Class containing static functions to help procedurally build meshes
  133215. */
  133216. export class TubeBuilder {
  133217. /**
  133218. * Creates a tube mesh.
  133219. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133220. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  133221. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  133222. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  133223. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  133224. * * 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)
  133225. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  133226. * * 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
  133227. * * 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
  133228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133230. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133232. * @param name defines the name of the mesh
  133233. * @param options defines the options used to create the mesh
  133234. * @param scene defines the hosting scene
  133235. * @returns the tube mesh
  133236. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133237. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  133238. */
  133239. static CreateTube(name: string, options: {
  133240. path: Vector3[];
  133241. radius?: number;
  133242. tessellation?: number;
  133243. radiusFunction?: {
  133244. (i: number, distance: number): number;
  133245. };
  133246. cap?: number;
  133247. arc?: number;
  133248. updatable?: boolean;
  133249. sideOrientation?: number;
  133250. frontUVs?: Vector4;
  133251. backUVs?: Vector4;
  133252. instance?: Mesh;
  133253. invertUV?: boolean;
  133254. }, scene?: Nullable<Scene>): Mesh;
  133255. }
  133256. }
  133257. declare module BABYLON {
  133258. /**
  133259. * Class containing static functions to help procedurally build meshes
  133260. */
  133261. export class IcoSphereBuilder {
  133262. /**
  133263. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133264. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133265. * * 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`)
  133266. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133267. * * 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
  133268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133271. * @param name defines the name of the mesh
  133272. * @param options defines the options used to create the mesh
  133273. * @param scene defines the hosting scene
  133274. * @returns the icosahedron mesh
  133275. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133276. */
  133277. static CreateIcoSphere(name: string, options: {
  133278. radius?: number;
  133279. radiusX?: number;
  133280. radiusY?: number;
  133281. radiusZ?: number;
  133282. flat?: boolean;
  133283. subdivisions?: number;
  133284. sideOrientation?: number;
  133285. frontUVs?: Vector4;
  133286. backUVs?: Vector4;
  133287. updatable?: boolean;
  133288. }, scene?: Nullable<Scene>): Mesh;
  133289. }
  133290. }
  133291. declare module BABYLON {
  133292. /**
  133293. * Class containing static functions to help procedurally build meshes
  133294. */
  133295. export class DecalBuilder {
  133296. /**
  133297. * Creates a decal mesh.
  133298. * 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
  133299. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  133300. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  133301. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  133302. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  133303. * @param name defines the name of the mesh
  133304. * @param sourceMesh defines the mesh where the decal must be applied
  133305. * @param options defines the options used to create the mesh
  133306. * @param scene defines the hosting scene
  133307. * @returns the decal mesh
  133308. * @see https://doc.babylonjs.com/how_to/decals
  133309. */
  133310. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  133311. position?: Vector3;
  133312. normal?: Vector3;
  133313. size?: Vector3;
  133314. angle?: number;
  133315. }): Mesh;
  133316. }
  133317. }
  133318. declare module BABYLON {
  133319. /**
  133320. * Class containing static functions to help procedurally build meshes
  133321. */
  133322. export class MeshBuilder {
  133323. /**
  133324. * Creates a box mesh
  133325. * * The parameter `size` sets the size (float) of each box side (default 1)
  133326. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  133327. * * 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)
  133328. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133332. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133333. * @param name defines the name of the mesh
  133334. * @param options defines the options used to create the mesh
  133335. * @param scene defines the hosting scene
  133336. * @returns the box mesh
  133337. */
  133338. static CreateBox(name: string, options: {
  133339. size?: number;
  133340. width?: number;
  133341. height?: number;
  133342. depth?: number;
  133343. faceUV?: Vector4[];
  133344. faceColors?: Color4[];
  133345. sideOrientation?: number;
  133346. frontUVs?: Vector4;
  133347. backUVs?: Vector4;
  133348. updatable?: boolean;
  133349. }, scene?: Nullable<Scene>): Mesh;
  133350. /**
  133351. * Creates a tiled box mesh
  133352. * * faceTiles sets the pattern, tile size and number of tiles for a face
  133353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133354. * @param name defines the name of the mesh
  133355. * @param options defines the options used to create the mesh
  133356. * @param scene defines the hosting scene
  133357. * @returns the tiled box mesh
  133358. */
  133359. static CreateTiledBox(name: string, options: {
  133360. pattern?: number;
  133361. size?: number;
  133362. width?: number;
  133363. height?: number;
  133364. depth: number;
  133365. tileSize?: number;
  133366. tileWidth?: number;
  133367. tileHeight?: number;
  133368. faceUV?: Vector4[];
  133369. faceColors?: Color4[];
  133370. alignHorizontal?: number;
  133371. alignVertical?: number;
  133372. sideOrientation?: number;
  133373. updatable?: boolean;
  133374. }, scene?: Nullable<Scene>): Mesh;
  133375. /**
  133376. * Creates a sphere mesh
  133377. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133378. * * 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`)
  133379. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133380. * * 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
  133381. * * 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)
  133382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133385. * @param name defines the name of the mesh
  133386. * @param options defines the options used to create the mesh
  133387. * @param scene defines the hosting scene
  133388. * @returns the sphere mesh
  133389. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133390. */
  133391. static CreateSphere(name: string, options: {
  133392. segments?: number;
  133393. diameter?: number;
  133394. diameterX?: number;
  133395. diameterY?: number;
  133396. diameterZ?: number;
  133397. arc?: number;
  133398. slice?: number;
  133399. sideOrientation?: number;
  133400. frontUVs?: Vector4;
  133401. backUVs?: Vector4;
  133402. updatable?: boolean;
  133403. }, scene?: Nullable<Scene>): Mesh;
  133404. /**
  133405. * Creates a plane polygonal mesh. By default, this is a disc
  133406. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  133407. * * 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
  133408. * * 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
  133409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133412. * @param name defines the name of the mesh
  133413. * @param options defines the options used to create the mesh
  133414. * @param scene defines the hosting scene
  133415. * @returns the plane polygonal mesh
  133416. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  133417. */
  133418. static CreateDisc(name: string, options: {
  133419. radius?: number;
  133420. tessellation?: number;
  133421. arc?: number;
  133422. updatable?: boolean;
  133423. sideOrientation?: number;
  133424. frontUVs?: Vector4;
  133425. backUVs?: Vector4;
  133426. }, scene?: Nullable<Scene>): Mesh;
  133427. /**
  133428. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133429. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133430. * * 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`)
  133431. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133432. * * 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
  133433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133436. * @param name defines the name of the mesh
  133437. * @param options defines the options used to create the mesh
  133438. * @param scene defines the hosting scene
  133439. * @returns the icosahedron mesh
  133440. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133441. */
  133442. static CreateIcoSphere(name: string, options: {
  133443. radius?: number;
  133444. radiusX?: number;
  133445. radiusY?: number;
  133446. radiusZ?: number;
  133447. flat?: boolean;
  133448. subdivisions?: number;
  133449. sideOrientation?: number;
  133450. frontUVs?: Vector4;
  133451. backUVs?: Vector4;
  133452. updatable?: boolean;
  133453. }, scene?: Nullable<Scene>): Mesh;
  133454. /**
  133455. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133456. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  133457. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  133458. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  133459. * * 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
  133460. * * 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
  133461. * * 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
  133462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133465. * * 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
  133466. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  133467. * * 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
  133468. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  133469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133470. * @param name defines the name of the mesh
  133471. * @param options defines the options used to create the mesh
  133472. * @param scene defines the hosting scene
  133473. * @returns the ribbon mesh
  133474. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  133475. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133476. */
  133477. static CreateRibbon(name: string, options: {
  133478. pathArray: Vector3[][];
  133479. closeArray?: boolean;
  133480. closePath?: boolean;
  133481. offset?: number;
  133482. updatable?: boolean;
  133483. sideOrientation?: number;
  133484. frontUVs?: Vector4;
  133485. backUVs?: Vector4;
  133486. instance?: Mesh;
  133487. invertUV?: boolean;
  133488. uvs?: Vector2[];
  133489. colors?: Color4[];
  133490. }, scene?: Nullable<Scene>): Mesh;
  133491. /**
  133492. * Creates a cylinder or a cone mesh
  133493. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  133494. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  133495. * * 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.
  133496. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  133497. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  133498. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  133499. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  133500. * * 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).
  133501. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  133502. * * 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).
  133503. * * 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
  133504. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  133505. * * 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
  133506. * * 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.
  133507. * * If `enclose` is false, a ring surface is one element.
  133508. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  133509. * * 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
  133510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133513. * @param name defines the name of the mesh
  133514. * @param options defines the options used to create the mesh
  133515. * @param scene defines the hosting scene
  133516. * @returns the cylinder mesh
  133517. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  133518. */
  133519. static CreateCylinder(name: string, options: {
  133520. height?: number;
  133521. diameterTop?: number;
  133522. diameterBottom?: number;
  133523. diameter?: number;
  133524. tessellation?: number;
  133525. subdivisions?: number;
  133526. arc?: number;
  133527. faceColors?: Color4[];
  133528. faceUV?: Vector4[];
  133529. updatable?: boolean;
  133530. hasRings?: boolean;
  133531. enclose?: boolean;
  133532. cap?: number;
  133533. sideOrientation?: number;
  133534. frontUVs?: Vector4;
  133535. backUVs?: Vector4;
  133536. }, scene?: Nullable<Scene>): Mesh;
  133537. /**
  133538. * Creates a torus mesh
  133539. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  133540. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  133541. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  133542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133545. * @param name defines the name of the mesh
  133546. * @param options defines the options used to create the mesh
  133547. * @param scene defines the hosting scene
  133548. * @returns the torus mesh
  133549. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  133550. */
  133551. static CreateTorus(name: string, options: {
  133552. diameter?: number;
  133553. thickness?: number;
  133554. tessellation?: number;
  133555. updatable?: boolean;
  133556. sideOrientation?: number;
  133557. frontUVs?: Vector4;
  133558. backUVs?: Vector4;
  133559. }, scene?: Nullable<Scene>): Mesh;
  133560. /**
  133561. * Creates a torus knot mesh
  133562. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133563. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133564. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133565. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133569. * @param name defines the name of the mesh
  133570. * @param options defines the options used to create the mesh
  133571. * @param scene defines the hosting scene
  133572. * @returns the torus knot mesh
  133573. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133574. */
  133575. static CreateTorusKnot(name: string, options: {
  133576. radius?: number;
  133577. tube?: number;
  133578. radialSegments?: number;
  133579. tubularSegments?: number;
  133580. p?: number;
  133581. q?: number;
  133582. updatable?: boolean;
  133583. sideOrientation?: number;
  133584. frontUVs?: Vector4;
  133585. backUVs?: Vector4;
  133586. }, scene?: Nullable<Scene>): Mesh;
  133587. /**
  133588. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133589. * * 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
  133590. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133591. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133592. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133593. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133594. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133595. * * 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
  133596. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133599. * @param name defines the name of the new line system
  133600. * @param options defines the options used to create the line system
  133601. * @param scene defines the hosting scene
  133602. * @returns a new line system mesh
  133603. */
  133604. static CreateLineSystem(name: string, options: {
  133605. lines: Vector3[][];
  133606. updatable?: boolean;
  133607. instance?: Nullable<LinesMesh>;
  133608. colors?: Nullable<Color4[][]>;
  133609. useVertexAlpha?: boolean;
  133610. }, scene: Nullable<Scene>): LinesMesh;
  133611. /**
  133612. * Creates a line mesh
  133613. * 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
  133614. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133615. * * The parameter `points` is an array successive Vector3
  133616. * * 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
  133617. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133618. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133619. * * When updating an instance, remember that only point positions can change, not the number of points
  133620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133622. * @param name defines the name of the new line system
  133623. * @param options defines the options used to create the line system
  133624. * @param scene defines the hosting scene
  133625. * @returns a new line mesh
  133626. */
  133627. static CreateLines(name: string, options: {
  133628. points: Vector3[];
  133629. updatable?: boolean;
  133630. instance?: Nullable<LinesMesh>;
  133631. colors?: Color4[];
  133632. useVertexAlpha?: boolean;
  133633. }, scene?: Nullable<Scene>): LinesMesh;
  133634. /**
  133635. * Creates a dashed line mesh
  133636. * * 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
  133637. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133638. * * The parameter `points` is an array successive Vector3
  133639. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133640. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133641. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133642. * * 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
  133643. * * When updating an instance, remember that only point positions can change, not the number of points
  133644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133645. * @param name defines the name of the mesh
  133646. * @param options defines the options used to create the mesh
  133647. * @param scene defines the hosting scene
  133648. * @returns the dashed line mesh
  133649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133650. */
  133651. static CreateDashedLines(name: string, options: {
  133652. points: Vector3[];
  133653. dashSize?: number;
  133654. gapSize?: number;
  133655. dashNb?: number;
  133656. updatable?: boolean;
  133657. instance?: LinesMesh;
  133658. }, scene?: Nullable<Scene>): LinesMesh;
  133659. /**
  133660. * 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.
  133661. * * 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.
  133662. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133663. * * 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.
  133664. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  133665. * * 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
  133666. * * 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
  133667. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  133668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  133671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133672. * @param name defines the name of the mesh
  133673. * @param options defines the options used to create the mesh
  133674. * @param scene defines the hosting scene
  133675. * @returns the extruded shape mesh
  133676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133678. */
  133679. static ExtrudeShape(name: string, options: {
  133680. shape: Vector3[];
  133681. path: Vector3[];
  133682. scale?: number;
  133683. rotation?: number;
  133684. cap?: number;
  133685. updatable?: boolean;
  133686. sideOrientation?: number;
  133687. frontUVs?: Vector4;
  133688. backUVs?: Vector4;
  133689. instance?: Mesh;
  133690. invertUV?: boolean;
  133691. }, scene?: Nullable<Scene>): Mesh;
  133692. /**
  133693. * Creates an custom extruded shape mesh.
  133694. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  133695. * * 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.
  133696. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133697. * * 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
  133698. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  133699. * * 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
  133700. * * It must returns a float value that will be the scale value applied to the shape on each path point
  133701. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  133702. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  133703. * * 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
  133704. * * 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
  133705. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  133706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133710. * @param name defines the name of the mesh
  133711. * @param options defines the options used to create the mesh
  133712. * @param scene defines the hosting scene
  133713. * @returns the custom extruded shape mesh
  133714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  133715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133717. */
  133718. static ExtrudeShapeCustom(name: string, options: {
  133719. shape: Vector3[];
  133720. path: Vector3[];
  133721. scaleFunction?: any;
  133722. rotationFunction?: any;
  133723. ribbonCloseArray?: boolean;
  133724. ribbonClosePath?: boolean;
  133725. cap?: number;
  133726. updatable?: boolean;
  133727. sideOrientation?: number;
  133728. frontUVs?: Vector4;
  133729. backUVs?: Vector4;
  133730. instance?: Mesh;
  133731. invertUV?: boolean;
  133732. }, scene?: Nullable<Scene>): Mesh;
  133733. /**
  133734. * Creates lathe mesh.
  133735. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133736. * * 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
  133737. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133738. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133739. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133740. * * 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
  133741. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133742. * * 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
  133743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133745. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133747. * @param name defines the name of the mesh
  133748. * @param options defines the options used to create the mesh
  133749. * @param scene defines the hosting scene
  133750. * @returns the lathe mesh
  133751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133752. */
  133753. static CreateLathe(name: string, options: {
  133754. shape: Vector3[];
  133755. radius?: number;
  133756. tessellation?: number;
  133757. clip?: number;
  133758. arc?: number;
  133759. closed?: boolean;
  133760. updatable?: boolean;
  133761. sideOrientation?: number;
  133762. frontUVs?: Vector4;
  133763. backUVs?: Vector4;
  133764. cap?: number;
  133765. invertUV?: boolean;
  133766. }, scene?: Nullable<Scene>): Mesh;
  133767. /**
  133768. * Creates a tiled plane mesh
  133769. * * You can set a limited pattern arrangement with the tiles
  133770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133773. * @param name defines the name of the mesh
  133774. * @param options defines the options used to create the mesh
  133775. * @param scene defines the hosting scene
  133776. * @returns the plane mesh
  133777. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  133778. */
  133779. static CreateTiledPlane(name: string, options: {
  133780. pattern?: number;
  133781. tileSize?: number;
  133782. tileWidth?: number;
  133783. tileHeight?: number;
  133784. size?: number;
  133785. width?: number;
  133786. height?: number;
  133787. alignHorizontal?: number;
  133788. alignVertical?: number;
  133789. sideOrientation?: number;
  133790. frontUVs?: Vector4;
  133791. backUVs?: Vector4;
  133792. updatable?: boolean;
  133793. }, scene?: Nullable<Scene>): Mesh;
  133794. /**
  133795. * Creates a plane mesh
  133796. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  133797. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  133798. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  133799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133802. * @param name defines the name of the mesh
  133803. * @param options defines the options used to create the mesh
  133804. * @param scene defines the hosting scene
  133805. * @returns the plane mesh
  133806. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  133807. */
  133808. static CreatePlane(name: string, options: {
  133809. size?: number;
  133810. width?: number;
  133811. height?: number;
  133812. sideOrientation?: number;
  133813. frontUVs?: Vector4;
  133814. backUVs?: Vector4;
  133815. updatable?: boolean;
  133816. sourcePlane?: Plane;
  133817. }, scene?: Nullable<Scene>): Mesh;
  133818. /**
  133819. * Creates a ground mesh
  133820. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  133821. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  133822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133823. * @param name defines the name of the mesh
  133824. * @param options defines the options used to create the mesh
  133825. * @param scene defines the hosting scene
  133826. * @returns the ground mesh
  133827. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  133828. */
  133829. static CreateGround(name: string, options: {
  133830. width?: number;
  133831. height?: number;
  133832. subdivisions?: number;
  133833. subdivisionsX?: number;
  133834. subdivisionsY?: number;
  133835. updatable?: boolean;
  133836. }, scene?: Nullable<Scene>): Mesh;
  133837. /**
  133838. * Creates a tiled ground mesh
  133839. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  133840. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  133841. * * 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
  133842. * * 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
  133843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133844. * @param name defines the name of the mesh
  133845. * @param options defines the options used to create the mesh
  133846. * @param scene defines the hosting scene
  133847. * @returns the tiled ground mesh
  133848. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  133849. */
  133850. static CreateTiledGround(name: string, options: {
  133851. xmin: number;
  133852. zmin: number;
  133853. xmax: number;
  133854. zmax: number;
  133855. subdivisions?: {
  133856. w: number;
  133857. h: number;
  133858. };
  133859. precision?: {
  133860. w: number;
  133861. h: number;
  133862. };
  133863. updatable?: boolean;
  133864. }, scene?: Nullable<Scene>): Mesh;
  133865. /**
  133866. * Creates a ground mesh from a height map
  133867. * * The parameter `url` sets the URL of the height map image resource.
  133868. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  133869. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  133870. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  133871. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  133872. * * 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.
  133873. * * 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).
  133874. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  133875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133876. * @param name defines the name of the mesh
  133877. * @param url defines the url to the height map
  133878. * @param options defines the options used to create the mesh
  133879. * @param scene defines the hosting scene
  133880. * @returns the ground mesh
  133881. * @see https://doc.babylonjs.com/babylon101/height_map
  133882. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  133883. */
  133884. static CreateGroundFromHeightMap(name: string, url: string, options: {
  133885. width?: number;
  133886. height?: number;
  133887. subdivisions?: number;
  133888. minHeight?: number;
  133889. maxHeight?: number;
  133890. colorFilter?: Color3;
  133891. alphaFilter?: number;
  133892. updatable?: boolean;
  133893. onReady?: (mesh: GroundMesh) => void;
  133894. }, scene?: Nullable<Scene>): GroundMesh;
  133895. /**
  133896. * Creates a polygon mesh
  133897. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133898. * * 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
  133899. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133902. * * Remember you can only change the shape positions, not their number when updating a polygon
  133903. * @param name defines the name of the mesh
  133904. * @param options defines the options used to create the mesh
  133905. * @param scene defines the hosting scene
  133906. * @param earcutInjection can be used to inject your own earcut reference
  133907. * @returns the polygon mesh
  133908. */
  133909. static CreatePolygon(name: string, options: {
  133910. shape: Vector3[];
  133911. holes?: Vector3[][];
  133912. depth?: number;
  133913. faceUV?: Vector4[];
  133914. faceColors?: Color4[];
  133915. updatable?: boolean;
  133916. sideOrientation?: number;
  133917. frontUVs?: Vector4;
  133918. backUVs?: Vector4;
  133919. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133920. /**
  133921. * Creates an extruded polygon mesh, with depth in the Y direction.
  133922. * * 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)
  133923. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133924. * @param name defines the name of the mesh
  133925. * @param options defines the options used to create the mesh
  133926. * @param scene defines the hosting scene
  133927. * @param earcutInjection can be used to inject your own earcut reference
  133928. * @returns the polygon mesh
  133929. */
  133930. static ExtrudePolygon(name: string, options: {
  133931. shape: Vector3[];
  133932. holes?: Vector3[][];
  133933. depth?: number;
  133934. faceUV?: Vector4[];
  133935. faceColors?: Color4[];
  133936. updatable?: boolean;
  133937. sideOrientation?: number;
  133938. frontUVs?: Vector4;
  133939. backUVs?: Vector4;
  133940. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133941. /**
  133942. * Creates a tube mesh.
  133943. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133944. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  133945. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  133946. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  133947. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  133948. * * 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)
  133949. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  133950. * * 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
  133951. * * 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
  133952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133954. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133956. * @param name defines the name of the mesh
  133957. * @param options defines the options used to create the mesh
  133958. * @param scene defines the hosting scene
  133959. * @returns the tube mesh
  133960. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133961. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  133962. */
  133963. static CreateTube(name: string, options: {
  133964. path: Vector3[];
  133965. radius?: number;
  133966. tessellation?: number;
  133967. radiusFunction?: {
  133968. (i: number, distance: number): number;
  133969. };
  133970. cap?: number;
  133971. arc?: number;
  133972. updatable?: boolean;
  133973. sideOrientation?: number;
  133974. frontUVs?: Vector4;
  133975. backUVs?: Vector4;
  133976. instance?: Mesh;
  133977. invertUV?: boolean;
  133978. }, scene?: Nullable<Scene>): Mesh;
  133979. /**
  133980. * Creates a polyhedron mesh
  133981. * * 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
  133982. * * The parameter `size` (positive float, default 1) sets the polygon size
  133983. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133984. * * 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`
  133985. * * 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
  133986. * * 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)`)
  133987. * * 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
  133988. * * 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
  133989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133992. * @param name defines the name of the mesh
  133993. * @param options defines the options used to create the mesh
  133994. * @param scene defines the hosting scene
  133995. * @returns the polyhedron mesh
  133996. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133997. */
  133998. static CreatePolyhedron(name: string, options: {
  133999. type?: number;
  134000. size?: number;
  134001. sizeX?: number;
  134002. sizeY?: number;
  134003. sizeZ?: number;
  134004. custom?: any;
  134005. faceUV?: Vector4[];
  134006. faceColors?: Color4[];
  134007. flat?: boolean;
  134008. updatable?: boolean;
  134009. sideOrientation?: number;
  134010. frontUVs?: Vector4;
  134011. backUVs?: Vector4;
  134012. }, scene?: Nullable<Scene>): Mesh;
  134013. /**
  134014. * Creates a decal mesh.
  134015. * 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
  134016. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134017. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134018. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134019. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134020. * @param name defines the name of the mesh
  134021. * @param sourceMesh defines the mesh where the decal must be applied
  134022. * @param options defines the options used to create the mesh
  134023. * @param scene defines the hosting scene
  134024. * @returns the decal mesh
  134025. * @see https://doc.babylonjs.com/how_to/decals
  134026. */
  134027. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134028. position?: Vector3;
  134029. normal?: Vector3;
  134030. size?: Vector3;
  134031. angle?: number;
  134032. }): Mesh;
  134033. }
  134034. }
  134035. declare module BABYLON {
  134036. /**
  134037. * A simplifier interface for future simplification implementations
  134038. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134039. */
  134040. export interface ISimplifier {
  134041. /**
  134042. * Simplification of a given mesh according to the given settings.
  134043. * Since this requires computation, it is assumed that the function runs async.
  134044. * @param settings The settings of the simplification, including quality and distance
  134045. * @param successCallback A callback that will be called after the mesh was simplified.
  134046. * @param errorCallback in case of an error, this callback will be called. optional.
  134047. */
  134048. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134049. }
  134050. /**
  134051. * Expected simplification settings.
  134052. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134053. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134054. */
  134055. export interface ISimplificationSettings {
  134056. /**
  134057. * Gets or sets the expected quality
  134058. */
  134059. quality: number;
  134060. /**
  134061. * Gets or sets the distance when this optimized version should be used
  134062. */
  134063. distance: number;
  134064. /**
  134065. * Gets an already optimized mesh
  134066. */
  134067. optimizeMesh?: boolean;
  134068. }
  134069. /**
  134070. * Class used to specify simplification options
  134071. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134072. */
  134073. export class SimplificationSettings implements ISimplificationSettings {
  134074. /** expected quality */
  134075. quality: number;
  134076. /** distance when this optimized version should be used */
  134077. distance: number;
  134078. /** already optimized mesh */
  134079. optimizeMesh?: boolean | undefined;
  134080. /**
  134081. * Creates a SimplificationSettings
  134082. * @param quality expected quality
  134083. * @param distance distance when this optimized version should be used
  134084. * @param optimizeMesh already optimized mesh
  134085. */
  134086. constructor(
  134087. /** expected quality */
  134088. quality: number,
  134089. /** distance when this optimized version should be used */
  134090. distance: number,
  134091. /** already optimized mesh */
  134092. optimizeMesh?: boolean | undefined);
  134093. }
  134094. /**
  134095. * Interface used to define a simplification task
  134096. */
  134097. export interface ISimplificationTask {
  134098. /**
  134099. * Array of settings
  134100. */
  134101. settings: Array<ISimplificationSettings>;
  134102. /**
  134103. * Simplification type
  134104. */
  134105. simplificationType: SimplificationType;
  134106. /**
  134107. * Mesh to simplify
  134108. */
  134109. mesh: Mesh;
  134110. /**
  134111. * Callback called on success
  134112. */
  134113. successCallback?: () => void;
  134114. /**
  134115. * Defines if parallel processing can be used
  134116. */
  134117. parallelProcessing: boolean;
  134118. }
  134119. /**
  134120. * Queue used to order the simplification tasks
  134121. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134122. */
  134123. export class SimplificationQueue {
  134124. private _simplificationArray;
  134125. /**
  134126. * Gets a boolean indicating that the process is still running
  134127. */
  134128. running: boolean;
  134129. /**
  134130. * Creates a new queue
  134131. */
  134132. constructor();
  134133. /**
  134134. * Adds a new simplification task
  134135. * @param task defines a task to add
  134136. */
  134137. addTask(task: ISimplificationTask): void;
  134138. /**
  134139. * Execute next task
  134140. */
  134141. executeNext(): void;
  134142. /**
  134143. * Execute a simplification task
  134144. * @param task defines the task to run
  134145. */
  134146. runSimplification(task: ISimplificationTask): void;
  134147. private getSimplifier;
  134148. }
  134149. /**
  134150. * The implemented types of simplification
  134151. * At the moment only Quadratic Error Decimation is implemented
  134152. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134153. */
  134154. export enum SimplificationType {
  134155. /** Quadratic error decimation */
  134156. QUADRATIC = 0
  134157. }
  134158. }
  134159. declare module BABYLON {
  134160. interface Scene {
  134161. /** @hidden (Backing field) */
  134162. _simplificationQueue: SimplificationQueue;
  134163. /**
  134164. * Gets or sets the simplification queue attached to the scene
  134165. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134166. */
  134167. simplificationQueue: SimplificationQueue;
  134168. }
  134169. interface Mesh {
  134170. /**
  134171. * Simplify the mesh according to the given array of settings.
  134172. * Function will return immediately and will simplify async
  134173. * @param settings a collection of simplification settings
  134174. * @param parallelProcessing should all levels calculate parallel or one after the other
  134175. * @param simplificationType the type of simplification to run
  134176. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  134177. * @returns the current mesh
  134178. */
  134179. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  134180. }
  134181. /**
  134182. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  134183. * created in a scene
  134184. */
  134185. export class SimplicationQueueSceneComponent implements ISceneComponent {
  134186. /**
  134187. * The component name helpfull to identify the component in the list of scene components.
  134188. */
  134189. readonly name: string;
  134190. /**
  134191. * The scene the component belongs to.
  134192. */
  134193. scene: Scene;
  134194. /**
  134195. * Creates a new instance of the component for the given scene
  134196. * @param scene Defines the scene to register the component in
  134197. */
  134198. constructor(scene: Scene);
  134199. /**
  134200. * Registers the component in a given scene
  134201. */
  134202. register(): void;
  134203. /**
  134204. * Rebuilds the elements related to this component in case of
  134205. * context lost for instance.
  134206. */
  134207. rebuild(): void;
  134208. /**
  134209. * Disposes the component and the associated ressources
  134210. */
  134211. dispose(): void;
  134212. private _beforeCameraUpdate;
  134213. }
  134214. }
  134215. declare module BABYLON {
  134216. /**
  134217. * Navigation plugin interface to add navigation constrained by a navigation mesh
  134218. */
  134219. export interface INavigationEnginePlugin {
  134220. /**
  134221. * plugin name
  134222. */
  134223. name: string;
  134224. /**
  134225. * Creates a navigation mesh
  134226. * @param meshes array of all the geometry used to compute the navigatio mesh
  134227. * @param parameters bunch of parameters used to filter geometry
  134228. */
  134229. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134230. /**
  134231. * Create a navigation mesh debug mesh
  134232. * @param scene is where the mesh will be added
  134233. * @returns debug display mesh
  134234. */
  134235. createDebugNavMesh(scene: Scene): Mesh;
  134236. /**
  134237. * Get a navigation mesh constrained position, closest to the parameter position
  134238. * @param position world position
  134239. * @returns the closest point to position constrained by the navigation mesh
  134240. */
  134241. getClosestPoint(position: Vector3): Vector3;
  134242. /**
  134243. * Get a navigation mesh constrained position, within a particular radius
  134244. * @param position world position
  134245. * @param maxRadius the maximum distance to the constrained world position
  134246. * @returns the closest point to position constrained by the navigation mesh
  134247. */
  134248. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134249. /**
  134250. * Compute the final position from a segment made of destination-position
  134251. * @param position world position
  134252. * @param destination world position
  134253. * @returns the resulting point along the navmesh
  134254. */
  134255. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134256. /**
  134257. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134258. * @param start world position
  134259. * @param end world position
  134260. * @returns array containing world position composing the path
  134261. */
  134262. computePath(start: Vector3, end: Vector3): Vector3[];
  134263. /**
  134264. * If this plugin is supported
  134265. * @returns true if plugin is supported
  134266. */
  134267. isSupported(): boolean;
  134268. /**
  134269. * Create a new Crowd so you can add agents
  134270. * @param maxAgents the maximum agent count in the crowd
  134271. * @param maxAgentRadius the maximum radius an agent can have
  134272. * @param scene to attach the crowd to
  134273. * @returns the crowd you can add agents to
  134274. */
  134275. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134276. /**
  134277. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134278. * The queries will try to find a solution within those bounds
  134279. * default is (1,1,1)
  134280. * @param extent x,y,z value that define the extent around the queries point of reference
  134281. */
  134282. setDefaultQueryExtent(extent: Vector3): void;
  134283. /**
  134284. * Get the Bounding box extent specified by setDefaultQueryExtent
  134285. * @returns the box extent values
  134286. */
  134287. getDefaultQueryExtent(): Vector3;
  134288. /**
  134289. * Release all resources
  134290. */
  134291. dispose(): void;
  134292. }
  134293. /**
  134294. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  134295. */
  134296. export interface ICrowd {
  134297. /**
  134298. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134299. * You can attach anything to that node. The node position is updated in the scene update tick.
  134300. * @param pos world position that will be constrained by the navigation mesh
  134301. * @param parameters agent parameters
  134302. * @param transform hooked to the agent that will be update by the scene
  134303. * @returns agent index
  134304. */
  134305. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134306. /**
  134307. * Returns the agent position in world space
  134308. * @param index agent index returned by addAgent
  134309. * @returns world space position
  134310. */
  134311. getAgentPosition(index: number): Vector3;
  134312. /**
  134313. * Gets the agent velocity in world space
  134314. * @param index agent index returned by addAgent
  134315. * @returns world space velocity
  134316. */
  134317. getAgentVelocity(index: number): Vector3;
  134318. /**
  134319. * remove a particular agent previously created
  134320. * @param index agent index returned by addAgent
  134321. */
  134322. removeAgent(index: number): void;
  134323. /**
  134324. * get the list of all agents attached to this crowd
  134325. * @returns list of agent indices
  134326. */
  134327. getAgents(): number[];
  134328. /**
  134329. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134330. * @param deltaTime in seconds
  134331. */
  134332. update(deltaTime: number): void;
  134333. /**
  134334. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134335. * @param index agent index returned by addAgent
  134336. * @param destination targeted world position
  134337. */
  134338. agentGoto(index: number, destination: Vector3): void;
  134339. /**
  134340. * Teleport the agent to a new position
  134341. * @param index agent index returned by addAgent
  134342. * @param destination targeted world position
  134343. */
  134344. agentTeleport(index: number, destination: Vector3): void;
  134345. /**
  134346. * Update agent parameters
  134347. * @param index agent index returned by addAgent
  134348. * @param parameters agent parameters
  134349. */
  134350. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  134351. /**
  134352. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134353. * The queries will try to find a solution within those bounds
  134354. * default is (1,1,1)
  134355. * @param extent x,y,z value that define the extent around the queries point of reference
  134356. */
  134357. setDefaultQueryExtent(extent: Vector3): void;
  134358. /**
  134359. * Get the Bounding box extent specified by setDefaultQueryExtent
  134360. * @returns the box extent values
  134361. */
  134362. getDefaultQueryExtent(): Vector3;
  134363. /**
  134364. * Release all resources
  134365. */
  134366. dispose(): void;
  134367. }
  134368. /**
  134369. * Configures an agent
  134370. */
  134371. export interface IAgentParameters {
  134372. /**
  134373. * Agent radius. [Limit: >= 0]
  134374. */
  134375. radius: number;
  134376. /**
  134377. * Agent height. [Limit: > 0]
  134378. */
  134379. height: number;
  134380. /**
  134381. * Maximum allowed acceleration. [Limit: >= 0]
  134382. */
  134383. maxAcceleration: number;
  134384. /**
  134385. * Maximum allowed speed. [Limit: >= 0]
  134386. */
  134387. maxSpeed: number;
  134388. /**
  134389. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  134390. */
  134391. collisionQueryRange: number;
  134392. /**
  134393. * The path visibility optimization range. [Limit: > 0]
  134394. */
  134395. pathOptimizationRange: number;
  134396. /**
  134397. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  134398. */
  134399. separationWeight: number;
  134400. }
  134401. /**
  134402. * Configures the navigation mesh creation
  134403. */
  134404. export interface INavMeshParameters {
  134405. /**
  134406. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  134407. */
  134408. cs: number;
  134409. /**
  134410. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  134411. */
  134412. ch: number;
  134413. /**
  134414. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  134415. */
  134416. walkableSlopeAngle: number;
  134417. /**
  134418. * Minimum floor to 'ceiling' height that will still allow the floor area to
  134419. * be considered walkable. [Limit: >= 3] [Units: vx]
  134420. */
  134421. walkableHeight: number;
  134422. /**
  134423. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  134424. */
  134425. walkableClimb: number;
  134426. /**
  134427. * The distance to erode/shrink the walkable area of the heightfield away from
  134428. * obstructions. [Limit: >=0] [Units: vx]
  134429. */
  134430. walkableRadius: number;
  134431. /**
  134432. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  134433. */
  134434. maxEdgeLen: number;
  134435. /**
  134436. * The maximum distance a simplfied contour's border edges should deviate
  134437. * the original raw contour. [Limit: >=0] [Units: vx]
  134438. */
  134439. maxSimplificationError: number;
  134440. /**
  134441. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  134442. */
  134443. minRegionArea: number;
  134444. /**
  134445. * Any regions with a span count smaller than this value will, if possible,
  134446. * be merged with larger regions. [Limit: >=0] [Units: vx]
  134447. */
  134448. mergeRegionArea: number;
  134449. /**
  134450. * The maximum number of vertices allowed for polygons generated during the
  134451. * contour to polygon conversion process. [Limit: >= 3]
  134452. */
  134453. maxVertsPerPoly: number;
  134454. /**
  134455. * Sets the sampling distance to use when generating the detail mesh.
  134456. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  134457. */
  134458. detailSampleDist: number;
  134459. /**
  134460. * The maximum distance the detail mesh surface should deviate from heightfield
  134461. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  134462. */
  134463. detailSampleMaxError: number;
  134464. }
  134465. }
  134466. declare module BABYLON {
  134467. /**
  134468. * RecastJS navigation plugin
  134469. */
  134470. export class RecastJSPlugin implements INavigationEnginePlugin {
  134471. /**
  134472. * Reference to the Recast library
  134473. */
  134474. bjsRECAST: any;
  134475. /**
  134476. * plugin name
  134477. */
  134478. name: string;
  134479. /**
  134480. * the first navmesh created. We might extend this to support multiple navmeshes
  134481. */
  134482. navMesh: any;
  134483. /**
  134484. * Initializes the recastJS plugin
  134485. * @param recastInjection can be used to inject your own recast reference
  134486. */
  134487. constructor(recastInjection?: any);
  134488. /**
  134489. * Creates a navigation mesh
  134490. * @param meshes array of all the geometry used to compute the navigatio mesh
  134491. * @param parameters bunch of parameters used to filter geometry
  134492. */
  134493. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134494. /**
  134495. * Create a navigation mesh debug mesh
  134496. * @param scene is where the mesh will be added
  134497. * @returns debug display mesh
  134498. */
  134499. createDebugNavMesh(scene: Scene): Mesh;
  134500. /**
  134501. * Get a navigation mesh constrained position, closest to the parameter position
  134502. * @param position world position
  134503. * @returns the closest point to position constrained by the navigation mesh
  134504. */
  134505. getClosestPoint(position: Vector3): Vector3;
  134506. /**
  134507. * Get a navigation mesh constrained position, within a particular radius
  134508. * @param position world position
  134509. * @param maxRadius the maximum distance to the constrained world position
  134510. * @returns the closest point to position constrained by the navigation mesh
  134511. */
  134512. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134513. /**
  134514. * Compute the final position from a segment made of destination-position
  134515. * @param position world position
  134516. * @param destination world position
  134517. * @returns the resulting point along the navmesh
  134518. */
  134519. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134520. /**
  134521. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134522. * @param start world position
  134523. * @param end world position
  134524. * @returns array containing world position composing the path
  134525. */
  134526. computePath(start: Vector3, end: Vector3): Vector3[];
  134527. /**
  134528. * Create a new Crowd so you can add agents
  134529. * @param maxAgents the maximum agent count in the crowd
  134530. * @param maxAgentRadius the maximum radius an agent can have
  134531. * @param scene to attach the crowd to
  134532. * @returns the crowd you can add agents to
  134533. */
  134534. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134535. /**
  134536. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134537. * The queries will try to find a solution within those bounds
  134538. * default is (1,1,1)
  134539. * @param extent x,y,z value that define the extent around the queries point of reference
  134540. */
  134541. setDefaultQueryExtent(extent: Vector3): void;
  134542. /**
  134543. * Get the Bounding box extent specified by setDefaultQueryExtent
  134544. * @returns the box extent values
  134545. */
  134546. getDefaultQueryExtent(): Vector3;
  134547. /**
  134548. * Disposes
  134549. */
  134550. dispose(): void;
  134551. /**
  134552. * If this plugin is supported
  134553. * @returns true if plugin is supported
  134554. */
  134555. isSupported(): boolean;
  134556. }
  134557. /**
  134558. * Recast detour crowd implementation
  134559. */
  134560. export class RecastJSCrowd implements ICrowd {
  134561. /**
  134562. * Recast/detour plugin
  134563. */
  134564. bjsRECASTPlugin: RecastJSPlugin;
  134565. /**
  134566. * Link to the detour crowd
  134567. */
  134568. recastCrowd: any;
  134569. /**
  134570. * One transform per agent
  134571. */
  134572. transforms: TransformNode[];
  134573. /**
  134574. * All agents created
  134575. */
  134576. agents: number[];
  134577. /**
  134578. * Link to the scene is kept to unregister the crowd from the scene
  134579. */
  134580. private _scene;
  134581. /**
  134582. * Observer for crowd updates
  134583. */
  134584. private _onBeforeAnimationsObserver;
  134585. /**
  134586. * Constructor
  134587. * @param plugin recastJS plugin
  134588. * @param maxAgents the maximum agent count in the crowd
  134589. * @param maxAgentRadius the maximum radius an agent can have
  134590. * @param scene to attach the crowd to
  134591. * @returns the crowd you can add agents to
  134592. */
  134593. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  134594. /**
  134595. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134596. * You can attach anything to that node. The node position is updated in the scene update tick.
  134597. * @param pos world position that will be constrained by the navigation mesh
  134598. * @param parameters agent parameters
  134599. * @param transform hooked to the agent that will be update by the scene
  134600. * @returns agent index
  134601. */
  134602. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134603. /**
  134604. * Returns the agent position in world space
  134605. * @param index agent index returned by addAgent
  134606. * @returns world space position
  134607. */
  134608. getAgentPosition(index: number): Vector3;
  134609. /**
  134610. * Returns the agent velocity in world space
  134611. * @param index agent index returned by addAgent
  134612. * @returns world space velocity
  134613. */
  134614. getAgentVelocity(index: number): Vector3;
  134615. /**
  134616. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134617. * @param index agent index returned by addAgent
  134618. * @param destination targeted world position
  134619. */
  134620. agentGoto(index: number, destination: Vector3): void;
  134621. /**
  134622. * Teleport the agent to a new position
  134623. * @param index agent index returned by addAgent
  134624. * @param destination targeted world position
  134625. */
  134626. agentTeleport(index: number, destination: Vector3): void;
  134627. /**
  134628. * Update agent parameters
  134629. * @param index agent index returned by addAgent
  134630. * @param parameters agent parameters
  134631. */
  134632. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  134633. /**
  134634. * remove a particular agent previously created
  134635. * @param index agent index returned by addAgent
  134636. */
  134637. removeAgent(index: number): void;
  134638. /**
  134639. * get the list of all agents attached to this crowd
  134640. * @returns list of agent indices
  134641. */
  134642. getAgents(): number[];
  134643. /**
  134644. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134645. * @param deltaTime in seconds
  134646. */
  134647. update(deltaTime: number): void;
  134648. /**
  134649. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134650. * The queries will try to find a solution within those bounds
  134651. * default is (1,1,1)
  134652. * @param extent x,y,z value that define the extent around the queries point of reference
  134653. */
  134654. setDefaultQueryExtent(extent: Vector3): void;
  134655. /**
  134656. * Get the Bounding box extent specified by setDefaultQueryExtent
  134657. * @returns the box extent values
  134658. */
  134659. getDefaultQueryExtent(): Vector3;
  134660. /**
  134661. * Release all resources
  134662. */
  134663. dispose(): void;
  134664. }
  134665. }
  134666. declare module BABYLON {
  134667. /**
  134668. * Class used to enable access to IndexedDB
  134669. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  134670. */
  134671. export class Database implements IOfflineProvider {
  134672. private _callbackManifestChecked;
  134673. private _currentSceneUrl;
  134674. private _db;
  134675. private _enableSceneOffline;
  134676. private _enableTexturesOffline;
  134677. private _manifestVersionFound;
  134678. private _mustUpdateRessources;
  134679. private _hasReachedQuota;
  134680. private _isSupported;
  134681. private _idbFactory;
  134682. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  134683. private static IsUASupportingBlobStorage;
  134684. /**
  134685. * Gets a boolean indicating if Database storate is enabled (off by default)
  134686. */
  134687. static IDBStorageEnabled: boolean;
  134688. /**
  134689. * Gets a boolean indicating if scene must be saved in the database
  134690. */
  134691. get enableSceneOffline(): boolean;
  134692. /**
  134693. * Gets a boolean indicating if textures must be saved in the database
  134694. */
  134695. get enableTexturesOffline(): boolean;
  134696. /**
  134697. * Creates a new Database
  134698. * @param urlToScene defines the url to load the scene
  134699. * @param callbackManifestChecked defines the callback to use when manifest is checked
  134700. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  134701. */
  134702. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  134703. private static _ParseURL;
  134704. private static _ReturnFullUrlLocation;
  134705. private _checkManifestFile;
  134706. /**
  134707. * Open the database and make it available
  134708. * @param successCallback defines the callback to call on success
  134709. * @param errorCallback defines the callback to call on error
  134710. */
  134711. open(successCallback: () => void, errorCallback: () => void): void;
  134712. /**
  134713. * Loads an image from the database
  134714. * @param url defines the url to load from
  134715. * @param image defines the target DOM image
  134716. */
  134717. loadImage(url: string, image: HTMLImageElement): void;
  134718. private _loadImageFromDBAsync;
  134719. private _saveImageIntoDBAsync;
  134720. private _checkVersionFromDB;
  134721. private _loadVersionFromDBAsync;
  134722. private _saveVersionIntoDBAsync;
  134723. /**
  134724. * Loads a file from database
  134725. * @param url defines the URL to load from
  134726. * @param sceneLoaded defines a callback to call on success
  134727. * @param progressCallBack defines a callback to call when progress changed
  134728. * @param errorCallback defines a callback to call on error
  134729. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  134730. */
  134731. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  134732. private _loadFileAsync;
  134733. private _saveFileAsync;
  134734. /**
  134735. * Validates if xhr data is correct
  134736. * @param xhr defines the request to validate
  134737. * @param dataType defines the expected data type
  134738. * @returns true if data is correct
  134739. */
  134740. private static _ValidateXHRData;
  134741. }
  134742. }
  134743. declare module BABYLON {
  134744. /** @hidden */
  134745. export var gpuUpdateParticlesPixelShader: {
  134746. name: string;
  134747. shader: string;
  134748. };
  134749. }
  134750. declare module BABYLON {
  134751. /** @hidden */
  134752. export var gpuUpdateParticlesVertexShader: {
  134753. name: string;
  134754. shader: string;
  134755. };
  134756. }
  134757. declare module BABYLON {
  134758. /** @hidden */
  134759. export var clipPlaneFragmentDeclaration2: {
  134760. name: string;
  134761. shader: string;
  134762. };
  134763. }
  134764. declare module BABYLON {
  134765. /** @hidden */
  134766. export var gpuRenderParticlesPixelShader: {
  134767. name: string;
  134768. shader: string;
  134769. };
  134770. }
  134771. declare module BABYLON {
  134772. /** @hidden */
  134773. export var clipPlaneVertexDeclaration2: {
  134774. name: string;
  134775. shader: string;
  134776. };
  134777. }
  134778. declare module BABYLON {
  134779. /** @hidden */
  134780. export var gpuRenderParticlesVertexShader: {
  134781. name: string;
  134782. shader: string;
  134783. };
  134784. }
  134785. declare module BABYLON {
  134786. /**
  134787. * This represents a GPU particle system in Babylon
  134788. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  134789. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  134790. */
  134791. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  134792. /**
  134793. * The layer mask we are rendering the particles through.
  134794. */
  134795. layerMask: number;
  134796. private _capacity;
  134797. private _activeCount;
  134798. private _currentActiveCount;
  134799. private _accumulatedCount;
  134800. private _renderEffect;
  134801. private _updateEffect;
  134802. private _buffer0;
  134803. private _buffer1;
  134804. private _spriteBuffer;
  134805. private _updateVAO;
  134806. private _renderVAO;
  134807. private _targetIndex;
  134808. private _sourceBuffer;
  134809. private _targetBuffer;
  134810. private _engine;
  134811. private _currentRenderId;
  134812. private _started;
  134813. private _stopped;
  134814. private _timeDelta;
  134815. private _randomTexture;
  134816. private _randomTexture2;
  134817. private _attributesStrideSize;
  134818. private _updateEffectOptions;
  134819. private _randomTextureSize;
  134820. private _actualFrame;
  134821. private readonly _rawTextureWidth;
  134822. /**
  134823. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  134824. */
  134825. static get IsSupported(): boolean;
  134826. /**
  134827. * An event triggered when the system is disposed.
  134828. */
  134829. onDisposeObservable: Observable<GPUParticleSystem>;
  134830. /**
  134831. * Gets the maximum number of particles active at the same time.
  134832. * @returns The max number of active particles.
  134833. */
  134834. getCapacity(): number;
  134835. /**
  134836. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  134837. * to override the particles.
  134838. */
  134839. forceDepthWrite: boolean;
  134840. /**
  134841. * Gets or set the number of active particles
  134842. */
  134843. get activeParticleCount(): number;
  134844. set activeParticleCount(value: number);
  134845. private _preWarmDone;
  134846. /**
  134847. * Is this system ready to be used/rendered
  134848. * @return true if the system is ready
  134849. */
  134850. isReady(): boolean;
  134851. /**
  134852. * Gets if the system has been started. (Note: this will still be true after stop is called)
  134853. * @returns True if it has been started, otherwise false.
  134854. */
  134855. isStarted(): boolean;
  134856. /**
  134857. * Starts the particle system and begins to emit
  134858. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  134859. */
  134860. start(delay?: number): void;
  134861. /**
  134862. * Stops the particle system.
  134863. */
  134864. stop(): void;
  134865. /**
  134866. * Remove all active particles
  134867. */
  134868. reset(): void;
  134869. /**
  134870. * Returns the string "GPUParticleSystem"
  134871. * @returns a string containing the class name
  134872. */
  134873. getClassName(): string;
  134874. private _colorGradientsTexture;
  134875. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  134876. /**
  134877. * Adds a new color gradient
  134878. * @param gradient defines the gradient to use (between 0 and 1)
  134879. * @param color1 defines the color to affect to the specified gradient
  134880. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  134881. * @returns the current particle system
  134882. */
  134883. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  134884. /**
  134885. * Remove a specific color gradient
  134886. * @param gradient defines the gradient to remove
  134887. * @returns the current particle system
  134888. */
  134889. removeColorGradient(gradient: number): GPUParticleSystem;
  134890. private _angularSpeedGradientsTexture;
  134891. private _sizeGradientsTexture;
  134892. private _velocityGradientsTexture;
  134893. private _limitVelocityGradientsTexture;
  134894. private _dragGradientsTexture;
  134895. private _addFactorGradient;
  134896. /**
  134897. * Adds a new size gradient
  134898. * @param gradient defines the gradient to use (between 0 and 1)
  134899. * @param factor defines the size factor to affect to the specified gradient
  134900. * @returns the current particle system
  134901. */
  134902. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  134903. /**
  134904. * Remove a specific size gradient
  134905. * @param gradient defines the gradient to remove
  134906. * @returns the current particle system
  134907. */
  134908. removeSizeGradient(gradient: number): GPUParticleSystem;
  134909. /**
  134910. * Adds a new angular speed gradient
  134911. * @param gradient defines the gradient to use (between 0 and 1)
  134912. * @param factor defines the angular speed to affect to the specified gradient
  134913. * @returns the current particle system
  134914. */
  134915. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  134916. /**
  134917. * Remove a specific angular speed gradient
  134918. * @param gradient defines the gradient to remove
  134919. * @returns the current particle system
  134920. */
  134921. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  134922. /**
  134923. * Adds a new velocity gradient
  134924. * @param gradient defines the gradient to use (between 0 and 1)
  134925. * @param factor defines the velocity to affect to the specified gradient
  134926. * @returns the current particle system
  134927. */
  134928. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  134929. /**
  134930. * Remove a specific velocity gradient
  134931. * @param gradient defines the gradient to remove
  134932. * @returns the current particle system
  134933. */
  134934. removeVelocityGradient(gradient: number): GPUParticleSystem;
  134935. /**
  134936. * Adds a new limit velocity gradient
  134937. * @param gradient defines the gradient to use (between 0 and 1)
  134938. * @param factor defines the limit velocity value to affect to the specified gradient
  134939. * @returns the current particle system
  134940. */
  134941. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  134942. /**
  134943. * Remove a specific limit velocity gradient
  134944. * @param gradient defines the gradient to remove
  134945. * @returns the current particle system
  134946. */
  134947. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  134948. /**
  134949. * Adds a new drag gradient
  134950. * @param gradient defines the gradient to use (between 0 and 1)
  134951. * @param factor defines the drag value to affect to the specified gradient
  134952. * @returns the current particle system
  134953. */
  134954. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  134955. /**
  134956. * Remove a specific drag gradient
  134957. * @param gradient defines the gradient to remove
  134958. * @returns the current particle system
  134959. */
  134960. removeDragGradient(gradient: number): GPUParticleSystem;
  134961. /**
  134962. * Not supported by GPUParticleSystem
  134963. * @param gradient defines the gradient to use (between 0 and 1)
  134964. * @param factor defines the emit rate value to affect to the specified gradient
  134965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  134966. * @returns the current particle system
  134967. */
  134968. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  134969. /**
  134970. * Not supported by GPUParticleSystem
  134971. * @param gradient defines the gradient to remove
  134972. * @returns the current particle system
  134973. */
  134974. removeEmitRateGradient(gradient: number): IParticleSystem;
  134975. /**
  134976. * Not supported by GPUParticleSystem
  134977. * @param gradient defines the gradient to use (between 0 and 1)
  134978. * @param factor defines the start size value to affect to the specified gradient
  134979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  134980. * @returns the current particle system
  134981. */
  134982. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  134983. /**
  134984. * Not supported by GPUParticleSystem
  134985. * @param gradient defines the gradient to remove
  134986. * @returns the current particle system
  134987. */
  134988. removeStartSizeGradient(gradient: number): IParticleSystem;
  134989. /**
  134990. * Not supported by GPUParticleSystem
  134991. * @param gradient defines the gradient to use (between 0 and 1)
  134992. * @param min defines the color remap minimal range
  134993. * @param max defines the color remap maximal range
  134994. * @returns the current particle system
  134995. */
  134996. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  134997. /**
  134998. * Not supported by GPUParticleSystem
  134999. * @param gradient defines the gradient to remove
  135000. * @returns the current particle system
  135001. */
  135002. removeColorRemapGradient(): IParticleSystem;
  135003. /**
  135004. * Not supported by GPUParticleSystem
  135005. * @param gradient defines the gradient to use (between 0 and 1)
  135006. * @param min defines the alpha remap minimal range
  135007. * @param max defines the alpha remap maximal range
  135008. * @returns the current particle system
  135009. */
  135010. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135011. /**
  135012. * Not supported by GPUParticleSystem
  135013. * @param gradient defines the gradient to remove
  135014. * @returns the current particle system
  135015. */
  135016. removeAlphaRemapGradient(): IParticleSystem;
  135017. /**
  135018. * Not supported by GPUParticleSystem
  135019. * @param gradient defines the gradient to use (between 0 and 1)
  135020. * @param color defines the color to affect to the specified gradient
  135021. * @returns the current particle system
  135022. */
  135023. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135024. /**
  135025. * Not supported by GPUParticleSystem
  135026. * @param gradient defines the gradient to remove
  135027. * @returns the current particle system
  135028. */
  135029. removeRampGradient(): IParticleSystem;
  135030. /**
  135031. * Not supported by GPUParticleSystem
  135032. * @returns the list of ramp gradients
  135033. */
  135034. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135035. /**
  135036. * Not supported by GPUParticleSystem
  135037. * Gets or sets a boolean indicating that ramp gradients must be used
  135038. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135039. */
  135040. get useRampGradients(): boolean;
  135041. set useRampGradients(value: boolean);
  135042. /**
  135043. * Not supported by GPUParticleSystem
  135044. * @param gradient defines the gradient to use (between 0 and 1)
  135045. * @param factor defines the life time factor to affect to the specified gradient
  135046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135047. * @returns the current particle system
  135048. */
  135049. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135050. /**
  135051. * Not supported by GPUParticleSystem
  135052. * @param gradient defines the gradient to remove
  135053. * @returns the current particle system
  135054. */
  135055. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135056. /**
  135057. * Instantiates a GPU particle system.
  135058. * 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.
  135059. * @param name The name of the particle system
  135060. * @param options The options used to create the system
  135061. * @param scene The scene the particle system belongs to
  135062. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135063. */
  135064. constructor(name: string, options: Partial<{
  135065. capacity: number;
  135066. randomTextureSize: number;
  135067. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135068. protected _reset(): void;
  135069. private _createUpdateVAO;
  135070. private _createRenderVAO;
  135071. private _initialize;
  135072. /** @hidden */
  135073. _recreateUpdateEffect(): void;
  135074. /** @hidden */
  135075. _recreateRenderEffect(): void;
  135076. /**
  135077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135078. * @param preWarm defines if we are in the pre-warmimg phase
  135079. */
  135080. animate(preWarm?: boolean): void;
  135081. private _createFactorGradientTexture;
  135082. private _createSizeGradientTexture;
  135083. private _createAngularSpeedGradientTexture;
  135084. private _createVelocityGradientTexture;
  135085. private _createLimitVelocityGradientTexture;
  135086. private _createDragGradientTexture;
  135087. private _createColorGradientTexture;
  135088. /**
  135089. * Renders the particle system in its current state
  135090. * @param preWarm defines if the system should only update the particles but not render them
  135091. * @returns the current number of particles
  135092. */
  135093. render(preWarm?: boolean): number;
  135094. /**
  135095. * Rebuilds the particle system
  135096. */
  135097. rebuild(): void;
  135098. private _releaseBuffers;
  135099. private _releaseVAOs;
  135100. /**
  135101. * Disposes the particle system and free the associated resources
  135102. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135103. */
  135104. dispose(disposeTexture?: boolean): void;
  135105. /**
  135106. * Clones the particle system.
  135107. * @param name The name of the cloned object
  135108. * @param newEmitter The new emitter to use
  135109. * @returns the cloned particle system
  135110. */
  135111. clone(name: string, newEmitter: any): GPUParticleSystem;
  135112. /**
  135113. * Serializes the particle system to a JSON object.
  135114. * @returns the JSON object
  135115. */
  135116. serialize(): any;
  135117. /**
  135118. * Parses a JSON object to create a GPU particle system.
  135119. * @param parsedParticleSystem The JSON object to parse
  135120. * @param scene The scene to create the particle system in
  135121. * @param rootUrl The root url to use to load external dependencies like texture
  135122. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135123. * @returns the parsed GPU particle system
  135124. */
  135125. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135126. }
  135127. }
  135128. declare module BABYLON {
  135129. /**
  135130. * Represents a set of particle systems working together to create a specific effect
  135131. */
  135132. export class ParticleSystemSet implements IDisposable {
  135133. /**
  135134. * Gets or sets base Assets URL
  135135. */
  135136. static BaseAssetsUrl: string;
  135137. private _emitterCreationOptions;
  135138. private _emitterNode;
  135139. /**
  135140. * Gets the particle system list
  135141. */
  135142. systems: IParticleSystem[];
  135143. /**
  135144. * Gets the emitter node used with this set
  135145. */
  135146. get emitterNode(): Nullable<TransformNode>;
  135147. /**
  135148. * Creates a new emitter mesh as a sphere
  135149. * @param options defines the options used to create the sphere
  135150. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135151. * @param scene defines the hosting scene
  135152. */
  135153. setEmitterAsSphere(options: {
  135154. diameter: number;
  135155. segments: number;
  135156. color: Color3;
  135157. }, renderingGroupId: number, scene: Scene): void;
  135158. /**
  135159. * Starts all particle systems of the set
  135160. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135161. */
  135162. start(emitter?: AbstractMesh): void;
  135163. /**
  135164. * Release all associated resources
  135165. */
  135166. dispose(): void;
  135167. /**
  135168. * Serialize the set into a JSON compatible object
  135169. * @returns a JSON compatible representation of the set
  135170. */
  135171. serialize(): any;
  135172. /**
  135173. * Parse a new ParticleSystemSet from a serialized source
  135174. * @param data defines a JSON compatible representation of the set
  135175. * @param scene defines the hosting scene
  135176. * @param gpu defines if we want GPU particles or CPU particles
  135177. * @returns a new ParticleSystemSet
  135178. */
  135179. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  135180. }
  135181. }
  135182. declare module BABYLON {
  135183. /**
  135184. * This class is made for on one-liner static method to help creating particle system set.
  135185. */
  135186. export class ParticleHelper {
  135187. /**
  135188. * Gets or sets base Assets URL
  135189. */
  135190. static BaseAssetsUrl: string;
  135191. /**
  135192. * Create a default particle system that you can tweak
  135193. * @param emitter defines the emitter to use
  135194. * @param capacity defines the system capacity (default is 500 particles)
  135195. * @param scene defines the hosting scene
  135196. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  135197. * @returns the new Particle system
  135198. */
  135199. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  135200. /**
  135201. * This is the main static method (one-liner) of this helper to create different particle systems
  135202. * @param type This string represents the type to the particle system to create
  135203. * @param scene The scene where the particle system should live
  135204. * @param gpu If the system will use gpu
  135205. * @returns the ParticleSystemSet created
  135206. */
  135207. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  135208. /**
  135209. * Static function used to export a particle system to a ParticleSystemSet variable.
  135210. * Please note that the emitter shape is not exported
  135211. * @param systems defines the particle systems to export
  135212. * @returns the created particle system set
  135213. */
  135214. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  135215. }
  135216. }
  135217. declare module BABYLON {
  135218. interface Engine {
  135219. /**
  135220. * Create an effect to use with particle systems.
  135221. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  135222. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  135223. * @param uniformsNames defines a list of attribute names
  135224. * @param samplers defines an array of string used to represent textures
  135225. * @param defines defines the string containing the defines to use to compile the shaders
  135226. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  135227. * @param onCompiled defines a function to call when the effect creation is successful
  135228. * @param onError defines a function to call when the effect creation has failed
  135229. * @returns the new Effect
  135230. */
  135231. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  135232. }
  135233. interface Mesh {
  135234. /**
  135235. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  135236. * @returns an array of IParticleSystem
  135237. */
  135238. getEmittedParticleSystems(): IParticleSystem[];
  135239. /**
  135240. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  135241. * @returns an array of IParticleSystem
  135242. */
  135243. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  135244. }
  135245. /**
  135246. * @hidden
  135247. */
  135248. export var _IDoNeedToBeInTheBuild: number;
  135249. }
  135250. declare module BABYLON {
  135251. /** Defines the 4 color options */
  135252. export enum PointColor {
  135253. /** color value */
  135254. Color = 2,
  135255. /** uv value */
  135256. UV = 1,
  135257. /** random value */
  135258. Random = 0,
  135259. /** stated value */
  135260. Stated = 3
  135261. }
  135262. /**
  135263. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  135264. * 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.
  135265. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  135266. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  135267. *
  135268. * Full documentation here : TO BE ENTERED
  135269. */
  135270. export class PointsCloudSystem implements IDisposable {
  135271. /**
  135272. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  135273. * Example : var p = SPS.particles[i];
  135274. */
  135275. particles: CloudPoint[];
  135276. /**
  135277. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  135278. */
  135279. nbParticles: number;
  135280. /**
  135281. * This a counter for your own usage. It's not set by any SPS functions.
  135282. */
  135283. counter: number;
  135284. /**
  135285. * The PCS name. This name is also given to the underlying mesh.
  135286. */
  135287. name: string;
  135288. /**
  135289. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  135290. */
  135291. mesh: Mesh;
  135292. /**
  135293. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  135294. * Please read :
  135295. */
  135296. vars: any;
  135297. /**
  135298. * @hidden
  135299. */
  135300. _size: number;
  135301. private _scene;
  135302. private _promises;
  135303. private _positions;
  135304. private _indices;
  135305. private _normals;
  135306. private _colors;
  135307. private _uvs;
  135308. private _indices32;
  135309. private _positions32;
  135310. private _colors32;
  135311. private _uvs32;
  135312. private _updatable;
  135313. private _isVisibilityBoxLocked;
  135314. private _alwaysVisible;
  135315. private _groups;
  135316. private _groupCounter;
  135317. private _computeParticleColor;
  135318. private _computeParticleTexture;
  135319. private _computeParticleRotation;
  135320. private _computeBoundingBox;
  135321. private _isReady;
  135322. /**
  135323. * Creates a PCS (Points Cloud System) object
  135324. * @param name (String) is the PCS name, this will be the underlying mesh name
  135325. * @param pointSize (number) is the size for each point
  135326. * @param scene (Scene) is the scene in which the PCS is added
  135327. * @param options defines the options of the PCS e.g.
  135328. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  135329. */
  135330. constructor(name: string, pointSize: number, scene: Scene, options?: {
  135331. updatable?: boolean;
  135332. });
  135333. /**
  135334. * Builds the PCS underlying mesh. Returns a standard Mesh.
  135335. * If no points were added to the PCS, the returned mesh is just a single point.
  135336. * @returns a promise for the created mesh
  135337. */
  135338. buildMeshAsync(): Promise<Mesh>;
  135339. /**
  135340. * @hidden
  135341. */
  135342. private _buildMesh;
  135343. private _addParticle;
  135344. private _randomUnitVector;
  135345. private _getColorIndicesForCoord;
  135346. private _setPointsColorOrUV;
  135347. private _colorFromTexture;
  135348. private _calculateDensity;
  135349. /**
  135350. * Adds points to the PCS in random positions within a unit sphere
  135351. * @param nb (positive integer) the number of particles to be created from this model
  135352. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  135353. * @returns the number of groups in the system
  135354. */
  135355. addPoints(nb: number, pointFunction?: any): number;
  135356. /**
  135357. * Adds points to the PCS from the surface of the model shape
  135358. * @param mesh is any Mesh object that will be used as a surface model for the points
  135359. * @param nb (positive integer) the number of particles to be created from this model
  135360. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135361. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135362. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135363. * @returns the number of groups in the system
  135364. */
  135365. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135366. /**
  135367. * Adds points to the PCS inside the model shape
  135368. * @param mesh is any Mesh object that will be used as a surface model for the points
  135369. * @param nb (positive integer) the number of particles to be created from this model
  135370. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135371. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135372. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135373. * @returns the number of groups in the system
  135374. */
  135375. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135376. /**
  135377. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  135378. * This method calls `updateParticle()` for each particle of the SPS.
  135379. * For an animated SPS, it is usually called within the render loop.
  135380. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  135381. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  135382. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  135383. * @returns the PCS.
  135384. */
  135385. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  135386. /**
  135387. * Disposes the PCS.
  135388. */
  135389. dispose(): void;
  135390. /**
  135391. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  135392. * doc :
  135393. * @returns the PCS.
  135394. */
  135395. refreshVisibleSize(): PointsCloudSystem;
  135396. /**
  135397. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  135398. * @param size the size (float) of the visibility box
  135399. * note : this doesn't lock the PCS mesh bounding box.
  135400. * doc :
  135401. */
  135402. setVisibilityBox(size: number): void;
  135403. /**
  135404. * Gets whether the PCS is always visible or not
  135405. * doc :
  135406. */
  135407. get isAlwaysVisible(): boolean;
  135408. /**
  135409. * Sets the PCS as always visible or not
  135410. * doc :
  135411. */
  135412. set isAlwaysVisible(val: boolean);
  135413. /**
  135414. * Tells to `setParticles()` to compute the particle rotations or not
  135415. * Default value : false. The PCS is faster when it's set to false
  135416. * Note : particle rotations are only applied to parent particles
  135417. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  135418. */
  135419. set computeParticleRotation(val: boolean);
  135420. /**
  135421. * Tells to `setParticles()` to compute the particle colors or not.
  135422. * Default value : true. The PCS is faster when it's set to false.
  135423. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135424. */
  135425. set computeParticleColor(val: boolean);
  135426. set computeParticleTexture(val: boolean);
  135427. /**
  135428. * Gets if `setParticles()` computes the particle colors or not.
  135429. * Default value : false. The PCS is faster when it's set to false.
  135430. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135431. */
  135432. get computeParticleColor(): boolean;
  135433. /**
  135434. * Gets if `setParticles()` computes the particle textures or not.
  135435. * Default value : false. The PCS is faster when it's set to false.
  135436. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  135437. */
  135438. get computeParticleTexture(): boolean;
  135439. /**
  135440. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  135441. */
  135442. set computeBoundingBox(val: boolean);
  135443. /**
  135444. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  135445. */
  135446. get computeBoundingBox(): boolean;
  135447. /**
  135448. * This function does nothing. It may be overwritten to set all the particle first values.
  135449. * The PCS doesn't call this function, you may have to call it by your own.
  135450. * doc :
  135451. */
  135452. initParticles(): void;
  135453. /**
  135454. * This function does nothing. It may be overwritten to recycle a particle
  135455. * The PCS doesn't call this function, you can to call it
  135456. * doc :
  135457. * @param particle The particle to recycle
  135458. * @returns the recycled particle
  135459. */
  135460. recycleParticle(particle: CloudPoint): CloudPoint;
  135461. /**
  135462. * Updates a particle : this function should be overwritten by the user.
  135463. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  135464. * doc :
  135465. * @example : just set a particle position or velocity and recycle conditions
  135466. * @param particle The particle to update
  135467. * @returns the updated particle
  135468. */
  135469. updateParticle(particle: CloudPoint): CloudPoint;
  135470. /**
  135471. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  135472. * This does nothing and may be overwritten by the user.
  135473. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135474. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135475. * @param update the boolean update value actually passed to setParticles()
  135476. */
  135477. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135478. /**
  135479. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  135480. * This will be passed three parameters.
  135481. * This does nothing and may be overwritten by the user.
  135482. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135483. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135484. * @param update the boolean update value actually passed to setParticles()
  135485. */
  135486. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135487. }
  135488. }
  135489. declare module BABYLON {
  135490. /**
  135491. * Represents one particle of a points cloud system.
  135492. */
  135493. export class CloudPoint {
  135494. /**
  135495. * particle global index
  135496. */
  135497. idx: number;
  135498. /**
  135499. * The color of the particle
  135500. */
  135501. color: Nullable<Color4>;
  135502. /**
  135503. * The world space position of the particle.
  135504. */
  135505. position: Vector3;
  135506. /**
  135507. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  135508. */
  135509. rotation: Vector3;
  135510. /**
  135511. * The world space rotation quaternion of the particle.
  135512. */
  135513. rotationQuaternion: Nullable<Quaternion>;
  135514. /**
  135515. * The uv of the particle.
  135516. */
  135517. uv: Nullable<Vector2>;
  135518. /**
  135519. * The current speed of the particle.
  135520. */
  135521. velocity: Vector3;
  135522. /**
  135523. * The pivot point in the particle local space.
  135524. */
  135525. pivot: Vector3;
  135526. /**
  135527. * Must the particle be translated from its pivot point in its local space ?
  135528. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  135529. * Default : false
  135530. */
  135531. translateFromPivot: boolean;
  135532. /**
  135533. * Index of this particle in the global "positions" array (Internal use)
  135534. * @hidden
  135535. */
  135536. _pos: number;
  135537. /**
  135538. * @hidden Index of this particle in the global "indices" array (Internal use)
  135539. */
  135540. _ind: number;
  135541. /**
  135542. * Group this particle belongs to
  135543. */
  135544. _group: PointsGroup;
  135545. /**
  135546. * Group id of this particle
  135547. */
  135548. groupId: number;
  135549. /**
  135550. * Index of the particle in its group id (Internal use)
  135551. */
  135552. idxInGroup: number;
  135553. /**
  135554. * @hidden Particle BoundingInfo object (Internal use)
  135555. */
  135556. _boundingInfo: BoundingInfo;
  135557. /**
  135558. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  135559. */
  135560. _pcs: PointsCloudSystem;
  135561. /**
  135562. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  135563. */
  135564. _stillInvisible: boolean;
  135565. /**
  135566. * @hidden Last computed particle rotation matrix
  135567. */
  135568. _rotationMatrix: number[];
  135569. /**
  135570. * Parent particle Id, if any.
  135571. * Default null.
  135572. */
  135573. parentId: Nullable<number>;
  135574. /**
  135575. * @hidden Internal global position in the PCS.
  135576. */
  135577. _globalPosition: Vector3;
  135578. /**
  135579. * Creates a Point Cloud object.
  135580. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  135581. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  135582. * @param group (PointsGroup) is the group the particle belongs to
  135583. * @param groupId (integer) is the group identifier in the PCS.
  135584. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  135585. * @param pcs defines the PCS it is associated to
  135586. */
  135587. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  135588. /**
  135589. * get point size
  135590. */
  135591. get size(): Vector3;
  135592. /**
  135593. * Set point size
  135594. */
  135595. set size(scale: Vector3);
  135596. /**
  135597. * Legacy support, changed quaternion to rotationQuaternion
  135598. */
  135599. get quaternion(): Nullable<Quaternion>;
  135600. /**
  135601. * Legacy support, changed quaternion to rotationQuaternion
  135602. */
  135603. set quaternion(q: Nullable<Quaternion>);
  135604. /**
  135605. * Returns a boolean. True if the particle intersects a mesh, else false
  135606. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  135607. * @param target is the object (point or mesh) what the intersection is computed against
  135608. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  135609. * @returns true if it intersects
  135610. */
  135611. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  135612. /**
  135613. * get the rotation matrix of the particle
  135614. * @hidden
  135615. */
  135616. getRotationMatrix(m: Matrix): void;
  135617. }
  135618. /**
  135619. * Represents a group of points in a points cloud system
  135620. * * PCS internal tool, don't use it manually.
  135621. */
  135622. export class PointsGroup {
  135623. /**
  135624. * The group id
  135625. * @hidden
  135626. */
  135627. groupID: number;
  135628. /**
  135629. * image data for group (internal use)
  135630. * @hidden
  135631. */
  135632. _groupImageData: Nullable<ArrayBufferView>;
  135633. /**
  135634. * Image Width (internal use)
  135635. * @hidden
  135636. */
  135637. _groupImgWidth: number;
  135638. /**
  135639. * Image Height (internal use)
  135640. * @hidden
  135641. */
  135642. _groupImgHeight: number;
  135643. /**
  135644. * Custom position function (internal use)
  135645. * @hidden
  135646. */
  135647. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  135648. /**
  135649. * density per facet for surface points
  135650. * @hidden
  135651. */
  135652. _groupDensity: number[];
  135653. /**
  135654. * Only when points are colored by texture carries pointer to texture list array
  135655. * @hidden
  135656. */
  135657. _textureNb: number;
  135658. /**
  135659. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  135660. * PCS internal tool, don't use it manually.
  135661. * @hidden
  135662. */
  135663. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  135664. }
  135665. }
  135666. declare module BABYLON {
  135667. interface Scene {
  135668. /** @hidden (Backing field) */
  135669. _physicsEngine: Nullable<IPhysicsEngine>;
  135670. /** @hidden */
  135671. _physicsTimeAccumulator: number;
  135672. /**
  135673. * Gets the current physics engine
  135674. * @returns a IPhysicsEngine or null if none attached
  135675. */
  135676. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  135677. /**
  135678. * Enables physics to the current scene
  135679. * @param gravity defines the scene's gravity for the physics engine
  135680. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  135681. * @return a boolean indicating if the physics engine was initialized
  135682. */
  135683. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  135684. /**
  135685. * Disables and disposes the physics engine associated with the scene
  135686. */
  135687. disablePhysicsEngine(): void;
  135688. /**
  135689. * Gets a boolean indicating if there is an active physics engine
  135690. * @returns a boolean indicating if there is an active physics engine
  135691. */
  135692. isPhysicsEnabled(): boolean;
  135693. /**
  135694. * Deletes a physics compound impostor
  135695. * @param compound defines the compound to delete
  135696. */
  135697. deleteCompoundImpostor(compound: any): void;
  135698. /**
  135699. * An event triggered when physic simulation is about to be run
  135700. */
  135701. onBeforePhysicsObservable: Observable<Scene>;
  135702. /**
  135703. * An event triggered when physic simulation has been done
  135704. */
  135705. onAfterPhysicsObservable: Observable<Scene>;
  135706. }
  135707. interface AbstractMesh {
  135708. /** @hidden */
  135709. _physicsImpostor: Nullable<PhysicsImpostor>;
  135710. /**
  135711. * Gets or sets impostor used for physic simulation
  135712. * @see http://doc.babylonjs.com/features/physics_engine
  135713. */
  135714. physicsImpostor: Nullable<PhysicsImpostor>;
  135715. /**
  135716. * Gets the current physics impostor
  135717. * @see http://doc.babylonjs.com/features/physics_engine
  135718. * @returns a physics impostor or null
  135719. */
  135720. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  135721. /** Apply a physic impulse to the mesh
  135722. * @param force defines the force to apply
  135723. * @param contactPoint defines where to apply the force
  135724. * @returns the current mesh
  135725. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135726. */
  135727. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  135728. /**
  135729. * Creates a physic joint between two meshes
  135730. * @param otherMesh defines the other mesh to use
  135731. * @param pivot1 defines the pivot to use on this mesh
  135732. * @param pivot2 defines the pivot to use on the other mesh
  135733. * @param options defines additional options (can be plugin dependent)
  135734. * @returns the current mesh
  135735. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  135736. */
  135737. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  135738. /** @hidden */
  135739. _disposePhysicsObserver: Nullable<Observer<Node>>;
  135740. }
  135741. /**
  135742. * Defines the physics engine scene component responsible to manage a physics engine
  135743. */
  135744. export class PhysicsEngineSceneComponent implements ISceneComponent {
  135745. /**
  135746. * The component name helpful to identify the component in the list of scene components.
  135747. */
  135748. readonly name: string;
  135749. /**
  135750. * The scene the component belongs to.
  135751. */
  135752. scene: Scene;
  135753. /**
  135754. * Creates a new instance of the component for the given scene
  135755. * @param scene Defines the scene to register the component in
  135756. */
  135757. constructor(scene: Scene);
  135758. /**
  135759. * Registers the component in a given scene
  135760. */
  135761. register(): void;
  135762. /**
  135763. * Rebuilds the elements related to this component in case of
  135764. * context lost for instance.
  135765. */
  135766. rebuild(): void;
  135767. /**
  135768. * Disposes the component and the associated ressources
  135769. */
  135770. dispose(): void;
  135771. }
  135772. }
  135773. declare module BABYLON {
  135774. /**
  135775. * A helper for physics simulations
  135776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  135777. */
  135778. export class PhysicsHelper {
  135779. private _scene;
  135780. private _physicsEngine;
  135781. /**
  135782. * Initializes the Physics helper
  135783. * @param scene Babylon.js scene
  135784. */
  135785. constructor(scene: Scene);
  135786. /**
  135787. * Applies a radial explosion impulse
  135788. * @param origin the origin of the explosion
  135789. * @param radiusOrEventOptions the radius or the options of radial explosion
  135790. * @param strength the explosion strength
  135791. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135792. * @returns A physics radial explosion event, or null
  135793. */
  135794. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135795. /**
  135796. * Applies a radial explosion force
  135797. * @param origin the origin of the explosion
  135798. * @param radiusOrEventOptions the radius or the options of radial explosion
  135799. * @param strength the explosion strength
  135800. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135801. * @returns A physics radial explosion event, or null
  135802. */
  135803. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135804. /**
  135805. * Creates a gravitational field
  135806. * @param origin the origin of the explosion
  135807. * @param radiusOrEventOptions the radius or the options of radial explosion
  135808. * @param strength the explosion strength
  135809. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135810. * @returns A physics gravitational field event, or null
  135811. */
  135812. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  135813. /**
  135814. * Creates a physics updraft event
  135815. * @param origin the origin of the updraft
  135816. * @param radiusOrEventOptions the radius or the options of the updraft
  135817. * @param strength the strength of the updraft
  135818. * @param height the height of the updraft
  135819. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  135820. * @returns A physics updraft event, or null
  135821. */
  135822. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  135823. /**
  135824. * Creates a physics vortex event
  135825. * @param origin the of the vortex
  135826. * @param radiusOrEventOptions the radius or the options of the vortex
  135827. * @param strength the strength of the vortex
  135828. * @param height the height of the vortex
  135829. * @returns a Physics vortex event, or null
  135830. * A physics vortex event or null
  135831. */
  135832. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  135833. }
  135834. /**
  135835. * Represents a physics radial explosion event
  135836. */
  135837. class PhysicsRadialExplosionEvent {
  135838. private _scene;
  135839. private _options;
  135840. private _sphere;
  135841. private _dataFetched;
  135842. /**
  135843. * Initializes a radial explosioin event
  135844. * @param _scene BabylonJS scene
  135845. * @param _options The options for the vortex event
  135846. */
  135847. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  135848. /**
  135849. * Returns the data related to the radial explosion event (sphere).
  135850. * @returns The radial explosion event data
  135851. */
  135852. getData(): PhysicsRadialExplosionEventData;
  135853. /**
  135854. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  135855. * @param impostor A physics imposter
  135856. * @param origin the origin of the explosion
  135857. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  135858. */
  135859. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  135860. /**
  135861. * Triggers affecterd impostors callbacks
  135862. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  135863. */
  135864. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  135865. /**
  135866. * Disposes the sphere.
  135867. * @param force Specifies if the sphere should be disposed by force
  135868. */
  135869. dispose(force?: boolean): void;
  135870. /*** Helpers ***/
  135871. private _prepareSphere;
  135872. private _intersectsWithSphere;
  135873. }
  135874. /**
  135875. * Represents a gravitational field event
  135876. */
  135877. class PhysicsGravitationalFieldEvent {
  135878. private _physicsHelper;
  135879. private _scene;
  135880. private _origin;
  135881. private _options;
  135882. private _tickCallback;
  135883. private _sphere;
  135884. private _dataFetched;
  135885. /**
  135886. * Initializes the physics gravitational field event
  135887. * @param _physicsHelper A physics helper
  135888. * @param _scene BabylonJS scene
  135889. * @param _origin The origin position of the gravitational field event
  135890. * @param _options The options for the vortex event
  135891. */
  135892. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  135893. /**
  135894. * Returns the data related to the gravitational field event (sphere).
  135895. * @returns A gravitational field event
  135896. */
  135897. getData(): PhysicsGravitationalFieldEventData;
  135898. /**
  135899. * Enables the gravitational field.
  135900. */
  135901. enable(): void;
  135902. /**
  135903. * Disables the gravitational field.
  135904. */
  135905. disable(): void;
  135906. /**
  135907. * Disposes the sphere.
  135908. * @param force The force to dispose from the gravitational field event
  135909. */
  135910. dispose(force?: boolean): void;
  135911. private _tick;
  135912. }
  135913. /**
  135914. * Represents a physics updraft event
  135915. */
  135916. class PhysicsUpdraftEvent {
  135917. private _scene;
  135918. private _origin;
  135919. private _options;
  135920. private _physicsEngine;
  135921. private _originTop;
  135922. private _originDirection;
  135923. private _tickCallback;
  135924. private _cylinder;
  135925. private _cylinderPosition;
  135926. private _dataFetched;
  135927. /**
  135928. * Initializes the physics updraft event
  135929. * @param _scene BabylonJS scene
  135930. * @param _origin The origin position of the updraft
  135931. * @param _options The options for the updraft event
  135932. */
  135933. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  135934. /**
  135935. * Returns the data related to the updraft event (cylinder).
  135936. * @returns A physics updraft event
  135937. */
  135938. getData(): PhysicsUpdraftEventData;
  135939. /**
  135940. * Enables the updraft.
  135941. */
  135942. enable(): void;
  135943. /**
  135944. * Disables the updraft.
  135945. */
  135946. disable(): void;
  135947. /**
  135948. * Disposes the cylinder.
  135949. * @param force Specifies if the updraft should be disposed by force
  135950. */
  135951. dispose(force?: boolean): void;
  135952. private getImpostorHitData;
  135953. private _tick;
  135954. /*** Helpers ***/
  135955. private _prepareCylinder;
  135956. private _intersectsWithCylinder;
  135957. }
  135958. /**
  135959. * Represents a physics vortex event
  135960. */
  135961. class PhysicsVortexEvent {
  135962. private _scene;
  135963. private _origin;
  135964. private _options;
  135965. private _physicsEngine;
  135966. private _originTop;
  135967. private _tickCallback;
  135968. private _cylinder;
  135969. private _cylinderPosition;
  135970. private _dataFetched;
  135971. /**
  135972. * Initializes the physics vortex event
  135973. * @param _scene The BabylonJS scene
  135974. * @param _origin The origin position of the vortex
  135975. * @param _options The options for the vortex event
  135976. */
  135977. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  135978. /**
  135979. * Returns the data related to the vortex event (cylinder).
  135980. * @returns The physics vortex event data
  135981. */
  135982. getData(): PhysicsVortexEventData;
  135983. /**
  135984. * Enables the vortex.
  135985. */
  135986. enable(): void;
  135987. /**
  135988. * Disables the cortex.
  135989. */
  135990. disable(): void;
  135991. /**
  135992. * Disposes the sphere.
  135993. * @param force
  135994. */
  135995. dispose(force?: boolean): void;
  135996. private getImpostorHitData;
  135997. private _tick;
  135998. /*** Helpers ***/
  135999. private _prepareCylinder;
  136000. private _intersectsWithCylinder;
  136001. }
  136002. /**
  136003. * Options fot the radial explosion event
  136004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136005. */
  136006. export class PhysicsRadialExplosionEventOptions {
  136007. /**
  136008. * The radius of the sphere for the radial explosion.
  136009. */
  136010. radius: number;
  136011. /**
  136012. * The strenth of the explosion.
  136013. */
  136014. strength: number;
  136015. /**
  136016. * The strenght of the force in correspondence to the distance of the affected object
  136017. */
  136018. falloff: PhysicsRadialImpulseFalloff;
  136019. /**
  136020. * Sphere options for the radial explosion.
  136021. */
  136022. sphere: {
  136023. segments: number;
  136024. diameter: number;
  136025. };
  136026. /**
  136027. * Sphere options for the radial explosion.
  136028. */
  136029. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136030. }
  136031. /**
  136032. * Options fot the updraft event
  136033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136034. */
  136035. export class PhysicsUpdraftEventOptions {
  136036. /**
  136037. * The radius of the cylinder for the vortex
  136038. */
  136039. radius: number;
  136040. /**
  136041. * The strenth of the updraft.
  136042. */
  136043. strength: number;
  136044. /**
  136045. * The height of the cylinder for the updraft.
  136046. */
  136047. height: number;
  136048. /**
  136049. * The mode for the the updraft.
  136050. */
  136051. updraftMode: PhysicsUpdraftMode;
  136052. }
  136053. /**
  136054. * Options fot the vortex event
  136055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136056. */
  136057. export class PhysicsVortexEventOptions {
  136058. /**
  136059. * The radius of the cylinder for the vortex
  136060. */
  136061. radius: number;
  136062. /**
  136063. * The strenth of the vortex.
  136064. */
  136065. strength: number;
  136066. /**
  136067. * The height of the cylinder for the vortex.
  136068. */
  136069. height: number;
  136070. /**
  136071. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136072. */
  136073. centripetalForceThreshold: number;
  136074. /**
  136075. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136076. */
  136077. centripetalForceMultiplier: number;
  136078. /**
  136079. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136080. */
  136081. centrifugalForceMultiplier: number;
  136082. /**
  136083. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136084. */
  136085. updraftForceMultiplier: number;
  136086. }
  136087. /**
  136088. * The strenght of the force in correspondence to the distance of the affected object
  136089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136090. */
  136091. export enum PhysicsRadialImpulseFalloff {
  136092. /** Defines that impulse is constant in strength across it's whole radius */
  136093. Constant = 0,
  136094. /** Defines that impulse gets weaker if it's further from the origin */
  136095. Linear = 1
  136096. }
  136097. /**
  136098. * The strength of the force in correspondence to the distance of the affected object
  136099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136100. */
  136101. export enum PhysicsUpdraftMode {
  136102. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136103. Center = 0,
  136104. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136105. Perpendicular = 1
  136106. }
  136107. /**
  136108. * Interface for a physics hit data
  136109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136110. */
  136111. export interface PhysicsHitData {
  136112. /**
  136113. * The force applied at the contact point
  136114. */
  136115. force: Vector3;
  136116. /**
  136117. * The contact point
  136118. */
  136119. contactPoint: Vector3;
  136120. /**
  136121. * The distance from the origin to the contact point
  136122. */
  136123. distanceFromOrigin: number;
  136124. }
  136125. /**
  136126. * Interface for radial explosion event data
  136127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136128. */
  136129. export interface PhysicsRadialExplosionEventData {
  136130. /**
  136131. * A sphere used for the radial explosion event
  136132. */
  136133. sphere: Mesh;
  136134. }
  136135. /**
  136136. * Interface for gravitational field event data
  136137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136138. */
  136139. export interface PhysicsGravitationalFieldEventData {
  136140. /**
  136141. * A sphere mesh used for the gravitational field event
  136142. */
  136143. sphere: Mesh;
  136144. }
  136145. /**
  136146. * Interface for updraft event data
  136147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136148. */
  136149. export interface PhysicsUpdraftEventData {
  136150. /**
  136151. * A cylinder used for the updraft event
  136152. */
  136153. cylinder: Mesh;
  136154. }
  136155. /**
  136156. * Interface for vortex event data
  136157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136158. */
  136159. export interface PhysicsVortexEventData {
  136160. /**
  136161. * A cylinder used for the vortex event
  136162. */
  136163. cylinder: Mesh;
  136164. }
  136165. /**
  136166. * Interface for an affected physics impostor
  136167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136168. */
  136169. export interface PhysicsAffectedImpostorWithData {
  136170. /**
  136171. * The impostor affected by the effect
  136172. */
  136173. impostor: PhysicsImpostor;
  136174. /**
  136175. * The data about the hit/horce from the explosion
  136176. */
  136177. hitData: PhysicsHitData;
  136178. }
  136179. }
  136180. declare module BABYLON {
  136181. /** @hidden */
  136182. export var blackAndWhitePixelShader: {
  136183. name: string;
  136184. shader: string;
  136185. };
  136186. }
  136187. declare module BABYLON {
  136188. /**
  136189. * Post process used to render in black and white
  136190. */
  136191. export class BlackAndWhitePostProcess extends PostProcess {
  136192. /**
  136193. * Linear about to convert he result to black and white (default: 1)
  136194. */
  136195. degree: number;
  136196. /**
  136197. * Creates a black and white post process
  136198. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  136199. * @param name The name of the effect.
  136200. * @param options The required width/height ratio to downsize to before computing the render pass.
  136201. * @param camera The camera to apply the render pass to.
  136202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136203. * @param engine The engine which the post process will be applied. (default: current engine)
  136204. * @param reusable If the post process can be reused on the same frame. (default: false)
  136205. */
  136206. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136207. }
  136208. }
  136209. declare module BABYLON {
  136210. /**
  136211. * This represents a set of one or more post processes in Babylon.
  136212. * A post process can be used to apply a shader to a texture after it is rendered.
  136213. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  136214. */
  136215. export class PostProcessRenderEffect {
  136216. private _postProcesses;
  136217. private _getPostProcesses;
  136218. private _singleInstance;
  136219. private _cameras;
  136220. private _indicesForCamera;
  136221. /**
  136222. * Name of the effect
  136223. * @hidden
  136224. */
  136225. _name: string;
  136226. /**
  136227. * Instantiates a post process render effect.
  136228. * A post process can be used to apply a shader to a texture after it is rendered.
  136229. * @param engine The engine the effect is tied to
  136230. * @param name The name of the effect
  136231. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  136232. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  136233. */
  136234. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  136235. /**
  136236. * Checks if all the post processes in the effect are supported.
  136237. */
  136238. get isSupported(): boolean;
  136239. /**
  136240. * Updates the current state of the effect
  136241. * @hidden
  136242. */
  136243. _update(): void;
  136244. /**
  136245. * Attaches the effect on cameras
  136246. * @param cameras The camera to attach to.
  136247. * @hidden
  136248. */
  136249. _attachCameras(cameras: Camera): void;
  136250. /**
  136251. * Attaches the effect on cameras
  136252. * @param cameras The camera to attach to.
  136253. * @hidden
  136254. */
  136255. _attachCameras(cameras: Camera[]): void;
  136256. /**
  136257. * Detaches the effect on cameras
  136258. * @param cameras The camera to detatch from.
  136259. * @hidden
  136260. */
  136261. _detachCameras(cameras: Camera): void;
  136262. /**
  136263. * Detatches the effect on cameras
  136264. * @param cameras The camera to detatch from.
  136265. * @hidden
  136266. */
  136267. _detachCameras(cameras: Camera[]): void;
  136268. /**
  136269. * Enables the effect on given cameras
  136270. * @param cameras The camera to enable.
  136271. * @hidden
  136272. */
  136273. _enable(cameras: Camera): void;
  136274. /**
  136275. * Enables the effect on given cameras
  136276. * @param cameras The camera to enable.
  136277. * @hidden
  136278. */
  136279. _enable(cameras: Nullable<Camera[]>): void;
  136280. /**
  136281. * Disables the effect on the given cameras
  136282. * @param cameras The camera to disable.
  136283. * @hidden
  136284. */
  136285. _disable(cameras: Camera): void;
  136286. /**
  136287. * Disables the effect on the given cameras
  136288. * @param cameras The camera to disable.
  136289. * @hidden
  136290. */
  136291. _disable(cameras: Nullable<Camera[]>): void;
  136292. /**
  136293. * Gets a list of the post processes contained in the effect.
  136294. * @param camera The camera to get the post processes on.
  136295. * @returns The list of the post processes in the effect.
  136296. */
  136297. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  136298. }
  136299. }
  136300. declare module BABYLON {
  136301. /** @hidden */
  136302. export var extractHighlightsPixelShader: {
  136303. name: string;
  136304. shader: string;
  136305. };
  136306. }
  136307. declare module BABYLON {
  136308. /**
  136309. * 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.
  136310. */
  136311. export class ExtractHighlightsPostProcess extends PostProcess {
  136312. /**
  136313. * The luminance threshold, pixels below this value will be set to black.
  136314. */
  136315. threshold: number;
  136316. /** @hidden */
  136317. _exposure: number;
  136318. /**
  136319. * Post process which has the input texture to be used when performing highlight extraction
  136320. * @hidden
  136321. */
  136322. _inputPostProcess: Nullable<PostProcess>;
  136323. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136324. }
  136325. }
  136326. declare module BABYLON {
  136327. /** @hidden */
  136328. export var bloomMergePixelShader: {
  136329. name: string;
  136330. shader: string;
  136331. };
  136332. }
  136333. declare module BABYLON {
  136334. /**
  136335. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136336. */
  136337. export class BloomMergePostProcess extends PostProcess {
  136338. /** Weight of the bloom to be added to the original input. */
  136339. weight: number;
  136340. /**
  136341. * Creates a new instance of @see BloomMergePostProcess
  136342. * @param name The name of the effect.
  136343. * @param originalFromInput Post process which's input will be used for the merge.
  136344. * @param blurred Blurred highlights post process which's output will be used.
  136345. * @param weight Weight of the bloom to be added to the original input.
  136346. * @param options The required width/height ratio to downsize to before computing the render pass.
  136347. * @param camera The camera to apply the render pass to.
  136348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136349. * @param engine The engine which the post process will be applied. (default: current engine)
  136350. * @param reusable If the post process can be reused on the same frame. (default: false)
  136351. * @param textureType Type of textures used when performing the post process. (default: 0)
  136352. * @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)
  136353. */
  136354. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  136355. /** Weight of the bloom to be added to the original input. */
  136356. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136357. }
  136358. }
  136359. declare module BABYLON {
  136360. /**
  136361. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  136362. */
  136363. export class BloomEffect extends PostProcessRenderEffect {
  136364. private bloomScale;
  136365. /**
  136366. * @hidden Internal
  136367. */
  136368. _effects: Array<PostProcess>;
  136369. /**
  136370. * @hidden Internal
  136371. */
  136372. _downscale: ExtractHighlightsPostProcess;
  136373. private _blurX;
  136374. private _blurY;
  136375. private _merge;
  136376. /**
  136377. * The luminance threshold to find bright areas of the image to bloom.
  136378. */
  136379. get threshold(): number;
  136380. set threshold(value: number);
  136381. /**
  136382. * The strength of the bloom.
  136383. */
  136384. get weight(): number;
  136385. set weight(value: number);
  136386. /**
  136387. * Specifies the size of the bloom blur kernel, relative to the final output size
  136388. */
  136389. get kernel(): number;
  136390. set kernel(value: number);
  136391. /**
  136392. * Creates a new instance of @see BloomEffect
  136393. * @param scene The scene the effect belongs to.
  136394. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  136395. * @param bloomKernel The size of the kernel to be used when applying the blur.
  136396. * @param bloomWeight The the strength of bloom.
  136397. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136398. * @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)
  136399. */
  136400. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  136401. /**
  136402. * Disposes each of the internal effects for a given camera.
  136403. * @param camera The camera to dispose the effect on.
  136404. */
  136405. disposeEffects(camera: Camera): void;
  136406. /**
  136407. * @hidden Internal
  136408. */
  136409. _updateEffects(): void;
  136410. /**
  136411. * Internal
  136412. * @returns if all the contained post processes are ready.
  136413. * @hidden
  136414. */
  136415. _isReady(): boolean;
  136416. }
  136417. }
  136418. declare module BABYLON {
  136419. /** @hidden */
  136420. export var chromaticAberrationPixelShader: {
  136421. name: string;
  136422. shader: string;
  136423. };
  136424. }
  136425. declare module BABYLON {
  136426. /**
  136427. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  136428. */
  136429. export class ChromaticAberrationPostProcess extends PostProcess {
  136430. /**
  136431. * The amount of seperation of rgb channels (default: 30)
  136432. */
  136433. aberrationAmount: number;
  136434. /**
  136435. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  136436. */
  136437. radialIntensity: number;
  136438. /**
  136439. * 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))
  136440. */
  136441. direction: Vector2;
  136442. /**
  136443. * 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))
  136444. */
  136445. centerPosition: Vector2;
  136446. /**
  136447. * Creates a new instance ChromaticAberrationPostProcess
  136448. * @param name The name of the effect.
  136449. * @param screenWidth The width of the screen to apply the effect on.
  136450. * @param screenHeight The height of the screen to apply the effect on.
  136451. * @param options The required width/height ratio to downsize to before computing the render pass.
  136452. * @param camera The camera to apply the render pass to.
  136453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136454. * @param engine The engine which the post process will be applied. (default: current engine)
  136455. * @param reusable If the post process can be reused on the same frame. (default: false)
  136456. * @param textureType Type of textures used when performing the post process. (default: 0)
  136457. * @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)
  136458. */
  136459. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136460. }
  136461. }
  136462. declare module BABYLON {
  136463. /** @hidden */
  136464. export var circleOfConfusionPixelShader: {
  136465. name: string;
  136466. shader: string;
  136467. };
  136468. }
  136469. declare module BABYLON {
  136470. /**
  136471. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  136472. */
  136473. export class CircleOfConfusionPostProcess extends PostProcess {
  136474. /**
  136475. * 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.
  136476. */
  136477. lensSize: number;
  136478. /**
  136479. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136480. */
  136481. fStop: number;
  136482. /**
  136483. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136484. */
  136485. focusDistance: number;
  136486. /**
  136487. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  136488. */
  136489. focalLength: number;
  136490. private _depthTexture;
  136491. /**
  136492. * Creates a new instance CircleOfConfusionPostProcess
  136493. * @param name The name of the effect.
  136494. * @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.
  136495. * @param options The required width/height ratio to downsize to before computing the render pass.
  136496. * @param camera The camera to apply the render pass to.
  136497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136498. * @param engine The engine which the post process will be applied. (default: current engine)
  136499. * @param reusable If the post process can be reused on the same frame. (default: false)
  136500. * @param textureType Type of textures used when performing the post process. (default: 0)
  136501. * @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)
  136502. */
  136503. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136504. /**
  136505. * 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.
  136506. */
  136507. set depthTexture(value: RenderTargetTexture);
  136508. }
  136509. }
  136510. declare module BABYLON {
  136511. /** @hidden */
  136512. export var colorCorrectionPixelShader: {
  136513. name: string;
  136514. shader: string;
  136515. };
  136516. }
  136517. declare module BABYLON {
  136518. /**
  136519. *
  136520. * This post-process allows the modification of rendered colors by using
  136521. * a 'look-up table' (LUT). This effect is also called Color Grading.
  136522. *
  136523. * The object needs to be provided an url to a texture containing the color
  136524. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  136525. * Use an image editing software to tweak the LUT to match your needs.
  136526. *
  136527. * For an example of a color LUT, see here:
  136528. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  136529. * For explanations on color grading, see here:
  136530. * @see http://udn.epicgames.com/Three/ColorGrading.html
  136531. *
  136532. */
  136533. export class ColorCorrectionPostProcess extends PostProcess {
  136534. private _colorTableTexture;
  136535. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136536. }
  136537. }
  136538. declare module BABYLON {
  136539. /** @hidden */
  136540. export var convolutionPixelShader: {
  136541. name: string;
  136542. shader: string;
  136543. };
  136544. }
  136545. declare module BABYLON {
  136546. /**
  136547. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  136548. * input texture to perform effects such as edge detection or sharpening
  136549. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  136550. */
  136551. export class ConvolutionPostProcess extends PostProcess {
  136552. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136553. kernel: number[];
  136554. /**
  136555. * Creates a new instance ConvolutionPostProcess
  136556. * @param name The name of the effect.
  136557. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  136558. * @param options The required width/height ratio to downsize to before computing the render pass.
  136559. * @param camera The camera to apply the render pass to.
  136560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136561. * @param engine The engine which the post process will be applied. (default: current engine)
  136562. * @param reusable If the post process can be reused on the same frame. (default: false)
  136563. * @param textureType Type of textures used when performing the post process. (default: 0)
  136564. */
  136565. constructor(name: string,
  136566. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136567. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136568. /**
  136569. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136570. */
  136571. static EdgeDetect0Kernel: number[];
  136572. /**
  136573. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136574. */
  136575. static EdgeDetect1Kernel: number[];
  136576. /**
  136577. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136578. */
  136579. static EdgeDetect2Kernel: number[];
  136580. /**
  136581. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136582. */
  136583. static SharpenKernel: number[];
  136584. /**
  136585. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136586. */
  136587. static EmbossKernel: number[];
  136588. /**
  136589. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136590. */
  136591. static GaussianKernel: number[];
  136592. }
  136593. }
  136594. declare module BABYLON {
  136595. /**
  136596. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  136597. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  136598. * based on samples that have a large difference in distance than the center pixel.
  136599. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  136600. */
  136601. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  136602. direction: Vector2;
  136603. /**
  136604. * Creates a new instance CircleOfConfusionPostProcess
  136605. * @param name The name of the effect.
  136606. * @param scene The scene the effect belongs to.
  136607. * @param direction The direction the blur should be applied.
  136608. * @param kernel The size of the kernel used to blur.
  136609. * @param options The required width/height ratio to downsize to before computing the render pass.
  136610. * @param camera The camera to apply the render pass to.
  136611. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  136612. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  136613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136614. * @param engine The engine which the post process will be applied. (default: current engine)
  136615. * @param reusable If the post process can be reused on the same frame. (default: false)
  136616. * @param textureType Type of textures used when performing the post process. (default: 0)
  136617. * @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)
  136618. */
  136619. 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);
  136620. }
  136621. }
  136622. declare module BABYLON {
  136623. /** @hidden */
  136624. export var depthOfFieldMergePixelShader: {
  136625. name: string;
  136626. shader: string;
  136627. };
  136628. }
  136629. declare module BABYLON {
  136630. /**
  136631. * Options to be set when merging outputs from the default pipeline.
  136632. */
  136633. export class DepthOfFieldMergePostProcessOptions {
  136634. /**
  136635. * The original image to merge on top of
  136636. */
  136637. originalFromInput: PostProcess;
  136638. /**
  136639. * Parameters to perform the merge of the depth of field effect
  136640. */
  136641. depthOfField?: {
  136642. circleOfConfusion: PostProcess;
  136643. blurSteps: Array<PostProcess>;
  136644. };
  136645. /**
  136646. * Parameters to perform the merge of bloom effect
  136647. */
  136648. bloom?: {
  136649. blurred: PostProcess;
  136650. weight: number;
  136651. };
  136652. }
  136653. /**
  136654. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136655. */
  136656. export class DepthOfFieldMergePostProcess extends PostProcess {
  136657. private blurSteps;
  136658. /**
  136659. * Creates a new instance of DepthOfFieldMergePostProcess
  136660. * @param name The name of the effect.
  136661. * @param originalFromInput Post process which's input will be used for the merge.
  136662. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  136663. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  136664. * @param options The required width/height ratio to downsize to before computing the render pass.
  136665. * @param camera The camera to apply the render pass to.
  136666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136667. * @param engine The engine which the post process will be applied. (default: current engine)
  136668. * @param reusable If the post process can be reused on the same frame. (default: false)
  136669. * @param textureType Type of textures used when performing the post process. (default: 0)
  136670. * @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)
  136671. */
  136672. 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);
  136673. /**
  136674. * Updates the effect with the current post process compile time values and recompiles the shader.
  136675. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  136676. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  136677. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  136678. * @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
  136679. * @param onCompiled Called when the shader has been compiled.
  136680. * @param onError Called if there is an error when compiling a shader.
  136681. */
  136682. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  136683. }
  136684. }
  136685. declare module BABYLON {
  136686. /**
  136687. * Specifies the level of max blur that should be applied when using the depth of field effect
  136688. */
  136689. export enum DepthOfFieldEffectBlurLevel {
  136690. /**
  136691. * Subtle blur
  136692. */
  136693. Low = 0,
  136694. /**
  136695. * Medium blur
  136696. */
  136697. Medium = 1,
  136698. /**
  136699. * Large blur
  136700. */
  136701. High = 2
  136702. }
  136703. /**
  136704. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  136705. */
  136706. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  136707. private _circleOfConfusion;
  136708. /**
  136709. * @hidden Internal, blurs from high to low
  136710. */
  136711. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  136712. private _depthOfFieldBlurY;
  136713. private _dofMerge;
  136714. /**
  136715. * @hidden Internal post processes in depth of field effect
  136716. */
  136717. _effects: Array<PostProcess>;
  136718. /**
  136719. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  136720. */
  136721. set focalLength(value: number);
  136722. get focalLength(): number;
  136723. /**
  136724. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136725. */
  136726. set fStop(value: number);
  136727. get fStop(): number;
  136728. /**
  136729. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136730. */
  136731. set focusDistance(value: number);
  136732. get focusDistance(): number;
  136733. /**
  136734. * 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.
  136735. */
  136736. set lensSize(value: number);
  136737. get lensSize(): number;
  136738. /**
  136739. * Creates a new instance DepthOfFieldEffect
  136740. * @param scene The scene the effect belongs to.
  136741. * @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.
  136742. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136743. * @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)
  136744. */
  136745. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  136746. /**
  136747. * Get the current class name of the current effet
  136748. * @returns "DepthOfFieldEffect"
  136749. */
  136750. getClassName(): string;
  136751. /**
  136752. * 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.
  136753. */
  136754. set depthTexture(value: RenderTargetTexture);
  136755. /**
  136756. * Disposes each of the internal effects for a given camera.
  136757. * @param camera The camera to dispose the effect on.
  136758. */
  136759. disposeEffects(camera: Camera): void;
  136760. /**
  136761. * @hidden Internal
  136762. */
  136763. _updateEffects(): void;
  136764. /**
  136765. * Internal
  136766. * @returns if all the contained post processes are ready.
  136767. * @hidden
  136768. */
  136769. _isReady(): boolean;
  136770. }
  136771. }
  136772. declare module BABYLON {
  136773. /** @hidden */
  136774. export var displayPassPixelShader: {
  136775. name: string;
  136776. shader: string;
  136777. };
  136778. }
  136779. declare module BABYLON {
  136780. /**
  136781. * DisplayPassPostProcess which produces an output the same as it's input
  136782. */
  136783. export class DisplayPassPostProcess extends PostProcess {
  136784. /**
  136785. * Creates the DisplayPassPostProcess
  136786. * @param name The name of the effect.
  136787. * @param options The required width/height ratio to downsize to before computing the render pass.
  136788. * @param camera The camera to apply the render pass to.
  136789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136790. * @param engine The engine which the post process will be applied. (default: current engine)
  136791. * @param reusable If the post process can be reused on the same frame. (default: false)
  136792. */
  136793. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136794. }
  136795. }
  136796. declare module BABYLON {
  136797. /** @hidden */
  136798. export var filterPixelShader: {
  136799. name: string;
  136800. shader: string;
  136801. };
  136802. }
  136803. declare module BABYLON {
  136804. /**
  136805. * Applies a kernel filter to the image
  136806. */
  136807. export class FilterPostProcess extends PostProcess {
  136808. /** The matrix to be applied to the image */
  136809. kernelMatrix: Matrix;
  136810. /**
  136811. *
  136812. * @param name The name of the effect.
  136813. * @param kernelMatrix The matrix to be applied to the image
  136814. * @param options The required width/height ratio to downsize to before computing the render pass.
  136815. * @param camera The camera to apply the render pass to.
  136816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136817. * @param engine The engine which the post process will be applied. (default: current engine)
  136818. * @param reusable If the post process can be reused on the same frame. (default: false)
  136819. */
  136820. constructor(name: string,
  136821. /** The matrix to be applied to the image */
  136822. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136823. }
  136824. }
  136825. declare module BABYLON {
  136826. /** @hidden */
  136827. export var fxaaPixelShader: {
  136828. name: string;
  136829. shader: string;
  136830. };
  136831. }
  136832. declare module BABYLON {
  136833. /** @hidden */
  136834. export var fxaaVertexShader: {
  136835. name: string;
  136836. shader: string;
  136837. };
  136838. }
  136839. declare module BABYLON {
  136840. /**
  136841. * Fxaa post process
  136842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  136843. */
  136844. export class FxaaPostProcess extends PostProcess {
  136845. /** @hidden */
  136846. texelWidth: number;
  136847. /** @hidden */
  136848. texelHeight: number;
  136849. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136850. private _getDefines;
  136851. }
  136852. }
  136853. declare module BABYLON {
  136854. /** @hidden */
  136855. export var grainPixelShader: {
  136856. name: string;
  136857. shader: string;
  136858. };
  136859. }
  136860. declare module BABYLON {
  136861. /**
  136862. * The GrainPostProcess adds noise to the image at mid luminance levels
  136863. */
  136864. export class GrainPostProcess extends PostProcess {
  136865. /**
  136866. * The intensity of the grain added (default: 30)
  136867. */
  136868. intensity: number;
  136869. /**
  136870. * If the grain should be randomized on every frame
  136871. */
  136872. animated: boolean;
  136873. /**
  136874. * Creates a new instance of @see GrainPostProcess
  136875. * @param name The name of the effect.
  136876. * @param options The required width/height ratio to downsize to before computing the render pass.
  136877. * @param camera The camera to apply the render pass to.
  136878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136879. * @param engine The engine which the post process will be applied. (default: current engine)
  136880. * @param reusable If the post process can be reused on the same frame. (default: false)
  136881. * @param textureType Type of textures used when performing the post process. (default: 0)
  136882. * @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)
  136883. */
  136884. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136885. }
  136886. }
  136887. declare module BABYLON {
  136888. /** @hidden */
  136889. export var highlightsPixelShader: {
  136890. name: string;
  136891. shader: string;
  136892. };
  136893. }
  136894. declare module BABYLON {
  136895. /**
  136896. * Extracts highlights from the image
  136897. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  136898. */
  136899. export class HighlightsPostProcess extends PostProcess {
  136900. /**
  136901. * Extracts highlights from the image
  136902. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  136903. * @param name The name of the effect.
  136904. * @param options The required width/height ratio to downsize to before computing the render pass.
  136905. * @param camera The camera to apply the render pass to.
  136906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136907. * @param engine The engine which the post process will be applied. (default: current engine)
  136908. * @param reusable If the post process can be reused on the same frame. (default: false)
  136909. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  136910. */
  136911. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136912. }
  136913. }
  136914. declare module BABYLON {
  136915. /** @hidden */
  136916. export var mrtFragmentDeclaration: {
  136917. name: string;
  136918. shader: string;
  136919. };
  136920. }
  136921. declare module BABYLON {
  136922. /** @hidden */
  136923. export var geometryPixelShader: {
  136924. name: string;
  136925. shader: string;
  136926. };
  136927. }
  136928. declare module BABYLON {
  136929. /** @hidden */
  136930. export var geometryVertexShader: {
  136931. name: string;
  136932. shader: string;
  136933. };
  136934. }
  136935. declare module BABYLON {
  136936. /** @hidden */
  136937. interface ISavedTransformationMatrix {
  136938. world: Matrix;
  136939. viewProjection: Matrix;
  136940. }
  136941. /**
  136942. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  136943. */
  136944. export class GeometryBufferRenderer {
  136945. /**
  136946. * Constant used to retrieve the position texture index in the G-Buffer textures array
  136947. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  136948. */
  136949. static readonly POSITION_TEXTURE_TYPE: number;
  136950. /**
  136951. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  136952. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  136953. */
  136954. static readonly VELOCITY_TEXTURE_TYPE: number;
  136955. /**
  136956. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  136957. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  136958. */
  136959. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  136960. /**
  136961. * Dictionary used to store the previous transformation matrices of each rendered mesh
  136962. * in order to compute objects velocities when enableVelocity is set to "true"
  136963. * @hidden
  136964. */
  136965. _previousTransformationMatrices: {
  136966. [index: number]: ISavedTransformationMatrix;
  136967. };
  136968. /**
  136969. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  136970. * in order to compute objects velocities when enableVelocity is set to "true"
  136971. * @hidden
  136972. */
  136973. _previousBonesTransformationMatrices: {
  136974. [index: number]: Float32Array;
  136975. };
  136976. /**
  136977. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  136978. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  136979. */
  136980. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  136981. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  136982. renderTransparentMeshes: boolean;
  136983. private _scene;
  136984. private _multiRenderTarget;
  136985. private _ratio;
  136986. private _enablePosition;
  136987. private _enableVelocity;
  136988. private _enableReflectivity;
  136989. private _positionIndex;
  136990. private _velocityIndex;
  136991. private _reflectivityIndex;
  136992. protected _effect: Effect;
  136993. protected _cachedDefines: string;
  136994. /**
  136995. * Set the render list (meshes to be rendered) used in the G buffer.
  136996. */
  136997. set renderList(meshes: Mesh[]);
  136998. /**
  136999. * Gets wether or not G buffer are supported by the running hardware.
  137000. * This requires draw buffer supports
  137001. */
  137002. get isSupported(): boolean;
  137003. /**
  137004. * Returns the index of the given texture type in the G-Buffer textures array
  137005. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137006. * @returns the index of the given texture type in the G-Buffer textures array
  137007. */
  137008. getTextureIndex(textureType: number): number;
  137009. /**
  137010. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137011. */
  137012. get enablePosition(): boolean;
  137013. /**
  137014. * Sets whether or not objects positions are enabled for the G buffer.
  137015. */
  137016. set enablePosition(enable: boolean);
  137017. /**
  137018. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137019. */
  137020. get enableVelocity(): boolean;
  137021. /**
  137022. * Sets wether or not objects velocities are enabled for the G buffer.
  137023. */
  137024. set enableVelocity(enable: boolean);
  137025. /**
  137026. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137027. */
  137028. get enableReflectivity(): boolean;
  137029. /**
  137030. * Sets wether or not objects roughness are enabled for the G buffer.
  137031. */
  137032. set enableReflectivity(enable: boolean);
  137033. /**
  137034. * Gets the scene associated with the buffer.
  137035. */
  137036. get scene(): Scene;
  137037. /**
  137038. * Gets the ratio used by the buffer during its creation.
  137039. * How big is the buffer related to the main canvas.
  137040. */
  137041. get ratio(): number;
  137042. /** @hidden */
  137043. static _SceneComponentInitialization: (scene: Scene) => void;
  137044. /**
  137045. * Creates a new G Buffer for the scene
  137046. * @param scene The scene the buffer belongs to
  137047. * @param ratio How big is the buffer related to the main canvas.
  137048. */
  137049. constructor(scene: Scene, ratio?: number);
  137050. /**
  137051. * Checks wether everything is ready to render a submesh to the G buffer.
  137052. * @param subMesh the submesh to check readiness for
  137053. * @param useInstances is the mesh drawn using instance or not
  137054. * @returns true if ready otherwise false
  137055. */
  137056. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137057. /**
  137058. * Gets the current underlying G Buffer.
  137059. * @returns the buffer
  137060. */
  137061. getGBuffer(): MultiRenderTarget;
  137062. /**
  137063. * Gets the number of samples used to render the buffer (anti aliasing).
  137064. */
  137065. get samples(): number;
  137066. /**
  137067. * Sets the number of samples used to render the buffer (anti aliasing).
  137068. */
  137069. set samples(value: number);
  137070. /**
  137071. * Disposes the renderer and frees up associated resources.
  137072. */
  137073. dispose(): void;
  137074. protected _createRenderTargets(): void;
  137075. private _copyBonesTransformationMatrices;
  137076. }
  137077. }
  137078. declare module BABYLON {
  137079. interface Scene {
  137080. /** @hidden (Backing field) */
  137081. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137082. /**
  137083. * Gets or Sets the current geometry buffer associated to the scene.
  137084. */
  137085. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137086. /**
  137087. * Enables a GeometryBufferRender and associates it with the scene
  137088. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137089. * @returns the GeometryBufferRenderer
  137090. */
  137091. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137092. /**
  137093. * Disables the GeometryBufferRender associated with the scene
  137094. */
  137095. disableGeometryBufferRenderer(): void;
  137096. }
  137097. /**
  137098. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137099. * in several rendering techniques.
  137100. */
  137101. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137102. /**
  137103. * The component name helpful to identify the component in the list of scene components.
  137104. */
  137105. readonly name: string;
  137106. /**
  137107. * The scene the component belongs to.
  137108. */
  137109. scene: Scene;
  137110. /**
  137111. * Creates a new instance of the component for the given scene
  137112. * @param scene Defines the scene to register the component in
  137113. */
  137114. constructor(scene: Scene);
  137115. /**
  137116. * Registers the component in a given scene
  137117. */
  137118. register(): void;
  137119. /**
  137120. * Rebuilds the elements related to this component in case of
  137121. * context lost for instance.
  137122. */
  137123. rebuild(): void;
  137124. /**
  137125. * Disposes the component and the associated ressources
  137126. */
  137127. dispose(): void;
  137128. private _gatherRenderTargets;
  137129. }
  137130. }
  137131. declare module BABYLON {
  137132. /** @hidden */
  137133. export var motionBlurPixelShader: {
  137134. name: string;
  137135. shader: string;
  137136. };
  137137. }
  137138. declare module BABYLON {
  137139. /**
  137140. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137141. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137142. * As an example, all you have to do is to create the post-process:
  137143. * var mb = new BABYLON.MotionBlurPostProcess(
  137144. * 'mb', // The name of the effect.
  137145. * scene, // The scene containing the objects to blur according to their velocity.
  137146. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137147. * camera // The camera to apply the render pass to.
  137148. * );
  137149. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137150. */
  137151. export class MotionBlurPostProcess extends PostProcess {
  137152. /**
  137153. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137154. */
  137155. motionStrength: number;
  137156. /**
  137157. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137158. */
  137159. get motionBlurSamples(): number;
  137160. /**
  137161. * Sets the number of iterations to be used for motion blur quality
  137162. */
  137163. set motionBlurSamples(samples: number);
  137164. private _motionBlurSamples;
  137165. private _geometryBufferRenderer;
  137166. /**
  137167. * Creates a new instance MotionBlurPostProcess
  137168. * @param name The name of the effect.
  137169. * @param scene The scene containing the objects to blur according to their velocity.
  137170. * @param options The required width/height ratio to downsize to before computing the render pass.
  137171. * @param camera The camera to apply the render pass to.
  137172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137173. * @param engine The engine which the post process will be applied. (default: current engine)
  137174. * @param reusable If the post process can be reused on the same frame. (default: false)
  137175. * @param textureType Type of textures used when performing the post process. (default: 0)
  137176. * @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)
  137177. */
  137178. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137179. /**
  137180. * Excludes the given skinned mesh from computing bones velocities.
  137181. * 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.
  137182. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  137183. */
  137184. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137185. /**
  137186. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  137187. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  137188. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  137189. */
  137190. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137191. /**
  137192. * Disposes the post process.
  137193. * @param camera The camera to dispose the post process on.
  137194. */
  137195. dispose(camera?: Camera): void;
  137196. }
  137197. }
  137198. declare module BABYLON {
  137199. /** @hidden */
  137200. export var refractionPixelShader: {
  137201. name: string;
  137202. shader: string;
  137203. };
  137204. }
  137205. declare module BABYLON {
  137206. /**
  137207. * Post process which applies a refractin texture
  137208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137209. */
  137210. export class RefractionPostProcess extends PostProcess {
  137211. /** the base color of the refraction (used to taint the rendering) */
  137212. color: Color3;
  137213. /** simulated refraction depth */
  137214. depth: number;
  137215. /** the coefficient of the base color (0 to remove base color tainting) */
  137216. colorLevel: number;
  137217. private _refTexture;
  137218. private _ownRefractionTexture;
  137219. /**
  137220. * Gets or sets the refraction texture
  137221. * Please note that you are responsible for disposing the texture if you set it manually
  137222. */
  137223. get refractionTexture(): Texture;
  137224. set refractionTexture(value: Texture);
  137225. /**
  137226. * Initializes the RefractionPostProcess
  137227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137228. * @param name The name of the effect.
  137229. * @param refractionTextureUrl Url of the refraction texture to use
  137230. * @param color the base color of the refraction (used to taint the rendering)
  137231. * @param depth simulated refraction depth
  137232. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  137233. * @param camera The camera to apply the render pass to.
  137234. * @param options The required width/height ratio to downsize to before computing the render pass.
  137235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137236. * @param engine The engine which the post process will be applied. (default: current engine)
  137237. * @param reusable If the post process can be reused on the same frame. (default: false)
  137238. */
  137239. constructor(name: string, refractionTextureUrl: string,
  137240. /** the base color of the refraction (used to taint the rendering) */
  137241. color: Color3,
  137242. /** simulated refraction depth */
  137243. depth: number,
  137244. /** the coefficient of the base color (0 to remove base color tainting) */
  137245. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137246. /**
  137247. * Disposes of the post process
  137248. * @param camera Camera to dispose post process on
  137249. */
  137250. dispose(camera: Camera): void;
  137251. }
  137252. }
  137253. declare module BABYLON {
  137254. /** @hidden */
  137255. export var sharpenPixelShader: {
  137256. name: string;
  137257. shader: string;
  137258. };
  137259. }
  137260. declare module BABYLON {
  137261. /**
  137262. * The SharpenPostProcess applies a sharpen kernel to every pixel
  137263. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137264. */
  137265. export class SharpenPostProcess extends PostProcess {
  137266. /**
  137267. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  137268. */
  137269. colorAmount: number;
  137270. /**
  137271. * How much sharpness should be applied (default: 0.3)
  137272. */
  137273. edgeAmount: number;
  137274. /**
  137275. * Creates a new instance ConvolutionPostProcess
  137276. * @param name The name of the effect.
  137277. * @param options The required width/height ratio to downsize to before computing the render pass.
  137278. * @param camera The camera to apply the render pass to.
  137279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137280. * @param engine The engine which the post process will be applied. (default: current engine)
  137281. * @param reusable If the post process can be reused on the same frame. (default: false)
  137282. * @param textureType Type of textures used when performing the post process. (default: 0)
  137283. * @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)
  137284. */
  137285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137286. }
  137287. }
  137288. declare module BABYLON {
  137289. /**
  137290. * PostProcessRenderPipeline
  137291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137292. */
  137293. export class PostProcessRenderPipeline {
  137294. private engine;
  137295. private _renderEffects;
  137296. private _renderEffectsForIsolatedPass;
  137297. /**
  137298. * List of inspectable custom properties (used by the Inspector)
  137299. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  137300. */
  137301. inspectableCustomProperties: IInspectable[];
  137302. /**
  137303. * @hidden
  137304. */
  137305. protected _cameras: Camera[];
  137306. /** @hidden */
  137307. _name: string;
  137308. /**
  137309. * Gets pipeline name
  137310. */
  137311. get name(): string;
  137312. /** Gets the list of attached cameras */
  137313. get cameras(): Camera[];
  137314. /**
  137315. * Initializes a PostProcessRenderPipeline
  137316. * @param engine engine to add the pipeline to
  137317. * @param name name of the pipeline
  137318. */
  137319. constructor(engine: Engine, name: string);
  137320. /**
  137321. * Gets the class name
  137322. * @returns "PostProcessRenderPipeline"
  137323. */
  137324. getClassName(): string;
  137325. /**
  137326. * If all the render effects in the pipeline are supported
  137327. */
  137328. get isSupported(): boolean;
  137329. /**
  137330. * Adds an effect to the pipeline
  137331. * @param renderEffect the effect to add
  137332. */
  137333. addEffect(renderEffect: PostProcessRenderEffect): void;
  137334. /** @hidden */
  137335. _rebuild(): void;
  137336. /** @hidden */
  137337. _enableEffect(renderEffectName: string, cameras: Camera): void;
  137338. /** @hidden */
  137339. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  137340. /** @hidden */
  137341. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137342. /** @hidden */
  137343. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137344. /** @hidden */
  137345. _attachCameras(cameras: Camera, unique: boolean): void;
  137346. /** @hidden */
  137347. _attachCameras(cameras: Camera[], unique: boolean): void;
  137348. /** @hidden */
  137349. _detachCameras(cameras: Camera): void;
  137350. /** @hidden */
  137351. _detachCameras(cameras: Nullable<Camera[]>): void;
  137352. /** @hidden */
  137353. _update(): void;
  137354. /** @hidden */
  137355. _reset(): void;
  137356. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  137357. /**
  137358. * Disposes of the pipeline
  137359. */
  137360. dispose(): void;
  137361. }
  137362. }
  137363. declare module BABYLON {
  137364. /**
  137365. * PostProcessRenderPipelineManager class
  137366. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137367. */
  137368. export class PostProcessRenderPipelineManager {
  137369. private _renderPipelines;
  137370. /**
  137371. * Initializes a PostProcessRenderPipelineManager
  137372. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137373. */
  137374. constructor();
  137375. /**
  137376. * Gets the list of supported render pipelines
  137377. */
  137378. get supportedPipelines(): PostProcessRenderPipeline[];
  137379. /**
  137380. * Adds a pipeline to the manager
  137381. * @param renderPipeline The pipeline to add
  137382. */
  137383. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  137384. /**
  137385. * Attaches a camera to the pipeline
  137386. * @param renderPipelineName The name of the pipeline to attach to
  137387. * @param cameras the camera to attach
  137388. * @param unique if the camera can be attached multiple times to the pipeline
  137389. */
  137390. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  137391. /**
  137392. * Detaches a camera from the pipeline
  137393. * @param renderPipelineName The name of the pipeline to detach from
  137394. * @param cameras the camera to detach
  137395. */
  137396. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  137397. /**
  137398. * Enables an effect by name on a pipeline
  137399. * @param renderPipelineName the name of the pipeline to enable the effect in
  137400. * @param renderEffectName the name of the effect to enable
  137401. * @param cameras the cameras that the effect should be enabled on
  137402. */
  137403. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137404. /**
  137405. * Disables an effect by name on a pipeline
  137406. * @param renderPipelineName the name of the pipeline to disable the effect in
  137407. * @param renderEffectName the name of the effect to disable
  137408. * @param cameras the cameras that the effect should be disabled on
  137409. */
  137410. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137411. /**
  137412. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  137413. */
  137414. update(): void;
  137415. /** @hidden */
  137416. _rebuild(): void;
  137417. /**
  137418. * Disposes of the manager and pipelines
  137419. */
  137420. dispose(): void;
  137421. }
  137422. }
  137423. declare module BABYLON {
  137424. interface Scene {
  137425. /** @hidden (Backing field) */
  137426. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137427. /**
  137428. * Gets the postprocess render pipeline manager
  137429. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137430. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137431. */
  137432. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137433. }
  137434. /**
  137435. * Defines the Render Pipeline scene component responsible to rendering pipelines
  137436. */
  137437. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  137438. /**
  137439. * The component name helpfull to identify the component in the list of scene components.
  137440. */
  137441. readonly name: string;
  137442. /**
  137443. * The scene the component belongs to.
  137444. */
  137445. scene: Scene;
  137446. /**
  137447. * Creates a new instance of the component for the given scene
  137448. * @param scene Defines the scene to register the component in
  137449. */
  137450. constructor(scene: Scene);
  137451. /**
  137452. * Registers the component in a given scene
  137453. */
  137454. register(): void;
  137455. /**
  137456. * Rebuilds the elements related to this component in case of
  137457. * context lost for instance.
  137458. */
  137459. rebuild(): void;
  137460. /**
  137461. * Disposes the component and the associated ressources
  137462. */
  137463. dispose(): void;
  137464. private _gatherRenderTargets;
  137465. }
  137466. }
  137467. declare module BABYLON {
  137468. /**
  137469. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  137470. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137471. */
  137472. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  137473. private _scene;
  137474. private _camerasToBeAttached;
  137475. /**
  137476. * ID of the sharpen post process,
  137477. */
  137478. private readonly SharpenPostProcessId;
  137479. /**
  137480. * @ignore
  137481. * ID of the image processing post process;
  137482. */
  137483. readonly ImageProcessingPostProcessId: string;
  137484. /**
  137485. * @ignore
  137486. * ID of the Fast Approximate Anti-Aliasing post process;
  137487. */
  137488. readonly FxaaPostProcessId: string;
  137489. /**
  137490. * ID of the chromatic aberration post process,
  137491. */
  137492. private readonly ChromaticAberrationPostProcessId;
  137493. /**
  137494. * ID of the grain post process
  137495. */
  137496. private readonly GrainPostProcessId;
  137497. /**
  137498. * Sharpen post process which will apply a sharpen convolution to enhance edges
  137499. */
  137500. sharpen: SharpenPostProcess;
  137501. private _sharpenEffect;
  137502. private bloom;
  137503. /**
  137504. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  137505. */
  137506. depthOfField: DepthOfFieldEffect;
  137507. /**
  137508. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  137509. */
  137510. fxaa: FxaaPostProcess;
  137511. /**
  137512. * Image post processing pass used to perform operations such as tone mapping or color grading.
  137513. */
  137514. imageProcessing: ImageProcessingPostProcess;
  137515. /**
  137516. * Chromatic aberration post process which will shift rgb colors in the image
  137517. */
  137518. chromaticAberration: ChromaticAberrationPostProcess;
  137519. private _chromaticAberrationEffect;
  137520. /**
  137521. * Grain post process which add noise to the image
  137522. */
  137523. grain: GrainPostProcess;
  137524. private _grainEffect;
  137525. /**
  137526. * Glow post process which adds a glow to emissive areas of the image
  137527. */
  137528. private _glowLayer;
  137529. /**
  137530. * Animations which can be used to tweak settings over a period of time
  137531. */
  137532. animations: Animation[];
  137533. private _imageProcessingConfigurationObserver;
  137534. private _sharpenEnabled;
  137535. private _bloomEnabled;
  137536. private _depthOfFieldEnabled;
  137537. private _depthOfFieldBlurLevel;
  137538. private _fxaaEnabled;
  137539. private _imageProcessingEnabled;
  137540. private _defaultPipelineTextureType;
  137541. private _bloomScale;
  137542. private _chromaticAberrationEnabled;
  137543. private _grainEnabled;
  137544. private _buildAllowed;
  137545. /**
  137546. * Gets active scene
  137547. */
  137548. get scene(): Scene;
  137549. /**
  137550. * Enable or disable the sharpen process from the pipeline
  137551. */
  137552. set sharpenEnabled(enabled: boolean);
  137553. get sharpenEnabled(): boolean;
  137554. private _resizeObserver;
  137555. private _hardwareScaleLevel;
  137556. private _bloomKernel;
  137557. /**
  137558. * Specifies the size of the bloom blur kernel, relative to the final output size
  137559. */
  137560. get bloomKernel(): number;
  137561. set bloomKernel(value: number);
  137562. /**
  137563. * Specifies the weight of the bloom in the final rendering
  137564. */
  137565. private _bloomWeight;
  137566. /**
  137567. * Specifies the luma threshold for the area that will be blurred by the bloom
  137568. */
  137569. private _bloomThreshold;
  137570. private _hdr;
  137571. /**
  137572. * The strength of the bloom.
  137573. */
  137574. set bloomWeight(value: number);
  137575. get bloomWeight(): number;
  137576. /**
  137577. * The strength of the bloom.
  137578. */
  137579. set bloomThreshold(value: number);
  137580. get bloomThreshold(): number;
  137581. /**
  137582. * The scale of the bloom, lower value will provide better performance.
  137583. */
  137584. set bloomScale(value: number);
  137585. get bloomScale(): number;
  137586. /**
  137587. * Enable or disable the bloom from the pipeline
  137588. */
  137589. set bloomEnabled(enabled: boolean);
  137590. get bloomEnabled(): boolean;
  137591. private _rebuildBloom;
  137592. /**
  137593. * If the depth of field is enabled.
  137594. */
  137595. get depthOfFieldEnabled(): boolean;
  137596. set depthOfFieldEnabled(enabled: boolean);
  137597. /**
  137598. * Blur level of the depth of field effect. (Higher blur will effect performance)
  137599. */
  137600. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  137601. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  137602. /**
  137603. * If the anti aliasing is enabled.
  137604. */
  137605. set fxaaEnabled(enabled: boolean);
  137606. get fxaaEnabled(): boolean;
  137607. private _samples;
  137608. /**
  137609. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  137610. */
  137611. set samples(sampleCount: number);
  137612. get samples(): number;
  137613. /**
  137614. * If image processing is enabled.
  137615. */
  137616. set imageProcessingEnabled(enabled: boolean);
  137617. get imageProcessingEnabled(): boolean;
  137618. /**
  137619. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  137620. */
  137621. set glowLayerEnabled(enabled: boolean);
  137622. get glowLayerEnabled(): boolean;
  137623. /**
  137624. * Gets the glow layer (or null if not defined)
  137625. */
  137626. get glowLayer(): Nullable<GlowLayer>;
  137627. /**
  137628. * Enable or disable the chromaticAberration process from the pipeline
  137629. */
  137630. set chromaticAberrationEnabled(enabled: boolean);
  137631. get chromaticAberrationEnabled(): boolean;
  137632. /**
  137633. * Enable or disable the grain process from the pipeline
  137634. */
  137635. set grainEnabled(enabled: boolean);
  137636. get grainEnabled(): boolean;
  137637. /**
  137638. * @constructor
  137639. * @param name - The rendering pipeline name (default: "")
  137640. * @param hdr - If high dynamic range textures should be used (default: true)
  137641. * @param scene - The scene linked to this pipeline (default: the last created scene)
  137642. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  137643. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  137644. */
  137645. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  137646. /**
  137647. * Get the class name
  137648. * @returns "DefaultRenderingPipeline"
  137649. */
  137650. getClassName(): string;
  137651. /**
  137652. * Force the compilation of the entire pipeline.
  137653. */
  137654. prepare(): void;
  137655. private _hasCleared;
  137656. private _prevPostProcess;
  137657. private _prevPrevPostProcess;
  137658. private _setAutoClearAndTextureSharing;
  137659. private _depthOfFieldSceneObserver;
  137660. private _buildPipeline;
  137661. private _disposePostProcesses;
  137662. /**
  137663. * Adds a camera to the pipeline
  137664. * @param camera the camera to be added
  137665. */
  137666. addCamera(camera: Camera): void;
  137667. /**
  137668. * Removes a camera from the pipeline
  137669. * @param camera the camera to remove
  137670. */
  137671. removeCamera(camera: Camera): void;
  137672. /**
  137673. * Dispose of the pipeline and stop all post processes
  137674. */
  137675. dispose(): void;
  137676. /**
  137677. * Serialize the rendering pipeline (Used when exporting)
  137678. * @returns the serialized object
  137679. */
  137680. serialize(): any;
  137681. /**
  137682. * Parse the serialized pipeline
  137683. * @param source Source pipeline.
  137684. * @param scene The scene to load the pipeline to.
  137685. * @param rootUrl The URL of the serialized pipeline.
  137686. * @returns An instantiated pipeline from the serialized object.
  137687. */
  137688. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  137689. }
  137690. }
  137691. declare module BABYLON {
  137692. /** @hidden */
  137693. export var lensHighlightsPixelShader: {
  137694. name: string;
  137695. shader: string;
  137696. };
  137697. }
  137698. declare module BABYLON {
  137699. /** @hidden */
  137700. export var depthOfFieldPixelShader: {
  137701. name: string;
  137702. shader: string;
  137703. };
  137704. }
  137705. declare module BABYLON {
  137706. /**
  137707. * BABYLON.JS Chromatic Aberration GLSL Shader
  137708. * Author: Olivier Guyot
  137709. * Separates very slightly R, G and B colors on the edges of the screen
  137710. * Inspired by Francois Tarlier & Martins Upitis
  137711. */
  137712. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  137713. /**
  137714. * @ignore
  137715. * The chromatic aberration PostProcess id in the pipeline
  137716. */
  137717. LensChromaticAberrationEffect: string;
  137718. /**
  137719. * @ignore
  137720. * The highlights enhancing PostProcess id in the pipeline
  137721. */
  137722. HighlightsEnhancingEffect: string;
  137723. /**
  137724. * @ignore
  137725. * The depth-of-field PostProcess id in the pipeline
  137726. */
  137727. LensDepthOfFieldEffect: string;
  137728. private _scene;
  137729. private _depthTexture;
  137730. private _grainTexture;
  137731. private _chromaticAberrationPostProcess;
  137732. private _highlightsPostProcess;
  137733. private _depthOfFieldPostProcess;
  137734. private _edgeBlur;
  137735. private _grainAmount;
  137736. private _chromaticAberration;
  137737. private _distortion;
  137738. private _highlightsGain;
  137739. private _highlightsThreshold;
  137740. private _dofDistance;
  137741. private _dofAperture;
  137742. private _dofDarken;
  137743. private _dofPentagon;
  137744. private _blurNoise;
  137745. /**
  137746. * @constructor
  137747. *
  137748. * Effect parameters are as follow:
  137749. * {
  137750. * chromatic_aberration: number; // from 0 to x (1 for realism)
  137751. * edge_blur: number; // from 0 to x (1 for realism)
  137752. * distortion: number; // from 0 to x (1 for realism)
  137753. * grain_amount: number; // from 0 to 1
  137754. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  137755. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  137756. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  137757. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  137758. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  137759. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  137760. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  137761. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  137762. * }
  137763. * Note: if an effect parameter is unset, effect is disabled
  137764. *
  137765. * @param name The rendering pipeline name
  137766. * @param parameters - An object containing all parameters (see above)
  137767. * @param scene The scene linked to this pipeline
  137768. * @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)
  137769. * @param cameras The array of cameras that the rendering pipeline will be attached to
  137770. */
  137771. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  137772. /**
  137773. * Get the class name
  137774. * @returns "LensRenderingPipeline"
  137775. */
  137776. getClassName(): string;
  137777. /**
  137778. * Gets associated scene
  137779. */
  137780. get scene(): Scene;
  137781. /**
  137782. * Gets or sets the edge blur
  137783. */
  137784. get edgeBlur(): number;
  137785. set edgeBlur(value: number);
  137786. /**
  137787. * Gets or sets the grain amount
  137788. */
  137789. get grainAmount(): number;
  137790. set grainAmount(value: number);
  137791. /**
  137792. * Gets or sets the chromatic aberration amount
  137793. */
  137794. get chromaticAberration(): number;
  137795. set chromaticAberration(value: number);
  137796. /**
  137797. * Gets or sets the depth of field aperture
  137798. */
  137799. get dofAperture(): number;
  137800. set dofAperture(value: number);
  137801. /**
  137802. * Gets or sets the edge distortion
  137803. */
  137804. get edgeDistortion(): number;
  137805. set edgeDistortion(value: number);
  137806. /**
  137807. * Gets or sets the depth of field distortion
  137808. */
  137809. get dofDistortion(): number;
  137810. set dofDistortion(value: number);
  137811. /**
  137812. * Gets or sets the darken out of focus amount
  137813. */
  137814. get darkenOutOfFocus(): number;
  137815. set darkenOutOfFocus(value: number);
  137816. /**
  137817. * Gets or sets a boolean indicating if blur noise is enabled
  137818. */
  137819. get blurNoise(): boolean;
  137820. set blurNoise(value: boolean);
  137821. /**
  137822. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  137823. */
  137824. get pentagonBokeh(): boolean;
  137825. set pentagonBokeh(value: boolean);
  137826. /**
  137827. * Gets or sets the highlight grain amount
  137828. */
  137829. get highlightsGain(): number;
  137830. set highlightsGain(value: number);
  137831. /**
  137832. * Gets or sets the highlight threshold
  137833. */
  137834. get highlightsThreshold(): number;
  137835. set highlightsThreshold(value: number);
  137836. /**
  137837. * Sets the amount of blur at the edges
  137838. * @param amount blur amount
  137839. */
  137840. setEdgeBlur(amount: number): void;
  137841. /**
  137842. * Sets edge blur to 0
  137843. */
  137844. disableEdgeBlur(): void;
  137845. /**
  137846. * Sets the amout of grain
  137847. * @param amount Amount of grain
  137848. */
  137849. setGrainAmount(amount: number): void;
  137850. /**
  137851. * Set grain amount to 0
  137852. */
  137853. disableGrain(): void;
  137854. /**
  137855. * Sets the chromatic aberration amount
  137856. * @param amount amount of chromatic aberration
  137857. */
  137858. setChromaticAberration(amount: number): void;
  137859. /**
  137860. * Sets chromatic aberration amount to 0
  137861. */
  137862. disableChromaticAberration(): void;
  137863. /**
  137864. * Sets the EdgeDistortion amount
  137865. * @param amount amount of EdgeDistortion
  137866. */
  137867. setEdgeDistortion(amount: number): void;
  137868. /**
  137869. * Sets edge distortion to 0
  137870. */
  137871. disableEdgeDistortion(): void;
  137872. /**
  137873. * Sets the FocusDistance amount
  137874. * @param amount amount of FocusDistance
  137875. */
  137876. setFocusDistance(amount: number): void;
  137877. /**
  137878. * Disables depth of field
  137879. */
  137880. disableDepthOfField(): void;
  137881. /**
  137882. * Sets the Aperture amount
  137883. * @param amount amount of Aperture
  137884. */
  137885. setAperture(amount: number): void;
  137886. /**
  137887. * Sets the DarkenOutOfFocus amount
  137888. * @param amount amount of DarkenOutOfFocus
  137889. */
  137890. setDarkenOutOfFocus(amount: number): void;
  137891. private _pentagonBokehIsEnabled;
  137892. /**
  137893. * Creates a pentagon bokeh effect
  137894. */
  137895. enablePentagonBokeh(): void;
  137896. /**
  137897. * Disables the pentagon bokeh effect
  137898. */
  137899. disablePentagonBokeh(): void;
  137900. /**
  137901. * Enables noise blur
  137902. */
  137903. enableNoiseBlur(): void;
  137904. /**
  137905. * Disables noise blur
  137906. */
  137907. disableNoiseBlur(): void;
  137908. /**
  137909. * Sets the HighlightsGain amount
  137910. * @param amount amount of HighlightsGain
  137911. */
  137912. setHighlightsGain(amount: number): void;
  137913. /**
  137914. * Sets the HighlightsThreshold amount
  137915. * @param amount amount of HighlightsThreshold
  137916. */
  137917. setHighlightsThreshold(amount: number): void;
  137918. /**
  137919. * Disables highlights
  137920. */
  137921. disableHighlights(): void;
  137922. /**
  137923. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  137924. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  137925. */
  137926. dispose(disableDepthRender?: boolean): void;
  137927. private _createChromaticAberrationPostProcess;
  137928. private _createHighlightsPostProcess;
  137929. private _createDepthOfFieldPostProcess;
  137930. private _createGrainTexture;
  137931. }
  137932. }
  137933. declare module BABYLON {
  137934. /** @hidden */
  137935. export var ssao2PixelShader: {
  137936. name: string;
  137937. shader: string;
  137938. };
  137939. }
  137940. declare module BABYLON {
  137941. /** @hidden */
  137942. export var ssaoCombinePixelShader: {
  137943. name: string;
  137944. shader: string;
  137945. };
  137946. }
  137947. declare module BABYLON {
  137948. /**
  137949. * Render pipeline to produce ssao effect
  137950. */
  137951. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  137952. /**
  137953. * @ignore
  137954. * The PassPostProcess id in the pipeline that contains the original scene color
  137955. */
  137956. SSAOOriginalSceneColorEffect: string;
  137957. /**
  137958. * @ignore
  137959. * The SSAO PostProcess id in the pipeline
  137960. */
  137961. SSAORenderEffect: string;
  137962. /**
  137963. * @ignore
  137964. * The horizontal blur PostProcess id in the pipeline
  137965. */
  137966. SSAOBlurHRenderEffect: string;
  137967. /**
  137968. * @ignore
  137969. * The vertical blur PostProcess id in the pipeline
  137970. */
  137971. SSAOBlurVRenderEffect: string;
  137972. /**
  137973. * @ignore
  137974. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  137975. */
  137976. SSAOCombineRenderEffect: string;
  137977. /**
  137978. * The output strength of the SSAO post-process. Default value is 1.0.
  137979. */
  137980. totalStrength: number;
  137981. /**
  137982. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  137983. */
  137984. maxZ: number;
  137985. /**
  137986. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  137987. */
  137988. minZAspect: number;
  137989. private _samples;
  137990. /**
  137991. * Number of samples used for the SSAO calculations. Default value is 8
  137992. */
  137993. set samples(n: number);
  137994. get samples(): number;
  137995. private _textureSamples;
  137996. /**
  137997. * Number of samples to use for antialiasing
  137998. */
  137999. set textureSamples(n: number);
  138000. get textureSamples(): number;
  138001. /**
  138002. * Ratio object used for SSAO ratio and blur ratio
  138003. */
  138004. private _ratio;
  138005. /**
  138006. * Dynamically generated sphere sampler.
  138007. */
  138008. private _sampleSphere;
  138009. /**
  138010. * Blur filter offsets
  138011. */
  138012. private _samplerOffsets;
  138013. private _expensiveBlur;
  138014. /**
  138015. * If bilateral blur should be used
  138016. */
  138017. set expensiveBlur(b: boolean);
  138018. get expensiveBlur(): boolean;
  138019. /**
  138020. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138021. */
  138022. radius: number;
  138023. /**
  138024. * The base color of the SSAO post-process
  138025. * The final result is "base + ssao" between [0, 1]
  138026. */
  138027. base: number;
  138028. /**
  138029. * Support test.
  138030. */
  138031. static get IsSupported(): boolean;
  138032. private _scene;
  138033. private _depthTexture;
  138034. private _normalTexture;
  138035. private _randomTexture;
  138036. private _originalColorPostProcess;
  138037. private _ssaoPostProcess;
  138038. private _blurHPostProcess;
  138039. private _blurVPostProcess;
  138040. private _ssaoCombinePostProcess;
  138041. /**
  138042. * Gets active scene
  138043. */
  138044. get scene(): Scene;
  138045. /**
  138046. * @constructor
  138047. * @param name The rendering pipeline name
  138048. * @param scene The scene linked to this pipeline
  138049. * @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 }
  138050. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138051. */
  138052. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138053. /**
  138054. * Get the class name
  138055. * @returns "SSAO2RenderingPipeline"
  138056. */
  138057. getClassName(): string;
  138058. /**
  138059. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138060. */
  138061. dispose(disableGeometryBufferRenderer?: boolean): void;
  138062. private _createBlurPostProcess;
  138063. /** @hidden */
  138064. _rebuild(): void;
  138065. private _bits;
  138066. private _radicalInverse_VdC;
  138067. private _hammersley;
  138068. private _hemisphereSample_uniform;
  138069. private _generateHemisphere;
  138070. private _createSSAOPostProcess;
  138071. private _createSSAOCombinePostProcess;
  138072. private _createRandomTexture;
  138073. /**
  138074. * Serialize the rendering pipeline (Used when exporting)
  138075. * @returns the serialized object
  138076. */
  138077. serialize(): any;
  138078. /**
  138079. * Parse the serialized pipeline
  138080. * @param source Source pipeline.
  138081. * @param scene The scene to load the pipeline to.
  138082. * @param rootUrl The URL of the serialized pipeline.
  138083. * @returns An instantiated pipeline from the serialized object.
  138084. */
  138085. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138086. }
  138087. }
  138088. declare module BABYLON {
  138089. /** @hidden */
  138090. export var ssaoPixelShader: {
  138091. name: string;
  138092. shader: string;
  138093. };
  138094. }
  138095. declare module BABYLON {
  138096. /**
  138097. * Render pipeline to produce ssao effect
  138098. */
  138099. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138100. /**
  138101. * @ignore
  138102. * The PassPostProcess id in the pipeline that contains the original scene color
  138103. */
  138104. SSAOOriginalSceneColorEffect: string;
  138105. /**
  138106. * @ignore
  138107. * The SSAO PostProcess id in the pipeline
  138108. */
  138109. SSAORenderEffect: string;
  138110. /**
  138111. * @ignore
  138112. * The horizontal blur PostProcess id in the pipeline
  138113. */
  138114. SSAOBlurHRenderEffect: string;
  138115. /**
  138116. * @ignore
  138117. * The vertical blur PostProcess id in the pipeline
  138118. */
  138119. SSAOBlurVRenderEffect: string;
  138120. /**
  138121. * @ignore
  138122. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138123. */
  138124. SSAOCombineRenderEffect: string;
  138125. /**
  138126. * The output strength of the SSAO post-process. Default value is 1.0.
  138127. */
  138128. totalStrength: number;
  138129. /**
  138130. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138131. */
  138132. radius: number;
  138133. /**
  138134. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138135. * Must not be equal to fallOff and superior to fallOff.
  138136. * Default value is 0.0075
  138137. */
  138138. area: number;
  138139. /**
  138140. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138141. * Must not be equal to area and inferior to area.
  138142. * Default value is 0.000001
  138143. */
  138144. fallOff: number;
  138145. /**
  138146. * The base color of the SSAO post-process
  138147. * The final result is "base + ssao" between [0, 1]
  138148. */
  138149. base: number;
  138150. private _scene;
  138151. private _depthTexture;
  138152. private _randomTexture;
  138153. private _originalColorPostProcess;
  138154. private _ssaoPostProcess;
  138155. private _blurHPostProcess;
  138156. private _blurVPostProcess;
  138157. private _ssaoCombinePostProcess;
  138158. private _firstUpdate;
  138159. /**
  138160. * Gets active scene
  138161. */
  138162. get scene(): Scene;
  138163. /**
  138164. * @constructor
  138165. * @param name - The rendering pipeline name
  138166. * @param scene - The scene linked to this pipeline
  138167. * @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 }
  138168. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  138169. */
  138170. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138171. /**
  138172. * Get the class name
  138173. * @returns "SSAORenderingPipeline"
  138174. */
  138175. getClassName(): string;
  138176. /**
  138177. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138178. */
  138179. dispose(disableDepthRender?: boolean): void;
  138180. private _createBlurPostProcess;
  138181. /** @hidden */
  138182. _rebuild(): void;
  138183. private _createSSAOPostProcess;
  138184. private _createSSAOCombinePostProcess;
  138185. private _createRandomTexture;
  138186. }
  138187. }
  138188. declare module BABYLON {
  138189. /** @hidden */
  138190. export var screenSpaceReflectionPixelShader: {
  138191. name: string;
  138192. shader: string;
  138193. };
  138194. }
  138195. declare module BABYLON {
  138196. /**
  138197. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  138198. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  138199. */
  138200. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  138201. /**
  138202. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  138203. */
  138204. threshold: number;
  138205. /**
  138206. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  138207. */
  138208. strength: number;
  138209. /**
  138210. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  138211. */
  138212. reflectionSpecularFalloffExponent: number;
  138213. /**
  138214. * 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]
  138215. */
  138216. step: number;
  138217. /**
  138218. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  138219. */
  138220. roughnessFactor: number;
  138221. private _geometryBufferRenderer;
  138222. private _enableSmoothReflections;
  138223. private _reflectionSamples;
  138224. private _smoothSteps;
  138225. /**
  138226. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  138227. * @param name The name of the effect.
  138228. * @param scene The scene containing the objects to calculate reflections.
  138229. * @param options The required width/height ratio to downsize to before computing the render pass.
  138230. * @param camera The camera to apply the render pass to.
  138231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138232. * @param engine The engine which the post process will be applied. (default: current engine)
  138233. * @param reusable If the post process can be reused on the same frame. (default: false)
  138234. * @param textureType Type of textures used when performing the post process. (default: 0)
  138235. * @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)
  138236. */
  138237. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138238. /**
  138239. * Gets wether or not smoothing reflections is enabled.
  138240. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138241. */
  138242. get enableSmoothReflections(): boolean;
  138243. /**
  138244. * Sets wether or not smoothing reflections is enabled.
  138245. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138246. */
  138247. set enableSmoothReflections(enabled: boolean);
  138248. /**
  138249. * Gets the number of samples taken while computing reflections. More samples count is high,
  138250. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138251. */
  138252. get reflectionSamples(): number;
  138253. /**
  138254. * Sets the number of samples taken while computing reflections. More samples count is high,
  138255. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138256. */
  138257. set reflectionSamples(samples: number);
  138258. /**
  138259. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  138260. * more the post-process will require GPU power and can generate a drop in FPS.
  138261. * Default value (5.0) work pretty well in all cases but can be adjusted.
  138262. */
  138263. get smoothSteps(): number;
  138264. set smoothSteps(steps: number);
  138265. private _updateEffectDefines;
  138266. }
  138267. }
  138268. declare module BABYLON {
  138269. /** @hidden */
  138270. export var standardPixelShader: {
  138271. name: string;
  138272. shader: string;
  138273. };
  138274. }
  138275. declare module BABYLON {
  138276. /**
  138277. * Standard rendering pipeline
  138278. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138279. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  138280. */
  138281. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138282. /**
  138283. * Public members
  138284. */
  138285. /**
  138286. * Post-process which contains the original scene color before the pipeline applies all the effects
  138287. */
  138288. originalPostProcess: Nullable<PostProcess>;
  138289. /**
  138290. * Post-process used to down scale an image x4
  138291. */
  138292. downSampleX4PostProcess: Nullable<PostProcess>;
  138293. /**
  138294. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  138295. */
  138296. brightPassPostProcess: Nullable<PostProcess>;
  138297. /**
  138298. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  138299. */
  138300. blurHPostProcesses: PostProcess[];
  138301. /**
  138302. * Post-process array storing all the vertical blur post-processes used by the pipeline
  138303. */
  138304. blurVPostProcesses: PostProcess[];
  138305. /**
  138306. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  138307. */
  138308. textureAdderPostProcess: Nullable<PostProcess>;
  138309. /**
  138310. * Post-process used to create volumetric lighting effect
  138311. */
  138312. volumetricLightPostProcess: Nullable<PostProcess>;
  138313. /**
  138314. * Post-process used to smooth the previous volumetric light post-process on the X axis
  138315. */
  138316. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  138317. /**
  138318. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  138319. */
  138320. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  138321. /**
  138322. * Post-process used to merge the volumetric light effect and the real scene color
  138323. */
  138324. volumetricLightMergePostProces: Nullable<PostProcess>;
  138325. /**
  138326. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  138327. */
  138328. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  138329. /**
  138330. * Base post-process used to calculate the average luminance of the final image for HDR
  138331. */
  138332. luminancePostProcess: Nullable<PostProcess>;
  138333. /**
  138334. * Post-processes used to create down sample post-processes in order to get
  138335. * the average luminance of the final image for HDR
  138336. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  138337. */
  138338. luminanceDownSamplePostProcesses: PostProcess[];
  138339. /**
  138340. * Post-process used to create a HDR effect (light adaptation)
  138341. */
  138342. hdrPostProcess: Nullable<PostProcess>;
  138343. /**
  138344. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  138345. */
  138346. textureAdderFinalPostProcess: Nullable<PostProcess>;
  138347. /**
  138348. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  138349. */
  138350. lensFlareFinalPostProcess: Nullable<PostProcess>;
  138351. /**
  138352. * Post-process used to merge the final HDR post-process and the real scene color
  138353. */
  138354. hdrFinalPostProcess: Nullable<PostProcess>;
  138355. /**
  138356. * Post-process used to create a lens flare effect
  138357. */
  138358. lensFlarePostProcess: Nullable<PostProcess>;
  138359. /**
  138360. * Post-process that merges the result of the lens flare post-process and the real scene color
  138361. */
  138362. lensFlareComposePostProcess: Nullable<PostProcess>;
  138363. /**
  138364. * Post-process used to create a motion blur effect
  138365. */
  138366. motionBlurPostProcess: Nullable<PostProcess>;
  138367. /**
  138368. * Post-process used to create a depth of field effect
  138369. */
  138370. depthOfFieldPostProcess: Nullable<PostProcess>;
  138371. /**
  138372. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138373. */
  138374. fxaaPostProcess: Nullable<FxaaPostProcess>;
  138375. /**
  138376. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  138377. */
  138378. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  138379. /**
  138380. * Represents the brightness threshold in order to configure the illuminated surfaces
  138381. */
  138382. brightThreshold: number;
  138383. /**
  138384. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  138385. */
  138386. blurWidth: number;
  138387. /**
  138388. * Sets if the blur for highlighted surfaces must be only horizontal
  138389. */
  138390. horizontalBlur: boolean;
  138391. /**
  138392. * Gets the overall exposure used by the pipeline
  138393. */
  138394. get exposure(): number;
  138395. /**
  138396. * Sets the overall exposure used by the pipeline
  138397. */
  138398. set exposure(value: number);
  138399. /**
  138400. * Texture used typically to simulate "dirty" on camera lens
  138401. */
  138402. lensTexture: Nullable<Texture>;
  138403. /**
  138404. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  138405. */
  138406. volumetricLightCoefficient: number;
  138407. /**
  138408. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  138409. */
  138410. volumetricLightPower: number;
  138411. /**
  138412. * Used the set the blur intensity to smooth the volumetric lights
  138413. */
  138414. volumetricLightBlurScale: number;
  138415. /**
  138416. * Light (spot or directional) used to generate the volumetric lights rays
  138417. * The source light must have a shadow generate so the pipeline can get its
  138418. * depth map
  138419. */
  138420. sourceLight: Nullable<SpotLight | DirectionalLight>;
  138421. /**
  138422. * For eye adaptation, represents the minimum luminance the eye can see
  138423. */
  138424. hdrMinimumLuminance: number;
  138425. /**
  138426. * For eye adaptation, represents the decrease luminance speed
  138427. */
  138428. hdrDecreaseRate: number;
  138429. /**
  138430. * For eye adaptation, represents the increase luminance speed
  138431. */
  138432. hdrIncreaseRate: number;
  138433. /**
  138434. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138435. */
  138436. get hdrAutoExposure(): boolean;
  138437. /**
  138438. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138439. */
  138440. set hdrAutoExposure(value: boolean);
  138441. /**
  138442. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  138443. */
  138444. lensColorTexture: Nullable<Texture>;
  138445. /**
  138446. * The overall strengh for the lens flare effect
  138447. */
  138448. lensFlareStrength: number;
  138449. /**
  138450. * Dispersion coefficient for lens flare ghosts
  138451. */
  138452. lensFlareGhostDispersal: number;
  138453. /**
  138454. * Main lens flare halo width
  138455. */
  138456. lensFlareHaloWidth: number;
  138457. /**
  138458. * Based on the lens distortion effect, defines how much the lens flare result
  138459. * is distorted
  138460. */
  138461. lensFlareDistortionStrength: number;
  138462. /**
  138463. * Configures the blur intensity used for for lens flare (halo)
  138464. */
  138465. lensFlareBlurWidth: number;
  138466. /**
  138467. * Lens star texture must be used to simulate rays on the flares and is available
  138468. * in the documentation
  138469. */
  138470. lensStarTexture: Nullable<Texture>;
  138471. /**
  138472. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  138473. * flare effect by taking account of the dirt texture
  138474. */
  138475. lensFlareDirtTexture: Nullable<Texture>;
  138476. /**
  138477. * Represents the focal length for the depth of field effect
  138478. */
  138479. depthOfFieldDistance: number;
  138480. /**
  138481. * Represents the blur intensity for the blurred part of the depth of field effect
  138482. */
  138483. depthOfFieldBlurWidth: number;
  138484. /**
  138485. * Gets how much the image is blurred by the movement while using the motion blur post-process
  138486. */
  138487. get motionStrength(): number;
  138488. /**
  138489. * Sets how much the image is blurred by the movement while using the motion blur post-process
  138490. */
  138491. set motionStrength(strength: number);
  138492. /**
  138493. * Gets wether or not the motion blur post-process is object based or screen based.
  138494. */
  138495. get objectBasedMotionBlur(): boolean;
  138496. /**
  138497. * Sets wether or not the motion blur post-process should be object based or screen based
  138498. */
  138499. set objectBasedMotionBlur(value: boolean);
  138500. /**
  138501. * List of animations for the pipeline (IAnimatable implementation)
  138502. */
  138503. animations: Animation[];
  138504. /**
  138505. * Private members
  138506. */
  138507. private _scene;
  138508. private _currentDepthOfFieldSource;
  138509. private _basePostProcess;
  138510. private _fixedExposure;
  138511. private _currentExposure;
  138512. private _hdrAutoExposure;
  138513. private _hdrCurrentLuminance;
  138514. private _motionStrength;
  138515. private _isObjectBasedMotionBlur;
  138516. private _floatTextureType;
  138517. private _camerasToBeAttached;
  138518. private _ratio;
  138519. private _bloomEnabled;
  138520. private _depthOfFieldEnabled;
  138521. private _vlsEnabled;
  138522. private _lensFlareEnabled;
  138523. private _hdrEnabled;
  138524. private _motionBlurEnabled;
  138525. private _fxaaEnabled;
  138526. private _screenSpaceReflectionsEnabled;
  138527. private _motionBlurSamples;
  138528. private _volumetricLightStepsCount;
  138529. private _samples;
  138530. /**
  138531. * @ignore
  138532. * Specifies if the bloom pipeline is enabled
  138533. */
  138534. get BloomEnabled(): boolean;
  138535. set BloomEnabled(enabled: boolean);
  138536. /**
  138537. * @ignore
  138538. * Specifies if the depth of field pipeline is enabed
  138539. */
  138540. get DepthOfFieldEnabled(): boolean;
  138541. set DepthOfFieldEnabled(enabled: boolean);
  138542. /**
  138543. * @ignore
  138544. * Specifies if the lens flare pipeline is enabed
  138545. */
  138546. get LensFlareEnabled(): boolean;
  138547. set LensFlareEnabled(enabled: boolean);
  138548. /**
  138549. * @ignore
  138550. * Specifies if the HDR pipeline is enabled
  138551. */
  138552. get HDREnabled(): boolean;
  138553. set HDREnabled(enabled: boolean);
  138554. /**
  138555. * @ignore
  138556. * Specifies if the volumetric lights scattering effect is enabled
  138557. */
  138558. get VLSEnabled(): boolean;
  138559. set VLSEnabled(enabled: boolean);
  138560. /**
  138561. * @ignore
  138562. * Specifies if the motion blur effect is enabled
  138563. */
  138564. get MotionBlurEnabled(): boolean;
  138565. set MotionBlurEnabled(enabled: boolean);
  138566. /**
  138567. * Specifies if anti-aliasing is enabled
  138568. */
  138569. get fxaaEnabled(): boolean;
  138570. set fxaaEnabled(enabled: boolean);
  138571. /**
  138572. * Specifies if screen space reflections are enabled.
  138573. */
  138574. get screenSpaceReflectionsEnabled(): boolean;
  138575. set screenSpaceReflectionsEnabled(enabled: boolean);
  138576. /**
  138577. * Specifies the number of steps used to calculate the volumetric lights
  138578. * Typically in interval [50, 200]
  138579. */
  138580. get volumetricLightStepsCount(): number;
  138581. set volumetricLightStepsCount(count: number);
  138582. /**
  138583. * Specifies the number of samples used for the motion blur effect
  138584. * Typically in interval [16, 64]
  138585. */
  138586. get motionBlurSamples(): number;
  138587. set motionBlurSamples(samples: number);
  138588. /**
  138589. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138590. */
  138591. get samples(): number;
  138592. set samples(sampleCount: number);
  138593. /**
  138594. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138595. * @constructor
  138596. * @param name The rendering pipeline name
  138597. * @param scene The scene linked to this pipeline
  138598. * @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)
  138599. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  138600. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138601. */
  138602. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  138603. private _buildPipeline;
  138604. private _createDownSampleX4PostProcess;
  138605. private _createBrightPassPostProcess;
  138606. private _createBlurPostProcesses;
  138607. private _createTextureAdderPostProcess;
  138608. private _createVolumetricLightPostProcess;
  138609. private _createLuminancePostProcesses;
  138610. private _createHdrPostProcess;
  138611. private _createLensFlarePostProcess;
  138612. private _createDepthOfFieldPostProcess;
  138613. private _createMotionBlurPostProcess;
  138614. private _getDepthTexture;
  138615. private _disposePostProcesses;
  138616. /**
  138617. * Dispose of the pipeline and stop all post processes
  138618. */
  138619. dispose(): void;
  138620. /**
  138621. * Serialize the rendering pipeline (Used when exporting)
  138622. * @returns the serialized object
  138623. */
  138624. serialize(): any;
  138625. /**
  138626. * Parse the serialized pipeline
  138627. * @param source Source pipeline.
  138628. * @param scene The scene to load the pipeline to.
  138629. * @param rootUrl The URL of the serialized pipeline.
  138630. * @returns An instantiated pipeline from the serialized object.
  138631. */
  138632. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  138633. /**
  138634. * Luminance steps
  138635. */
  138636. static LuminanceSteps: number;
  138637. }
  138638. }
  138639. declare module BABYLON {
  138640. /** @hidden */
  138641. export var tonemapPixelShader: {
  138642. name: string;
  138643. shader: string;
  138644. };
  138645. }
  138646. declare module BABYLON {
  138647. /** Defines operator used for tonemapping */
  138648. export enum TonemappingOperator {
  138649. /** Hable */
  138650. Hable = 0,
  138651. /** Reinhard */
  138652. Reinhard = 1,
  138653. /** HejiDawson */
  138654. HejiDawson = 2,
  138655. /** Photographic */
  138656. Photographic = 3
  138657. }
  138658. /**
  138659. * Defines a post process to apply tone mapping
  138660. */
  138661. export class TonemapPostProcess extends PostProcess {
  138662. private _operator;
  138663. /** Defines the required exposure adjustement */
  138664. exposureAdjustment: number;
  138665. /**
  138666. * Creates a new TonemapPostProcess
  138667. * @param name defines the name of the postprocess
  138668. * @param _operator defines the operator to use
  138669. * @param exposureAdjustment defines the required exposure adjustement
  138670. * @param camera defines the camera to use (can be null)
  138671. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  138672. * @param engine defines the hosting engine (can be ignore if camera is set)
  138673. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138674. */
  138675. constructor(name: string, _operator: TonemappingOperator,
  138676. /** Defines the required exposure adjustement */
  138677. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  138678. }
  138679. }
  138680. declare module BABYLON {
  138681. /** @hidden */
  138682. export var volumetricLightScatteringPixelShader: {
  138683. name: string;
  138684. shader: string;
  138685. };
  138686. }
  138687. declare module BABYLON {
  138688. /** @hidden */
  138689. export var volumetricLightScatteringPassVertexShader: {
  138690. name: string;
  138691. shader: string;
  138692. };
  138693. }
  138694. declare module BABYLON {
  138695. /** @hidden */
  138696. export var volumetricLightScatteringPassPixelShader: {
  138697. name: string;
  138698. shader: string;
  138699. };
  138700. }
  138701. declare module BABYLON {
  138702. /**
  138703. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  138704. */
  138705. export class VolumetricLightScatteringPostProcess extends PostProcess {
  138706. private _volumetricLightScatteringPass;
  138707. private _volumetricLightScatteringRTT;
  138708. private _viewPort;
  138709. private _screenCoordinates;
  138710. private _cachedDefines;
  138711. /**
  138712. * If not undefined, the mesh position is computed from the attached node position
  138713. */
  138714. attachedNode: {
  138715. position: Vector3;
  138716. };
  138717. /**
  138718. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  138719. */
  138720. customMeshPosition: Vector3;
  138721. /**
  138722. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  138723. */
  138724. useCustomMeshPosition: boolean;
  138725. /**
  138726. * If the post-process should inverse the light scattering direction
  138727. */
  138728. invert: boolean;
  138729. /**
  138730. * The internal mesh used by the post-process
  138731. */
  138732. mesh: Mesh;
  138733. /**
  138734. * @hidden
  138735. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  138736. */
  138737. get useDiffuseColor(): boolean;
  138738. set useDiffuseColor(useDiffuseColor: boolean);
  138739. /**
  138740. * Array containing the excluded meshes not rendered in the internal pass
  138741. */
  138742. excludedMeshes: AbstractMesh[];
  138743. /**
  138744. * Controls the overall intensity of the post-process
  138745. */
  138746. exposure: number;
  138747. /**
  138748. * Dissipates each sample's contribution in range [0, 1]
  138749. */
  138750. decay: number;
  138751. /**
  138752. * Controls the overall intensity of each sample
  138753. */
  138754. weight: number;
  138755. /**
  138756. * Controls the density of each sample
  138757. */
  138758. density: number;
  138759. /**
  138760. * @constructor
  138761. * @param name The post-process name
  138762. * @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)
  138763. * @param camera The camera that the post-process will be attached to
  138764. * @param mesh The mesh used to create the light scattering
  138765. * @param samples The post-process quality, default 100
  138766. * @param samplingModeThe post-process filtering mode
  138767. * @param engine The babylon engine
  138768. * @param reusable If the post-process is reusable
  138769. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  138770. */
  138771. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  138772. /**
  138773. * Returns the string "VolumetricLightScatteringPostProcess"
  138774. * @returns "VolumetricLightScatteringPostProcess"
  138775. */
  138776. getClassName(): string;
  138777. private _isReady;
  138778. /**
  138779. * Sets the new light position for light scattering effect
  138780. * @param position The new custom light position
  138781. */
  138782. setCustomMeshPosition(position: Vector3): void;
  138783. /**
  138784. * Returns the light position for light scattering effect
  138785. * @return Vector3 The custom light position
  138786. */
  138787. getCustomMeshPosition(): Vector3;
  138788. /**
  138789. * Disposes the internal assets and detaches the post-process from the camera
  138790. */
  138791. dispose(camera: Camera): void;
  138792. /**
  138793. * Returns the render target texture used by the post-process
  138794. * @return the render target texture used by the post-process
  138795. */
  138796. getPass(): RenderTargetTexture;
  138797. private _meshExcluded;
  138798. private _createPass;
  138799. private _updateMeshScreenCoordinates;
  138800. /**
  138801. * Creates a default mesh for the Volumeric Light Scattering post-process
  138802. * @param name The mesh name
  138803. * @param scene The scene where to create the mesh
  138804. * @return the default mesh
  138805. */
  138806. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  138807. }
  138808. }
  138809. declare module BABYLON {
  138810. interface Scene {
  138811. /** @hidden (Backing field) */
  138812. _boundingBoxRenderer: BoundingBoxRenderer;
  138813. /** @hidden (Backing field) */
  138814. _forceShowBoundingBoxes: boolean;
  138815. /**
  138816. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  138817. */
  138818. forceShowBoundingBoxes: boolean;
  138819. /**
  138820. * Gets the bounding box renderer associated with the scene
  138821. * @returns a BoundingBoxRenderer
  138822. */
  138823. getBoundingBoxRenderer(): BoundingBoxRenderer;
  138824. }
  138825. interface AbstractMesh {
  138826. /** @hidden (Backing field) */
  138827. _showBoundingBox: boolean;
  138828. /**
  138829. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  138830. */
  138831. showBoundingBox: boolean;
  138832. }
  138833. /**
  138834. * Component responsible of rendering the bounding box of the meshes in a scene.
  138835. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  138836. */
  138837. export class BoundingBoxRenderer implements ISceneComponent {
  138838. /**
  138839. * The component name helpfull to identify the component in the list of scene components.
  138840. */
  138841. readonly name: string;
  138842. /**
  138843. * The scene the component belongs to.
  138844. */
  138845. scene: Scene;
  138846. /**
  138847. * Color of the bounding box lines placed in front of an object
  138848. */
  138849. frontColor: Color3;
  138850. /**
  138851. * Color of the bounding box lines placed behind an object
  138852. */
  138853. backColor: Color3;
  138854. /**
  138855. * Defines if the renderer should show the back lines or not
  138856. */
  138857. showBackLines: boolean;
  138858. /**
  138859. * @hidden
  138860. */
  138861. renderList: SmartArray<BoundingBox>;
  138862. private _colorShader;
  138863. private _vertexBuffers;
  138864. private _indexBuffer;
  138865. private _fillIndexBuffer;
  138866. private _fillIndexData;
  138867. /**
  138868. * Instantiates a new bounding box renderer in a scene.
  138869. * @param scene the scene the renderer renders in
  138870. */
  138871. constructor(scene: Scene);
  138872. /**
  138873. * Registers the component in a given scene
  138874. */
  138875. register(): void;
  138876. private _evaluateSubMesh;
  138877. private _activeMesh;
  138878. private _prepareRessources;
  138879. private _createIndexBuffer;
  138880. /**
  138881. * Rebuilds the elements related to this component in case of
  138882. * context lost for instance.
  138883. */
  138884. rebuild(): void;
  138885. /**
  138886. * @hidden
  138887. */
  138888. reset(): void;
  138889. /**
  138890. * Render the bounding boxes of a specific rendering group
  138891. * @param renderingGroupId defines the rendering group to render
  138892. */
  138893. render(renderingGroupId: number): void;
  138894. /**
  138895. * In case of occlusion queries, we can render the occlusion bounding box through this method
  138896. * @param mesh Define the mesh to render the occlusion bounding box for
  138897. */
  138898. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  138899. /**
  138900. * Dispose and release the resources attached to this renderer.
  138901. */
  138902. dispose(): void;
  138903. }
  138904. }
  138905. declare module BABYLON {
  138906. interface Scene {
  138907. /** @hidden (Backing field) */
  138908. _depthRenderer: {
  138909. [id: string]: DepthRenderer;
  138910. };
  138911. /**
  138912. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  138913. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  138914. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  138915. * @returns the created depth renderer
  138916. */
  138917. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  138918. /**
  138919. * Disables a depth renderer for a given camera
  138920. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  138921. */
  138922. disableDepthRenderer(camera?: Nullable<Camera>): void;
  138923. }
  138924. /**
  138925. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  138926. * in several rendering techniques.
  138927. */
  138928. export class DepthRendererSceneComponent implements ISceneComponent {
  138929. /**
  138930. * The component name helpfull to identify the component in the list of scene components.
  138931. */
  138932. readonly name: string;
  138933. /**
  138934. * The scene the component belongs to.
  138935. */
  138936. scene: Scene;
  138937. /**
  138938. * Creates a new instance of the component for the given scene
  138939. * @param scene Defines the scene to register the component in
  138940. */
  138941. constructor(scene: Scene);
  138942. /**
  138943. * Registers the component in a given scene
  138944. */
  138945. register(): void;
  138946. /**
  138947. * Rebuilds the elements related to this component in case of
  138948. * context lost for instance.
  138949. */
  138950. rebuild(): void;
  138951. /**
  138952. * Disposes the component and the associated ressources
  138953. */
  138954. dispose(): void;
  138955. private _gatherRenderTargets;
  138956. private _gatherActiveCameraRenderTargets;
  138957. }
  138958. }
  138959. declare module BABYLON {
  138960. /** @hidden */
  138961. export var outlinePixelShader: {
  138962. name: string;
  138963. shader: string;
  138964. };
  138965. }
  138966. declare module BABYLON {
  138967. /** @hidden */
  138968. export var outlineVertexShader: {
  138969. name: string;
  138970. shader: string;
  138971. };
  138972. }
  138973. declare module BABYLON {
  138974. interface Scene {
  138975. /** @hidden */
  138976. _outlineRenderer: OutlineRenderer;
  138977. /**
  138978. * Gets the outline renderer associated with the scene
  138979. * @returns a OutlineRenderer
  138980. */
  138981. getOutlineRenderer(): OutlineRenderer;
  138982. }
  138983. interface AbstractMesh {
  138984. /** @hidden (Backing field) */
  138985. _renderOutline: boolean;
  138986. /**
  138987. * Gets or sets a boolean indicating if the outline must be rendered as well
  138988. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  138989. */
  138990. renderOutline: boolean;
  138991. /** @hidden (Backing field) */
  138992. _renderOverlay: boolean;
  138993. /**
  138994. * Gets or sets a boolean indicating if the overlay must be rendered as well
  138995. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  138996. */
  138997. renderOverlay: boolean;
  138998. }
  138999. /**
  139000. * This class is responsible to draw bothe outline/overlay of meshes.
  139001. * It should not be used directly but through the available method on mesh.
  139002. */
  139003. export class OutlineRenderer implements ISceneComponent {
  139004. /**
  139005. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139006. */
  139007. private static _StencilReference;
  139008. /**
  139009. * The name of the component. Each component must have a unique name.
  139010. */
  139011. name: string;
  139012. /**
  139013. * The scene the component belongs to.
  139014. */
  139015. scene: Scene;
  139016. /**
  139017. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139018. */
  139019. zOffset: number;
  139020. private _engine;
  139021. private _effect;
  139022. private _cachedDefines;
  139023. private _savedDepthWrite;
  139024. /**
  139025. * Instantiates a new outline renderer. (There could be only one per scene).
  139026. * @param scene Defines the scene it belongs to
  139027. */
  139028. constructor(scene: Scene);
  139029. /**
  139030. * Register the component to one instance of a scene.
  139031. */
  139032. register(): void;
  139033. /**
  139034. * Rebuilds the elements related to this component in case of
  139035. * context lost for instance.
  139036. */
  139037. rebuild(): void;
  139038. /**
  139039. * Disposes the component and the associated ressources.
  139040. */
  139041. dispose(): void;
  139042. /**
  139043. * Renders the outline in the canvas.
  139044. * @param subMesh Defines the sumesh to render
  139045. * @param batch Defines the batch of meshes in case of instances
  139046. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139047. */
  139048. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139049. /**
  139050. * Returns whether or not the outline renderer is ready for a given submesh.
  139051. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139052. * @param subMesh Defines the submesh to check readyness for
  139053. * @param useInstances Defines wheter wee are trying to render instances or not
  139054. * @returns true if ready otherwise false
  139055. */
  139056. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139057. private _beforeRenderingMesh;
  139058. private _afterRenderingMesh;
  139059. }
  139060. }
  139061. declare module BABYLON {
  139062. /**
  139063. * Defines the basic options interface of a Sprite Frame Source Size.
  139064. */
  139065. export interface ISpriteJSONSpriteSourceSize {
  139066. /**
  139067. * number of the original width of the Frame
  139068. */
  139069. w: number;
  139070. /**
  139071. * number of the original height of the Frame
  139072. */
  139073. h: number;
  139074. }
  139075. /**
  139076. * Defines the basic options interface of a Sprite Frame Data.
  139077. */
  139078. export interface ISpriteJSONSpriteFrameData {
  139079. /**
  139080. * number of the x offset of the Frame
  139081. */
  139082. x: number;
  139083. /**
  139084. * number of the y offset of the Frame
  139085. */
  139086. y: number;
  139087. /**
  139088. * number of the width of the Frame
  139089. */
  139090. w: number;
  139091. /**
  139092. * number of the height of the Frame
  139093. */
  139094. h: number;
  139095. }
  139096. /**
  139097. * Defines the basic options interface of a JSON Sprite.
  139098. */
  139099. export interface ISpriteJSONSprite {
  139100. /**
  139101. * string name of the Frame
  139102. */
  139103. filename: string;
  139104. /**
  139105. * ISpriteJSONSpriteFrame basic object of the frame data
  139106. */
  139107. frame: ISpriteJSONSpriteFrameData;
  139108. /**
  139109. * boolean to flag is the frame was rotated.
  139110. */
  139111. rotated: boolean;
  139112. /**
  139113. * boolean to flag is the frame was trimmed.
  139114. */
  139115. trimmed: boolean;
  139116. /**
  139117. * ISpriteJSONSpriteFrame basic object of the source data
  139118. */
  139119. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139120. /**
  139121. * ISpriteJSONSpriteFrame basic object of the source data
  139122. */
  139123. sourceSize: ISpriteJSONSpriteSourceSize;
  139124. }
  139125. /**
  139126. * Defines the basic options interface of a JSON atlas.
  139127. */
  139128. export interface ISpriteJSONAtlas {
  139129. /**
  139130. * Array of objects that contain the frame data.
  139131. */
  139132. frames: Array<ISpriteJSONSprite>;
  139133. /**
  139134. * object basic object containing the sprite meta data.
  139135. */
  139136. meta?: object;
  139137. }
  139138. }
  139139. declare module BABYLON {
  139140. /** @hidden */
  139141. export var spriteMapPixelShader: {
  139142. name: string;
  139143. shader: string;
  139144. };
  139145. }
  139146. declare module BABYLON {
  139147. /** @hidden */
  139148. export var spriteMapVertexShader: {
  139149. name: string;
  139150. shader: string;
  139151. };
  139152. }
  139153. declare module BABYLON {
  139154. /**
  139155. * Defines the basic options interface of a SpriteMap
  139156. */
  139157. export interface ISpriteMapOptions {
  139158. /**
  139159. * Vector2 of the number of cells in the grid.
  139160. */
  139161. stageSize?: Vector2;
  139162. /**
  139163. * Vector2 of the size of the output plane in World Units.
  139164. */
  139165. outputSize?: Vector2;
  139166. /**
  139167. * Vector3 of the position of the output plane in World Units.
  139168. */
  139169. outputPosition?: Vector3;
  139170. /**
  139171. * Vector3 of the rotation of the output plane.
  139172. */
  139173. outputRotation?: Vector3;
  139174. /**
  139175. * number of layers that the system will reserve in resources.
  139176. */
  139177. layerCount?: number;
  139178. /**
  139179. * number of max animation frames a single cell will reserve in resources.
  139180. */
  139181. maxAnimationFrames?: number;
  139182. /**
  139183. * number cell index of the base tile when the system compiles.
  139184. */
  139185. baseTile?: number;
  139186. /**
  139187. * boolean flip the sprite after its been repositioned by the framing data.
  139188. */
  139189. flipU?: boolean;
  139190. /**
  139191. * Vector3 scalar of the global RGB values of the SpriteMap.
  139192. */
  139193. colorMultiply?: Vector3;
  139194. }
  139195. /**
  139196. * Defines the IDisposable interface in order to be cleanable from resources.
  139197. */
  139198. export interface ISpriteMap extends IDisposable {
  139199. /**
  139200. * String name of the SpriteMap.
  139201. */
  139202. name: string;
  139203. /**
  139204. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  139205. */
  139206. atlasJSON: ISpriteJSONAtlas;
  139207. /**
  139208. * Texture of the SpriteMap.
  139209. */
  139210. spriteSheet: Texture;
  139211. /**
  139212. * The parameters to initialize the SpriteMap with.
  139213. */
  139214. options: ISpriteMapOptions;
  139215. }
  139216. /**
  139217. * Class used to manage a grid restricted sprite deployment on an Output plane.
  139218. */
  139219. export class SpriteMap implements ISpriteMap {
  139220. /** The Name of the spriteMap */
  139221. name: string;
  139222. /** The JSON file with the frame and meta data */
  139223. atlasJSON: ISpriteJSONAtlas;
  139224. /** The systems Sprite Sheet Texture */
  139225. spriteSheet: Texture;
  139226. /** Arguments passed with the Constructor */
  139227. options: ISpriteMapOptions;
  139228. /** Public Sprite Storage array, parsed from atlasJSON */
  139229. sprites: Array<ISpriteJSONSprite>;
  139230. /** Returns the Number of Sprites in the System */
  139231. get spriteCount(): number;
  139232. /** Returns the Position of Output Plane*/
  139233. get position(): Vector3;
  139234. /** Returns the Position of Output Plane*/
  139235. set position(v: Vector3);
  139236. /** Returns the Rotation of Output Plane*/
  139237. get rotation(): Vector3;
  139238. /** Returns the Rotation of Output Plane*/
  139239. set rotation(v: Vector3);
  139240. /** Sets the AnimationMap*/
  139241. get animationMap(): RawTexture;
  139242. /** Sets the AnimationMap*/
  139243. set animationMap(v: RawTexture);
  139244. /** Scene that the SpriteMap was created in */
  139245. private _scene;
  139246. /** Texture Buffer of Float32 that holds tile frame data*/
  139247. private _frameMap;
  139248. /** Texture Buffers of Float32 that holds tileMap data*/
  139249. private _tileMaps;
  139250. /** Texture Buffer of Float32 that holds Animation Data*/
  139251. private _animationMap;
  139252. /** Custom ShaderMaterial Central to the System*/
  139253. private _material;
  139254. /** Custom ShaderMaterial Central to the System*/
  139255. private _output;
  139256. /** Systems Time Ticker*/
  139257. private _time;
  139258. /**
  139259. * Creates a new SpriteMap
  139260. * @param name defines the SpriteMaps Name
  139261. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  139262. * @param spriteSheet is the Texture that the Sprites are on.
  139263. * @param options a basic deployment configuration
  139264. * @param scene The Scene that the map is deployed on
  139265. */
  139266. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  139267. /**
  139268. * Returns tileID location
  139269. * @returns Vector2 the cell position ID
  139270. */
  139271. getTileID(): Vector2;
  139272. /**
  139273. * Gets the UV location of the mouse over the SpriteMap.
  139274. * @returns Vector2 the UV position of the mouse interaction
  139275. */
  139276. getMousePosition(): Vector2;
  139277. /**
  139278. * Creates the "frame" texture Buffer
  139279. * -------------------------------------
  139280. * Structure of frames
  139281. * "filename": "Falling-Water-2.png",
  139282. * "frame": {"x":69,"y":103,"w":24,"h":32},
  139283. * "rotated": true,
  139284. * "trimmed": true,
  139285. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  139286. * "sourceSize": {"w":32,"h":32}
  139287. * @returns RawTexture of the frameMap
  139288. */
  139289. private _createFrameBuffer;
  139290. /**
  139291. * Creates the tileMap texture Buffer
  139292. * @param buffer normally and array of numbers, or a false to generate from scratch
  139293. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  139294. * @returns RawTexture of the tileMap
  139295. */
  139296. private _createTileBuffer;
  139297. /**
  139298. * Modifies the data of the tileMaps
  139299. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  139300. * @param pos is the iVector2 Coordinates of the Tile
  139301. * @param tile The SpriteIndex of the new Tile
  139302. */
  139303. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  139304. /**
  139305. * Creates the animationMap texture Buffer
  139306. * @param buffer normally and array of numbers, or a false to generate from scratch
  139307. * @returns RawTexture of the animationMap
  139308. */
  139309. private _createTileAnimationBuffer;
  139310. /**
  139311. * Modifies the data of the animationMap
  139312. * @param cellID is the Index of the Sprite
  139313. * @param _frame is the target Animation frame
  139314. * @param toCell is the Target Index of the next frame of the animation
  139315. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  139316. * @param speed is a global scalar of the time variable on the map.
  139317. */
  139318. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  139319. /**
  139320. * Exports the .tilemaps file
  139321. */
  139322. saveTileMaps(): void;
  139323. /**
  139324. * Imports the .tilemaps file
  139325. * @param url of the .tilemaps file
  139326. */
  139327. loadTileMaps(url: string): void;
  139328. /**
  139329. * Release associated resources
  139330. */
  139331. dispose(): void;
  139332. }
  139333. }
  139334. declare module BABYLON {
  139335. /**
  139336. * Class used to manage multiple sprites of different sizes on the same spritesheet
  139337. * @see http://doc.babylonjs.com/babylon101/sprites
  139338. */
  139339. export class SpritePackedManager extends SpriteManager {
  139340. /** defines the packed manager's name */
  139341. name: string;
  139342. /**
  139343. * Creates a new sprite manager from a packed sprite sheet
  139344. * @param name defines the manager's name
  139345. * @param imgUrl defines the sprite sheet url
  139346. * @param capacity defines the maximum allowed number of sprites
  139347. * @param scene defines the hosting scene
  139348. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  139349. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  139350. * @param samplingMode defines the smapling mode to use with spritesheet
  139351. * @param fromPacked set to true; do not alter
  139352. */
  139353. constructor(
  139354. /** defines the packed manager's name */
  139355. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  139356. }
  139357. }
  139358. declare module BABYLON {
  139359. /**
  139360. * Defines the list of states available for a task inside a AssetsManager
  139361. */
  139362. export enum AssetTaskState {
  139363. /**
  139364. * Initialization
  139365. */
  139366. INIT = 0,
  139367. /**
  139368. * Running
  139369. */
  139370. RUNNING = 1,
  139371. /**
  139372. * Done
  139373. */
  139374. DONE = 2,
  139375. /**
  139376. * Error
  139377. */
  139378. ERROR = 3
  139379. }
  139380. /**
  139381. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  139382. */
  139383. export abstract class AbstractAssetTask {
  139384. /**
  139385. * Task name
  139386. */ name: string;
  139387. /**
  139388. * Callback called when the task is successful
  139389. */
  139390. onSuccess: (task: any) => void;
  139391. /**
  139392. * Callback called when the task is not successful
  139393. */
  139394. onError: (task: any, message?: string, exception?: any) => void;
  139395. /**
  139396. * Creates a new AssetsManager
  139397. * @param name defines the name of the task
  139398. */
  139399. constructor(
  139400. /**
  139401. * Task name
  139402. */ name: string);
  139403. private _isCompleted;
  139404. private _taskState;
  139405. private _errorObject;
  139406. /**
  139407. * Get if the task is completed
  139408. */
  139409. get isCompleted(): boolean;
  139410. /**
  139411. * Gets the current state of the task
  139412. */
  139413. get taskState(): AssetTaskState;
  139414. /**
  139415. * Gets the current error object (if task is in error)
  139416. */
  139417. get errorObject(): {
  139418. message?: string;
  139419. exception?: any;
  139420. };
  139421. /**
  139422. * Internal only
  139423. * @hidden
  139424. */
  139425. _setErrorObject(message?: string, exception?: any): void;
  139426. /**
  139427. * Execute the current task
  139428. * @param scene defines the scene where you want your assets to be loaded
  139429. * @param onSuccess is a callback called when the task is successfully executed
  139430. * @param onError is a callback called if an error occurs
  139431. */
  139432. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139433. /**
  139434. * Execute the current task
  139435. * @param scene defines the scene where you want your assets to be loaded
  139436. * @param onSuccess is a callback called when the task is successfully executed
  139437. * @param onError is a callback called if an error occurs
  139438. */
  139439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139440. /**
  139441. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  139442. * This can be used with failed tasks that have the reason for failure fixed.
  139443. */
  139444. reset(): void;
  139445. private onErrorCallback;
  139446. private onDoneCallback;
  139447. }
  139448. /**
  139449. * Define the interface used by progress events raised during assets loading
  139450. */
  139451. export interface IAssetsProgressEvent {
  139452. /**
  139453. * Defines the number of remaining tasks to process
  139454. */
  139455. remainingCount: number;
  139456. /**
  139457. * Defines the total number of tasks
  139458. */
  139459. totalCount: number;
  139460. /**
  139461. * Defines the task that was just processed
  139462. */
  139463. task: AbstractAssetTask;
  139464. }
  139465. /**
  139466. * Class used to share progress information about assets loading
  139467. */
  139468. export class AssetsProgressEvent implements IAssetsProgressEvent {
  139469. /**
  139470. * Defines the number of remaining tasks to process
  139471. */
  139472. remainingCount: number;
  139473. /**
  139474. * Defines the total number of tasks
  139475. */
  139476. totalCount: number;
  139477. /**
  139478. * Defines the task that was just processed
  139479. */
  139480. task: AbstractAssetTask;
  139481. /**
  139482. * Creates a AssetsProgressEvent
  139483. * @param remainingCount defines the number of remaining tasks to process
  139484. * @param totalCount defines the total number of tasks
  139485. * @param task defines the task that was just processed
  139486. */
  139487. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  139488. }
  139489. /**
  139490. * Define a task used by AssetsManager to load meshes
  139491. */
  139492. export class MeshAssetTask extends AbstractAssetTask {
  139493. /**
  139494. * Defines the name of the task
  139495. */
  139496. name: string;
  139497. /**
  139498. * Defines the list of mesh's names you want to load
  139499. */
  139500. meshesNames: any;
  139501. /**
  139502. * Defines the root url to use as a base to load your meshes and associated resources
  139503. */
  139504. rootUrl: string;
  139505. /**
  139506. * Defines the filename of the scene to load from
  139507. */
  139508. sceneFilename: string;
  139509. /**
  139510. * Gets the list of loaded meshes
  139511. */
  139512. loadedMeshes: Array<AbstractMesh>;
  139513. /**
  139514. * Gets the list of loaded particle systems
  139515. */
  139516. loadedParticleSystems: Array<IParticleSystem>;
  139517. /**
  139518. * Gets the list of loaded skeletons
  139519. */
  139520. loadedSkeletons: Array<Skeleton>;
  139521. /**
  139522. * Gets the list of loaded animation groups
  139523. */
  139524. loadedAnimationGroups: Array<AnimationGroup>;
  139525. /**
  139526. * Callback called when the task is successful
  139527. */
  139528. onSuccess: (task: MeshAssetTask) => void;
  139529. /**
  139530. * Callback called when the task is successful
  139531. */
  139532. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  139533. /**
  139534. * Creates a new MeshAssetTask
  139535. * @param name defines the name of the task
  139536. * @param meshesNames defines the list of mesh's names you want to load
  139537. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  139538. * @param sceneFilename defines the filename of the scene to load from
  139539. */
  139540. constructor(
  139541. /**
  139542. * Defines the name of the task
  139543. */
  139544. name: string,
  139545. /**
  139546. * Defines the list of mesh's names you want to load
  139547. */
  139548. meshesNames: any,
  139549. /**
  139550. * Defines the root url to use as a base to load your meshes and associated resources
  139551. */
  139552. rootUrl: string,
  139553. /**
  139554. * Defines the filename of the scene to load from
  139555. */
  139556. sceneFilename: string);
  139557. /**
  139558. * Execute the current task
  139559. * @param scene defines the scene where you want your assets to be loaded
  139560. * @param onSuccess is a callback called when the task is successfully executed
  139561. * @param onError is a callback called if an error occurs
  139562. */
  139563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139564. }
  139565. /**
  139566. * Define a task used by AssetsManager to load text content
  139567. */
  139568. export class TextFileAssetTask extends AbstractAssetTask {
  139569. /**
  139570. * Defines the name of the task
  139571. */
  139572. name: string;
  139573. /**
  139574. * Defines the location of the file to load
  139575. */
  139576. url: string;
  139577. /**
  139578. * Gets the loaded text string
  139579. */
  139580. text: string;
  139581. /**
  139582. * Callback called when the task is successful
  139583. */
  139584. onSuccess: (task: TextFileAssetTask) => void;
  139585. /**
  139586. * Callback called when the task is successful
  139587. */
  139588. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  139589. /**
  139590. * Creates a new TextFileAssetTask object
  139591. * @param name defines the name of the task
  139592. * @param url defines the location of the file to load
  139593. */
  139594. constructor(
  139595. /**
  139596. * Defines the name of the task
  139597. */
  139598. name: string,
  139599. /**
  139600. * Defines the location of the file to load
  139601. */
  139602. url: string);
  139603. /**
  139604. * Execute the current task
  139605. * @param scene defines the scene where you want your assets to be loaded
  139606. * @param onSuccess is a callback called when the task is successfully executed
  139607. * @param onError is a callback called if an error occurs
  139608. */
  139609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139610. }
  139611. /**
  139612. * Define a task used by AssetsManager to load binary data
  139613. */
  139614. export class BinaryFileAssetTask extends AbstractAssetTask {
  139615. /**
  139616. * Defines the name of the task
  139617. */
  139618. name: string;
  139619. /**
  139620. * Defines the location of the file to load
  139621. */
  139622. url: string;
  139623. /**
  139624. * Gets the lodaded data (as an array buffer)
  139625. */
  139626. data: ArrayBuffer;
  139627. /**
  139628. * Callback called when the task is successful
  139629. */
  139630. onSuccess: (task: BinaryFileAssetTask) => void;
  139631. /**
  139632. * Callback called when the task is successful
  139633. */
  139634. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  139635. /**
  139636. * Creates a new BinaryFileAssetTask object
  139637. * @param name defines the name of the new task
  139638. * @param url defines the location of the file to load
  139639. */
  139640. constructor(
  139641. /**
  139642. * Defines the name of the task
  139643. */
  139644. name: string,
  139645. /**
  139646. * Defines the location of the file to load
  139647. */
  139648. url: string);
  139649. /**
  139650. * Execute the current task
  139651. * @param scene defines the scene where you want your assets to be loaded
  139652. * @param onSuccess is a callback called when the task is successfully executed
  139653. * @param onError is a callback called if an error occurs
  139654. */
  139655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139656. }
  139657. /**
  139658. * Define a task used by AssetsManager to load images
  139659. */
  139660. export class ImageAssetTask extends AbstractAssetTask {
  139661. /**
  139662. * Defines the name of the task
  139663. */
  139664. name: string;
  139665. /**
  139666. * Defines the location of the image to load
  139667. */
  139668. url: string;
  139669. /**
  139670. * Gets the loaded images
  139671. */
  139672. image: HTMLImageElement;
  139673. /**
  139674. * Callback called when the task is successful
  139675. */
  139676. onSuccess: (task: ImageAssetTask) => void;
  139677. /**
  139678. * Callback called when the task is successful
  139679. */
  139680. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  139681. /**
  139682. * Creates a new ImageAssetTask
  139683. * @param name defines the name of the task
  139684. * @param url defines the location of the image to load
  139685. */
  139686. constructor(
  139687. /**
  139688. * Defines the name of the task
  139689. */
  139690. name: string,
  139691. /**
  139692. * Defines the location of the image to load
  139693. */
  139694. url: string);
  139695. /**
  139696. * Execute the current task
  139697. * @param scene defines the scene where you want your assets to be loaded
  139698. * @param onSuccess is a callback called when the task is successfully executed
  139699. * @param onError is a callback called if an error occurs
  139700. */
  139701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139702. }
  139703. /**
  139704. * Defines the interface used by texture loading tasks
  139705. */
  139706. export interface ITextureAssetTask<TEX extends BaseTexture> {
  139707. /**
  139708. * Gets the loaded texture
  139709. */
  139710. texture: TEX;
  139711. }
  139712. /**
  139713. * Define a task used by AssetsManager to load 2D textures
  139714. */
  139715. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  139716. /**
  139717. * Defines the name of the task
  139718. */
  139719. name: string;
  139720. /**
  139721. * Defines the location of the file to load
  139722. */
  139723. url: string;
  139724. /**
  139725. * Defines if mipmap should not be generated (default is false)
  139726. */
  139727. noMipmap?: boolean | undefined;
  139728. /**
  139729. * Defines if texture must be inverted on Y axis (default is false)
  139730. */
  139731. invertY?: boolean | undefined;
  139732. /**
  139733. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139734. */
  139735. samplingMode: number;
  139736. /**
  139737. * Gets the loaded texture
  139738. */
  139739. texture: Texture;
  139740. /**
  139741. * Callback called when the task is successful
  139742. */
  139743. onSuccess: (task: TextureAssetTask) => void;
  139744. /**
  139745. * Callback called when the task is successful
  139746. */
  139747. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  139748. /**
  139749. * Creates a new TextureAssetTask object
  139750. * @param name defines the name of the task
  139751. * @param url defines the location of the file to load
  139752. * @param noMipmap defines if mipmap should not be generated (default is false)
  139753. * @param invertY defines if texture must be inverted on Y axis (default is false)
  139754. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139755. */
  139756. constructor(
  139757. /**
  139758. * Defines the name of the task
  139759. */
  139760. name: string,
  139761. /**
  139762. * Defines the location of the file to load
  139763. */
  139764. url: string,
  139765. /**
  139766. * Defines if mipmap should not be generated (default is false)
  139767. */
  139768. noMipmap?: boolean | undefined,
  139769. /**
  139770. * Defines if texture must be inverted on Y axis (default is false)
  139771. */
  139772. invertY?: boolean | undefined,
  139773. /**
  139774. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139775. */
  139776. samplingMode?: number);
  139777. /**
  139778. * Execute the current task
  139779. * @param scene defines the scene where you want your assets to be loaded
  139780. * @param onSuccess is a callback called when the task is successfully executed
  139781. * @param onError is a callback called if an error occurs
  139782. */
  139783. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139784. }
  139785. /**
  139786. * Define a task used by AssetsManager to load cube textures
  139787. */
  139788. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  139789. /**
  139790. * Defines the name of the task
  139791. */
  139792. name: string;
  139793. /**
  139794. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139795. */
  139796. url: string;
  139797. /**
  139798. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139799. */
  139800. extensions?: string[] | undefined;
  139801. /**
  139802. * Defines if mipmaps should not be generated (default is false)
  139803. */
  139804. noMipmap?: boolean | undefined;
  139805. /**
  139806. * Defines the explicit list of files (undefined by default)
  139807. */
  139808. files?: string[] | undefined;
  139809. /**
  139810. * Gets the loaded texture
  139811. */
  139812. texture: CubeTexture;
  139813. /**
  139814. * Callback called when the task is successful
  139815. */
  139816. onSuccess: (task: CubeTextureAssetTask) => void;
  139817. /**
  139818. * Callback called when the task is successful
  139819. */
  139820. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  139821. /**
  139822. * Creates a new CubeTextureAssetTask
  139823. * @param name defines the name of the task
  139824. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139825. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139826. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139827. * @param files defines the explicit list of files (undefined by default)
  139828. */
  139829. constructor(
  139830. /**
  139831. * Defines the name of the task
  139832. */
  139833. name: string,
  139834. /**
  139835. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139836. */
  139837. url: string,
  139838. /**
  139839. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139840. */
  139841. extensions?: string[] | undefined,
  139842. /**
  139843. * Defines if mipmaps should not be generated (default is false)
  139844. */
  139845. noMipmap?: boolean | undefined,
  139846. /**
  139847. * Defines the explicit list of files (undefined by default)
  139848. */
  139849. files?: string[] | undefined);
  139850. /**
  139851. * Execute the current task
  139852. * @param scene defines the scene where you want your assets to be loaded
  139853. * @param onSuccess is a callback called when the task is successfully executed
  139854. * @param onError is a callback called if an error occurs
  139855. */
  139856. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139857. }
  139858. /**
  139859. * Define a task used by AssetsManager to load HDR cube textures
  139860. */
  139861. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  139862. /**
  139863. * Defines the name of the task
  139864. */
  139865. name: string;
  139866. /**
  139867. * Defines the location of the file to load
  139868. */
  139869. url: string;
  139870. /**
  139871. * Defines the desired size (the more it increases the longer the generation will be)
  139872. */
  139873. size: number;
  139874. /**
  139875. * Defines if mipmaps should not be generated (default is false)
  139876. */
  139877. noMipmap: boolean;
  139878. /**
  139879. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139880. */
  139881. generateHarmonics: boolean;
  139882. /**
  139883. * 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)
  139884. */
  139885. gammaSpace: boolean;
  139886. /**
  139887. * Internal Use Only
  139888. */
  139889. reserved: boolean;
  139890. /**
  139891. * Gets the loaded texture
  139892. */
  139893. texture: HDRCubeTexture;
  139894. /**
  139895. * Callback called when the task is successful
  139896. */
  139897. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  139898. /**
  139899. * Callback called when the task is successful
  139900. */
  139901. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  139902. /**
  139903. * Creates a new HDRCubeTextureAssetTask object
  139904. * @param name defines the name of the task
  139905. * @param url defines the location of the file to load
  139906. * @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.
  139907. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139908. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139909. * @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)
  139910. * @param reserved Internal use only
  139911. */
  139912. constructor(
  139913. /**
  139914. * Defines the name of the task
  139915. */
  139916. name: string,
  139917. /**
  139918. * Defines the location of the file to load
  139919. */
  139920. url: string,
  139921. /**
  139922. * Defines the desired size (the more it increases the longer the generation will be)
  139923. */
  139924. size: number,
  139925. /**
  139926. * Defines if mipmaps should not be generated (default is false)
  139927. */
  139928. noMipmap?: boolean,
  139929. /**
  139930. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139931. */
  139932. generateHarmonics?: boolean,
  139933. /**
  139934. * 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)
  139935. */
  139936. gammaSpace?: boolean,
  139937. /**
  139938. * Internal Use Only
  139939. */
  139940. reserved?: boolean);
  139941. /**
  139942. * Execute the current task
  139943. * @param scene defines the scene where you want your assets to be loaded
  139944. * @param onSuccess is a callback called when the task is successfully executed
  139945. * @param onError is a callback called if an error occurs
  139946. */
  139947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139948. }
  139949. /**
  139950. * Define a task used by AssetsManager to load Equirectangular cube textures
  139951. */
  139952. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  139953. /**
  139954. * Defines the name of the task
  139955. */
  139956. name: string;
  139957. /**
  139958. * Defines the location of the file to load
  139959. */
  139960. url: string;
  139961. /**
  139962. * Defines the desired size (the more it increases the longer the generation will be)
  139963. */
  139964. size: number;
  139965. /**
  139966. * Defines if mipmaps should not be generated (default is false)
  139967. */
  139968. noMipmap: boolean;
  139969. /**
  139970. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  139971. * but the standard material would require them in Gamma space) (default is true)
  139972. */
  139973. gammaSpace: boolean;
  139974. /**
  139975. * Gets the loaded texture
  139976. */
  139977. texture: EquiRectangularCubeTexture;
  139978. /**
  139979. * Callback called when the task is successful
  139980. */
  139981. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  139982. /**
  139983. * Callback called when the task is successful
  139984. */
  139985. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  139986. /**
  139987. * Creates a new EquiRectangularCubeTextureAssetTask object
  139988. * @param name defines the name of the task
  139989. * @param url defines the location of the file to load
  139990. * @param size defines the desired size (the more it increases the longer the generation will be)
  139991. * If the size is omitted this implies you are using a preprocessed cubemap.
  139992. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139993. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  139994. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  139995. * (default is true)
  139996. */
  139997. constructor(
  139998. /**
  139999. * Defines the name of the task
  140000. */
  140001. name: string,
  140002. /**
  140003. * Defines the location of the file to load
  140004. */
  140005. url: string,
  140006. /**
  140007. * Defines the desired size (the more it increases the longer the generation will be)
  140008. */
  140009. size: number,
  140010. /**
  140011. * Defines if mipmaps should not be generated (default is false)
  140012. */
  140013. noMipmap?: boolean,
  140014. /**
  140015. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140016. * but the standard material would require them in Gamma space) (default is true)
  140017. */
  140018. gammaSpace?: boolean);
  140019. /**
  140020. * Execute the current task
  140021. * @param scene defines the scene where you want your assets to be loaded
  140022. * @param onSuccess is a callback called when the task is successfully executed
  140023. * @param onError is a callback called if an error occurs
  140024. */
  140025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140026. }
  140027. /**
  140028. * This class can be used to easily import assets into a scene
  140029. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140030. */
  140031. export class AssetsManager {
  140032. private _scene;
  140033. private _isLoading;
  140034. protected _tasks: AbstractAssetTask[];
  140035. protected _waitingTasksCount: number;
  140036. protected _totalTasksCount: number;
  140037. /**
  140038. * Callback called when all tasks are processed
  140039. */
  140040. onFinish: (tasks: AbstractAssetTask[]) => void;
  140041. /**
  140042. * Callback called when a task is successful
  140043. */
  140044. onTaskSuccess: (task: AbstractAssetTask) => void;
  140045. /**
  140046. * Callback called when a task had an error
  140047. */
  140048. onTaskError: (task: AbstractAssetTask) => void;
  140049. /**
  140050. * Callback called when a task is done (whatever the result is)
  140051. */
  140052. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140053. /**
  140054. * Observable called when all tasks are processed
  140055. */
  140056. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140057. /**
  140058. * Observable called when a task had an error
  140059. */
  140060. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140061. /**
  140062. * Observable called when all tasks were executed
  140063. */
  140064. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140065. /**
  140066. * Observable called when a task is done (whatever the result is)
  140067. */
  140068. onProgressObservable: Observable<IAssetsProgressEvent>;
  140069. /**
  140070. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140071. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140072. */
  140073. useDefaultLoadingScreen: boolean;
  140074. /**
  140075. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140076. * when all assets have been downloaded.
  140077. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140078. */
  140079. autoHideLoadingUI: boolean;
  140080. /**
  140081. * Creates a new AssetsManager
  140082. * @param scene defines the scene to work on
  140083. */
  140084. constructor(scene: Scene);
  140085. /**
  140086. * Add a MeshAssetTask to the list of active tasks
  140087. * @param taskName defines the name of the new task
  140088. * @param meshesNames defines the name of meshes to load
  140089. * @param rootUrl defines the root url to use to locate files
  140090. * @param sceneFilename defines the filename of the scene file
  140091. * @returns a new MeshAssetTask object
  140092. */
  140093. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140094. /**
  140095. * Add a TextFileAssetTask to the list of active tasks
  140096. * @param taskName defines the name of the new task
  140097. * @param url defines the url of the file to load
  140098. * @returns a new TextFileAssetTask object
  140099. */
  140100. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140101. /**
  140102. * Add a BinaryFileAssetTask to the list of active tasks
  140103. * @param taskName defines the name of the new task
  140104. * @param url defines the url of the file to load
  140105. * @returns a new BinaryFileAssetTask object
  140106. */
  140107. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140108. /**
  140109. * Add a ImageAssetTask to the list of active tasks
  140110. * @param taskName defines the name of the new task
  140111. * @param url defines the url of the file to load
  140112. * @returns a new ImageAssetTask object
  140113. */
  140114. addImageTask(taskName: string, url: string): ImageAssetTask;
  140115. /**
  140116. * Add a TextureAssetTask to the list of active tasks
  140117. * @param taskName defines the name of the new task
  140118. * @param url defines the url of the file to load
  140119. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140120. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140121. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140122. * @returns a new TextureAssetTask object
  140123. */
  140124. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140125. /**
  140126. * Add a CubeTextureAssetTask to the list of active tasks
  140127. * @param taskName defines the name of the new task
  140128. * @param url defines the url of the file to load
  140129. * @param extensions defines the extension to use to load the cube map (can be null)
  140130. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140131. * @param files defines the list of files to load (can be null)
  140132. * @returns a new CubeTextureAssetTask object
  140133. */
  140134. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140135. /**
  140136. *
  140137. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140138. * @param taskName defines the name of the new task
  140139. * @param url defines the url of the file to load
  140140. * @param size defines the size you want for the cubemap (can be null)
  140141. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140142. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140143. * @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)
  140144. * @param reserved Internal use only
  140145. * @returns a new HDRCubeTextureAssetTask object
  140146. */
  140147. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140148. /**
  140149. *
  140150. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140151. * @param taskName defines the name of the new task
  140152. * @param url defines the url of the file to load
  140153. * @param size defines the size you want for the cubemap (can be null)
  140154. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140155. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140156. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140157. * @returns a new EquiRectangularCubeTextureAssetTask object
  140158. */
  140159. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140160. /**
  140161. * Remove a task from the assets manager.
  140162. * @param task the task to remove
  140163. */
  140164. removeTask(task: AbstractAssetTask): void;
  140165. private _decreaseWaitingTasksCount;
  140166. private _runTask;
  140167. /**
  140168. * Reset the AssetsManager and remove all tasks
  140169. * @return the current instance of the AssetsManager
  140170. */
  140171. reset(): AssetsManager;
  140172. /**
  140173. * Start the loading process
  140174. * @return the current instance of the AssetsManager
  140175. */
  140176. load(): AssetsManager;
  140177. /**
  140178. * Start the loading process as an async operation
  140179. * @return a promise returning the list of failed tasks
  140180. */
  140181. loadAsync(): Promise<void>;
  140182. }
  140183. }
  140184. declare module BABYLON {
  140185. /**
  140186. * Wrapper class for promise with external resolve and reject.
  140187. */
  140188. export class Deferred<T> {
  140189. /**
  140190. * The promise associated with this deferred object.
  140191. */
  140192. readonly promise: Promise<T>;
  140193. private _resolve;
  140194. private _reject;
  140195. /**
  140196. * The resolve method of the promise associated with this deferred object.
  140197. */
  140198. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  140199. /**
  140200. * The reject method of the promise associated with this deferred object.
  140201. */
  140202. get reject(): (reason?: any) => void;
  140203. /**
  140204. * Constructor for this deferred object.
  140205. */
  140206. constructor();
  140207. }
  140208. }
  140209. declare module BABYLON {
  140210. /**
  140211. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  140212. */
  140213. export class MeshExploder {
  140214. private _centerMesh;
  140215. private _meshes;
  140216. private _meshesOrigins;
  140217. private _toCenterVectors;
  140218. private _scaledDirection;
  140219. private _newPosition;
  140220. private _centerPosition;
  140221. /**
  140222. * Explodes meshes from a center mesh.
  140223. * @param meshes The meshes to explode.
  140224. * @param centerMesh The mesh to be center of explosion.
  140225. */
  140226. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  140227. private _setCenterMesh;
  140228. /**
  140229. * Get class name
  140230. * @returns "MeshExploder"
  140231. */
  140232. getClassName(): string;
  140233. /**
  140234. * "Exploded meshes"
  140235. * @returns Array of meshes with the centerMesh at index 0.
  140236. */
  140237. getMeshes(): Array<Mesh>;
  140238. /**
  140239. * Explodes meshes giving a specific direction
  140240. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  140241. */
  140242. explode(direction?: number): void;
  140243. }
  140244. }
  140245. declare module BABYLON {
  140246. /**
  140247. * Class used to help managing file picking and drag'n'drop
  140248. */
  140249. export class FilesInput {
  140250. /**
  140251. * List of files ready to be loaded
  140252. */
  140253. static get FilesToLoad(): {
  140254. [key: string]: File;
  140255. };
  140256. /**
  140257. * Callback called when a file is processed
  140258. */
  140259. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  140260. private _engine;
  140261. private _currentScene;
  140262. private _sceneLoadedCallback;
  140263. private _progressCallback;
  140264. private _additionalRenderLoopLogicCallback;
  140265. private _textureLoadingCallback;
  140266. private _startingProcessingFilesCallback;
  140267. private _onReloadCallback;
  140268. private _errorCallback;
  140269. private _elementToMonitor;
  140270. private _sceneFileToLoad;
  140271. private _filesToLoad;
  140272. /**
  140273. * Creates a new FilesInput
  140274. * @param engine defines the rendering engine
  140275. * @param scene defines the hosting scene
  140276. * @param sceneLoadedCallback callback called when scene is loaded
  140277. * @param progressCallback callback called to track progress
  140278. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  140279. * @param textureLoadingCallback callback called when a texture is loading
  140280. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  140281. * @param onReloadCallback callback called when a reload is requested
  140282. * @param errorCallback callback call if an error occurs
  140283. */
  140284. 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);
  140285. private _dragEnterHandler;
  140286. private _dragOverHandler;
  140287. private _dropHandler;
  140288. /**
  140289. * Calls this function to listen to drag'n'drop events on a specific DOM element
  140290. * @param elementToMonitor defines the DOM element to track
  140291. */
  140292. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  140293. /**
  140294. * Release all associated resources
  140295. */
  140296. dispose(): void;
  140297. private renderFunction;
  140298. private drag;
  140299. private drop;
  140300. private _traverseFolder;
  140301. private _processFiles;
  140302. /**
  140303. * Load files from a drop event
  140304. * @param event defines the drop event to use as source
  140305. */
  140306. loadFiles(event: any): void;
  140307. private _processReload;
  140308. /**
  140309. * Reload the current scene from the loaded files
  140310. */
  140311. reload(): void;
  140312. }
  140313. }
  140314. declare module BABYLON {
  140315. /**
  140316. * Defines the root class used to create scene optimization to use with SceneOptimizer
  140317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140318. */
  140319. export class SceneOptimization {
  140320. /**
  140321. * Defines the priority of this optimization (0 by default which means first in the list)
  140322. */
  140323. priority: number;
  140324. /**
  140325. * Gets a string describing the action executed by the current optimization
  140326. * @returns description string
  140327. */
  140328. getDescription(): string;
  140329. /**
  140330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140331. * @param scene defines the current scene where to apply this optimization
  140332. * @param optimizer defines the current optimizer
  140333. * @returns true if everything that can be done was applied
  140334. */
  140335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140336. /**
  140337. * Creates the SceneOptimization object
  140338. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140339. * @param desc defines the description associated with the optimization
  140340. */
  140341. constructor(
  140342. /**
  140343. * Defines the priority of this optimization (0 by default which means first in the list)
  140344. */
  140345. priority?: number);
  140346. }
  140347. /**
  140348. * Defines an optimization used to reduce the size of render target textures
  140349. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140350. */
  140351. export class TextureOptimization extends SceneOptimization {
  140352. /**
  140353. * Defines the priority of this optimization (0 by default which means first in the list)
  140354. */
  140355. priority: number;
  140356. /**
  140357. * 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
  140358. */
  140359. maximumSize: number;
  140360. /**
  140361. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140362. */
  140363. step: number;
  140364. /**
  140365. * Gets a string describing the action executed by the current optimization
  140366. * @returns description string
  140367. */
  140368. getDescription(): string;
  140369. /**
  140370. * Creates the TextureOptimization object
  140371. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140372. * @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
  140373. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140374. */
  140375. constructor(
  140376. /**
  140377. * Defines the priority of this optimization (0 by default which means first in the list)
  140378. */
  140379. priority?: number,
  140380. /**
  140381. * 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
  140382. */
  140383. maximumSize?: number,
  140384. /**
  140385. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140386. */
  140387. step?: number);
  140388. /**
  140389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140390. * @param scene defines the current scene where to apply this optimization
  140391. * @param optimizer defines the current optimizer
  140392. * @returns true if everything that can be done was applied
  140393. */
  140394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140395. }
  140396. /**
  140397. * Defines an optimization used to increase or decrease the rendering resolution
  140398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140399. */
  140400. export class HardwareScalingOptimization extends SceneOptimization {
  140401. /**
  140402. * Defines the priority of this optimization (0 by default which means first in the list)
  140403. */
  140404. priority: number;
  140405. /**
  140406. * Defines the maximum scale to use (2 by default)
  140407. */
  140408. maximumScale: number;
  140409. /**
  140410. * Defines the step to use between two passes (0.5 by default)
  140411. */
  140412. step: number;
  140413. private _currentScale;
  140414. private _directionOffset;
  140415. /**
  140416. * Gets a string describing the action executed by the current optimization
  140417. * @return description string
  140418. */
  140419. getDescription(): string;
  140420. /**
  140421. * Creates the HardwareScalingOptimization object
  140422. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140423. * @param maximumScale defines the maximum scale to use (2 by default)
  140424. * @param step defines the step to use between two passes (0.5 by default)
  140425. */
  140426. constructor(
  140427. /**
  140428. * Defines the priority of this optimization (0 by default which means first in the list)
  140429. */
  140430. priority?: number,
  140431. /**
  140432. * Defines the maximum scale to use (2 by default)
  140433. */
  140434. maximumScale?: number,
  140435. /**
  140436. * Defines the step to use between two passes (0.5 by default)
  140437. */
  140438. step?: number);
  140439. /**
  140440. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140441. * @param scene defines the current scene where to apply this optimization
  140442. * @param optimizer defines the current optimizer
  140443. * @returns true if everything that can be done was applied
  140444. */
  140445. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140446. }
  140447. /**
  140448. * Defines an optimization used to remove shadows
  140449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140450. */
  140451. export class ShadowsOptimization extends SceneOptimization {
  140452. /**
  140453. * Gets a string describing the action executed by the current optimization
  140454. * @return description string
  140455. */
  140456. getDescription(): string;
  140457. /**
  140458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140459. * @param scene defines the current scene where to apply this optimization
  140460. * @param optimizer defines the current optimizer
  140461. * @returns true if everything that can be done was applied
  140462. */
  140463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140464. }
  140465. /**
  140466. * Defines an optimization used to turn post-processes off
  140467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140468. */
  140469. export class PostProcessesOptimization extends SceneOptimization {
  140470. /**
  140471. * Gets a string describing the action executed by the current optimization
  140472. * @return description string
  140473. */
  140474. getDescription(): string;
  140475. /**
  140476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140477. * @param scene defines the current scene where to apply this optimization
  140478. * @param optimizer defines the current optimizer
  140479. * @returns true if everything that can be done was applied
  140480. */
  140481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140482. }
  140483. /**
  140484. * Defines an optimization used to turn lens flares off
  140485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140486. */
  140487. export class LensFlaresOptimization extends SceneOptimization {
  140488. /**
  140489. * Gets a string describing the action executed by the current optimization
  140490. * @return description string
  140491. */
  140492. getDescription(): string;
  140493. /**
  140494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140495. * @param scene defines the current scene where to apply this optimization
  140496. * @param optimizer defines the current optimizer
  140497. * @returns true if everything that can be done was applied
  140498. */
  140499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140500. }
  140501. /**
  140502. * Defines an optimization based on user defined callback.
  140503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140504. */
  140505. export class CustomOptimization extends SceneOptimization {
  140506. /**
  140507. * Callback called to apply the custom optimization.
  140508. */
  140509. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  140510. /**
  140511. * Callback called to get custom description
  140512. */
  140513. onGetDescription: () => string;
  140514. /**
  140515. * Gets a string describing the action executed by the current optimization
  140516. * @returns description string
  140517. */
  140518. getDescription(): string;
  140519. /**
  140520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140521. * @param scene defines the current scene where to apply this optimization
  140522. * @param optimizer defines the current optimizer
  140523. * @returns true if everything that can be done was applied
  140524. */
  140525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140526. }
  140527. /**
  140528. * Defines an optimization used to turn particles off
  140529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140530. */
  140531. export class ParticlesOptimization extends SceneOptimization {
  140532. /**
  140533. * Gets a string describing the action executed by the current optimization
  140534. * @return description string
  140535. */
  140536. getDescription(): string;
  140537. /**
  140538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140539. * @param scene defines the current scene where to apply this optimization
  140540. * @param optimizer defines the current optimizer
  140541. * @returns true if everything that can be done was applied
  140542. */
  140543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140544. }
  140545. /**
  140546. * Defines an optimization used to turn render targets off
  140547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140548. */
  140549. export class RenderTargetsOptimization extends SceneOptimization {
  140550. /**
  140551. * Gets a string describing the action executed by the current optimization
  140552. * @return description string
  140553. */
  140554. getDescription(): string;
  140555. /**
  140556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140557. * @param scene defines the current scene where to apply this optimization
  140558. * @param optimizer defines the current optimizer
  140559. * @returns true if everything that can be done was applied
  140560. */
  140561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140562. }
  140563. /**
  140564. * Defines an optimization used to merge meshes with compatible materials
  140565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140566. */
  140567. export class MergeMeshesOptimization extends SceneOptimization {
  140568. private static _UpdateSelectionTree;
  140569. /**
  140570. * Gets or sets a boolean which defines if optimization octree has to be updated
  140571. */
  140572. static get UpdateSelectionTree(): boolean;
  140573. /**
  140574. * Gets or sets a boolean which defines if optimization octree has to be updated
  140575. */
  140576. static set UpdateSelectionTree(value: boolean);
  140577. /**
  140578. * Gets a string describing the action executed by the current optimization
  140579. * @return description string
  140580. */
  140581. getDescription(): string;
  140582. private _canBeMerged;
  140583. /**
  140584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140585. * @param scene defines the current scene where to apply this optimization
  140586. * @param optimizer defines the current optimizer
  140587. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  140588. * @returns true if everything that can be done was applied
  140589. */
  140590. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  140591. }
  140592. /**
  140593. * Defines a list of options used by SceneOptimizer
  140594. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140595. */
  140596. export class SceneOptimizerOptions {
  140597. /**
  140598. * Defines the target frame rate to reach (60 by default)
  140599. */
  140600. targetFrameRate: number;
  140601. /**
  140602. * Defines the interval between two checkes (2000ms by default)
  140603. */
  140604. trackerDuration: number;
  140605. /**
  140606. * Gets the list of optimizations to apply
  140607. */
  140608. optimizations: SceneOptimization[];
  140609. /**
  140610. * Creates a new list of options used by SceneOptimizer
  140611. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  140612. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  140613. */
  140614. constructor(
  140615. /**
  140616. * Defines the target frame rate to reach (60 by default)
  140617. */
  140618. targetFrameRate?: number,
  140619. /**
  140620. * Defines the interval between two checkes (2000ms by default)
  140621. */
  140622. trackerDuration?: number);
  140623. /**
  140624. * Add a new optimization
  140625. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  140626. * @returns the current SceneOptimizerOptions
  140627. */
  140628. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  140629. /**
  140630. * Add a new custom optimization
  140631. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  140632. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  140633. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140634. * @returns the current SceneOptimizerOptions
  140635. */
  140636. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  140637. /**
  140638. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  140639. * @param targetFrameRate defines the target frame rate (60 by default)
  140640. * @returns a SceneOptimizerOptions object
  140641. */
  140642. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140643. /**
  140644. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  140645. * @param targetFrameRate defines the target frame rate (60 by default)
  140646. * @returns a SceneOptimizerOptions object
  140647. */
  140648. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140649. /**
  140650. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  140651. * @param targetFrameRate defines the target frame rate (60 by default)
  140652. * @returns a SceneOptimizerOptions object
  140653. */
  140654. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140655. }
  140656. /**
  140657. * Class used to run optimizations in order to reach a target frame rate
  140658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140659. */
  140660. export class SceneOptimizer implements IDisposable {
  140661. private _isRunning;
  140662. private _options;
  140663. private _scene;
  140664. private _currentPriorityLevel;
  140665. private _targetFrameRate;
  140666. private _trackerDuration;
  140667. private _currentFrameRate;
  140668. private _sceneDisposeObserver;
  140669. private _improvementMode;
  140670. /**
  140671. * Defines an observable called when the optimizer reaches the target frame rate
  140672. */
  140673. onSuccessObservable: Observable<SceneOptimizer>;
  140674. /**
  140675. * Defines an observable called when the optimizer enables an optimization
  140676. */
  140677. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  140678. /**
  140679. * Defines an observable called when the optimizer is not able to reach the target frame rate
  140680. */
  140681. onFailureObservable: Observable<SceneOptimizer>;
  140682. /**
  140683. * Gets a boolean indicating if the optimizer is in improvement mode
  140684. */
  140685. get isInImprovementMode(): boolean;
  140686. /**
  140687. * Gets the current priority level (0 at start)
  140688. */
  140689. get currentPriorityLevel(): number;
  140690. /**
  140691. * Gets the current frame rate checked by the SceneOptimizer
  140692. */
  140693. get currentFrameRate(): number;
  140694. /**
  140695. * Gets or sets the current target frame rate (60 by default)
  140696. */
  140697. get targetFrameRate(): number;
  140698. /**
  140699. * Gets or sets the current target frame rate (60 by default)
  140700. */
  140701. set targetFrameRate(value: number);
  140702. /**
  140703. * Gets or sets the current interval between two checks (every 2000ms by default)
  140704. */
  140705. get trackerDuration(): number;
  140706. /**
  140707. * Gets or sets the current interval between two checks (every 2000ms by default)
  140708. */
  140709. set trackerDuration(value: number);
  140710. /**
  140711. * Gets the list of active optimizations
  140712. */
  140713. get optimizations(): SceneOptimization[];
  140714. /**
  140715. * Creates a new SceneOptimizer
  140716. * @param scene defines the scene to work on
  140717. * @param options defines the options to use with the SceneOptimizer
  140718. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  140719. * @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)
  140720. */
  140721. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  140722. /**
  140723. * Stops the current optimizer
  140724. */
  140725. stop(): void;
  140726. /**
  140727. * Reset the optimizer to initial step (current priority level = 0)
  140728. */
  140729. reset(): void;
  140730. /**
  140731. * Start the optimizer. By default it will try to reach a specific framerate
  140732. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  140733. */
  140734. start(): void;
  140735. private _checkCurrentState;
  140736. /**
  140737. * Release all resources
  140738. */
  140739. dispose(): void;
  140740. /**
  140741. * Helper function to create a SceneOptimizer with one single line of code
  140742. * @param scene defines the scene to work on
  140743. * @param options defines the options to use with the SceneOptimizer
  140744. * @param onSuccess defines a callback to call on success
  140745. * @param onFailure defines a callback to call on failure
  140746. * @returns the new SceneOptimizer object
  140747. */
  140748. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  140749. }
  140750. }
  140751. declare module BABYLON {
  140752. /**
  140753. * Class used to serialize a scene into a string
  140754. */
  140755. export class SceneSerializer {
  140756. /**
  140757. * Clear cache used by a previous serialization
  140758. */
  140759. static ClearCache(): void;
  140760. /**
  140761. * Serialize a scene into a JSON compatible object
  140762. * @param scene defines the scene to serialize
  140763. * @returns a JSON compatible object
  140764. */
  140765. static Serialize(scene: Scene): any;
  140766. /**
  140767. * Serialize a mesh into a JSON compatible object
  140768. * @param toSerialize defines the mesh to serialize
  140769. * @param withParents defines if parents must be serialized as well
  140770. * @param withChildren defines if children must be serialized as well
  140771. * @returns a JSON compatible object
  140772. */
  140773. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  140774. }
  140775. }
  140776. declare module BABYLON {
  140777. /**
  140778. * Class used to host texture specific utilities
  140779. */
  140780. export class TextureTools {
  140781. /**
  140782. * Uses the GPU to create a copy texture rescaled at a given size
  140783. * @param texture Texture to copy from
  140784. * @param width defines the desired width
  140785. * @param height defines the desired height
  140786. * @param useBilinearMode defines if bilinear mode has to be used
  140787. * @return the generated texture
  140788. */
  140789. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  140790. }
  140791. }
  140792. declare module BABYLON {
  140793. /**
  140794. * This represents the different options available for the video capture.
  140795. */
  140796. export interface VideoRecorderOptions {
  140797. /** Defines the mime type of the video. */
  140798. mimeType: string;
  140799. /** Defines the FPS the video should be recorded at. */
  140800. fps: number;
  140801. /** Defines the chunk size for the recording data. */
  140802. recordChunckSize: number;
  140803. /** The audio tracks to attach to the recording. */
  140804. audioTracks?: MediaStreamTrack[];
  140805. }
  140806. /**
  140807. * This can help with recording videos from BabylonJS.
  140808. * This is based on the available WebRTC functionalities of the browser.
  140809. *
  140810. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  140811. */
  140812. export class VideoRecorder {
  140813. private static readonly _defaultOptions;
  140814. /**
  140815. * Returns whether or not the VideoRecorder is available in your browser.
  140816. * @param engine Defines the Babylon Engine.
  140817. * @returns true if supported otherwise false.
  140818. */
  140819. static IsSupported(engine: Engine): boolean;
  140820. private readonly _options;
  140821. private _canvas;
  140822. private _mediaRecorder;
  140823. private _recordedChunks;
  140824. private _fileName;
  140825. private _resolve;
  140826. private _reject;
  140827. /**
  140828. * True when a recording is already in progress.
  140829. */
  140830. get isRecording(): boolean;
  140831. /**
  140832. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  140833. * @param engine Defines the BabylonJS Engine you wish to record.
  140834. * @param options Defines options that can be used to customize the capture.
  140835. */
  140836. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  140837. /**
  140838. * Stops the current recording before the default capture timeout passed in the startRecording function.
  140839. */
  140840. stopRecording(): void;
  140841. /**
  140842. * Starts recording the canvas for a max duration specified in parameters.
  140843. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  140844. * If null no automatic download will start and you can rely on the promise to get the data back.
  140845. * @param maxDuration Defines the maximum recording time in seconds.
  140846. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  140847. * @return A promise callback at the end of the recording with the video data in Blob.
  140848. */
  140849. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  140850. /**
  140851. * Releases internal resources used during the recording.
  140852. */
  140853. dispose(): void;
  140854. private _handleDataAvailable;
  140855. private _handleError;
  140856. private _handleStop;
  140857. }
  140858. }
  140859. declare module BABYLON {
  140860. /**
  140861. * Class containing a set of static utilities functions for screenshots
  140862. */
  140863. export class ScreenshotTools {
  140864. /**
  140865. * Captures a screenshot of the current rendering
  140866. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140867. * @param engine defines the rendering engine
  140868. * @param camera defines the source camera
  140869. * @param size This parameter can be set to a single number or to an object with the
  140870. * following (optional) properties: precision, width, height. If a single number is passed,
  140871. * it will be used for both width and height. If an object is passed, the screenshot size
  140872. * will be derived from the parameters. The precision property is a multiplier allowing
  140873. * rendering at a higher or lower resolution
  140874. * @param successCallback defines the callback receives a single parameter which contains the
  140875. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  140876. * src parameter of an <img> to display it
  140877. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  140878. * Check your browser for supported MIME types
  140879. */
  140880. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  140881. /**
  140882. * Captures a screenshot of the current rendering
  140883. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140884. * @param engine defines the rendering engine
  140885. * @param camera defines the source camera
  140886. * @param size This parameter can be set to a single number or to an object with the
  140887. * following (optional) properties: precision, width, height. If a single number is passed,
  140888. * it will be used for both width and height. If an object is passed, the screenshot size
  140889. * will be derived from the parameters. The precision property is a multiplier allowing
  140890. * rendering at a higher or lower resolution
  140891. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  140892. * Check your browser for supported MIME types
  140893. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  140894. * to the src parameter of an <img> to display it
  140895. */
  140896. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  140897. /**
  140898. * Generates an image screenshot from the specified camera.
  140899. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140900. * @param engine The engine to use for rendering
  140901. * @param camera The camera to use for rendering
  140902. * @param size This parameter can be set to a single number or to an object with the
  140903. * following (optional) properties: precision, width, height. If a single number is passed,
  140904. * it will be used for both width and height. If an object is passed, the screenshot size
  140905. * will be derived from the parameters. The precision property is a multiplier allowing
  140906. * rendering at a higher or lower resolution
  140907. * @param successCallback The callback receives a single parameter which contains the
  140908. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  140909. * src parameter of an <img> to display it
  140910. * @param mimeType The MIME type of the screenshot image (default: image/png).
  140911. * Check your browser for supported MIME types
  140912. * @param samples Texture samples (default: 1)
  140913. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  140914. * @param fileName A name for for the downloaded file.
  140915. */
  140916. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  140917. /**
  140918. * Generates an image screenshot from the specified camera.
  140919. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140920. * @param engine The engine to use for rendering
  140921. * @param camera The camera to use for rendering
  140922. * @param size This parameter can be set to a single number or to an object with the
  140923. * following (optional) properties: precision, width, height. If a single number is passed,
  140924. * it will be used for both width and height. If an object is passed, the screenshot size
  140925. * will be derived from the parameters. The precision property is a multiplier allowing
  140926. * rendering at a higher or lower resolution
  140927. * @param mimeType The MIME type of the screenshot image (default: image/png).
  140928. * Check your browser for supported MIME types
  140929. * @param samples Texture samples (default: 1)
  140930. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  140931. * @param fileName A name for for the downloaded file.
  140932. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  140933. * to the src parameter of an <img> to display it
  140934. */
  140935. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  140936. /**
  140937. * Gets height and width for screenshot size
  140938. * @private
  140939. */
  140940. private static _getScreenshotSize;
  140941. }
  140942. }
  140943. declare module BABYLON {
  140944. /**
  140945. * Interface for a data buffer
  140946. */
  140947. export interface IDataBuffer {
  140948. /**
  140949. * Reads bytes from the data buffer.
  140950. * @param byteOffset The byte offset to read
  140951. * @param byteLength The byte length to read
  140952. * @returns A promise that resolves when the bytes are read
  140953. */
  140954. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  140955. /**
  140956. * The byte length of the buffer.
  140957. */
  140958. readonly byteLength: number;
  140959. }
  140960. /**
  140961. * Utility class for reading from a data buffer
  140962. */
  140963. export class DataReader {
  140964. /**
  140965. * The data buffer associated with this data reader.
  140966. */
  140967. readonly buffer: IDataBuffer;
  140968. /**
  140969. * The current byte offset from the beginning of the data buffer.
  140970. */
  140971. byteOffset: number;
  140972. private _dataView;
  140973. private _dataByteOffset;
  140974. /**
  140975. * Constructor
  140976. * @param buffer The buffer to read
  140977. */
  140978. constructor(buffer: IDataBuffer);
  140979. /**
  140980. * Loads the given byte length.
  140981. * @param byteLength The byte length to load
  140982. * @returns A promise that resolves when the load is complete
  140983. */
  140984. loadAsync(byteLength: number): Promise<void>;
  140985. /**
  140986. * Read a unsigned 32-bit integer from the currently loaded data range.
  140987. * @returns The 32-bit integer read
  140988. */
  140989. readUint32(): number;
  140990. /**
  140991. * Read a byte array from the currently loaded data range.
  140992. * @param byteLength The byte length to read
  140993. * @returns The byte array read
  140994. */
  140995. readUint8Array(byteLength: number): Uint8Array;
  140996. /**
  140997. * Read a string from the currently loaded data range.
  140998. * @param byteLength The byte length to read
  140999. * @returns The string read
  141000. */
  141001. readString(byteLength: number): string;
  141002. /**
  141003. * Skips the given byte length the currently loaded data range.
  141004. * @param byteLength The byte length to skip
  141005. */
  141006. skipBytes(byteLength: number): void;
  141007. }
  141008. }
  141009. declare module BABYLON {
  141010. /**
  141011. * A cursor which tracks a point on a path
  141012. */
  141013. export class PathCursor {
  141014. private path;
  141015. /**
  141016. * Stores path cursor callbacks for when an onchange event is triggered
  141017. */
  141018. private _onchange;
  141019. /**
  141020. * The value of the path cursor
  141021. */
  141022. value: number;
  141023. /**
  141024. * The animation array of the path cursor
  141025. */
  141026. animations: Animation[];
  141027. /**
  141028. * Initializes the path cursor
  141029. * @param path The path to track
  141030. */
  141031. constructor(path: Path2);
  141032. /**
  141033. * Gets the cursor point on the path
  141034. * @returns A point on the path cursor at the cursor location
  141035. */
  141036. getPoint(): Vector3;
  141037. /**
  141038. * Moves the cursor ahead by the step amount
  141039. * @param step The amount to move the cursor forward
  141040. * @returns This path cursor
  141041. */
  141042. moveAhead(step?: number): PathCursor;
  141043. /**
  141044. * Moves the cursor behind by the step amount
  141045. * @param step The amount to move the cursor back
  141046. * @returns This path cursor
  141047. */
  141048. moveBack(step?: number): PathCursor;
  141049. /**
  141050. * Moves the cursor by the step amount
  141051. * If the step amount is greater than one, an exception is thrown
  141052. * @param step The amount to move the cursor
  141053. * @returns This path cursor
  141054. */
  141055. move(step: number): PathCursor;
  141056. /**
  141057. * Ensures that the value is limited between zero and one
  141058. * @returns This path cursor
  141059. */
  141060. private ensureLimits;
  141061. /**
  141062. * Runs onchange callbacks on change (used by the animation engine)
  141063. * @returns This path cursor
  141064. */
  141065. private raiseOnChange;
  141066. /**
  141067. * Executes a function on change
  141068. * @param f A path cursor onchange callback
  141069. * @returns This path cursor
  141070. */
  141071. onchange(f: (cursor: PathCursor) => void): PathCursor;
  141072. }
  141073. }
  141074. declare module BABYLON {
  141075. /** @hidden */
  141076. export var blurPixelShader: {
  141077. name: string;
  141078. shader: string;
  141079. };
  141080. }
  141081. declare module BABYLON {
  141082. /** @hidden */
  141083. export var pointCloudVertexDeclaration: {
  141084. name: string;
  141085. shader: string;
  141086. };
  141087. }
  141088. // Mixins
  141089. interface Window {
  141090. mozIndexedDB: IDBFactory;
  141091. webkitIndexedDB: IDBFactory;
  141092. msIndexedDB: IDBFactory;
  141093. webkitURL: typeof URL;
  141094. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  141095. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  141096. WebGLRenderingContext: WebGLRenderingContext;
  141097. MSGesture: MSGesture;
  141098. CANNON: any;
  141099. AudioContext: AudioContext;
  141100. webkitAudioContext: AudioContext;
  141101. PointerEvent: any;
  141102. Math: Math;
  141103. Uint8Array: Uint8ArrayConstructor;
  141104. Float32Array: Float32ArrayConstructor;
  141105. mozURL: typeof URL;
  141106. msURL: typeof URL;
  141107. VRFrameData: any; // WebVR, from specs 1.1
  141108. DracoDecoderModule: any;
  141109. setImmediate(handler: (...args: any[]) => void): number;
  141110. }
  141111. interface HTMLCanvasElement {
  141112. requestPointerLock(): void;
  141113. msRequestPointerLock?(): void;
  141114. mozRequestPointerLock?(): void;
  141115. webkitRequestPointerLock?(): void;
  141116. /** Track wether a record is in progress */
  141117. isRecording: boolean;
  141118. /** Capture Stream method defined by some browsers */
  141119. captureStream(fps?: number): MediaStream;
  141120. }
  141121. interface CanvasRenderingContext2D {
  141122. msImageSmoothingEnabled: boolean;
  141123. }
  141124. interface MouseEvent {
  141125. mozMovementX: number;
  141126. mozMovementY: number;
  141127. webkitMovementX: number;
  141128. webkitMovementY: number;
  141129. msMovementX: number;
  141130. msMovementY: number;
  141131. }
  141132. interface Navigator {
  141133. mozGetVRDevices: (any: any) => any;
  141134. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141135. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141136. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141137. webkitGetGamepads(): Gamepad[];
  141138. msGetGamepads(): Gamepad[];
  141139. webkitGamepads(): Gamepad[];
  141140. }
  141141. interface HTMLVideoElement {
  141142. mozSrcObject: any;
  141143. }
  141144. interface Math {
  141145. fround(x: number): number;
  141146. imul(a: number, b: number): number;
  141147. }
  141148. interface WebGLRenderingContext {
  141149. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  141150. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  141151. vertexAttribDivisor(index: number, divisor: number): void;
  141152. createVertexArray(): any;
  141153. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  141154. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  141155. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  141156. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  141157. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  141158. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  141159. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  141160. // Queries
  141161. createQuery(): WebGLQuery;
  141162. deleteQuery(query: WebGLQuery): void;
  141163. beginQuery(target: number, query: WebGLQuery): void;
  141164. endQuery(target: number): void;
  141165. getQueryParameter(query: WebGLQuery, pname: number): any;
  141166. getQuery(target: number, pname: number): any;
  141167. MAX_SAMPLES: number;
  141168. RGBA8: number;
  141169. READ_FRAMEBUFFER: number;
  141170. DRAW_FRAMEBUFFER: number;
  141171. UNIFORM_BUFFER: number;
  141172. HALF_FLOAT_OES: number;
  141173. RGBA16F: number;
  141174. RGBA32F: number;
  141175. R32F: number;
  141176. RG32F: number;
  141177. RGB32F: number;
  141178. R16F: number;
  141179. RG16F: number;
  141180. RGB16F: number;
  141181. RED: number;
  141182. RG: number;
  141183. R8: number;
  141184. RG8: number;
  141185. UNSIGNED_INT_24_8: number;
  141186. DEPTH24_STENCIL8: number;
  141187. MIN: number;
  141188. MAX: number;
  141189. /* Multiple Render Targets */
  141190. drawBuffers(buffers: number[]): void;
  141191. readBuffer(src: number): void;
  141192. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  141193. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  141194. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  141195. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  141196. // Occlusion Query
  141197. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  141198. ANY_SAMPLES_PASSED: number;
  141199. QUERY_RESULT_AVAILABLE: number;
  141200. QUERY_RESULT: number;
  141201. }
  141202. interface WebGLProgram {
  141203. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  141204. }
  141205. interface EXT_disjoint_timer_query {
  141206. QUERY_COUNTER_BITS_EXT: number;
  141207. TIME_ELAPSED_EXT: number;
  141208. TIMESTAMP_EXT: number;
  141209. GPU_DISJOINT_EXT: number;
  141210. QUERY_RESULT_EXT: number;
  141211. QUERY_RESULT_AVAILABLE_EXT: number;
  141212. queryCounterEXT(query: WebGLQuery, target: number): void;
  141213. createQueryEXT(): WebGLQuery;
  141214. beginQueryEXT(target: number, query: WebGLQuery): void;
  141215. endQueryEXT(target: number): void;
  141216. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  141217. deleteQueryEXT(query: WebGLQuery): void;
  141218. }
  141219. interface WebGLUniformLocation {
  141220. _currentState: any;
  141221. }
  141222. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  141223. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  141224. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  141225. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  141226. interface WebGLRenderingContext {
  141227. readonly RASTERIZER_DISCARD: number;
  141228. readonly DEPTH_COMPONENT24: number;
  141229. readonly TEXTURE_3D: number;
  141230. readonly TEXTURE_2D_ARRAY: number;
  141231. readonly TEXTURE_COMPARE_FUNC: number;
  141232. readonly TEXTURE_COMPARE_MODE: number;
  141233. readonly COMPARE_REF_TO_TEXTURE: number;
  141234. readonly TEXTURE_WRAP_R: number;
  141235. readonly HALF_FLOAT: number;
  141236. readonly RGB8: number;
  141237. readonly RED_INTEGER: number;
  141238. readonly RG_INTEGER: number;
  141239. readonly RGB_INTEGER: number;
  141240. readonly RGBA_INTEGER: number;
  141241. readonly R8_SNORM: number;
  141242. readonly RG8_SNORM: number;
  141243. readonly RGB8_SNORM: number;
  141244. readonly RGBA8_SNORM: number;
  141245. readonly R8I: number;
  141246. readonly RG8I: number;
  141247. readonly RGB8I: number;
  141248. readonly RGBA8I: number;
  141249. readonly R8UI: number;
  141250. readonly RG8UI: number;
  141251. readonly RGB8UI: number;
  141252. readonly RGBA8UI: number;
  141253. readonly R16I: number;
  141254. readonly RG16I: number;
  141255. readonly RGB16I: number;
  141256. readonly RGBA16I: number;
  141257. readonly R16UI: number;
  141258. readonly RG16UI: number;
  141259. readonly RGB16UI: number;
  141260. readonly RGBA16UI: number;
  141261. readonly R32I: number;
  141262. readonly RG32I: number;
  141263. readonly RGB32I: number;
  141264. readonly RGBA32I: number;
  141265. readonly R32UI: number;
  141266. readonly RG32UI: number;
  141267. readonly RGB32UI: number;
  141268. readonly RGBA32UI: number;
  141269. readonly RGB10_A2UI: number;
  141270. readonly R11F_G11F_B10F: number;
  141271. readonly RGB9_E5: number;
  141272. readonly RGB10_A2: number;
  141273. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  141274. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  141275. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  141276. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  141277. readonly DEPTH_COMPONENT32F: number;
  141278. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  141279. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  141280. 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;
  141281. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  141282. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  141283. readonly TRANSFORM_FEEDBACK: number;
  141284. readonly INTERLEAVED_ATTRIBS: number;
  141285. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  141286. createTransformFeedback(): WebGLTransformFeedback;
  141287. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  141288. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  141289. beginTransformFeedback(primitiveMode: number): void;
  141290. endTransformFeedback(): void;
  141291. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  141292. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141293. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141294. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  141295. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  141296. }
  141297. interface ImageBitmap {
  141298. readonly width: number;
  141299. readonly height: number;
  141300. close(): void;
  141301. }
  141302. interface WebGLQuery extends WebGLObject {
  141303. }
  141304. declare var WebGLQuery: {
  141305. prototype: WebGLQuery;
  141306. new(): WebGLQuery;
  141307. };
  141308. interface WebGLSampler extends WebGLObject {
  141309. }
  141310. declare var WebGLSampler: {
  141311. prototype: WebGLSampler;
  141312. new(): WebGLSampler;
  141313. };
  141314. interface WebGLSync extends WebGLObject {
  141315. }
  141316. declare var WebGLSync: {
  141317. prototype: WebGLSync;
  141318. new(): WebGLSync;
  141319. };
  141320. interface WebGLTransformFeedback extends WebGLObject {
  141321. }
  141322. declare var WebGLTransformFeedback: {
  141323. prototype: WebGLTransformFeedback;
  141324. new(): WebGLTransformFeedback;
  141325. };
  141326. interface WebGLVertexArrayObject extends WebGLObject {
  141327. }
  141328. declare var WebGLVertexArrayObject: {
  141329. prototype: WebGLVertexArrayObject;
  141330. new(): WebGLVertexArrayObject;
  141331. };
  141332. // Type definitions for WebVR API
  141333. // Project: https://w3c.github.io/webvr/
  141334. // Definitions by: six a <https://github.com/lostfictions>
  141335. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  141336. interface VRDisplay extends EventTarget {
  141337. /**
  141338. * Dictionary of capabilities describing the VRDisplay.
  141339. */
  141340. readonly capabilities: VRDisplayCapabilities;
  141341. /**
  141342. * z-depth defining the far plane of the eye view frustum
  141343. * enables mapping of values in the render target depth
  141344. * attachment to scene coordinates. Initially set to 10000.0.
  141345. */
  141346. depthFar: number;
  141347. /**
  141348. * z-depth defining the near plane of the eye view frustum
  141349. * enables mapping of values in the render target depth
  141350. * attachment to scene coordinates. Initially set to 0.01.
  141351. */
  141352. depthNear: number;
  141353. /**
  141354. * An identifier for this distinct VRDisplay. Used as an
  141355. * association point in the Gamepad API.
  141356. */
  141357. readonly displayId: number;
  141358. /**
  141359. * A display name, a user-readable name identifying it.
  141360. */
  141361. readonly displayName: string;
  141362. readonly isConnected: boolean;
  141363. readonly isPresenting: boolean;
  141364. /**
  141365. * If this VRDisplay supports room-scale experiences, the optional
  141366. * stage attribute contains details on the room-scale parameters.
  141367. */
  141368. readonly stageParameters: VRStageParameters | null;
  141369. /**
  141370. * Passing the value returned by `requestAnimationFrame` to
  141371. * `cancelAnimationFrame` will unregister the callback.
  141372. * @param handle Define the hanle of the request to cancel
  141373. */
  141374. cancelAnimationFrame(handle: number): void;
  141375. /**
  141376. * Stops presenting to the VRDisplay.
  141377. * @returns a promise to know when it stopped
  141378. */
  141379. exitPresent(): Promise<void>;
  141380. /**
  141381. * Return the current VREyeParameters for the given eye.
  141382. * @param whichEye Define the eye we want the parameter for
  141383. * @returns the eye parameters
  141384. */
  141385. getEyeParameters(whichEye: string): VREyeParameters;
  141386. /**
  141387. * Populates the passed VRFrameData with the information required to render
  141388. * the current frame.
  141389. * @param frameData Define the data structure to populate
  141390. * @returns true if ok otherwise false
  141391. */
  141392. getFrameData(frameData: VRFrameData): boolean;
  141393. /**
  141394. * Get the layers currently being presented.
  141395. * @returns the list of VR layers
  141396. */
  141397. getLayers(): VRLayer[];
  141398. /**
  141399. * Return a VRPose containing the future predicted pose of the VRDisplay
  141400. * when the current frame will be presented. The value returned will not
  141401. * change until JavaScript has returned control to the browser.
  141402. *
  141403. * The VRPose will contain the position, orientation, velocity,
  141404. * and acceleration of each of these properties.
  141405. * @returns the pose object
  141406. */
  141407. getPose(): VRPose;
  141408. /**
  141409. * Return the current instantaneous pose of the VRDisplay, with no
  141410. * prediction applied.
  141411. * @returns the current instantaneous pose
  141412. */
  141413. getImmediatePose(): VRPose;
  141414. /**
  141415. * The callback passed to `requestAnimationFrame` will be called
  141416. * any time a new frame should be rendered. When the VRDisplay is
  141417. * presenting the callback will be called at the native refresh
  141418. * rate of the HMD. When not presenting this function acts
  141419. * identically to how window.requestAnimationFrame acts. Content should
  141420. * make no assumptions of frame rate or vsync behavior as the HMD runs
  141421. * asynchronously from other displays and at differing refresh rates.
  141422. * @param callback Define the eaction to run next frame
  141423. * @returns the request handle it
  141424. */
  141425. requestAnimationFrame(callback: FrameRequestCallback): number;
  141426. /**
  141427. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  141428. * Repeat calls while already presenting will update the VRLayers being displayed.
  141429. * @param layers Define the list of layer to present
  141430. * @returns a promise to know when the request has been fulfilled
  141431. */
  141432. requestPresent(layers: VRLayer[]): Promise<void>;
  141433. /**
  141434. * Reset the pose for this display, treating its current position and
  141435. * orientation as the "origin/zero" values. VRPose.position,
  141436. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  141437. * updated when calling resetPose(). This should be called in only
  141438. * sitting-space experiences.
  141439. */
  141440. resetPose(): void;
  141441. /**
  141442. * The VRLayer provided to the VRDisplay will be captured and presented
  141443. * in the HMD. Calling this function has the same effect on the source
  141444. * canvas as any other operation that uses its source image, and canvases
  141445. * created without preserveDrawingBuffer set to true will be cleared.
  141446. * @param pose Define the pose to submit
  141447. */
  141448. submitFrame(pose?: VRPose): void;
  141449. }
  141450. declare var VRDisplay: {
  141451. prototype: VRDisplay;
  141452. new(): VRDisplay;
  141453. };
  141454. interface VRLayer {
  141455. leftBounds?: number[] | Float32Array | null;
  141456. rightBounds?: number[] | Float32Array | null;
  141457. source?: HTMLCanvasElement | null;
  141458. }
  141459. interface VRDisplayCapabilities {
  141460. readonly canPresent: boolean;
  141461. readonly hasExternalDisplay: boolean;
  141462. readonly hasOrientation: boolean;
  141463. readonly hasPosition: boolean;
  141464. readonly maxLayers: number;
  141465. }
  141466. interface VREyeParameters {
  141467. /** @deprecated */
  141468. readonly fieldOfView: VRFieldOfView;
  141469. readonly offset: Float32Array;
  141470. readonly renderHeight: number;
  141471. readonly renderWidth: number;
  141472. }
  141473. interface VRFieldOfView {
  141474. readonly downDegrees: number;
  141475. readonly leftDegrees: number;
  141476. readonly rightDegrees: number;
  141477. readonly upDegrees: number;
  141478. }
  141479. interface VRFrameData {
  141480. readonly leftProjectionMatrix: Float32Array;
  141481. readonly leftViewMatrix: Float32Array;
  141482. readonly pose: VRPose;
  141483. readonly rightProjectionMatrix: Float32Array;
  141484. readonly rightViewMatrix: Float32Array;
  141485. readonly timestamp: number;
  141486. }
  141487. interface VRPose {
  141488. readonly angularAcceleration: Float32Array | null;
  141489. readonly angularVelocity: Float32Array | null;
  141490. readonly linearAcceleration: Float32Array | null;
  141491. readonly linearVelocity: Float32Array | null;
  141492. readonly orientation: Float32Array | null;
  141493. readonly position: Float32Array | null;
  141494. readonly timestamp: number;
  141495. }
  141496. interface VRStageParameters {
  141497. sittingToStandingTransform?: Float32Array;
  141498. sizeX?: number;
  141499. sizeY?: number;
  141500. }
  141501. interface Navigator {
  141502. getVRDisplays(): Promise<VRDisplay[]>;
  141503. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  141504. }
  141505. interface Window {
  141506. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  141507. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  141508. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  141509. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  141510. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  141511. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  141512. }
  141513. interface Gamepad {
  141514. readonly displayId: number;
  141515. }
  141516. type XRSessionMode =
  141517. | "inline"
  141518. | "immersive-vr"
  141519. | "immersive-ar";
  141520. type XRReferenceSpaceType =
  141521. | "viewer"
  141522. | "local"
  141523. | "local-floor"
  141524. | "bounded-floor"
  141525. | "unbounded";
  141526. type XREnvironmentBlendMode =
  141527. | "opaque"
  141528. | "additive"
  141529. | "alpha-blend";
  141530. type XRVisibilityState =
  141531. | "visible"
  141532. | "visible-blurred"
  141533. | "hidden";
  141534. type XRHandedness =
  141535. | "none"
  141536. | "left"
  141537. | "right";
  141538. type XRTargetRayMode =
  141539. | "gaze"
  141540. | "tracked-pointer"
  141541. | "screen";
  141542. type XREye =
  141543. | "none"
  141544. | "left"
  141545. | "right";
  141546. interface XRSpace extends EventTarget {
  141547. }
  141548. interface XRRenderState {
  141549. depthNear?: number;
  141550. depthFar?: number;
  141551. inlineVerticalFieldOfView?: number;
  141552. baseLayer?: XRWebGLLayer;
  141553. }
  141554. interface XRInputSource {
  141555. handedness: XRHandedness;
  141556. targetRayMode: XRTargetRayMode;
  141557. targetRaySpace: XRSpace;
  141558. gripSpace: XRSpace | undefined;
  141559. gamepad: Gamepad | undefined;
  141560. profiles: Array<string>;
  141561. }
  141562. interface XRSessionInit {
  141563. optionalFeatures?: XRReferenceSpaceType[];
  141564. requiredFeatures?: XRReferenceSpaceType[];
  141565. }
  141566. interface XRSession extends XRAnchorCreator {
  141567. addEventListener: Function;
  141568. removeEventListener: Function;
  141569. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  141570. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  141571. requestAnimationFrame: Function;
  141572. end(): Promise<void>;
  141573. renderState: XRRenderState;
  141574. inputSources: Array<XRInputSource>;
  141575. // AR hit test
  141576. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141577. updateWorldTrackingState(options: {
  141578. planeDetectionState?: { enabled: boolean; }
  141579. }): void;
  141580. }
  141581. interface XRReferenceSpace extends XRSpace {
  141582. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  141583. onreset: any;
  141584. }
  141585. type XRPlaneSet = Set<XRPlane>;
  141586. type XRAnchorSet = Set<XRAnchor>;
  141587. interface XRFrame {
  141588. session: XRSession;
  141589. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  141590. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  141591. // Anchors
  141592. trackedAnchors?: XRAnchorSet;
  141593. // Planes
  141594. worldInformation: {
  141595. detectedPlanes?: XRPlaneSet;
  141596. };
  141597. }
  141598. interface XRViewerPose extends XRPose {
  141599. views: Array<XRView>;
  141600. }
  141601. interface XRPose {
  141602. transform: XRRigidTransform;
  141603. emulatedPosition: boolean;
  141604. }
  141605. interface XRWebGLLayerOptions {
  141606. antialias?: boolean;
  141607. depth?: boolean;
  141608. stencil?: boolean;
  141609. alpha?: boolean;
  141610. multiview?: boolean;
  141611. framebufferScaleFactor?: number;
  141612. }
  141613. declare var XRWebGLLayer: {
  141614. prototype: XRWebGLLayer;
  141615. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  141616. };
  141617. interface XRWebGLLayer {
  141618. framebuffer: WebGLFramebuffer;
  141619. framebufferWidth: number;
  141620. framebufferHeight: number;
  141621. getViewport: Function;
  141622. }
  141623. declare class XRRigidTransform {
  141624. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  141625. position: DOMPointReadOnly;
  141626. orientation: DOMPointReadOnly;
  141627. matrix: Float32Array;
  141628. inverse: XRRigidTransform;
  141629. }
  141630. interface XRView {
  141631. eye: XREye;
  141632. projectionMatrix: Float32Array;
  141633. transform: XRRigidTransform;
  141634. }
  141635. interface XRInputSourceChangeEvent {
  141636. session: XRSession;
  141637. removed: Array<XRInputSource>;
  141638. added: Array<XRInputSource>;
  141639. }
  141640. interface XRInputSourceEvent extends Event {
  141641. readonly frame: XRFrame;
  141642. readonly inputSource: XRInputSource;
  141643. }
  141644. // Experimental(er) features
  141645. declare class XRRay {
  141646. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  141647. origin: DOMPointReadOnly;
  141648. direction: DOMPointReadOnly;
  141649. matrix: Float32Array;
  141650. }
  141651. interface XRHitResult {
  141652. hitMatrix: Float32Array;
  141653. }
  141654. interface XRAnchor {
  141655. // remove?
  141656. id?: string;
  141657. anchorSpace: XRSpace;
  141658. lastChangedTime: number;
  141659. detach(): void;
  141660. }
  141661. interface XRPlane extends XRAnchorCreator {
  141662. orientation: "Horizontal" | "Vertical";
  141663. planeSpace: XRSpace;
  141664. polygon: Array<DOMPointReadOnly>;
  141665. lastChangedTime: number;
  141666. }
  141667. interface XRAnchorCreator {
  141668. // AR Anchors
  141669. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  141670. }